Archived

This topic is now archived and is closed to further replies.

MaxwellMurder

MilkShape Textures and SDL

Recommended Posts

I''m using Lesson 31 Milkshape, and Model files to load an object, in SDL. I can get the object up but I can''t get the texture to map, at all. no matter where I put the pModel->reloadTexture() function in my code all it does is slow the object down, make me grind my teeth and wish for the good ol days of Jet set Willy. I know the texture is being loaded, it''s the correct depth, power of two size (256x256), I have reversed the RGG for SDL. GL_TEXTURE_2D is set. Do I need set lighting for the Material? Do I need my head examining? Any help would be appreciated, gratefully recieved any thing to save my teeth from any more grinding.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
This is where it is bound in the code :-

for ( int i = 0; i < m_numMeshes; i++ )
{
int materialIndex = m_pMeshes.m_materialIndex;
if ( materialIndex >= 0 )
{
//SEt up Light settings frmo model
glMaterialfv( GL_FRONT, GL_AMBIENT, m_pMaterials[materialIndex].m_ambient );
glMaterialfv( GL_FRONT, GL_DIFFUSE, m_pMaterials[materialIndex].m_diffuse );
glMaterialfv( GL_FRONT, GL_SPECULAR, m_pMaterials[materialIndex].m_specular );
glMaterialfv( GL_FRONT, GL_EMISSION, m_pMaterials[materialIndex].m_emissive );
glMaterialf( GL_FRONT, GL_SHININESS, m_pMaterials[materialIndex].m_shininess );

if ( m_pMaterials[materialIndex].m_texture > 0 )
{//Bind Texture id there is a material index
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, m_pMaterials[materialIndex].m_texture );

basically each group in the model run through and the material ID (if there is one) is set up and then bound. Would this function need to reload the textures again, or is there something missing?

Yeah I initalized the reload textures both before and after tyhe resize window (And other combinations) to no avail.

I have a snekay suspicon I am being an idiot and have missed something so basic.

Share this post


Link to post
Share on other sites
Are you absolutely sure you''re loading the texture?

Milkshape''s fileformat stores textures with a relative path from the model. This tend to mess people up when their program has a different path to the model, as the path in the file no longer leads to texture.

BTW, yes you do need to enable lighting to see the materials make any difference. You should still see the texture though.

If OpenGL isn''t getting the texture the model will be white. Otherwise, the problem is something else (tex coords, blendfunc, etc etc)

Share this post


Link to post
Share on other sites
First, does the texture appear at all? What does appear on the screen?
Second, Are you setting the texture coordinates right?
Third, try to single step the program and see if it enters either of the loops that set the material or the one that binds the texture.

Hope this helps!

Share this post


Link to post
Share on other sites