Pages: « 1 2 3 »
  Print  
Author Topic: Massive GL3.3 changes.... again  (Read 11174 times)
Offline (Unknown gender) sorlok_reaves
Reply #15 Posted on: October 04, 2014, 05:41:45 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Now I'm getting a compile error:
Code: [Select]
Bridges/xlib-OpenGL3/graphics_bridge.cpp:132:21: error: ‘glxewInit’ was not declared in this scope
    err = glxewInit();

What's really weird about this is that you include glxew.h. So I tracked down within that file:
Code: [Select]
#ifdef GLEW_MX
#define glxewInit() glxewContextInit(glxewGetContext())
#endif

GLEW_MX is an optional macro, and defining it makes a lot of other things more annoying (like glewGetContext()). Not entirely sure what the right response here is.
Logged
Offline (Unknown gender) TheExDeus
Reply #16 Posted on: October 04, 2014, 06:24:11 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Yeah, I was mistaken. Turns out it's only used for multiple contexts or something. It also actually calls the same thing glewInit() calls. So I removed it - try now. It might work, because I left the temporary context in, which was still needed for glewInit().
Logged
Offline (Unknown gender) sorlok_reaves
Reply #17 Posted on: October 04, 2014, 07:21:11 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Unfortunately, it still crashes at the same line:
Code: [Select]
fbc = glXChooseFBConfig(enigma::x11::disp, DefaultScreen(enigma::x11::disp), visual_attribs, &fbcount);
Fun time; I just figured out that glXChooseFBConfig is NULL on my machine. Like, the function pointer returned by glxew is null. This shouldn't be happening (modern graphics card, etc.), but I'll dig into it a bit more.

EDIT: Ok, so it seems the function pointers are only set to non-null if glxewInit() is called. But that can only work if GLEW_MX is defined... which requires us to track the current render context.

My question is... did glXChooseFBConfig() work before, or was it added just to this commit?
« Last Edit: October 04, 2014, 07:29:37 PM by sorlok_reaves » Logged
Offline (Unknown gender) TheExDeus
Reply #18 Posted on: October 05, 2014, 07:24:34 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Actually it's defined in line 303, where there is no GLEW_MX required. glxewInit calls glxewContextInit() which is in glew.c line 13227. So the whole thing seems weird to me.

Quote
My question is... did glXChooseFBConfig() work before, or was it added just to this commit?
It was added. Previously only glXChooseVisual was called. For proper GL3 context it seems we need glXChooseFBConfig as well. I'm honestly out of ideas. You can try using GLEW_MX, as glxewGetContext() shouldn't cause problems. GLEW homepage says that GLEW_MX is not actually included in default release. So you might need to make a custom glew build to enable that (http://glew.sourceforge.net/advanced.html). But it does look that we have everything we need already. It would be 100x easier for me to fix this if I had Linux. I guess I will have to either dual-boot or do a vm thing.

Try compiling this simple example: https://www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_%28GLX%29 . It doesn't use glew, and uses old school pointer stuff. But if nothing else, then you can at least get the pointer for that function alone. And use glew for the rest.

Also, we might look into glbinding, https://github.com/hpicgs/glbinding . It the newest and most recently worked on binding framework. It basically replaces glew and many others. It uses C++11 features and is quite interesting. But changing this will probably be a little painful, and we haven't decided if we go towards supporting C++11 compilers only, so I guess we should hold off of that for a while.
« Last Edit: October 05, 2014, 07:26:31 AM by TheExDeus » Logged
Offline (Unknown gender) sorlok_reaves
Reply #19 Posted on: October 05, 2014, 10:51:28 AM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Quote from: TheExDeus
Actually it's defined in line 303, where there is no GLEW_MX required. glxewInit calls glxewContextInit() which is in glew.c line 13227. So the whole thing seems weird to me.

Which file are we talking about? I'm referring to glxew.h, where glxewInit() is defined on line 1566, but only if GLEW_MX is defined. glXChooseFBConfig() will always be defined, but it might point to nothing if glxewInit() is never called.


Quote from: TheExDeus
Previously only glXChooseVisual was called. For proper GL3 context it seems we need glXChooseFBConfig as well. I'm honestly out of ideas. You can try using GLEW_MX, as glxewGetContext() shouldn't cause problems. GLEW homepage says that GLEW_MX is not actually included in default release. So you might need to make a custom glew build to enable that (http://glew.sourceforge.net/advanced.html). But it does look that we have everything we need already. It would be 100x easier for me to fix this if I had Linux. I guess I will have to either dual-boot or do a vm thing.

You might want to look at putting Ubuntu in a VM; I've tried enabling GLEW_MX, and got a bit stuck since it requires you to manually handle the render contexts yourself.


Quote from: TheExDeus
Try compiling this simple example: https://www.opengl.org/wiki/Tutorial:_OpenGL_3.0_Context_Creation_%28GLX%29 . It doesn't use glew, and uses old school pointer stuff. But if nothing else, then you can at least get the pointer for that function alone. And use glew for the rest.

The example works.


Quote from: TheExDeus
Also, we might look into glbinding, https://github.com/hpicgs/glbinding . It the newest and most recently worked on binding framework. It basically replaces glew and many others. It uses C++11 features and is quite interesting. But changing this will probably be a little painful, and we haven't decided if we go towards supporting C++11 compilers only, so I guess we should hold off of that for a while.

From my point of view, C++11 support would be great! I think the main concern is double-checking that MinGW on Windows has all the C++11 features we'll need. The other devs will probably have different opinions.

Actually, if this is just in the graphics Bridge, couldn't we selectively enable C++11 on Linux when GL3 is used?
Logged
Offline (Unknown gender) TheExDeus
Reply #20 Posted on: October 06, 2014, 04:58:42 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Quote
The example works.
Then maybe you can try that method. Get the glXChooseFBConfig pointer and use that.

Quote
From my point of view, C++11 support would be great! I think the main concern is double-checking that MinGW on Windows has all the C++11 features we'll need. The other devs will probably have different opinions.
New MinGW (that is last few years) supports C++11 just fine. We also pack our own MinGW in ENIGMA installation, so we can control what version they are using. But supporting C++11 is a lot bigger decision, for which I would want Josh's input.

Quote
Running on master compiles and runs, and then the game is unplayable (just a single blue screen and the cursor, but it's not clear if I'm actually moving, since everything is blue).
But when you were running minecraft on the branch (when you also saw ground and some blocks), were you able to hit those blocks then? Because if we cannot do this context fix properly, then I might as well revert so Linux at least partly works. Because it might have been that it rendered fine (your scaling and text was still messed up, but still), and it was the world generation that broke.

You also said that you fixed the shader example segfault, by disabling the build path. Did render correctly then? Can you post a picture?

Because it seems that Linux might have worked fine for the most part. Even if you don't have a proper GL3.3 context and debugging. This can be done later.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #21 Posted on: October 06, 2014, 08:24:27 AM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Yes, placing blocks an destroying them in Minecraft works on the branch. I think it's correct to say that the world generation broke.

The Shader example crashes at the same place as Minecraft (the glXChooseFBConfig() thing).

I'll try to integrate the sample code's context stuff and see if that helps.
Logged
Offline (Unknown gender) TheExDeus
Reply #22 Posted on: October 06, 2014, 08:48:19 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
It's possible then that everything was actually already working except some draw_getpixel() somewhere. So if you are unsuccessful, then I will just revert.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #23 Posted on: October 06, 2014, 09:39:17 AM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
If I force the pointer (using these changes), then the program runs past initialization and crashes immediately on:

Code: [Select]
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0  0x0000000000000000 in ?? ()
#1  0x0000000000483ad8 in enigma::Shader::Shader (this=0x919620, type=0)
    at Graphics_Systems/OpenGL3/GLSLshader.h:40
#2  0x000000000047cd3d in enigma_user::glsl_shader_create (type=0)
    at Graphics_Systems/OpenGL3/GL3shader.cpp:490
#3  0x00000000004990de in enigma::graphicssystem_initialize ()
    at Graphics_Systems/OpenGL3/OPENGL3Std.cpp:101
#4  0x000000000051d598 in enigma::initialize_everything ()
    at Universal_System/loading.cpp:59
#5  0x0000000000455f1c in main (argc=1, argv=0x7fffffffe0b8)
    at Platforms/xlib/XLIBmain.cpp:306

Does this look like we're making progress, or did I just cause all sorts of nondeterminism by casting function pointers around? After all, the point of Glew is to handle this kind of stuff automatically.
Logged
Offline (Unknown gender) TheExDeus
Reply #24 Posted on: October 06, 2014, 10:45:40 AM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
You should try debug mode. It crashed on glCreateShader(), which means you either don't support shaders, glCreateShader is also NULL, or the core context just says we using something deprecated. You can also try uncommenting "//GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB," in xlib bridge. That will turn on the compatibility context, so it's more probable that it will run. Nvidia actually discourages disabling this compatibility context (because when later even GL3.3 is deprecated, your already compiled programs will not run without it), and I actually only did it to make the code compatible with GLES. After all these changes, I will probably turn that flag back on.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #25 Posted on: October 06, 2014, 10:14:12 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
glCreateShader() was also NULL. Enabling the COMPATIBILITY_PROFILE does not help.

I think this is almost certainly because I'm fiddling with raw pointers. I think the correct approach is to use glxew.h with GLEW_MX, or maybe that new approach you mentioned.

Anyway, I'm always free to help debug this; I'd like very much to see GLES integration.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #26 Posted on: October 06, 2014, 10:58:28 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Ok, I tried GLEW_MX, and glXChooseFBConfig is still a null pointer. There is clearly something weird going on there.

Edit: Just for kicks, I tried updating the glew.c/glew.h packaged with ENIGMA. Still no dice.
« Last Edit: October 06, 2014, 11:15:11 PM by sorlok_reaves » Logged
Offline (Unknown gender) TheExDeus
Reply #27 Posted on: October 09, 2014, 12:10:23 PM

Developer
Joined: Apr 2008
Posts: 1872

View Profile
Another thing we didn't try (or at least I think we didn't) is adding glXMakeCurrent after creating the temporary context, but before the glew init's. It's actually required (also on Windows), so it was my bad that I forgot to add it. Try the last commit.
Logged
Offline (Unknown gender) sorlok_reaves
Reply #28 Posted on: October 09, 2014, 07:51:00 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
I'll give it a try and get back to you (stuck in a meeting).
Logged
Offline (Unknown gender) sorlok_reaves
Reply #29 Posted on: October 10, 2014, 08:19:02 PM
Contributor
Joined: Dec 2013
Posts: 261

View Profile
Got an error compiling:

Code: [Select]
In file included from Bridges/xlib-OpenGL3/../General/glxew.h:102:0,
                 from Bridges/xlib-OpenGL3/graphics_bridge.cpp:21:
Bridges/xlib-OpenGL3/graphics_bridge.cpp: In function ‘void enigma::EnableDrawing()’:
Bridges/xlib-OpenGL3/../General/../../Graphics_Systems/General/glew.h:18011:51: error: ‘glewGetContext’ was not declared in this scope
 #define glewInit() glewContextInit(glewGetContext())
                                                   ^
Bridges/xlib-OpenGL3/graphics_bridge.cpp:128:18: note: in expansion of macro ‘glewInit’
     GLenum err = glewInit();

Turns out that when you define GLEW_MX, you need to define your own glewGetContext() function (since there can be multiple contexts now).
Logged
Pages: « 1 2 3 »
  Print