🔒 Locked
Problems with model's textures
Advertisement
Original Post
Hello everybody,
I''m creating a little game using OpenGL and I wanted to put some MilkShape 3D models into it. I have several such objects and I''m able to draw them properly, but only one of this objects is textured. All the rest is drawn in white, despite the textures are defined for them.
Is this a problem with texture bitmaps (I mean file format, size or something?) or rather implementation problem? Does anyone have idea how to deal with it?
Thanks for help in advance,
Olek
Could be either, could be both, could be something else entirely. Post some code.
If you talking about the code that loads the models and draw them it''s too big to post it here. But I''m using the files from NeHe page so I could give you the link - http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=31
As I said one object is drawn correctly but the rest isn''t. They are displayed without any textures on them (in white color). The files I''m using from that tutorial should be fine I suppose, so maybe it''s not a programming problem but anyway I would be grateful for solution.
Olek
As I said one object is drawn correctly but the rest isn''t. They are displayed without any textures on them (in white color). The files I''m using from that tutorial should be fine I suppose, so maybe it''s not a programming problem but anyway I would be grateful for solution.
Olek
What happens if you use one of the other loaded textures to draw that first object? Does the texture show up? Might help narrow down the problem.
White textures usually indicate a problem with either the texture loading routines or the creation of the texutres.
-=[ Megahertz ]=-
White textures usually indicate a problem with either the texture loading routines or the creation of the texutres.
-=[ Megahertz ]=-
Are you binding the texture before drawing each object? Are you for some reason disabling textures before drawing the other objects? Do you have a light source? Is your light source somehow "washing out" the texture?
Have you checked that your texture that doesn''t work has sides that are power-of-two? 64, 128, 256 etc.
Checked glGetError?
Checked glGetError?
I think that there''s something wrong with the code I took from the link previously posted. When I deleted three lines of code that was disabling the textures when their count was >0 the all objects were textured, but they had the same textures as objects drawn before them (and not the textures they should have) which is quite annoying.
Anyone have idea what could be wrong with the code?
Anyone have idea what could be wrong with the code?
If you want each object to have a unique texture, you have to bind a different texture object before drawing each object. Something to the tune of:
glBindTexture(GL_TEXTURE2D, water);
glCallList(waterList);//draw water
glBindTexture(GL_TEXTURE2D, ground);
glCallList(groundList);//draw ground
glBindTexture(GL_TEXTURE2D, sky);
glCallList(skyList);//draw sky
For simplicity, the display lists contain the drawing instructions. Just note that a different texture object was used during each glBindTexture and the bind occured right before the object was drawn. Hope that gives you something to compare with your code.
glBindTexture(GL_TEXTURE2D, water);
glCallList(waterList);//draw water
glBindTexture(GL_TEXTURE2D, ground);
glCallList(groundList);//draw ground
glBindTexture(GL_TEXTURE2D, sky);
glCallList(skyList);//draw sky
For simplicity, the display lists contain the drawing instructions. Just note that a different texture object was used during each glBindTexture and the bind occured right before the object was drawn. Hope that gives you something to compare with your code.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement