I made an even better version joining windows and linux code into one large block without redundancy. I renamed _IRR_LINUX_OPENGL_USE_EXTENSIONS_ to _IRR_OPENGL_USE_EXTENSIONS_ to handle windows and linux the same. The test for number of multitextures moved into the if(MultiTextureExtension) block. The pointer declaration in CVideoOpenGL.h can be joined as well (maybe using some ifdefs to test OpenGL versions?). The caller functions have to change their ifdef checks as well, an example is added below.
I'm not sure whether ARBVertexProgramExtension and ARBFragmentProgramExtension should also be checked before the pointer is assigned?! Wasn't done for windows before, so I did not change.
Code: Select all
if (MultiTextureExtension)
{
#ifdef _IRR_OPENGL_USE_EXTENSIONS_
#ifdef _WIN32
#define GetProcAddress(X) wglGetProcAddress(X)
#else
#ifdef GLX_VERSION_1_4
#define GetProcAddress(X) glXGetProcAddress(reinterpret_cast<const GLubyte*>(X))
#else
#define GetProcAddress(X) glXGetProcAddressARB(reinterpret_cast<const GLubyte*>(X))
#endif
#endif // _WIN32
pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) GetProcAddress("glActiveTextureARB");
pGlClientActiveTextureARB= (PFNGLCLIENTACTIVETEXTUREARBPROC) GetProcAddress("glClientActiveTextureARB");
if (!pGlActiveTextureARB || !pGlClientActiveTextureARB)
{
MultiTextureExtension = false;
os::Printer::log("Failed to load OpenGL's multitexture extension, proceeding without.", ELL_WARNING);
}
// get fragment and vertex program function pointers
pGlGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) GetProcAddress("glGenProgramsARB");
pGlBindProgramARB = (PFNGLBINDPROGRAMARBPROC) GetProcAddress("glBindProgramARB");
pGlProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) GetProcAddress("glProgramStringARB");
pglDeleteProgramsARB = (PFNGLDELETEPROGRAMSNVPROC) GetProcAddress("glDeleteProgramsARB");
pglProgramLocalParameter4fvARB = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) GetProcAddress("glProgramLocalParameter4fvARB");
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &MaxTextureUnits);
if (MaxTextureUnits < 2)
{
MultiTextureExtension = false;
os::Printer::log("Warning: OpenGL device only has one texture unit. Disabling multitexturing.", ELL_WARNING);
}
#else // _IRR_OPENGL_USE_EXTENSIONS_
MultiTextureExtension = false;
ARBVertexProgramExtension = false;
ARBFragmentProgramExtension = false;
os::Printer::log("Extensions disabled.", ELL_WARNING);
#endif // _IRR_OPENGL_USE_EXTENSIONS_
}
Here is an example for a caller function:
Code: Select all
void CVideoOpenGL::extGlActiveTextureARB(GLenum texture)
{
#if defined(_IRR_OPENGL_USE_EXTENSIONS_)
if (MultiTextureExtension && pGlActiveTextureARB)
pGlActiveTextureARB(texture);
#endif
}
Could please somebody test this with windows, and does one know about a linux gfx driver supporting programs? With Mesa-6.2.3 (GLX 1.4) it compiles, but I can't test the executable.