ColleagueRiley / RGFW

A cross platform lightweight single-header simple-to-use window abstraction library for creating graphical programs or libraries.
zlib License
280 stars 16 forks source link

Cannot build with RGFW_EGL (Linux) #15

Closed tomas closed 5 months ago

tomas commented 5 months ago

Getting lots of errors when trying to build the most barebones program:

#define RGFW_IMPLEMENTATION
#define RGFW_EGL
#include "RGFW.h"

int main() {
    RGFW_window* win = RGFW_createWindow("Test", RGFW_RECT(500, 500, 500, 500), RGFW_CENTER);
    RGFW_window_makeCurrent(win);
    RGFW_window_close(win);
}
In file included from examples/basic/main.c:3:
./RGFW.h: In function ‘RGFW_createOpenGLContext’:
./RGFW.h:2266:33: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
 2266 |                 EGLint attribs[]{
      |                                 ^
./RGFW.h:2267:56: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 2267 |                         EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
      |                                                        ^
./RGFW.h:2267:102: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 2267 |                         EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT,
      |                                                                                                      ^
./RGFW.h:2268:26: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 2268 |                         0, 0, 0, 0
      |                          ^
./RGFW.h:2268:29: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 2268 |                         0, 0, 0, 0
      |                             ^
./RGFW.h:2268:32: warning: left-hand operand of comma expression has no effect [-Wunused-value]
 2268 |                         0, 0, 0, 0
      |                                ^
./RGFW.h:2268:32: warning: statement with no effect [-Wunused-value]
./RGFW.h:2268:35: error: expected ‘;’ before ‘}’ token
 2268 |                         0, 0, 0, 0
      |                                   ^
      |                                   ;
 2269 |                 };
      |                 ~                  
./RGFW.h:2272:54: error: ‘RGFW_STENCIL’ undeclared (first use in this function); did you mean ‘GL_STENCIL’?
 2272 |                 RGFW_GL_ADD_ATTRIB(EGL_STENCIL_SIZE, RGFW_STENCIL);
      |                                                      ^~~~~~~~~~~~
./RGFW.h:2210:13: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2210 |         if (attVal) { \
      |             ^~~~~~
./RGFW.h:2272:54: note: each undeclared identifier is reported only once for each function it appears in
 2272 |                 RGFW_GL_ADD_ATTRIB(EGL_STENCIL_SIZE, RGFW_STENCIL);
      |                                                      ^~~~~~~~~~~~
./RGFW.h:2210:13: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2210 |         if (attVal) { \
      |             ^~~~~~
./RGFW.h:2211:17: error: ‘attribs’ undeclared (first use in this function)
 2211 |                 attribs[index] = attrib;\
      |                 ^~~~~~~
./RGFW.h:2272:17: note: in expansion of macro ‘RGFW_GL_ADD_ATTRIB’
 2272 |                 RGFW_GL_ADD_ATTRIB(EGL_STENCIL_SIZE, RGFW_STENCIL);
      |                 ^~~~~~~~~~~~~~~~~~
./RGFW.h:2273:49: error: ‘RGFW_SAMPLES’ undeclared (first use in this function); did you mean ‘EGL_SAMPLES’?
 2273 |                 RGFW_GL_ADD_ATTRIB(EGL_SAMPLES, RGFW_SAMPLES);
      |                                                 ^~~~~~~~~~~~
./RGFW.h:2210:13: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2210 |         if (attVal) { \
      |             ^~~~~~
./RGFW.h:2274:63: error: ‘RGFW_majorVersion’ undeclared (first use in this function)
 2274 |                 RGFW_GL_ADD_ATTRIB(EGL_CONTEXT_MAJOR_VERSION, RGFW_majorVersion);
      |                                                               ^~~~~~~~~~~~~~~~~
./RGFW.h:2210:13: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2210 |         if (attVal) { \
      |             ^~~~~~
./RGFW.h:2275:63: error: ‘RGFW_minorVersion’ undeclared (first use in this function)
 2275 |                 RGFW_GL_ADD_ATTRIB(EGL_CONTEXT_MINOR_VERSION, RGFW_minorVersion);
      |                                                               ^~~~~~~~~~~~~~~~~
./RGFW.h:2210:13: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2210 |         if (attVal) { \
      |             ^~~~~~
./RGFW.h:2277:25: error: ‘RGFW_window_src’ has no member named ‘rSurf’
 2277 |                 win->src.rSurf = eglCreateContext(win->src.EGL_display, config, globalCtx, attribs);
      |                         ^
./RGFW.h:2281:25: error: ‘RGFW_EGLglobalContext’ undeclared (first use in this function)
 2281 |                         RGFW_EGLglobalContext = win->src.rSurf;
      |                         ^~~~~~~~~~~~~~~~~~~~~
./RGFW.h:2281:57: error: ‘RGFW_window_src’ has no member named ‘rSurf’
 2281 |                         RGFW_EGLglobalContext = win->src.rSurf;
      |                                                         ^
./RGFW.h:2283:106: error: ‘RGFW_window_src’ has no member named ‘rSurf’
 2283 |                 eglMakeCurrent(win->src.EGL_display, win->src.EGL_surface, win->src.EGL_surface, win->src.rSurf);
      |                                                                                                          ^
./RGFW.h: In function ‘RGFW_closeEGL’:
./RGFW.h:2293:65: error: ‘RGFW_window_src’ has no member named ‘rSurf’
 2293 |                 eglDestroyContext(win->src.EGL_display, win->src.rSurf);
      |                                                                 ^
./RGFW.h: In function ‘RGFW_window_makeCurrent_OpenGL’:
./RGFW.h:5851:106: error: ‘RGFW_window_src’ has no member named ‘rSurf’
 5851 |                 eglMakeCurrent(win->src.EGL_display, win->src.EGL_surface, win->src.EGL_surface, win->src.rSurf);
      |                                                                                                          ^
make: *** [Makefile:57: basic] Error 1

_Update: Same result when using RGFW_OPENGL_ES1 and RGFW_OPENGL_ES2._

EimaMei commented 5 months ago

I'm pretty sure just adding a = between the [] and { at the EGLint attribs[]{ line fixes the issue. Seems like a silly RGFW bug

ColleagueRiley commented 5 months ago

@EimaMei There were a few other issues with EGL other than that issue.

@tomas This issue should be fixed with the newest commit.

tomas commented 5 months ago

Still no workie:

In file included from examples/basic/main.c:3:
./RGFW.h:429:3: error: unknown type name ‘GLXContext’
  429 |   GLXContext rSurf; /*!< source graphics context */
      |   ^~~~~~~~~~
./RGFW.h: In function ‘RGFW_initAttribs’:
./RGFW.h:2058:51: error: ‘GLX_X_VISUAL_TYPE’ undeclared (first use in this function)
 2058 | #define RGFW_GL_RENDER_TYPE   RGFW_OS_BASED_VALUE(GLX_X_VISUAL_TYPE,     0x2003,  73)
      |                                                   ^~~~~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2092:9: note: in expansion of macro ‘RGFW_GL_RENDER_TYPE’
 2092 |         RGFW_GL_RENDER_TYPE,
      |         ^~~~~~~~~~~~~~~~~~~
./RGFW.h:2058:51: note: each undeclared identifier is reported only once for each function it appears in
 2058 | #define RGFW_GL_RENDER_TYPE   RGFW_OS_BASED_VALUE(GLX_X_VISUAL_TYPE,     0x2003,  73)
      |                                                   ^~~~~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2092:9: note: in expansion of macro ‘RGFW_GL_RENDER_TYPE’
 2092 |         RGFW_GL_RENDER_TYPE,
      |         ^~~~~~~~~~~~~~~~~~~
./RGFW.h:2071:50: error: ‘GLX_TRUE_COLOR’ undeclared (first use in this function); did you mean ‘GL_SRC1_COLOR’?
 2071 | #define RGFW_GL_FULL_FORMAT  RGFW_OS_BASED_VALUE(GLX_TRUE_COLOR,      0x2027,      0)
      |                                                  ^~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2093:9: note: in expansion of macro ‘RGFW_GL_FULL_FORMAT’
 2093 |         RGFW_GL_FULL_FORMAT,
      |         ^~~~~~~~~~~~~~~~~~~
./RGFW.h:2059:50: error: ‘GLX_ALPHA_SIZE’ undeclared (first use in this function); did you mean ‘EGL_ALPHA_SIZE’?
 2059 | #define RGFW_GL_ALPHA_SIZE   RGFW_OS_BASED_VALUE(GLX_ALPHA_SIZE,        0x201b,  11)
      |                                                  ^~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2095:9: note: in expansion of macro ‘RGFW_GL_ALPHA_SIZE’
 2095 |         RGFW_GL_ALPHA_SIZE      , 8,
      |         ^~~~~~~~~~~~~~~~~~
./RGFW.h:2060:50: error: ‘GLX_DEPTH_SIZE’ undeclared (first use in this function); did you mean ‘EGL_DEPTH_SIZE’?
 2060 | #define RGFW_GL_DEPTH_SIZE   RGFW_OS_BASED_VALUE(GLX_DEPTH_SIZE,        0x2022,  12)
      |                                                  ^~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2096:9: note: in expansion of macro ‘RGFW_GL_DEPTH_SIZE’
 2096 |         RGFW_GL_DEPTH_SIZE      , 24,
      |         ^~~~~~~~~~~~~~~~~~
./RGFW.h:2061:52: error: ‘GLX_DOUBLEBUFFER’ undeclared (first use in this function); did you mean ‘GL_DOUBLEBUFFER’?
 2061 | #define RGFW_GL_DOUBLEBUFFER   RGFW_OS_BASED_VALUE(GLX_DOUBLEBUFFER,      0x2011,  5)
      |                                                    ^~~~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2097:9: note: in expansion of macro ‘RGFW_GL_DOUBLEBUFFER’
 2097 |         RGFW_GL_DOUBLEBUFFER    ,
      |         ^~~~~~~~~~~~~~~~~~~~
./RGFW.h:2070:49: error: ‘GLX_USE_GL’ undeclared (first use in this function)
 2070 | #define RGFW_GL_USE_OPENGL  RGFW_OS_BASED_VALUE(GLX_USE_GL,    0x2010,      0)
      |                                                 ^~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2103:9: note: in expansion of macro ‘RGFW_GL_USE_OPENGL’
 2103 |         RGFW_GL_USE_OPENGL,  1,
      |         ^~~~~~~~~~~~~~~~~~
./RGFW.h:2068:45: error: ‘GLX_X_RENDERABLE’ undeclared (first use in this function); did you mean ‘GL_COLOR_RENDERABLE’?
 2068 | #define RGFW_GL_DRAW    RGFW_OS_BASED_VALUE(GLX_X_RENDERABLE,   0x2001,     0)
      |                                             ^~~~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2104:9: note: in expansion of macro ‘RGFW_GL_DRAW’
 2104 |         RGFW_GL_DRAW, 1,
      |         ^~~~~~~~~~~~
./RGFW.h:2072:47: error: ‘GLX_RED_SIZE’ undeclared (first use in this function); did you mean ‘EGL_RED_SIZE’?
 2072 | #define RGFW_GL_RED_SIZE  RGFW_OS_BASED_VALUE(GLX_RED_SIZE,          0x2015,      0)
      |                                               ^~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2105:9: note: in expansion of macro ‘RGFW_GL_RED_SIZE’
 2105 |         RGFW_GL_RED_SIZE        , 8,
      |         ^~~~~~~~~~~~~~~~
./RGFW.h:2073:49: error: ‘GLX_GREEN_SIZE’ undeclared (first use in this function); did you mean ‘EGL_GREEN_SIZE’?
 2073 | #define RGFW_GL_GREEN_SIZE  RGFW_OS_BASED_VALUE(GLX_GREEN_SIZE,        0x2017,      0)
      |                                                 ^~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2106:9: note: in expansion of macro ‘RGFW_GL_GREEN_SIZE’
 2106 |         RGFW_GL_GREEN_SIZE      , 8,
      |         ^~~~~~~~~~~~~~~~~~
./RGFW.h:2074:48: error: ‘GLX_BLUE_SIZE’ undeclared (first use in this function); did you mean ‘EGL_BLUE_SIZE’?
 2074 | #define RGFW_GL_BLUE_SIZE  RGFW_OS_BASED_VALUE(GLX_BLUE_SIZE,     0x2019,      0)
      |                                                ^~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2107:9: note: in expansion of macro ‘RGFW_GL_BLUE_SIZE’
 2107 |         RGFW_GL_BLUE_SIZE       , 8,
      |         ^~~~~~~~~~~~~~~~~
./RGFW.h:2069:49: error: ‘GLX_RENDER_TYPE’ undeclared (first use in this function); did you mean ‘GL_SHADER_TYPE’?
 2069 | #define RGFW_GL_DRAW_TYPE   RGFW_OS_BASED_VALUE(GLX_RENDER_TYPE,      0x2013,      0)
      |                                                 ^~~~~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2108:9: note: in expansion of macro ‘RGFW_GL_DRAW_TYPE’
 2108 |         RGFW_GL_DRAW_TYPE     , RGFW_GL_USE_RGBA,
      |         ^~~~~~~~~~~~~~~~~
./RGFW.h:2075:47: error: ‘GLX_RGBA_BIT’ undeclared (first use in this function); did you mean ‘GL_RGB2_EXT’?
 2075 | #define RGFW_GL_USE_RGBA  RGFW_OS_BASED_VALUE(GLX_RGBA_BIT,      0x202B,      0)
      |                                               ^~~~~~~~~~~~
./RGFW.h:844:38: note: in definition of macro ‘RGFW_OS_BASED_VALUE’
  844 | #define RGFW_OS_BASED_VALUE(l, w, m) l
      |                                      ^
./RGFW.h:2108:33: note: in expansion of macro ‘RGFW_GL_USE_RGBA’
 2108 |         RGFW_GL_DRAW_TYPE     , RGFW_GL_USE_RGBA,
      |                                 ^~~~~~~~~~~~~~~~
In file included from examples/basic/main.c:3:
./RGFW.h:2112:9: error: ‘GLX_DRAWABLE_TYPE’ undeclared (first use in this function)
 2112 |         GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT,
      |         ^~~~~~~~~~~~~~~~~
./RGFW.h:2112:31: error: ‘GLX_WINDOW_BIT’ undeclared (first use in this function); did you mean ‘EGL_WINDOW_BIT’?
 2112 |         GLX_DRAWABLE_TYPE   , GLX_WINDOW_BIT,
      |                               ^~~~~~~~~~~~~~
      |                               EGL_WINDOW_BIT
./RGFW.h:2062:52: error: ‘GLX_STENCIL_SIZE’ undeclared (first use in this function); did you mean ‘EGL_STENCIL_SIZE’?
 2062 | #define RGFW_GL_STENCIL_SIZE   RGFW_OS_BASED_VALUE(GLX_STENCIL_SIZE,   0x2023, 13)
      |                                                    ^~~~~~~~~~~~~~~~
./RGFW.h:2131:21: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2131 |    attribs[index] = attrib;\
      |                     ^~~~~~
./RGFW.h:2062:32: note: in expansion of macro ‘RGFW_OS_BASED_VALUE’
 2062 | #define RGFW_GL_STENCIL_SIZE   RGFW_OS_BASED_VALUE(GLX_STENCIL_SIZE,   0x2023, 13)
      |                                ^~~~~~~~~~~~~~~~~~~
./RGFW.h:2136:22: note: in expansion of macro ‘RGFW_GL_STENCIL_SIZE’
 2136 |   RGFW_GL_ADD_ATTRIB(RGFW_GL_STENCIL_SIZE, RGFW_STENCIL);
      |                      ^~~~~~~~~~~~~~~~~~~~
./RGFW.h:2064:47: error: ‘GLX_STEREO’ undeclared (first use in this function); did you mean ‘GL_STEREO’?
 2064 | #define RGFW_GL_STEREO    RGFW_OS_BASED_VALUE(GLX_STEREO,      0x2012,   6)
      |                                               ^~~~~~~~~~
./RGFW.h:2131:21: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2131 |    attribs[index] = attrib;\
      |                     ^~~~~~
./RGFW.h:2064:27: note: in expansion of macro ‘RGFW_OS_BASED_VALUE’
 2064 | #define RGFW_GL_STEREO    RGFW_OS_BASED_VALUE(GLX_STEREO,      0x2012,   6)
      |                           ^~~~~~~~~~~~~~~~~~~
./RGFW.h:2137:22: note: in expansion of macro ‘RGFW_GL_STEREO’
 2137 |   RGFW_GL_ADD_ATTRIB(RGFW_GL_STEREO, RGFW_STEREO);
      |                      ^~~~~~~~~~~~~~
./RGFW.h:2065:50: error: ‘GLX_AUX_BUFFERS’ undeclared (first use in this function); did you mean ‘GL_AUX_BUFFERS’?
 2065 | #define RGFW_GL_AUX_BUFFERS  RGFW_OS_BASED_VALUE(GLX_AUX_BUFFERS,     0x2024, 7)
      |                                                  ^~~~~~~~~~~~~~~
./RGFW.h:2131:21: note: in definition of macro ‘RGFW_GL_ADD_ATTRIB’
 2131 |    attribs[index] = attrib;\
      |                     ^~~~~~
./RGFW.h:2065:30: note: in expansion of macro ‘RGFW_OS_BASED_VALUE’
 2065 | #define RGFW_GL_AUX_BUFFERS  RGFW_OS_BASED_VALUE(GLX_AUX_BUFFERS,     0x2024, 7)
      |                              ^~~~~~~~~~~~~~~~~~~
./RGFW.h:2138:22: note: in expansion of macro ‘RGFW_GL_AUX_BUFFERS’
 2138 |   RGFW_GL_ADD_ATTRIB(RGFW_GL_AUX_BUFFERS, RGFW_AUX_BUFFERS);
      |                      ^~~~~~~~~~~~~~~~~~~
./RGFW.h: In function ‘RGFW_createOpenGLContext’:
./RGFW.h:2281:18: warning: assignment to ‘int’ from ‘EGLContext’ {aka ‘void *’} makes integer from pointer without a cast [-Wint-conversion]
 2281 |   win->src.rSurf = eglCreateContext(win->src.EGL_display, config, globalCtx, attribs);
      |                  ^
./RGFW.h:2285:14: warning: assignment to ‘EGLContext’ {aka ‘void *’} from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 2285 |    globalCtx = win->src.rSurf;
      |              ^
./RGFW.h:2287:92: warning: passing argument 4 of ‘eglMakeCurrent’ makes pointer from integer without a cast [-Wint-conversion]
 2287 |   eglMakeCurrent(win->src.EGL_display, win->src.EGL_surface, win->src.EGL_surface, win->src.rSurf);
      |                                                                                    ~~~~~~~~^~~~~~
      |                                                                                            |
      |                                                                                            int
In file included from ./RGFW.h:204,
                 from examples/basic/main.c:3:
/usr/include/EGL/egl.h:166:108: note: expected ‘EGLContext’ {aka ‘void *’} but argument is of type ‘int’
  166 | EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
      |                                                                                                 ~~~~~~~~~~~^~~
In file included from examples/basic/main.c:3:
./RGFW.h: In function ‘RGFW_getProcAddress’:
./RGFW.h:2303:10: warning: implicit declaration of function ‘glXGetProcAddress’; did you mean ‘eglGetProcAddress’? [-Wimplicit-function-declaration]
 2303 |   proc = glXGetProcAddress((GLubyte*) procname);
      |          ^~~~~~~~~~~~~~~~~
      |          eglGetProcAddress
./RGFW.h:2303:8: warning: assignment to ‘void *’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion]
 2303 |   proc = glXGetProcAddress((GLubyte*) procname);
      |        ^
./RGFW.h: In function ‘RGFW_closeEGL’:
./RGFW.h:2330:51: warning: passing argument 2 of ‘eglDestroyContext’ makes pointer from integer without a cast [-Wint-conversion]
 2330 |   eglDestroyContext(win->src.EGL_display, win->src.rSurf);
      |                                           ~~~~~~~~^~~~~~
      |                                                   |
      |                                                   int
In file included from ./RGFW.h:204,
                 from examples/basic/main.c:3:
/usr/include/EGL/egl.h:156:77: note: expected ‘EGLContext’ {aka ‘void *’} but argument is of type ‘int’
  156 | EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
      |                                                                  ~~~~~~~~~~~^~~
In file included from examples/basic/main.c:3:
./RGFW.h: In function ‘RGFW_window_makeCurrent_OpenGL’:
./RGFW.h:5890:92: warning: passing argument 4 of ‘eglMakeCurrent’ makes pointer from integer without a cast [-Wint-conversion]
 5890 |   eglMakeCurrent(win->src.EGL_display, win->src.EGL_surface, win->src.EGL_surface, win->src.rSurf);
      |                                                                                    ~~~~~~~~^~~~~~
      |                                                                                            |
      |                                                                                            int
In file included from ./RGFW.h:204,
                 from examples/basic/main.c:3:
/usr/include/EGL/egl.h:166:108: note: expected ‘EGLContext’ {aka ‘void *’} but argument is of type ‘int’
  166 | EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
      |                                                                                                 ~~~~~~~~~~~^~~
In file included from examples/basic/main.c:3:
At top level:

Please note that I'm running this on another computer with an older version of Ubuntu (20.04 x64).

I also had to add -ldl as well as -lpthread to the Makefile for the examples to compile.

ColleagueRiley commented 5 months ago

Okay, thank you. I didn't test it on linux.

ColleagueRiley commented 5 months ago

These issues should be fixed now :)

tomas commented 5 months ago

Ok now it builds... but crashes:

Failed to find any valid GLX configs
basic: ./RGFW.h:5897: RGFW_window_makeCurrent: Assertion `win != NULL' failed.
Aborted (core dumped)

This is not because of EGL though. Building the example without RGFW_EGL has the same result.

ColleagueRiley commented 5 months ago

@tomas I'm not getting this error on Linux (using an LUbuntu VM)

Your system is printing "Failed to find any valid GLX configs". So I'm assuming it's something wrong with your system or libraries.

Ubuntu is also using Wayland and supporting X11 via backward compatibility, which could be the issue.

I will create a Ubuntu VM and test that.

tomas commented 5 months ago

Well I just built a a simple GLFW example (shown below) and it worked without a problem. So it seems RGFW is doing something different.

#include <GLFW/glfw3.h>
#include <stdlib.h>
#include <stdio.h>

int main(void) {
    GLFWwindow* window;
    if (!glfwInit())
        exit(EXIT_FAILURE);

    window = glfwCreateWindow(640, 480, "Simple example", NULL, NULL);
    if (!window) {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    glfwMakeContextCurrent(window);
    printf("OpenGL shader language version: %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
    glfwDestroyWindow(window);
    glfwTerminate();
    exit(EXIT_SUCCESS);
}

Built with:

gcc glfw-example.c -lGL -lglfw
ColleagueRiley commented 5 months ago

That's correct, GLFW is using the native Wayland API while RGFW is using Xlib.

ColleagueRiley commented 5 months ago

@tomas I'm not getting this issue on the Ubuntu VM.

tomas commented 5 months ago

That's correct, GLFW is using the native Wayland API while RGFW is using Xlib.

Nope, I'm not running Wayland.

ColleagueRiley commented 5 months ago

Update: I was able to repeat the issue somehow

ColleagueRiley commented 5 months ago

I believe this is a driver issue because it seems this issue only happens when GLX doesn't find a valid config due toany of them matching the multisample count.

ColleagueRiley commented 5 months ago

@tomas my newest commit should fix that issue for you

tomas commented 5 months ago

I'm back in the other computer and the basic example "works" with EGL but doesn't show anything:

image

It does work with the default settings though (a triangle is shown over a white background).

Now, when using RGFW_OPENGL_ES1 I get the following error:

In file included from examples/basic/main.c:12:
./RGFW.h: In function ‘RGFW_createOpenGLContext’:
./RGFW.h:2250:25: error: ‘EGL_OPENGL_ES1_BIT’ undeclared (first use in this function); did you mean ‘EGL_OPENGL_ES2_BIT’?
 2250 |                         EGL_OPENGL_ES1_BIT,
      |                         ^~~~~~~~~~~~~~~~~~
      |                         EGL_OPENGL_ES2_BIT
./RGFW.h:2250:25: note: each undeclared identifier is reported only once for each function it appears in
./RGFW.h: At top level:

RGFW_OPENGL_ES2 has the same effect as RGFW_EGL (no output).

ColleagueRiley commented 5 months ago

A similar thing happens to me on Linux (but not on Windows). I’ve not really tested EGL so I didn't know this happened. I’m not sure what the issue is but I’m looking into it right now.

ColleagueRiley commented 5 months ago

Update: I found this example which works. I should be able to use this to find out what RGFW is doing wrong.

tomas commented 5 months ago

Great! Here's another one that you can use as reference. I used it a while ago for testing EGL+Xcb.

ColleagueRiley commented 5 months ago

@tomas this issue should be fixed now with the newest commit :)

tomas commented 5 months ago

Ok now RGFW_EGL finally works!

Also, RGFW_OPENGL_ES1 builds correctly now, but has the same behaviour as I showed before. RGFW_OPENGL_ES2 on the other hands just shows a white screen (no triangle).

ColleagueRiley commented 5 months ago

Ok now RGFW_EGL finally works!

Also, RGFW_OPENGL_ES1 builds correctly now, but has the same behaviour as I showed before. RGFW_OPENGL_ES2 on the other hands just shows a white screen (no triangle).

Yes, I tested this. I'm not sure about ES1 but ES2 is rendering properly. I believe you're supposed to render it differently for ES2 (see the EGL example I sent).

tomas commented 5 months ago

I'm not sure what you mean. How can I make the basic example work with ES2?

ColleagueRiley commented 5 months ago

I'm not sure what you mean. How can I make the basic example work with ES2?

I believe the basic example simply isn't written to support ES2. ES2 only uses certain parts of the OpenGL api I think. The EGL example I sent works fine with ES2 and RGFW. But not the basic example, so I assume there's a proper way to render using ES2 that the RGFW examples don't do.

tomas commented 5 months ago

I see. It would be great to have a working ES2 example in the repo though.

And maybe one for ES1 too. :)

ColleagueRiley commented 5 months ago

Okay, I created a OpenGL ES 2 example.

ColleagueRiley commented 5 months ago

@tomas I can't find any examples of OpenGL ES 1 on X11.

ColleagueRiley commented 5 months ago

I cannot seem to get OpenGL ES 1 to work on GLFW either... perhaps it's not possible.

tomas commented 5 months ago

That's odd. The docs mention the macro GLFW_INCLUDE_ES1 for loading that version.

ColleagueRiley commented 5 months ago

That's odd. The docs mention the macro GLFW_INCLUDE_ES1 for loading that version.

Perhaps this is only for mobile/web? I'm struggling to find anything about OpenGL ES for desktop. I'll try out GLES/gl.h

update: that doesn't seem to work either

ColleagueRiley commented 5 months ago

@tomas I'm thinking I'll just put a note about ES1 not working on desktop platforms. I plan on adding webASM support in the future.

tomas commented 5 months ago

Sure, you're the boss here. Do you plan to support ES3 later?

ColleagueRiley commented 5 months ago

Sure, you're the boss here. Do you plan to support ES3 later?

Yes, I believe it should work with minimal changes.

ColleagueRiley commented 5 months ago

I added GL ES 3 support, it drew the background but did not render. I tried it with GLFW and the same thing happened. It could be a driver issue.