LWJGL Forum

Programming => OpenGL => Topic started by: chris_c on November 22, 2014, 09:43:08

Title: using later GL standards without depricated older standards
Post by: chris_c on November 22, 2014, 09:43:08
I like the way the tests statically import GL1.1 however the structure of the bindings seems to be there is no way to use say *just* GL3.3 without importing some deprecated bits of GL1.1 (I could be wrong!)

If I want use say GL3.3 and I want to use GL_TRUE etc I seem to need to import GL1.1 as well.

However it would be quite possible for me to then use some deprecated function of GL1.1 and end up with a not really GL3.3 application...

Do bleeding edge cards even know about glVertex (for example) ? can they even run in GL1.1 mode ?

Is it quite possible to accidentally make an app that might work on one card but baulk at some post deprecated function ?

Am I missing something here ?
Title: Re: using later GL standards without depricated older standards
Post by: Cornix on November 22, 2014, 10:06:23
It is not like GL11 contains only deprecated functionality. Rather GL11 contains all functionality that was present at OpenGL version 1.1.
Methods like GL11.glEnable(param) are still used even in OpenGL Version 4.X.

OpenGL is also downwardly compatible. Newer cards can still use OpenGL 1.1 functionality, in the worst case it will be done by the software driver that will translate it to newer methods for the graphics card.
Title: Re: using later GL standards without depricated older standards
Post by: chris_c on November 22, 2014, 10:12:00
I kinda suspected that would be the case, I don't doubt you at all, but out of curiosity can you cite an official source for this backwards compatibility? (you never know I might learn something!)
Title: Re: using later GL standards without depricated older standards
Post by: spasi on November 22, 2014, 13:52:01
You can use the forward compatibility flag when creating the OpenGL context. With GLFW, this means:

glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
This will be detected by LWJGL and it will not load function pointers for any deprecated OpenGL function. This will work with either Core or Compatibility profile contexts, which is important, because using the Core profile often means additional driver overhead. Note this will only work with functions, LWJGL cannot do anything about deprecated constants. You can use a Core profile context to be absolutely sure:

glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // requires OpenGL 3.2 or later
For more information, see Core and Compatibility in Contexts (https://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts).

On legacy functionality, modern GPUs indeed have no hardware dedicated to obsolete OpenGL features. They're emulated with shaders managed by the driver.
Title: Re: using later GL standards without depricated older standards
Post by: chris_c on November 23, 2014, 14:57:14
I had to also add
        glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); // Use OpenGL Core v3.2
        glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);

or am I doing something wrong?
Title: Re: using later GL standards without depricated older standards
Post by: spasi on November 23, 2014, 16:05:48
GLFW_OPENGL_FORWARD_COMPAT requires OpenGL 3.0+ and GLFW_OPENGL_PROFILE requires OpenGL 3.2+.
Title: Re: using later GL standards without depricated older standards
Post by: ra4king on November 23, 2014, 23:46:09
Is reading really that difficult? ???