Nothing drawn when creating a window with minimum OpenGL version?

Started by skoovo, March 21, 2021, 20:57:10

Previous topic - Next topic

skoovo

Hello,

Firstly, I am very new to LWJGL so I apologise if this is "obvious", but I didn't find an answer either on or off the forum.

When creating a window using GLFW, I'm trying to set window hints to request a minimum version of OpenGL. For my purposes I requested version 4.3 like so:

glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4)
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3)


After creating a window, I check the OpenGL version with:

glGetString(GL_VERSION)


It shows that the version is set correctly, but nothing is drawn. The clear colour is applied, but my geometry isn't rendered. I'm using features that require GLSL version 430. If I remove the window hints, it defaults to OpenGL 4.6 and draws perfectly. However, if I then request 4.6 through window hints, nothing is drawn. I am really confused, since it seems to be the process of hinting that is causing me issues.

I've tried several versions and the results are interesting:









Hinted Version   Actual Version   Drawn
(none)4.6Yes
4.64.6No
4.34.3No
3.13.1Yes
3.04.6Yes
2.14.6Yes

I also checked the version of GLFW and it says 3.4.0. Is this a pre-release/beta of the next GLFW version? It seems that 3.3.3 is the current. I'm using Kotlin with gradle and LWJGL version 3.2.3, if that helps.

This could just be a really newbie mistake that I just can't spot, but it seems strange to me that hinting causes OpenGL to not draw. If anyone has come across this before, or can point me in the right direction, I would really appreciate it. Thanks for your time! :)

sumwise

Aloha,

just by looking at your - quite neat - table of hinted / actual version and drawn relations it looks like you are using some functionality that is deprecated in core profile
just a shot in the dark: maybe you do not bind a vertex array object prior to setting up your vertex attribs / rendering, which in core profile must be bound
during development i can always recommend using a debug callback (have a look at ARBDebugOutput), it will probably tell you what is wrong
there is also a hint for the profile, search for GLFW_OPENGL_PROFILE

greetings from the shire,
sumwise

skoovo

Hi,

Thanks for the quick reply. You were absolutely right about the VAO. Although I *thought* I was creating it and binding it, an incorrect function call meant that I wasn't.  This only showed itself when explicitly requesting an OpenGL version which in turn gave me a CORE profile. The default appears to be a COMPAT profile.

Also, nice tip about the debug output. I looked into ARBDebugOutput, and it told me exactly where I had messed up with the VAO.

Thanks for taking the time to solve my headache. I appreciate it! :)