Skip to main content
gamedev.net
🔒 Locked

drawing hud problem

Started by Basiror Oct 29, 2002 at 10:58 AM 1 replies 300+ views
Original Post
Basiror
Basiror
i have pasted the code at the bottom it is executed in the same order as pasted below well my problem is my orthographic plane stays at the same position i can only draw in 2d on my screen when i don t call the Render3D() function is there something i am doing wrong or whats on?
  
void CRenderer::Render3D()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			// Clear The Screen And The Depth Buffer

	glMatrixMode(GL_PROJECTION);
	//glLoadIdentity();

	//glRotatef(-0.1,1,0,0);

	glRotatef(0.4,0,1,0);
	glTranslatef(5,-0.2,5);
	//glTranslatef(origin);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();							// Reset The Current Modelview Matrix

	//glRotatef(45,0,0,1);

	glEnable(GL_TEXTURE_2D);
	
	
	int i=0;
	int a=0;
	int s=2;
	int iMode=0;
	int iOldMode=0;
	
	//if(gApp.polygonstack)

		//return;

	glBindTexture(GL_TEXTURE_2D, gApp.texture.texID);	
	
	if(gApp.polygonstack){
	for(i=0;i<gApp.m_iPolygons;i++)
	{
		if(1)//gApp.polygonstack[i].flags & POLYGON_INVISIBLE)

		{
		
			if(gApp.polygonstack[i].m_iVertices==3)
			{
				iMode=GL_TRIANGLES;
			}
			else if(gApp.polygonstack[i].m_iVertices==4)
			{
				iMode=GL_QUADS;
			}
			else if(gApp.polygonstack[i].m_iVertices>4)
			{
				iMode=GL_TRIANGLE_FAN;
			}
			if(gApp.polygonstack[i].m_iVertices>2)
			{
				if(iMode!=iOldMode)
				{
					glEnd();
					glBegin(iMode);
				}
				
				s++;
				if(s>8)
					s=0;
				//if(iMode!=GL_QUADS)

					//glColor3f(color[s][0],color[s][1],color[s][2]);

				for(a=0;a<gApp.polygonstack[i].m_iVertices;a++)
				{
					if(iMode!=GL_TRIANGLE_FAN)
						glTexCoord2f(texcoord[a][0],texcoord[a][1]);
					glVertex3f(gApp.polygonstack[i].v[a].p[0],
					gApp.polygonstack[i].v[a].p[2],
					-gApp.polygonstack[i].v[a].p[1]);
			
				}
				//if(iMode!=iOldMode)

					//glEnd();

				iOldMode=iMode;
			}
		}
		else
		{
			
			if(gApp.polygonstack[i].m_iVertices==3)
			{
				iMode=GL_TRIANGLES;
			}
			else if(gApp.polygonstack[i].m_iVertices==4)
			{
				iMode=GL_QUADS;
			}
			else if(gApp.polygonstack[i].m_iVertices>4)
			{
				iMode=GL_TRIANGLE_FAN;
			}
			if(gApp.polygonstack[i].m_iVertices>2)
			{
				glBegin(iMode);
				s++;
				if(s>8)
					s=0;
				glColor3f(color[s][0],color[s][1],color[s][2]);
				for(a=0;a<gApp.polygonstack[i].m_iVertices;a++)
				{
					glVertex3f(gApp.polygonstack[i].v[a].p[0],
					gApp.polygonstack[i].v[a].p[1],
					gApp.polygonstack[i].v[a].p[2]);
			
				}
				glEnd();
			}
		}
	}
	}
}

void CRenderer::EnableOrthoMode()
{
	//hardcoded for 1280*1024 to make design easier

	glDisable(GL_DEPTH_TEST);
	glDisable(GL_CULL_FACE);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glOrtho(0,1280,1024,0,-1,1);
	

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();
}

void CRenderer::DisableOrthoMode()
{
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);
}

void CRenderer::RenderOrtho()
{

	DrawOrthoQuadRotate(128,256,128,128,gApp.texture.texID,45);
	DrawOrthoQuad(128,128,128,128,gApp.texture.texID);

	//DrawOrthoQuad(0,0,1280,512,gApp.consoleimage.texID);


	//always draw cursor as the last depth test is disabled

	DrawCursor();
}

void CRenderer::DrawOrthoQuad(int x,int y,int width,int height,int textureID)
{
	glLoadIdentity();
	glBindTexture(GL_TEXTURE_2D, textureID);
	
	glTranslated(x,y,0);
		
	glBegin(GL_QUADS);
	glTexCoord2f(texcoord[0][0],texcoord[0][1]);
	glVertex2i(0,0);
	glTexCoord2f(texcoord[1][0],texcoord[1][1]);
	glVertex2i(width,0);
	glTexCoord2f(texcoord[2][0],texcoord[2][1]);
	glVertex2i(width,height);
	glTexCoord2f(texcoord[3][0],texcoord[3][1]);
	glVertex2i(0,height);
	glEnd();
}

//x,y is rotation origin

void CRenderer::DrawOrthoQuadRotate(int x,int y,int width,int height,int textureID,float flrot)
{
	glLoadIdentity();
	glBindTexture(GL_TEXTURE_2D, textureID);
	
	glTranslated(x,y,0);
	glRotatef(flrot,0,0,1);
		
	glBegin(GL_QUADS);
	glTexCoord2f(texcoord[0][0],texcoord[0][1]);
	glVertex2i(0,0);
	glTexCoord2f(texcoord[1][0],texcoord[1][1]);
	glVertex2i(width,0);
	glTexCoord2f(texcoord[2][0],texcoord[2][1]);
	glVertex2i(width,height);
	glTexCoord2f(texcoord[3][0],texcoord[3][1]);
	glVertex2i(0,height);
	glEnd();
}

void CRenderer::DrawOrthoBlendQuadAlpha(int x,int y,int width,int height,int textureID)
{
	glLoadIdentity();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glBindTexture(GL_TEXTURE_2D, textureID);
	glTranslated(x,y,0);
		
	glBegin(GL_QUADS);
	glTexCoord2f(texcoord[0][0],texcoord[0][1]);
	glVertex2i(0,0);
	glTexCoord2f(texcoord[1][0],texcoord[1][1]);
	glVertex2i(width,0);
	glTexCoord2f(texcoord[2][0],texcoord[2][1]);
	glVertex2i(width,height);
	glTexCoord2f(texcoord[3][0],texcoord[3][1]);
	glVertex2i(0,height);
	glEnd();
	glDisable(GL_BLEND);
}

//x,y is rotation origin

void CRenderer::DrawOrthoBlendQuadAlphaRotate(int x,int y,int width,int height,int textureID,float flrot)
{
	glLoadIdentity();
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glBindTexture(GL_TEXTURE_2D, textureID);
	
	glTranslated(x,y,0);
	glRotatef(flrot,0,0,1);
		
	glBegin(GL_QUADS);
	glTexCoord2f(texcoord[0][0],texcoord[0][1]);
	glVertex2i(0,0);
	glTexCoord2f(texcoord[1][0],texcoord[1][1]);
	glVertex2i(width,0);
	glTexCoord2f(texcoord[2][0],texcoord[2][1]);
	glVertex2i(width,height);
	glTexCoord2f(texcoord[3][0],texcoord[3][1]);
	glVertex2i(0,height);
	glEnd();
	glDisable(GL_BLEND);
}

void CRenderer::DrawCursor()
{
	POINT mpos;
	GetCursorPos(&mpos);

	DrawOrthoBlendQuadAlpha(mpos.x,mpos.y,24,24,gApp.cursor.texID);
}
  
[edited by - Basiror on October 29, 2002 12:06:14 PM]
http://www.8ung.at/basiror/theironcross.html
Basiror
Basiror
!up
sorry had tp up it because the forum didn t display it on the forum summary page
http://www.8ung.at/basiror/theironcross.html
Basiror
Basiror
ok after hours of hacking i fixed the bug a little glEnd(); call was missing and screwed everything up lol :D
http://www.8ung.at/basiror/theironcross.html

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.