PDA

View Full Version : loading & applying texture



OgliX
08-22-2002, 11:40 PM
I am writing a small program which uses 35 Bitmap images as texturs at appropriate place
but since one can't call methods related to texture once entered in glBegin() I have to load all of them at start and which obviously causes my program to run at slowest speed. Instead is it possible to use
one common image and apply its parts as textures? If it is Possible please tell me how?(or link me to solution)

Rob Fletcher
08-22-2002, 11:47 PM
Hi,

glTexSubImage2D


Is your friend!!!!!

Rob.

nexusone
08-23-2002, 04:54 AM
The are a few examples of multiple textures in one texture file.

Try nehe.gamedev.net for staters.



Originally posted by OgliX:
I am writing a small program which uses 35 Bitmap images as texturs at appropriate place
but since one can't call methods related to texture once entered in glBegin() I have to load all of them at start and which obviously causes my program to run at slowest speed. Instead is it possible to use
one common image and apply its parts as textures? If it is Possible please tell me how?(or link me to solution)

Relic
08-23-2002, 04:56 AM
Yes, glTexSubImage2D allows you to download them piecewise, selection of them is done with the appropriate glTexCoord values.
Let's say they are packed in a 6x6 grid (i x j)in your case, texture coordinates go from i/6 to (i+1)/6 in u for 0 <= i <= 5, same for j and v.
Now for the tricky part. This works nicely with neqarest filtering, but if you want to filter linearly or, even worse, mipmapped, you get in trouble. Edges can only be clamped at the real texture dimension and not in the middle of a texture. You either need to put a border around each sub-texture and/or adjust the texture coordinates a little to the inside.

Do a search on "lightmaps" in the forum, this has been discussed before.