Skip to content

Commit

Permalink
runtime: add support for opengl2d to Windows
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 27, 2024
1 parent 61e7fa4 commit edccff5
Show file tree
Hide file tree
Showing 9 changed files with 255 additions and 79 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
10 changes: 6 additions & 4 deletions src/h/opengl.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

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

#define GL2D_DEBUG

#ifdef GL2D_DEBUG
#define glprintf(s, ...) printf(stderr,s, ##__VA_ARGS__)
#define glprintf(s, ...) fprintf(stderr, "%s:%s:%d: " s, __FILE__, __func__, __LINE__, ##__VA_ARGS__)
#else /* GL2D_DEBUG */
#define glprintf(s, ...)
#endif /* GL2D_DEBUG */
Expand Down Expand Up @@ -111,15 +113,15 @@
#define GL2D_DRAWOP_COPY GL_COPY
#define GL2D_DRAWOP_REVERSE GL_XOR


/*
* Structures
*/

/*
* For a linked list color structure
*/
typedef struct color {
typedef struct color
{
char name[6+MAXCOLORNAME];
unsigned short r, g, b, a;
/* for referencing a mutable color (negative) */
Expand All @@ -128,7 +130,7 @@ typedef struct color {
unsigned long c; /* X11 color handle */
#endif /* XWindows */
struct color *prev, *next;
} *clrp;
} *clrp;

/*
* Object for storing font characters (uses textures)
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
2 changes: 1 addition & 1 deletion src/runtime/rdebug.r
Original file line number Diff line number Diff line change
Expand Up @@ -1040,7 +1040,7 @@ oneop:
fprintf(stderr,"; coexpression_%ld failed to thread_%ld\n",
(long)ccp->id, (long)ncp->id);
else
#endif
#endif /* Concurrent */
fprintf(stderr,"; co-expression_%ld failed to co-expression_%ld\n",
(long)ccp->id, (long)ncp->id);
fflush(stderr);
Expand Down
Loading

0 comments on commit edccff5

Please sign in to comment.