Closed tomas closed 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
@EimaMei There were a few other issues with EGL other than that issue.
@tomas This issue should be fixed with the newest commit.
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.
Okay, thank you. I didn't test it on linux.
These issues should be fixed now :)
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.
@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.
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
That's correct, GLFW is using the native Wayland API while RGFW is using Xlib.
@tomas I'm not getting this issue on the Ubuntu VM.
That's correct, GLFW is using the native Wayland API while RGFW is using Xlib.
Nope, I'm not running Wayland.
Update: I was able to repeat the issue somehow
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.
@tomas my newest commit should fix that issue for you
I'm back in the other computer and the basic example "works" with EGL but doesn't show anything:
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).
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.
Update: I found this example which works. I should be able to use this to find out what RGFW is doing wrong.
Great! Here's another one that you can use as reference. I used it a while ago for testing EGL+Xcb.
@tomas this issue should be fixed now with the newest commit :)
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).
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).
I'm not sure what you mean. How can I make the basic example work with ES2?
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.
I see. It would be great to have a working ES2 example in the repo though.
And maybe one for ES1 too. :)
Okay, I created a OpenGL ES 2 example.
@tomas I can't find any examples of OpenGL ES 1 on X11.
I cannot seem to get OpenGL ES 1 to work on GLFW either... perhaps it's not possible.
That's odd. The docs mention the macro GLFW_INCLUDE_ES1
for loading that version.
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
@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.
Sure, you're the boss here. Do you plan to support ES3 later?
Sure, you're the boss here. Do you plan to support ES3 later?
Yes, I believe it should work with minimal changes.
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.
Getting lots of errors when trying to build the most barebones program:
_Update: Same result when using
RGFW_OPENGL_ES1
andRGFW_OPENGL_ES2
._