Jump to content
  • Advertisement
Sign in to follow this  
amigocz

mipmaps and compressed textures

This topic is 3494 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

Hello, I'm trying to manually create a compressed texture with mipmaps, but I've got a problem. I want to have a function like SetMipMapData(unsigned int miplevel, unsigned char *data, unsigned int len); which would fill the given mipmap layer with a given data. Now I guess that I've got 2 options while creating a texture. The first one is to create the texture layers blank. glInternalFormat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; glCompressedTexImage2DARB(GL_TEXTURE_2D, i, glInternalFormat, width, height, 0, 0, 0); but this causes "The operation is illegal in its current state!" error and the texture is black. The other way is to create a texture with one layer and later bind it again and add an layer but I don't know if I can do that, because it causes the same error . bool CTextureWrapper::SetMipMapData(unsigned int miplevel, unsigned char *data, unsigned int len) { unsigned int w, h; if(miplevel == 0) { w = m_texSize.x; h = m_texSize.y; } else { w = m_texSize.x/(2*miplevel); h = m_texSize.y/(2*miplevel); } glBindTexture(GL_TEXTURE_2D, m_texID); glCompressedTexImage2DARB(GL_TEXTURE_2D, miplevel, m_internalFormat, w, h, 0, len, data); CheckGLErrors("SetMipMapData"); return true; } Do you have any suggestions, please?

Share this post


Link to post
Share on other sites
Advertisement
Oh, sorry

I've got Windows Vista, GTX260 graphics card with latest grahics drivers (even those for ogl 3, but I'm not using it) and I'm not using GLEW or anything like that.

It seems to me like if I could not setup another layer that 0 in the glCompressedTexImage2DARB function.

Share this post


Link to post
Share on other sites
Are you saying that your application crashes or you get a GL error?

void CompressedTexImage2D( enum target, int level,
enum internalformat, sizei width, sizei height,
int border, sizei imageSize, void *data );


I didn't see it in the spec but I think you need to have an actual value for imageSize and provide a read *data or else GL_INVALID_VALUE might be thrown.

For the mipmapping, try to let it generate the mipmaps
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

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!