I load textures like this:
if ( !b.load( "ffont.bmp" ) )
b = QImage( 16, 16, 32);
b.fill( Qt::red.rgb() );
t = QGLWidget::convertToGLFormat( b );
glGenTextures( 1, &texture);
glBindTexture( GL_TEXTURE_2D, texture);
glTexImage2D( GL_TEXTURE_2D, 0,3, t.width(), t.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, t.bits());
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
I would like to store more than just one Texture in a (1) BMP file (e.g. for fonts) and I just dont know how…
I thought I could just write 32 instead of t.width() and it should give me the first 32 pixels of the bitmap. However its not working so far… Or is there a function like glTexCoord2 to set the width and height of the Texture later?
I use Fedora Core 4 and QT.
Thank you for your help!!!
How about uploading the whole large texture as one texture object and use texture coordinates to select which sub texture you wish to use (this is how I do it for texture fonts)? This will be more efficient anyway as it reduces the number of texture binds.
Look up “texture atlases.”
I tried to do it like this:
…But it doesnt work. It gives me a very distorted texture. What am i doing wrong?
Thank you for your help!
i have to use float instead of int! :rolleyes:
it has nothing to do with ogl, but with c+ when you divide two integers, then the result is also an integer when at least one of them is float, then the result is float.
so it would be 1/40.0f or 1.0f/40 or 1.0f/40.0f …