automatic mipmapsgeneration

in a presentation from nvidia i read that using the SGIS_generate_mipmap extension would speed up daynamic texture genartion by 50%. now if replace my existing gluBuild2DMipmaps( GL_TEXTURE_2D, 3, Width, Height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels ); by
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE ); texturing doesn’t work. what do i do wrong?
thx in advance, floww

If you just replace glBuild2DMipmaps with glTexParameter, then of course it won’t work since you’re not uplaoding any texture data. At least a call to glTexImage is required.

i’m aware of thatbut still it doesnt work,
here is my entire displaymethod:
void display(void){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GrabScreen();
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
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_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE );
//gluBuild2DMipmaps( GL_TEXTURE_2D, 3, Width, Height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels );
glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, Width, Height, GL_RGB8, GL_INT, image );
drawAll(GL_RENDER);
glutSwapBuffers();
}

Since you’re updating an existing texture with TexSubImage, have you created the texture in the first place? TexSubImage won’t create one, only update an existing. Also make sure width and height have valid values (applies to the texture itself only, the image you update the texture with can be of any size). Build2DMipmaps will resize the image if necessary, which is a common mistake to believe the image is valid. Only powers of two are valid dimensions.

You must tell the GL what the internal texture format should be. A glTexImage2D call (without “Sub”) is required.

Eg

glBindTexture(GL_TEXTURE_2D,gl_tex_obj);
glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP_SGIS,true);
<...> //other texparam stuff
glTexImage2D(GL_TEXTURE_2D,0,3,width,height,GL_BGRA_EXT,GL_UNSIGNED_BYTE,[b]NULL[/b]);

The ‘NULL’ can be used in place of a data pointer to mean something like “no data yet”. You can fill in a proper data pointer, of course.

Now your texture object has been properly created. Whenever you wish to update the data, you can

glTexSubImage2D(GL_TEXTURE_2D,0,0,0,width,height,GL_BGRA_EXT,GL_UNSIGNED_BYTE,image);

Another hint: use “GL_RGB” instead of “3”. It’s IMO easier to understand.

GL_RGB8 is not a valid source format for TexSubImage. It’s a valid internal format, so it can be used in place of “3”. For source formats, only the ordering (rgba vs bgra) can be specified while the data type (bytes vs ints) is the next function argument.

Originally posted by floww:
in a presentation from nvidia i read that using the SGIS_generate_mipmap extension would speed up daynamic texture genartion by 50%.
Unfortunately, on ATI cards the opposite seems to be the case.

thank u all
we finally made it… =)