How do I create more than 1 texture?
Lesson 6 tells how to load one bmp to a texture. How do you use 2 or more? what variations do I need to make to lesson 6 to use 2 bitmapped textures
Steve Sherrin
when you get openGL to generate space for a texture, it returns an unsigned integer number to you, as an 'id' for the texture... (this is why glBindTexture takes an unsigned integer).
This way, when you use glGenTextures, you pass in the number of textures you want to generate space for (1) and a pointer to an unsigned integer, which openGL will set for you. (it must be a pointer so openGL can modify it for you)
Thus, if you want another texture, you simply have to have more than one unsigned interger to keep track of your textures...
And when you load each texture, you need to make sure that the call to glGenTextures is fed the pointer of a DIFFERENT unsigned integer each time... Ie, your load texture function should either take an pointer to an unsigned int, or return an unsigned int.
thus, you might have: (in a simple world
)
unsigned int wallTexture, floorTexture, ....;
loadTexture(&wallTexture,"wall.bmp");
loadTexture(&floorTexture,"floor.bmp");
...
later on...
glBindTexture(wallTexture);
glBegin
...
...
...
glEnd
glBindTexture(floorTexture);
...
does that make sense?
| - Project-X - my mega project.. getting warmer
- | - adDeath - an ad blocker I made - | - email me - |
[edited by - RipTorn on April 14, 2003 10:57:20 PM]
This way, when you use glGenTextures, you pass in the number of textures you want to generate space for (1) and a pointer to an unsigned integer, which openGL will set for you. (it must be a pointer so openGL can modify it for you)
Thus, if you want another texture, you simply have to have more than one unsigned interger to keep track of your textures...
And when you load each texture, you need to make sure that the call to glGenTextures is fed the pointer of a DIFFERENT unsigned integer each time... Ie, your load texture function should either take an pointer to an unsigned int, or return an unsigned int.
thus, you might have: (in a simple world

unsigned int wallTexture, floorTexture, ....;
loadTexture(&wallTexture,"wall.bmp");
loadTexture(&floorTexture,"floor.bmp");
...
later on...
glBindTexture(wallTexture);
glBegin
...
...
...
glEnd
glBindTexture(floorTexture);
...
does that make sense?
| - Project-X - my mega project.. getting warmer

[edited by - RipTorn on April 14, 2003 10:57:20 PM]
Suggested reading into the later tutorials. Try lesson 32 or 33 they load multiple TGA''s but i''m sure your smart enough to figure it out
Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com

Dustin Davis
Owner / CEO
Programmers Unlimited
www.Programmers-Unlimited.com
Dustin DavisOwner / CEOProgrammers Unlimitedwww.Programmers-Unlimited.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement