Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 24 Apr 2007
Offline Last Active Dec 23 2015 05:39 PM

Posts I've Made

In Topic: Compiling and running on different OpenGL versions

23 December 2015 - 12:36 PM

Hi cgrant,


I think my confusion right now is just one question: regardless how the code was compiled and on what platform, and with what version of OpenGL, is GL_VERSION (major and minor) obtained at runtime reliable ways (at runtime!) do bracket the source with "if" statements to skip over code that compiled properly but should not be called because the runtime version of opengl does not support it?


In other words, if my running machine only supports GL 1.1, can I reliably count on the fact that glGetString(GL_VERSION) will tell me that the runtime version is 1.1 and that I should skip some code that uses functionality in GL > 1.1?


I'm just hoping that glGetString(GL_VERSION) has no relation to the version used for compiling the code.



In Topic: Compiling and running on different OpenGL versions

23 December 2015 - 11:02 AM

Thanks to all for the responses.


So basically this is what I'm planning on doing:


1) When compiling I'll use #ifdef GL_VERSION_X_Y to make sure the compilation works properly.


2) When running it, let's say that glGetString(GL_VERSION) is supported. I understand that GLEW may have a bug in this function; but if I have a reliable way of parsing this string to get the major and minor version numbers, then these will be the ones available at runtime. Let's say I define an integer iversion = 10*major + minor. Then I can use

#ifdef GL_VERSION_3_1
if(iversion >= 31) {
   /* my happy OpenGL 3.1 code here */

Of course, this is all predicated on two facts: (1) I can construct iversion reliably; and (2) iversion created at runtime by extracting the version through gl calls will give me the supported runtime version of gl - regardless of how it was compiled.


Am I correct?

In Topic: Compiling and running on different OpenGL versions

22 December 2015 - 06:14 PM



Messy all right...


Following the link that Waterlimon posted I learned that glGetString(GL_VERSION) is deprecated and has been removed in 3.1. So in order to find out the version I'm using at runtime I need to first know the version (!) so I know which function to call. I can certainly use #ifdef GL_VERSION_3_1 to decide which function to call depending on the compiler being used. But then I need to retrieve the runtime version to decide what to do.


For the moment we use no extensions, only the #ifdef GL_VERSION_X_Y at compile time, and glGetString(GL_VERSION) at runtime. I'm sure in the near future this will need to change...

In Topic: Compiling and running on different OpenGL versions

22 December 2015 - 05:41 PM

Hi mhagain,




Unfortunately, what we distribute is a library that gets embedded into an end-user application that may go to thousands of end users. And I have no control over what end users are still using (you'd be surprised!).


So I have to assume the worst - even if that means people may still be at GL 1 (ok... maybe not that far back). But my source is full of #ifdef GL_VERSION_X_Y so that the end-user application can be compiled regardless of the version of GL they choose to use, and their end users can run it also regardless of what they have on their machine.

In Topic: Compiling and running on different OpenGL versions

22 December 2015 - 04:57 PM

One more thing - although I'm not sure this is the place for the question:


I'm using GLEW on Windows, and include the GLEW DLL with the distribution.


Suppose I build with the latest version of GLEW then I try to run on a machine that is so old that the graphics card is unable to support the version I include in my distribution. Would glewInit() fail? Or - because the DLL is from the latest version of GLEW - could I see that glGetString returns a version I believe would work (because it is my GLEW DLL they are using), but the call could still fail?


In other words, I'm trying to protect myself from a crash. I have no problem reporting that a feature is not supported, but I cannot have the application crash. If glewInit() fails that's no problem because I will report this as an error.


Thanks again.