Jump to content
  • Advertisement

Archived

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

Deranged

Undesired Affect

This topic is 5277 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Before MD2 Loading Undesired Affect MD2 CODE
int InitGL(GLvoid)										// All Setup For OpenGL Goes Here

{       

   	g_FontListID = CreateOpenGLFont("Arial", FONT_HEIGHT);
	

	glShadeModel(GL_SMOOTH);							// Enable Smooth Shading

	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);				// Black Background

	glClearDepth(1.0f);	
 	g_Camera.PositionCamera(0, 1.5f, 6,   0, 1.5f, 0,   0, 1, 0);						
		glDisable(GL_DEPTH_TEST);
 	glDisable(GL_CULL_FACE);
  	glDisable(GL_TEXTURE_2D);					

 	glDisable(GL_TEXTURE_2D);
   
    
          
    	g_LoadMd2.ImportMD2(&g_3DModel, FILE_NAME, TEXTURE_NAME);		
         
	// Go through all the materials

	for(int i = 0; i < g_3DModel.numOfMaterials; i++)
	{
		// Check to see if there is a file name to load in this material

		if(strlen(g_3DModel.pMaterials[i].strFile) > 0)
		{
			// Use the name of the texture file to load the bitmap, with a texture ID (i).

			// We pass in our global texture array, the name of the texture, and an ID to reference it.	

			CreateTexture2(g_Texture2, g_3DModel.pMaterials[i].strFile, i);			
		}

		// Set the texture ID for this material

		g_3DModel.pMaterials[i].texureId = i;
	}
          
	glEnable(GL_DEPTH_TEST);
 	glEnable(GL_CULL_FACE);
  	glEnable(GL_TEXTURE_2D);					
	glCullFace(GL_FRONT);
 	glEnable(GL_TEXTURE_2D);
    glDepthFunc(GL_LEQUAL);	              							// The Type Of Depth Testing To Do

	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);	// Really Nice Perspective Calculations

	return TRUE;										// Initialization Went OK

}

Side Bar Code
   int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear Screen And Depth Buffer

	glLoadIdentity();
	 glColor3f(1,1,1);
	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix

	glLoadIdentity();									// Reset The Projection Matrix

	glOrtho(0,SCREEN_HEIGHT,0,SCREEN_WIDTH,500,-500);
	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix

	glLoadIdentity();
	glPopMatrix();
	glPushMatrix();
	
	glBegin(GL_QUADS);						// Draw A Quad

	glColor3f(0, 0, 1);glVertex3f( 0.0f, 1024.0f, 0.0f);				// Top Left

	glColor3f(0, 1, 0);glVertex3f( 140.0f, 1024.0f , 0.0f);				// Top Right

	glColor3ub(0, 0, 0);glVertex3f( 110.0f,0.0f , 0.0f);				// Bottom Right

	glColor3ub(0, 0, 0);glVertex3f(0.0f,0.0f, 0.0f);				// Bottom Left

	glEnd();
	
	glBegin(GL_QUADS);						// Draw A Quad

        glColor3ub(0, 0, 0);
    	glVertex3f( 10.0f, 970.0f, 0.0f);				// Top Left

	    glVertex3f( 130.0f, 970.0f , 0.0f);				// Top Right

		glVertex3f( 130.0f,940.0f , 0.0f);				// Bottom Right

		glVertex3f(10.0f,940.0f, 0.0f);				// Bottom Left

	glEnd();
	glBegin(GL_QUADS);						// Draw A Quad

        glColor3ub(0, 0, 0);
    	glVertex3f( 10.0f, 920.0f, 0.0f);				// Top Left

	    glVertex3f( 130.0f, 920.0f , 0.0f);				// Top Right

		glVertex3f( 130.0f,890.0f , 0.0f);				// Bottom Right

		glVertex3f(10.0f,890.0f, 0.0f);				// Bottom Left

	glEnd();
		glBegin(GL_QUADS);						// Draw A Quad

        glColor3f(0, 0, 1);
    	glVertex3f( 20.0f, 965.0f, 0.0f);				// Top Left

	    glVertex3f( hpbar, 965.0f , 0.0f);				// Top Right

		glVertex3f( hpbar,945.0f , 0.0f);				// Bottom Right

		glVertex3f(20.0f,945.0f, 0.0f);				// Bottom Left

	glEnd();
			glBegin(GL_QUADS);						// Draw A Quad

        glColor3f(0, 0, 1);
    	glVertex3f( 20.0f, 915.0f, 0.0f);				// Top Left

	    glVertex3f( mpbar, 915.0f , 0.0f);				// Top Right

		glVertex3f( mpbar,895.0f , 0.0f);				// Bottom Right

		glVertex3f(20.0f,895.0f, 0.0f);				// Bottom Left

	glEnd();
	glMatrixMode(GL_PROJECTION);						// Select The Projection Matrix

	glLoadIdentity();									// Reset The Projection Matrix

	gluPerspective(45.0f,(GLfloat)SCREEN_WIDTH/(GLfloat)SCREEN_HEIGHT,0.1f,100.0f);
	glMatrixMode(GL_MODELVIEW);							// Select The Modelview Matrix

	glLoadIdentity();
	glPopMatrix();
	glPushMatrix();
    g_Camera.Look();
    glColor3f(1,1,1);		
	glDrawText(60, 38 , "HP: %d / %d", hp, Maxhp);	
	glDrawText(60, 77 , "MP: %d / %d", mp, Maxmp);		
	g_bar();


	
   AnimateMD2Model(&g_3DModel);
   glColor3f(1,1,1);
       
         			
    Draw3DSGrid();
    SwapBuffers(hDC);
	return TRUE;										// Everything Went OK

}
Im using the MD2 Anim code from GameTutorials.com. [edited by - DerAngeD on January 5, 2004 8:55:36 PM]

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by cowsarenotevil
Um, what's the undesired effect?




Please look at those 2 links. First the before than the Effect.

EDIT: If you cant tell the effect is the grid and the side bar turns black after i load the MD2.


[edited by - DerAngeD on January 5, 2004 9:01:39 PM]

Share this post


Link to post
Share on other sites
Uhm, your code probably either moves the camera away from your original stuff, or overwrites it since the loading code is after the other code.

Share this post


Link to post
Share on other sites
its not overwriting things because i moved the loadeing code around and it was the same. Its not moving the camera because ive tried rendering it before the camera.

Share this post


Link to post
Share on other sites
quote:
Original post by pinacolada
Maybe it''s that a big monster comes and takes over his desktop!


That''s what I would have though ...

Being serious though, it looks like you''re setting up your projections wrong. Try it like this:

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
//--Width then height

glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, -1, 1);
//--Might also be:

//glOrtho(0, SCREEN_WIDTH, 0, SCREEN_HEIGHT, 0, 1);

//--Or... (I usually have to play with the orthographic

//--projection for it to work right...)

//glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0, 1);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//

//--Render 2D Data

//

glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
//

//--Render 3D Data

//



Also, I would render the 3D grid then the model. If not you''re going to have render order problems (The grid will look like it''s going through the model)

Also, whats g_bar();? Is that the frame on the left side? If it is, why are you rendering it in the perspective projection area instead of the orthographic projection?

Also, when rendering your quake model, does it reverse the winding order of the vertices? If it does and you have glCullFace(GL_FRONT);, then it could be culling the 2D data?

Also, did you try taking out glDepthFunc(GL_LEQUAL); as that might be doing it? Just comment it out once and see what it does...

Theres a lot of things that it could be. It''s hard to fix it without actually playing with it.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites
commenting out glDepthFunc(GL_LEQUAL); doesnt help and g_bar(); is the calcuations for how much hp/mp is left in the health/mp bar.

Share this post


Link to post
Share on other sites
Well here is what I was mostly concerned about:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1,1,1);
glMatrixMode(GL_PROJECTION);
glOrtho(0,SCREEN_HEIGHT,0,SCREEN_WIDTH,500,-500);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPopMatrix();
glPushMatrix();

If I''m thinking right, your popping the modelview matrix. Usually when you don''t want the matrices messed with, you push a new matrix, do whatever you have to do, and then pop it. I''ve never seen it where you pop a matrix after setting the modelview. Take out the pushing and popping and see what happens...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!