Using GL_GENERATE_MIPMAP_SGIS

I’ve attempted to use this however when I use it with glCopyTexImage2D I get no texture.

That make sence as I’ve notice that glCopyTexImage2D gets no pointer to my data.

How does this all work? Do I need to load the texture in first with glTexImage2D then call glCopyTexImage2D ?

I’ve tried a few combinations but can’t seem to work out how this is meant to be operated.

Any clues?

Chris

Im not sure about the correct way to do it, but when I used glCopyTexSubImage2D(), I had to do this:

Initialization:
glGenTextures()
glBindTexture()
glTexImage2D() with texture data all 0’s, i.e. black.
glTexParameteri() for whatever parameters you want, and set generate mipmaps to true

Without the glTexImage2D, it didnt work.

The mipmaps should be regenerated every time you change the level 0 image – regardless of how you modify it. Are you sure you enabled mipmap generation before calling glCopyTexImage2D()?

– Tom

Originally posted by gimp:
That make sence as I’ve notice that glCopyTexImage2D gets no pointer to my data.

The framebuffer is the source for glCopyTexImage2D.
To use a memory area as source, you have to use glTexImage2D.

The …SubImage commands only work to replace (a part of) the color information of an already created texture.

Mipmaps should be generated when using GL_GENERATE_MIPMAP_SGIS whenever level zero of a texture is modified.

Jean-Marc.

This is my best attempt:

unsigned int Index = 0;
glGenTextures(1, &Index);
glBindTexture(GL_TEXTURE_2D, Index);

if (m_HardwareGenerateMipmap == true)
{
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
glTexImage2D( GL_TEXTURE_2D,
TEXTURE_LEVEL_0,
GL_RGBA,
a_Image.GetWidth(),
a_Image.GetHeight(),
NO_BORDER,
GL_BGRA_EXT,
GL_UNSIGNED_BYTE,
a_Image.GetData());

  glCopyTexImage2D(	GL_TEXTURE_2D,
  					TEXTURE_LEVEL_0,
  					GL_RGBA,
  					0,
  					0,
  					a_Image.GetWidth(), 
  					a_Image.GetHeight(), 
  					NO_BORDER);

}

When this code is run glGetError() returns 0 but all my textured area are blank.

However when I remove the glCopyTexImage2D code the textures are generated normally. However I suspect thats just because no mipmaps are being generated, not that I know how to check this either.

This looks to be what you guys are suggesting, but it still doesn’t work.

I’ve followed up every link in google for ‘GL_GENERATE_MIPMAP_SGIS’ but haven’t found any simple demo’s\code that describe how this is meant to work…

Many thanks,

Chris

Do you understand that glCopyTexImage2D take it’s data fromt he frame buffer? if it’s blank then the texture will be blank…

What are you trying to do anyway? If you really try to copy your frame buffer into a texture, there is no sense in calling glTexImage2D with real data. Send it NULL instead.

if you use glCopyTexImage to create your texture, why creating it before with glTexImage as well? you just need ONE TIME A TexImage call per texture. ONE TIME. eighter glCopy or just gl. if you use gCopyTexImage, you need data in the screenbuffer (the one you defined to readout).