Original Post
Hi,
I was working on a small scenegraph and got stuck with textures for some reason. Basicly, when I define my texture object in the main class and set it to a pyramid model, it works. When I define this texture object in my pyramid model class (with the same code), it does not work. Both compile, just the latter won''t show any textures.
I have a small class "MyPyramidModel" that renders a basic colored pyramid with a texture applied on it as follows (this does not show the textures):
CMyPyramidModel :: CMyPyramidModel()
{
CTexture * texture = new CTexture();
texture->LoadFromFile( "../textures/text.rgb", TEX_FILE_TYPE_RGB );
texture->SetWrap( GL_REPEAT, GL_REPEAT );
texture->SetFilter( GL_LINEAR, GL_LINEAR );
CPart * side = new CPart( GL_TRIANGLES, 3 ); // front
side->SetColor( 1.0, 0.0, 0.0 ); // red
side->SetTexture( texture );
side->Add( CVector( 0.0, 1.0, 0.0 ), TexCoordType( 0.5, 1.0 ) );
side->Add( CVector( 1.0, -1.0, 1.0 ), TexCoordType( 1.0, 0.0 ) );
side->Add( CVector( -1.0, -1.0, 1.0 ), TexCoordType( 0.0, 0.0 ) );
side->SetDefaultNormal();
this->Add( side );
...
However, if I adjust the previous code with the code below and pass a texture to it, it does work:
CMyPyramidModel :: CMyPyramidModel( CTexture * texture )
{
CPart * side = new CPart( GL_TRIANGLES, 3 ); // front
side->SetColor( 1.0, 0.0, 0.0 ); // red
side->SetTexture( texture );
side->Add( CVector( 0.0, 1.0, 0.0 ), TexCoordType( 0.5, 1.0 ) );
side->Add( CVector( 1.0, -1.0, 1.0 ), TexCoordType( 1.0, 0.0 ) );
side->Add( CVector( -1.0, -1.0, 1.0 ), TexCoordType( 0.0, 0.0 ) );
side->SetDefaultNormal();
this->Add( side );
...
Any ideas?