OpenGL shader operations issues.

For discussion of ports to POSIX based systems, especially using GNUStep.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Getafix
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 979
Joined: Tue Apr 01, 2008 12:55 pm
Location: A small ice asteroid, orbiting Oresrati in Galaxy 8 (a.k.a. northwest Armorica).
Contact:

OpenGL shader operations issues.

Post by Getafix »

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:

Code: Select all

#ifdef GL_GLEXT_PROTOTYPES
...
<list of OpenGL extensions function prototypes>
...
#endif /* GL_GLEXT_PROTOTYPES */
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 define prototypes as well as typedefs, the application must #define GL_GLEXT_PROTOTYPES prior to including gl.h or glx.h ...
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)

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>
to look like
(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
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:
  • 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.
Question
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.)?
Last edited by Getafix on Wed Apr 09, 2008 10:36 am, edited 1 time in total.
"Any sufficiently advanced information is indistinguishable from noise." [Newman, Lachmann, Moore]
User avatar
davcefai
---- E L I T E ----
---- E L I T E ----
Posts: 400
Joined: Sun Dec 03, 2006 9:07 pm

Post by davcefai »

Running Debian Unstable on an Athlon 64 3200+ and an NVidia GS8400.

I have noticed that, in recent builds of v1.71 the planet are less "pretty" and the alloy fragments are plain white.

I don't have the OXPs you refer to.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6740
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

davcefai, can you please give a try with Freaky Thargoids? The latest version is downloadable from the wiki, OXP section.

I am curious as to how come nobody has noticed the total lack of shaders on Linux. I think it is important to know if Getafix's observation is specific to his system or if it is a general Linux issue.
User avatar
Getafix
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 979
Joined: Tue Apr 01, 2008 12:55 pm
Location: A small ice asteroid, orbiting Oresrati in Galaxy 8 (a.k.a. northwest Armorica).
Contact:

Post by Getafix »

Davcefai,
you can just click here to download the compressed OXP folder. Unzip it in your "Addons" folder and launch Oolite. Press 'N' to dismiss the option to load a saved game, and watch the various space crafts and things zooming in and out on your screen. Wait until the "Thargoid Warship" appears. It should have animated textures and a glow that travels up and down the sides and across the bars underneath. Follow this link to get an idea of the textures (static) used.
"Any sufficiently advanced information is indistinguishable from noise." [Newman, Lachmann, Moore]
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6740
Joined: Wed Feb 28, 2007 7:54 am

Re: OpenGL shader operations issues.

Post by another_commander »

Getafix wrote:
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.
It looks like the code is already taking good care of this. I think it is safe for this fix to go in.
User avatar
Getafix
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 979
Joined: Tue Apr 01, 2008 12:55 pm
Location: A small ice asteroid, orbiting Oresrati in Galaxy 8 (a.k.a. northwest Armorica).
Contact:

Post by Getafix »

another_commander wrote:
It looks like the code is already taking good care of this.
The code takes care of it, indeed, in the function "checkShadersSupported" that is defined and used in "OOOpenGLExtensionManager.m" file.

Note
You will notice an "#if OOLITE_WINDOWS" section, within the same function. In Windows environment, you must use "wglGetProcAddress" to get the addresses of vendor-specific extension functions, because extension functions are not exported by OpenGL (see Microsoft Developer Network Library). There is no need for a Linux equivalent section and therefore the fix should be enough.
"Any sufficiently advanced information is indistinguishable from noise." [Newman, Lachmann, Moore]
User avatar
davcefai
---- E L I T E ----
---- E L I T E ----
Posts: 400
Joined: Sun Dec 03, 2006 9:07 pm

Post by davcefai »

I get the wild colour scheme and the glow but no animation.

FWIW the Galcop Viper, as modded by Little Bear in Assasins, has flashing lights.
User avatar
Getafix
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 979
Joined: Tue Apr 01, 2008 12:55 pm
Location: A small ice asteroid, orbiting Oresrati in Galaxy 8 (a.k.a. northwest Armorica).
Contact:

Post by Getafix »

The GalCop Viper had flashing lights for me too, even before I tried the code fix. The issue appeared with the enhanced effects thargoid.

As soon as the fix is checked-in, I will invite you to try again, hoping that you will also get full effects.
"Any sufficiently advanced information is indistinguishable from noise." [Newman, Lachmann, Moore]
User avatar
davcefai
---- E L I T E ----
---- E L I T E ----
Posts: 400
Joined: Sun Dec 03, 2006 9:07 pm

Post by davcefai »

I am curious as to how come nobody has noticed the total lack of shaders on Linux.
Nothing to compare with! I thought that all the chat about shaders was related to planet appearance.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6740
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

The Linux shaders fix is in the trunk now, revision 1547. Linux users with systems supporting shaders, please confirm that it works for you. Linux users with systems not supporting shaders, please check that everything still runs OK and the fix has not created any side effects for you.

The check is to use Freaky Thargoids and ensure that the textures on Thargoid Warships and Thargoid Robot Fighters are animated.
User avatar
Getafix
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 979
Joined: Tue Apr 01, 2008 12:55 pm
Location: A small ice asteroid, orbiting Oresrati in Galaxy 8 (a.k.a. northwest Armorica).
Contact:

Post by Getafix »

The first post, in this thread, has been altered so as to display the code checked in for v1.71 svn rev. 1547.
"Any sufficiently advanced information is indistinguishable from noise." [Newman, Lachmann, Moore]
User avatar
davcefai
---- E L I T E ----
---- E L I T E ----
Posts: 400
Joined: Sun Dec 03, 2006 9:07 pm

Post by davcefai »

I confirm that I am seeing the animated paint jobs on the freaky Thargoids.

Thanks gentlemen.
User avatar
Getafix
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 979
Joined: Tue Apr 01, 2008 12:55 pm
Location: A small ice asteroid, orbiting Oresrati in Galaxy 8 (a.k.a. northwest Armorica).
Contact:

Post by Getafix »

Another one bites the dust! 8)
"Any sufficiently advanced information is indistinguishable from noise." [Newman, Lachmann, Moore]
User avatar
davcefai
---- E L I T E ----
---- E L I T E ----
Posts: 400
Joined: Sun Dec 03, 2006 9:07 pm

Post by davcefai »

Another one bites the dust!
Shouldn't that be:

Another one out of the airlock? :D
Post Reply