OpenGL shader operations issues.
Posted: Thu Apr 03, 2008 6:26 pm
Trying to build Oolite 1.71 (1537) on my PC (Ubuntu Desktop 64bit, Intel Dual Core, nVidia 8600GT), burning the midnight oil with Another_Commander, he didn't like the fact that OpenGL function warnings were being generated. Furthermore, I didn't like the fact that my Oolite did not display the shader example OXPs correctly (i.e. no animated shaders, no metallic glowing etc.). These two facts seemed related and we started the code-digging. Almost two hours later we had nailed the little trumble! Since Another_Commander left to me the honor to post this, today I continued my investigation on the issue, browsing through several BBs, digging more into the code, in order to have a more educated opinion and prepare the following issue analysis:
Issue Detection
The build of Oolite generates 'implicit declaration' warnings on OpenGL functions in various code locations. In my environment the files 'PlanetEntity.m, OOShaderProgram.m, OOShaderUniform.m' raised the OpenGL warnings while the svn revision 1537 nightly build status also reports the 'OOShaderMaterial.m'. The consequence is shading operations malfunction that can be easily be tested using any shader example OXP (e.g. Griff Station and Freaky Thargoids have no animated shaders).
Issue Analysis
1. Depending to the compiler or the compilation options, '<OpenGL function-name> undeclared' errors could also be generated.
2. The functions which raise the warnings/errors are declared in a code-block within the 'SDL_opengl.h, glext.h' files. However, these declarations are embraced within the following '#ifdef...#endif' statements:
and there was no file defining "GL_GLEXT_PROTOTYPES".
3. The same desktop workstation using Vista 32bit does not present this problem, due to 'OOOpenGLExtensionManager.m' that explicitely handles the OpenGL extended functions' entry points.
Issue Action
The OpenGL organization states the following in the ABI for Linux:
to look like
(EDIT on the 9th of April 2008 to comply with v1.71 svn rev. 1547)
and then rebuilt Oolite. The shaders should now be operational.
Note
This is just a workaround in order to have shaders. Normally, the code should check the video card's shader compliance and do the following:
Is there anyone else with Linux platform that has managed to see shaders correctly (i.e. freaky thargoid's texture is animated apart from freaky, Griff Station's antenna has animated color etc.)?
Issue Detection
The build of Oolite generates 'implicit declaration' warnings on OpenGL functions in various code locations. In my environment the files 'PlanetEntity.m, OOShaderProgram.m, OOShaderUniform.m' raised the OpenGL warnings while the svn revision 1537 nightly build status also reports the 'OOShaderMaterial.m'. The consequence is shading operations malfunction that can be easily be tested using any shader example OXP (e.g. Griff Station and Freaky Thargoids have no animated shaders).
Issue Analysis
1. Depending to the compiler or the compilation options, '<OpenGL function-name> undeclared' errors could also be generated.
2. The functions which raise the warnings/errors are declared in a code-block within the 'SDL_opengl.h, glext.h' files. However, these declarations are embraced within the following '#ifdef...#endif' statements:
Code: Select all
#ifdef GL_GLEXT_PROTOTYPES
...
<list of OpenGL extensions function prototypes>
...
#endif /* GL_GLEXT_PROTOTYPES */
3. The same desktop workstation using Vista 32bit does not present this problem, due to 'OOOpenGLExtensionManager.m' that explicitely handles the OpenGL extended functions' entry points.
Issue Action
The OpenGL organization states the following in the ABI for Linux:
In order to comply to this statement, while minimizing the risk of undesirable side-effects, the 'OOOpenGL.h' code must be altered (SpiceIsland's original post adaptation)... To define prototypes as well as typedefs, the application must #define GL_GLEXT_PROTOTYPES prior to including gl.h or glx.h ...
Code: Select all
#elif OOLITE_SDL
// SDL OpenGL includes...
// prevent the including of SDL_opengl.h loading a previous version of glext.h
#define NO_SDL_GLEXT
// the standard SDL_opengl.h
#include <SDL_opengl.h>
// include an up-to-date version of glext.h
#include <GL/glext.h>
(EDIT on the 9th of April 2008 to comply with v1.71 svn rev. 1547)
Code: Select all
#elif OOLITE_SDL
// SDL OpenGL includes...
// prevent the including of SDL_opengl.h loading a previous version of glext.h
#define NO_SDL_GLEXT
// GL_GLEXT_PROTOTYPES must be defined for the Linux build to use shaders.
// The preprocessor if statement below is required as is, because the LINUX
// symbol is defined for both Windows and Linux builds.
#if (OOLITE_LINUX && !OOLITE_WINDOWS)
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
#define __DEFINED_GL_GLEXT_PROTOTYPES
#endif // GL_GLEXT_PROTOTYPES
#endif // OOLITE_LINUX && !OOLITE_WINDOWS
// the standard SDL_opengl.h
#include <SDL_opengl.h>
// include an up-to-date version of glext.h
#include <GL/glext.h>
#ifdef __DEFINED_GL_GLEXT_PROTOTYPES
#undef GL_GLEXT_PROTOTYPES
#undef __DEFINED_GL_GLEXT_PROTOTYPES
#endif
Note
This is just a workaround in order to have shaders. Normally, the code should check the video card's shader compliance and do the following:
- 1. If all of the Oolite mandatory functions are supported then continue with shaders on.
2. If none of the Oolite mandatory functions are supported then continue with no shaders.
3. If the Oolite mandatory functions are partially supported then exit writing a descriptive serious error message to the log.
Is there anyone else with Linux platform that has managed to see shaders correctly (i.e. freaky thargoid's texture is animated apart from freaky, Griff Station's antenna has animated color etc.)?