[Bf-committers] Error in GE files while compiling with scons + mingw

Christian Monfort monfort.c at gmail.com
Sat Apr 19 17:04:03 CEST 2008



Christian Monfort a écrit :
> Kent Mein a écrit :
>   
>> In reply to Christian Monfort (monfort.c at gmail.com):
>>
>>   
>>     
>>> Stephen Swaney a ?crit :
>>>     
>>>       
>>>> On Fri, Apr 18, 2008 at 04:02:52PM +0200, Christian Monfort wrote:
>>>>   
>>>>       
>>>>         
>>>>> In my MinGW directory (MinGW 5.1.3), glext.h is at version 11 (2002/03/22)
>>>>> and blDeleteObjectARB is not defined.
>>>>>
>>>>> Downloading latest glext.h from www.opengl.org shows latest version is 40
>>>>> (20080324), and there is a definition for blDeleteObjectARB...
>>>>>
>>>>> So this was introduced somewhere between V11 and V40; from there I see only
>>>>> 2 solutions:
>>>>>
>>>>> 1) get latest MinGW and check if blDeleteObjectARB is defined in glext.h
>>>>> 2) downlad openGL headers from www.opengl.org and put the new ones in MinGW
>>>>>
>>>>> Now another question: what happens if graphic card driver does not support
>>>>> the openGL extensions used here?
>>>>>     
>>>>>         
>>>>>           
>>>> 3)  set WITH_BF_GLEXT = 'false'
>>>>   
>>>>       
>>>>         
>>> Yes, of course, but not exactly what I had in mind... So I rephrase:
>>>
>>> What happens if Blender is compiled using openGL extensions (ie. 
>>> WITH_BF_GLEXT='true') and you graphic card does not support such extension?
>>> Is there some fall back mechanism (Blender detecting extensions are not 
>>> implemented, and so does not use them), or does it crash...
>>>
>>> If there is nothing in the code to prevent using extensions when they're 
>>> not implemented, I guess final release will be compiled with them turned 
>>> off, and you'll have to make your own build if you want to use them...
>>>     
>>>       
>> It's suppose to auto detect, there may be things that need tweaking
>> though since there are some values that have been hard coded.
>>
>> Once this is done theres still more to do....
>> If you look at 
>> source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
>> You'll see that it has this line in there:
>> #  undef GL_ARB_multitexture // (ubuntu)
>> This is a workaround that disables chunks of code, it would be better
>> to remove this and tell people with problems to disable it at runtime, and or
>> find out what the problem was/is...
>>
>> Kent
>>   
>>     
>
> Maybe there is other solution, somewhere in the openGL initialisation
> code (I don't remember where for now, I have to search for it...), there
> is a lot of function pointer initialization depending on the abilities
> of the openGL libraries. It maybe possible to test if funtions were
> found in library, and skip the code for those  that are not supported
> (or assume openGL extensions are not supported if one function is not
> found).
>
> I think I made something like that in a V2.43 custom build I made for
> displaying a mix of 2 textures in 3D view textured mode.
> I'll look in my code and post here what I found.
>
>   
Ok I've found the code (not the cleanest code I've wrote, but it was 
just a hack...):

The main thing was in blender/src/drawmesh.c file (in V2.43 release, I 
don't know if it's still there) - condititional compiling on "WITH_FO2":

I added the following at beginning of file:

----- 8< -----
#ifdef WITH_FO2
#ifdef WIN32
#include <windows.h>
#endif
#include <GL/glext.h>

PFNGLACTIVETEXTUREARBPROC       glActiveTextureARB       = NULL;
PFNGLMULTITEXCOORD2FARBPROC     glMultiTexCoord2fARB     = NULL;
PFNGLMULTITEXCOORD2FVARBPROC    glMultiTexCoord2fvARB    = NULL;
PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB = NULL;

int FO2_has_GL_ARB       = 0;
int FO2_nNumTextureUnits = 0;

#endif // WITH_FO2
----- 8< -----

and modified the init_realtime_GL() function like this:

----- 8< -----
void init_realtime_GL(void)
{
#ifdef WITH_FO2
    char *ext = (char*)glGetString( GL_EXTENSIONS );
    if( NULL == strstr( ext, "GL_ARB_multitexture" )) {
        printf("GL_ARB_multitexture not detected\n" );
    } else {
        printf("GL_ARB_multitexture detected\n" );
    //
    // If the required extension is present, get the addresses of its
    // functions that we wish to use...
    //
        glActiveTextureARB       = 
(PFNGLCLIENTACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB");
        glMultiTexCoord2fARB     = 
(PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB");
        glMultiTexCoord2fvARB    = 
(PFNGLMULTITEXCOORD2FVARBPROC)wglGetProcAddress("glMultiTexCoord2fvARB");
        glClientActiveTextureARB = 
(PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glClientActiveTextureARB");
        if( glActiveTextureARB &&
            glMultiTexCoord2fARB &&
            glMultiTexCoord2fvARB &&
            glClientActiveTextureARB ) {

            FO2_has_GL_ARB = 1;
            glGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, 
&FO2_nNumTextureUnits );

            printf("GL_ARB_multitexture enabled\n" );

#ifdef WITH_FO2_DBG
            printf( "GL_ARB_multitexture MaxTextures=%d\n",
                    FO2_nNumTextureUnits );
#endif // WITH_FO2_DBG

        } else {
            FO2_has_GL_ARB = FO2_nNumTextureUnits = 0;
            glActiveTextureARB       = NULL;
            glMultiTexCoord2fARB     = NULL;
            glMultiTexCoord2fvARB    = NULL;
            glClientActiveTextureARB = NULL;

            printf("GL_ARB_multitexture disabled (init error)\n" );
        }

    }
#endif // WITH_FO2

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);

}
----- 8< -----

Then when I needed to use some of the openGL extentions, I only had to 
test for FO2_has_GL_ARB; if 0 I used the original Blender code, else I 
used my new code, that way users with hardware /drivers supporting 
openGL extensions I used could benefit from new functionalities, and 
others were using original features.

Christian.
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>
>   


More information about the Bf-committers mailing list