Jump to content
  • Advertisement
Sign in to follow this  
Lazy Foo

Can't find the cause of "invalid enumerant" error

This topic is 3926 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I managed to isolate the problem to this function, which creates a white texture of the requested size.
bool Texture::blank_image( GLuint w, GLuint h )
{
    GLuint buf[ w * h ];
    
    imgW = w;
    imgH = h;
    
    texW = w;
    texH = h;
    
    for( int i = 0; i < w * h; i++ )
    {
        buf[ i ] = 0xFFFFFFFF;
    }
    
    glGenTextures( 1, &texture );
        
    glBindTexture( GL_TEXTURE_2D, texture );

    glTexImage2D( GL_TEXTURE_2D, 0, 32, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf );
        
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); 
    glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); 
    
    return true;
}


It's pretty much identical to my image loading function except for the source of the pixel data. I have no idea what's causing it.

Share this post


Link to post
Share on other sites
Advertisement
Hmm... I'm not entirely confident of this, but is "32" a valid value for parameter three of glTexImage2D? Should it not be "GL_RGBA" instead?

Share this post


Link to post
Share on other sites
Quote:
Original post by Lazy Foo
...well that was embarrassing.

Actually it's supposed to be 4. I forgot that it's bytes, not bits per pixel.
Actually it's neither. It's the internal format that OpenGL should store the texture data in. It can accept either the number of channels (1, 2, 3, or 4) or one of several constants. You should prefer to use the constants instead because 1-4 are only supported for backwards compatibility with OpenGL 1.0. You should also use the constant that describes what you want in the most detail. So if you want a 32-bit RGBA texture, use GL_RGBA8 instead of GL_RGBA.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!