matus-chochlik / oglplus

OGLplus is a collection of open-source, cross-platform libraries which implement an object-oriented facade over the OpenGL® (version 3 and higher) and also OpenAL® (version 1.1) and EGL (version 1.4) C-language APIs. It provides wrappers which automate resource and object management and make the use of these libraries in C++ safer and more convenient.
http://oglplus.org/
Boost Software License 1.0
494 stars 71 forks source link

Detection of supported GL version in the build system #6

Closed matus-chochlik closed 11 years ago

matus-chochlik commented 11 years ago

Examples (and test-modules?) should be built only if they use version less or equal than the detected version.

matus-chochlik commented 11 years ago

The detection of GL version supported by the library that provides GL API (for example GLEW) has been added to the build system.

Tomius commented 11 years ago

It is a bit o' buggy. It says I have OpenGL 4.3 while my hardware is only capable of ogl 3.3, so it includes wrong headers, tries to build tutorials that it shouldn't and basically floods with error messages upon build. Unless I manually specify the max OpenGL version when running the configure.py. I think Windows users without too much command line experience could have some trouble with it.

matus-chochlik commented 11 years ago

The current method of GL version detection is rather rudimentary and therefore not 100% reliable. Detecting the supported version reliably would require checking if everything is according to the specification which is a quite difficult task. I'll reopen this issue, but getting it done will take some time.

Tomius commented 11 years ago

I don't actually understand the method you are checking the OpenGL version, but extension loaders seem to have quite reliable method for doing this, at least for me, they report good version numbers. For ex: GLEW: if (!GLEW_VERSION_4_1) GL3W: if (!gl3wIsSupported(4, 1)) GLLoad: if (!glload::IsVersionGEQ(4, 1))

matus-chochlik commented 11 years ago

Right now the only thing that is checked is what the 'GL header' reports i.e. whether GL_VERSION_X_Y is defined. You could use GLEW/GL3W/etc. or even use oglplus::Context::VersionMajor() and VersionMinor(), but GLEW & co. may not be available everywhere, and also it requires an initialized GL context to work properly and I've seen instances when the returned version was not correct. Furthermore whatever method of version detection you use you have to integrate it into the cmake build-system. It is doable, but not trivial. I have this thing on the TODO list and I've been doing some changes to the build system recently so I'll probably have a look at this.

Tomius commented 11 years ago

Now it works well on all the 3 PCs I've tried! Great job!

matus-chochlik commented 11 years ago

Unfortunately not really :) It is too strict now. I have several machines where 'technically' the version is only 3.3 but many of the 4.x examples compile and run OK thanks to extensions and with the new detection method these don't get built now. I'll have to add extensions somehow and in the meantime I'll temporarily disable the strict version check. But stay tuned.

matus-chochlik commented 11 years ago

I've updated the detection of GL version + GL extensions and also the example dependencies (which still might not be 100% accurate) so it now should be more reliable. If anyone spots any problems related to this, please report them.