glXGetProcAddress-> glXGetProcAddressARB (irrlich 0.9 Lin

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
cal
Posts: 3
Joined: Tue Feb 24, 2004 11:01 pm
Location: Germany

glXGetProcAddress-> glXGetProcAddressARB (irrlich 0.9 Lin

Post by cal »

If I compile the examples with irrlicht 0.9 at Linux, I get this error:

../../lib/Linux/libIrrlicht.a(CVideoOpenGL.o)(.text+0xde4): In function `irr::video::CVideoOpenGL::loadExtensions()':
: undefined reference to `glXGetProcAddress'

I think you can fix this if you change

Code: Select all

 glXGetProcAddress to glXGetProcAddressARB 
in CVideoOpenGL.cpp.
and add

Code: Select all

 #define GLX_GLXEXT_PROTOTYPES 
in COpenGLTexture.h

What do u think about this fix?
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Hm, it's an idea.
I don't really know what the right or best way is to do it. For example, on my PC, glXGetProcAddressARB doesn't work and glXGetProcAddress does. I know why I like Windows better than linux :) I should have investigated more into this stuff before releasing 0.9.
Guest

Post by Guest »

I have the same problem and it's because of that, but is there any solution?
Guest

Post by Guest »

Simply replace any glXGetProcAddress with glXGetProcAddressARB.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

thnx Cal, your fix works great!

I was having the same problem in linux.

:D
hybrid

Post by hybrid »

In glx.h the following can be found:

Code: Select all

/* GLX 1.4 and later */
extern void (*glXGetProcAddress(const GLubyte *procname))( void );

#ifndef GLX_GLXEXT_LEGACY
#include <GL/glxext.h>
#else

[...]
/*
 * ARB 2. GLX_ARB_get_proc_address
 */
#ifndef GLX_ARB_get_proc_address
#define GLX_ARB_get_proc_address 1

extern void (*glXGetProcAddressARB(const GLubyte *procName))();
#endif /* GLX_ARB_get_proc_address */

#endif /* GLX_GLXEXT_LEGACY */
So I guess it is a version problem?! I will have to check for the proper defines to test for, but there are definitely some means to distinguish the different versions and use a proper function.
Mike

Post by Mike »

Replacing glXGetProcAddress with glXGetProcAddressARB in CVideoOpenGL.cpp didn't work for me under Fedora Core 3.
Mike

Post by Mike »

Oops it does - just had to replace the default glx.h file with the one from NVIDIA.
Thoth_Onegan

Post by Thoth_Onegan »

This problem is because in GLX1.3 they had glXGetProcAddressARB, however with GLX1.4, they changed it to simply glXGetProcAddress.

That also explains the really simple fix :)
hybrid

Post by hybrid »

Ok, the complete and backward compatible fix would be the following:

Code: Select all

#ifdef GLX_VERSION_1_4
glXGetProcAddress(reinterpret_cast<const GLubyte*>("glActiveTextureARB"));
#else
glXGetProcAddressARB(reinterpret_cast<const GLubyte*>("glActiveTextureARB"));
#endif
Or, if we want to reduce redundant code one might re-define glXGetProcAddress to glXGetProcAddressARB if the symbol is not defined.
hybrid

Post by hybrid »

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.
Post Reply