Thread: Drawing Bug

  1. #1
    Absent Minded Programmer
    Join Date
    May 2005
    Posts
    968

    Drawing Bug

    Before you ask:
    The Model is loaded correctly (when rotated certain parts fall in and out of view)


    http://img.photobucket.com/albums/v1...o/ModelBug.jpg

    Eh?

    Here is my draw thingy

    Code:
    void Draw (void) 
    { 
         glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);     
         glLoadIdentity ();                                                   
    	 gluLookAt( 65, 65, 65, 0, 0, 0, 0, 1, 0 );
    
    	 Model1->DrawMS3DModels();
    
         glFlush ();                                                                 
    }
    And here is the DrawMS3DModels() functon

    Code:
    void MS3DModel::DrawMS3DModels()
    {
    	GLboolean texEnabled = glIsEnabled( GL_TEXTURE_2D );
    
    	for ( int i = 0; i < NumMeshes; i++ )
    	{
    		int materialIndex = Meshes[i].MaterialIndex;
    
    		if ( materialIndex >= 0 )
    		{
    			glMaterialfv( GL_FRONT, GL_AMBIENT, Materials[materialIndex].Ambient );
    			glMaterialfv( GL_FRONT, GL_DIFFUSE, Materials[materialIndex].Diffuse );
    			glMaterialfv( GL_FRONT, GL_SPECULAR, Materials[materialIndex].Specular );
    			glMaterialfv( GL_FRONT, GL_EMISSION, Materials[materialIndex].Emissive );
    			glMaterialf( GL_FRONT, GL_SHININESS, Materials[materialIndex].Shininess );
    
    			if ( Materials[materialIndex].Texture > 0 )
    			{
    				glBindTexture( GL_TEXTURE_2D, Materials[materialIndex].Texture );
    				glEnable( GL_TEXTURE_2D );
    			}
    			else
    				glDisable( GL_TEXTURE_2D );
    		}
    		else
    		{
    			glDisable( GL_TEXTURE_2D );
    		}
    
    		glBegin( GL_TRIANGLES );
    		{
    			for ( int j = 0; j < Meshes[i].NumTriangles; j++ )
    			{
    				int triangleIndex = Meshes[i].TriangleIndices[j];
    				const Triangle* pTri = &Triangles[triangleIndex];
    
    				for ( int k = 0; k < 3; k++ )
    				{
    					int index = pTri->VertexIndices[k];
    
    					glNormal3fv( pTri->VertexNormals[k] );
    					glTexCoord2f( pTri->Textures1[k], pTri->Textures2[k] );
    					glVertex3fv( Vertices[index].Location );
    				}
    			}
    		}
    		glEnd();
    	}
    	if ( texEnabled )
    		glEnable( GL_TEXTURE_2D );
    	else
    		glDisable( GL_TEXTURE_2D );
    }
    If you need it I can post the LoadModelData() function, but I'm almost 85% sure its not that

    Why does it look like that? Certain parts seem to be cut off of the viewport?

    BTW The model is a 3d Cross
    Last edited by Shamino; 12-06-2005 at 10:43 PM.
    Sometimes I forget what I am doing when I enter a room, actually, quite often.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 02:47 PM
  2. Slow drawing code
    By tjpanda in forum Windows Programming
    Replies: 5
    Last Post: 05-09-2008, 05:09 PM
  3. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 07:52 AM
  4. Drawing Bug
    By Shamino in forum Game Programming
    Replies: 2
    Last Post: 12-18-2005, 11:46 PM
  5. drawing minimaps and radar screens.
    By Eber Kain in forum Game Programming
    Replies: 4
    Last Post: 03-08-2002, 11:44 AM