Sign in to follow this  
Lazy Foo

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

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 );
    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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this