TarmoPikaro
TarmoPikaro

Reputation: 5223

OpenGL, loading textures - additional noise on textures

In our own 3d application I'm loading multiple textures, using devil library. When attempting to load one texture, I'm calling ilutRenderer( ILUT_OPENGL );, which in a turn perform following function calls:

ILboolean ilutGLInit()
{
    // Use PROXY_TEXTURE_2D with glTexImage2D() to test more accurately...
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&MaxTexW);
    glGetIntegerv(GL_MAX_TEXTURE_SIZE, (GLint*)&MaxTexH);
    if (MaxTexW == 0 || MaxTexH == 0)
        MaxTexW = MaxTexH = 256;  // Trying this because of the VooDoo series of cards...

    // Should we really be setting all this ourselves?  Seems too much like a glu(t) approach...
    glEnable(GL_TEXTURE_2D);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
    glPixelStorei(GL_PACK_ALIGNMENT, 1);

#ifdef _MSC_VER
    if (IsExtensionSupported("GL_ARB_texture_compression") &&
        IsExtensionSupported("GL_EXT_texture_compression_s3tc")) {
            ilGLCompressed2D = (ILGLCOMPRESSEDTEXIMAGE2DARBPROC)
                wglGetProcAddress("glCompressedTexImage2DARB");
    }
#endif

    if (IsExtensionSupported("GL_ARB_texture_cube_map"))
        HasCubemapHardware = IL_TRUE;

    return IL_TRUE;
}

ilutRenderer( ILUT_OPENGL ); needs to be called only once (for each newly created window), but while experimenting I've called same function multiple times. (one call for each loaded texture)

If same function were called multiple times - loaded openGl texture was looking with poorer quality than if called once. (I have multiple textures, but most of them with poorer quality, not sure about first image).

I was stumbled about it - since from my perspective that call did not do anything special - why it cannot tolerate multiple similar calls ?

Well, I've started to filter out which functions can be called multiple times and which cannot be - and concluded that it was glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); which triggered odd behavior. So wrapping function like this:

    if( !bInitDone )
    {
        bInitDone = TRUE;
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    }

after that ilutRenderer( ILUT_OPENGL ) can be called as many times as needed.

I have also tried to centralize opengl initialization like this:

...
InitGL( OnWindowReady )

...

void OnWindowReady( void )
{
    ilInit();
    ilutRenderer( ILUT_OPENGL );
}

... may be some rendering code ...

void LoadModel( const wchar_t* file )
{
    ... load texture 1 ...
    ... load texture 2 ...
}

But textures are still appearing "as corrupted". Maybe window should be rendered at least once before starting to load textures, but I want to know what functions in OpenGL are reflecting texture corruption / looking nice kind of state.

I have "NVidia Quadro K2100M", driver version 375.86.

Is this display driver bug ? How do you typically report bugs to NVidia ?

Upvotes: 0

Views: 200

Answers (0)

Related Questions