How can I use Multiple Textures in Lesson 10
I''ve run through lesson 10 and created some interesting worlds in text data files using the lesson 10 format, but how would I change the code from that lesson to include more than one texture, and how would I adjust my text data file?
Steve Sherrin
I''m a beginner with OpenGL and there are probably better ways to do this, but this is what I did to solve this problem. First I used the LoadGLTextures() code from Lesson 20 to load in multiple textures. I then broke up the for loop in DrawGLScene() into for loops for each texture. I then placed a glBindTexture() before each for loop to specify the texture that is to be mapped on the triangles drawn in that loop. The file would then need to be arranged so that the triangles for each texture are grouped together. Hope this helps.
That''s pretty much what I''ve been looking at doing, but is there a way to trigger the end of the loop from the text file? Otherwise, if I add additional faces to one texture in the text file, I''d have to go and change the length of the loop in the code as well. Is there a way that I can set it up so the code is generic will build the faces of each texture regardless of how many faces there are?
Steve Sherrin
Steve Sherrin
Steve Sherrin
wait- I think I have it... at the beginning of the file, after NUMPOLIES put a line for each texture that tells how many vertices there are for each texture. Then use those variables as the upper limit of the loop... I think this will do it. If you have a more efficient way, though, I''m always looking for better ideas
Steve Sherrin
Steve Sherrin
Steve Sherrin
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement