noob help matrix crazyness
Got some 3d shapes but now i need a 2d hud to go with them seems no matter what i try the hud doesnt display ever could some one have a quick look through the code and tell me whats up plz,
I searched around the forums tried nearly everything but nothin works for me
Just wanted a draw3d function and a draw2d function as simple as possible so i can understand it.
thx for any help(how do i post in pritty white boxes :D)
void Render_2D()
{
glDisable(GL_DEPTH_TEST);
glClear(GL_DEPTH_BUFFER_BIT) ;
glDisable(GL_LIGHTING);
glDisable(GL_LIGHT0);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glViewport(0,0,wind_Width,wind_Height);
glMatrixMode(GL_PROJECTION);
glPushMatrix(); //save old projection matrix
glLoadIdentity();
glOrtho(0, wind_Width, 0, wind_Height, 1, -1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//draw ne thing 2d here
glBegin(GL_QUADS);
glColor3f(0,0,1);
glVertex3f(-200.0f,-200.0f, -0.5);
glVertex3f(-200.0f,-100.0f, -0.5);
glVertex3f(200.0f,-100.0f, -0.5);
glVertex3f(200.0f,-200.0f, -0.5);
glEnd();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
}
void Render_3D()
{
int i = 0;
glPushMatrix();
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
gluPerspective(madcam.fov,wind_Width/wind_Height,madcam.planes[0],madcam.planes[1]);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//view transform
glRotatef(-madcam.inc, 1, 0, 0);
glRotatef(madcam.head, 0, 1, 0);
glTranslatef(-madcam.interest[0],-madcam.interest[1],-madcam.interest[2]);
glPushMatrix();
//Draw 3d stuff
glPopMatrix();
glPopMatrix();
}
void DisplayCallback(void)
{
glEnable(GL_DEPTH_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_COLOR_MATERIAL);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
draw3d();
draw2d();
}
Thx for any help sorry for giant post,
}
ur y coords are out of bounds in the glvertex .. give some values withing the frustum and it will work for sure
sorry im not to sure what you mean the window is 400 by 400 so i thought that would be ok
glVertex3f(-200.0f,-200.0f, -0.5);
glVertex3f(-200.0f,-100.0f, -0.5);
glVertex3f(200.0f,-100.0f, -0.5);
glVertex3f(200.0f,-200.0f, -0.5);
plz explain.
i get my 3d stuff but anything 2d never appears
[edited by - fishleg2 on April 6, 2004 5:25:08 PM]
glVertex3f(-200.0f,-200.0f, -0.5);
glVertex3f(-200.0f,-100.0f, -0.5);
glVertex3f(200.0f,-100.0f, -0.5);
glVertex3f(200.0f,-200.0f, -0.5);
plz explain.
i get my 3d stuff but anything 2d never appears
[edited by - fishleg2 on April 6, 2004 5:25:08 PM]
try using:
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0,640,0,480,-1,1);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glDisable(GL_BLEND);
...
glBegin( GL_QUADS );
glColor3f( 1.0f, 1.0f, 1.0f );
glVertex3f( 0.0f, 235.0f, -0.5f );
glVertex3f( 640.0f, 235.0f, -0.5f );
...
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glViewport is going to be setup only once (or on window resizes)
[edited by - brimful on April 6, 2004 11:08:11 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement