Hi, I’m looking for some performance advice for texture mapping, specifically how to achieve the highest frame rates with ‘large’ texture files.
I use my texture as a background for coding GIS type data on top off (i.e. my texture is an a aerial photograph). Because of this my texture could be much more than the maximum of 1024x1024 pixels allowed by OpenGl (is that correct ?). Currently I restrict the max texture size I can use to 1024x124.
So my question is which will render faster, one large texture (say 1024x124) or X number of small textures (say 4 x 512x512) ?
If it’s the case that many small textures can be drawn faster than one large texture, how should I approach splitting up my one large texture into multiple 2^X smaller textures ? More importantly how can I scale/stretch my texture (the char* part ) to make sure the many smaller parts conform to 2^X while marinating the integrity of the image ? Any code suggestions etc. are welcome as this has me completely stumped !
Currently when I render my single texture (max size 1024x124) I map it to a simple Quad, I use the code below to carry out the mapping/rendering; the drawing part of this code is inside a display list to help improve re-draw times. Is there a quicker way ?
Any help etc. is appreciated, I’m stuck !
Thanks in advance,
Ewan
/* =====================================================
-
Bind the texture data to the gl texture object ‘new_texture_id’ , only used
-
once when the texture file (a BMP) is processed */
{
glBindTexture(GL_TEXTURE_2D, new_texture_id);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);/* scaling a streching */
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_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);/* bind the texture */
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, no_boarder,
GL_RGB, GL_UNSIGNED_BYTE, texture_rgb_char_data);
}
/* =====================================================
- now map the texture to the quad, this section is inside the display list */
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, id);
glBegin(GL_QUADS);
/* lower left corner /
glTexCoord2f(0.0f,0.0f);
glVertex3f(-texture_width/2, -texture_height/2, texture_z_offset);
/ lower right corner /
glTexCoord2f(1.0f, 0.0f);
glVertex3f(texture_width/2, -texture_height/2, texture_z_offset);
/ upper right corner /
glTexCoord2f(1.0f, 1.0f);
glVertex3f(texture_width/2, texture_height/2, texture_z_offset);
/ upper left corner */
glTexCoord2f(0.0f, 1.0f);
glVertex3f(-texture_width/2, texture_height/2, texture_z_offset);
glEnd ();
glDisable (GL_TEXTURE_2D);
}