Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Jafar Al-Gharaibeh <[email protected]>
  • Loading branch information
Jafaral committed May 25, 2024
1 parent bb39f90 commit d8a7c82
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 35 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ pacman -S --needed base-devel mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86
- Install the optional libraries for a full build (Unicon will build without them but some features
will be absent).
```
pacman -S mingw-w64-ucrt-x86_64-openssl mingw-w64-ucrt-x86_64-libpng mingw-w64-ucrt-x86_64-libjpeg-turbo
pacman -S mingw-w64-ucrt-x86_64-openssl mingw-w64-ucrt-x86_64-libpng
pacman -S mingw-w64-ucrt-x86_64-libjpeg-turbo mingw-w64-ucrt-x86_64-freetype
```

- Clone the Unicon repository:
Expand All @@ -149,7 +150,7 @@ git clone --config core.autocrlf=input https://github.com/uniconproject/unicon

- Configure Unicon:
```
./configure --build=x86_64-w64-mingw32
./configure --build=x86_64-w64-mingw32 CPPFLAGS=-I/ucrt64/include/freetype2
```
The option `x86_64-w64-mingw32` ensures the build is 64-bit. After the script finishes do:
```
Expand Down
2 changes: 2 additions & 0 deletions src/h/opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

//#define GL2D_DRAWARRAYS 1 /* Punt this off as a TODO item */

#define GL2D_DEBUG

#ifdef GL2D_DEBUG
#define glprintf(s, ...) fprintf(stderr, "%s:%s:%d: " s, __FILE__, __func__, __LINE__, ##__VA_ARGS__)
#else /* GL2D_DEBUG */
Expand Down
1 change: 1 addition & 0 deletions src/h/rproto.h
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,7 @@ int checkOpenConsole( FILE *w, char *s );
*/
wcp gl_alc_context(wbp w);
wdp gl_alc_display(char *s);
wdp gl_alc_display_font(wdp wd);
wsp gl_alc_winstate();
void gl_free_context(wcp wc);
void gl_free_display(wdp wd);
Expand Down
28 changes: 11 additions & 17 deletions src/runtime/fsys.r
Original file line number Diff line number Diff line change
Expand Up @@ -475,31 +475,25 @@ Deliberate Syntax Error
XInitThreads();
#endif /* XWindows */
#ifdef GraphicsGL
/*
* For now, having FreeType is a requirement for the OpenGL
* 2D and 2D/3D implementation
*/
#if HAVE_LIBFREETYPE
/* for enabling OpenGL 2D implementation in a convenient way */
if (!getenv("UNICONGL2D"))
if (getenv("UNICONGL2D")) {
/*
* FreeType is a requirement for OpenGL 2D
*/
#if !HAVE_LIBFREETYPE
set_errortext(1045);
fail;
#endif /* HAVE_LIBFREETYPE */
if (status & Fs_Window) {
status |= Fs_WinGL2D;
}
}
#endif /* GraphicsGL */
continue;
#else /* Graphics */
set_errortext(148);
fail;
#endif /* Graphics */
#ifdef GraphicsGL
/* OpenGL 2D implementation */
if (status & Fs_Window) {
status |= Fs_WinGL2D;
continue;
}
#else
/* Does it need a specific code? */
set_errortext(1045);
fail;
#endif /* GraphicsGL */
case 'l':
case 'L':
#ifdef PosixFns
Expand Down
68 changes: 55 additions & 13 deletions src/runtime/rmswin.ri
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,14 @@ FILE *wopen(char *name, struct b_list *lp, dptr attr, int n, int *err_index, int
set_errortext(145);
return NULL;
}
if ((gl_alc_display_font(ws->display)) == NULL) {
if (!is_3d) {
*err_index = -1;
free_binding(w);
set_errortext(145);
return NULL;
}
}
}
else
#endif /* GraphicsGL */
Expand All @@ -298,6 +306,10 @@ FILE *wopen(char *name, struct b_list *lp, dptr attr, int n, int *err_index, int
ws->listp.dword = D_List;
BlkLoc(ws->listp) = (union block *) tlp;

#ifdef GraphicsGL
ws->is_3D = is_3d;
#endif /* GraphicsGL */

/*
* some attributes of the display and window are used in the context
*/
Expand All @@ -321,7 +333,7 @@ FILE *wopen(char *name, struct b_list *lp, dptr attr, int n, int *err_index, int

#ifdef GraphicsGL
if (is_gl) {
ws->is_3D = wc->rendermode = is_3d;
wc->rendermode = is_3d;

/* Allocate display lists */
if (is_3d) {
Expand Down Expand Up @@ -428,18 +440,23 @@ FILE *wopen(char *name, struct b_list *lp, dptr attr, int n, int *err_index, int
scp[1].type = CLR_SHARED;
strcpy(scp[1].name, "white");
}
oldfont = SelectObject(hdc, wc->font->font);
GetTextMetrics(hdc, &metrics);
wc->font->charwidth = dc_maxcharwidth(hdc);
SelectObject(hdc, oldfont);
ReleaseDC(ws->iconwin, hdc);
wc->font->ascent = metrics.tmAscent;
wc->font->descent = metrics.tmDescent;
/* wc->font->charwidth = metrics.tmMaxCharWidth; buggy */
wc->font->height = metrics.tmHeight;
wc->leading = metrics.tmHeight;

if (wc->font) {
oldfont = SelectObject(hdc, wc->font->font);
GetTextMetrics(hdc, &metrics);
wc->font->charwidth = dc_maxcharwidth(hdc);
SelectObject(hdc, oldfont);
ReleaseDC(ws->iconwin, hdc);
wc->font->ascent = metrics.tmAscent;
wc->font->descent = metrics.tmDescent;
/* wc->font->charwidth = metrics.tmMaxCharWidth; buggy */
wc->font->height = metrics.tmHeight;
wc->leading = metrics.tmHeight;
ws->y = ASCENT(w);
}
else
ws->y = 7;
ws->x = 0;
ws->y = ASCENT(w);
ws->y += w->context->dy;
ws->x += w->context->dx;
/*
Expand Down Expand Up @@ -1245,12 +1262,37 @@ int pollevent()
wbp w;
MSG m;
extern jmp_buf mark_sj;
#ifdef GraphicsGL
wbp wb;
static int gpx_poll = FLUSH_POLL_INTERVAL;
#endif /* GraphicsGL */
#ifdef Concurrent
int isbusy;
MUTEX_TRYLOCKID(MTX_POLLEVENT, isbusy);
if (isbusy) return POLL_INTERVAL;
#endif /* Concurrent */

#ifdef GraphicsGL
if (gpx_poll) gpx_poll--;
if (!gpx_poll) {
for (wb = wbndngs; wb; wb=wb->next) {
wsp ws = wb->window;
if (ws->buffermode == UGL_IMMEDIATE) {
if (ws->redraw_flag && !ws->busy_flag) {
ws->busy_flag = 1;

MakeCurrent(wb);
glFlush();

ws->redraw_flag = 0;
ws->busy_flag = 0;
}
}
}
gpx_poll = FLUSH_POLL_INTERVAL;
}
#endif /* GraphicsGL */

/* some while PeekMessage loops here, maybe one per window ? */
while (PeekMessage(&m, NULL, 0, 0, PM_NOREMOVE)) {
if (GetMessage(&m, NULL, 0, 0) == 0) longjmp(mark_sj, -1);
Expand Down Expand Up @@ -3718,7 +3760,7 @@ wbp w;

GRFX_ALLOC(wc, _wcontext);

if (getenv_r("ICONFONT", icnfnt, 255 ) == 0)
if (getenv_r("ICONFONT", fnt, 255 ) == 0)
icnfnt = fnt;

wc->serial = ++context_serial;
Expand Down
25 changes: 23 additions & 2 deletions src/runtime/ropengl2d.ri
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,16 @@ int init_2dcontext(wcp wc)
glprintf("fonts not allocated\n");
wc->font = NULL;
wc->leading = 0;
wc->font = (wfp)alloc(sizeof (struct _wfont));
wc->font->name = salloc("fixed");
wc->font->font = CreateFont(16,0,0,0,FW_NORMAL,0,0,0,
((MAXBYTESPERCHAR==1)?ANSI_CHARSET:DEFAULT_CHARSET),
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, FIXED_PITCH | FF_MODERN,
NULL);

wc->font->charwidth = 8; /* looks like a bug */
wc->leading = 16;
}

/* drawing */
Expand Down Expand Up @@ -7528,9 +7538,19 @@ wdp gl_alc_display(char *s)
wd->maxTexIds = 256;
wd->numTexIds = 0;
wd->texIds = (unsigned int *)malloc(wd->maxTexIds*sizeof(unsigned int));
if (!wd->texIds) return NULL;
if (!wd->texIds) {
free(wd);
return NULL;
}
}
return wd;
}

/*
* allocate font for a display
*/
wdp gl_alc_display_font(wdp wd)
{
if (!wd->glfonts) {
wd->numFonts = 1;
wd->glfonts = loadfont(wd,DEFAULTFONTNAME,strlen(DEFAULTFONTNAME));
Expand All @@ -7540,7 +7560,8 @@ wdp gl_alc_display(char *s)
}
}
return wd;
}
}




Expand Down
5 changes: 4 additions & 1 deletion uni/3d/viewer/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
include ../../Makedefs
BASE=../../..
include $(BASE)/Makedefs.uni

UC=$(UNICON)
DEL = $(RM)
BASE=../../..
UC=$(UNICON)
Expand Down

0 comments on commit d8a7c82

Please sign in to comment.