PDA

View Full Version : How must i use my crosshair in here?



Helegurbann
12-16-2011, 09:25 PM
#include <GL/glew.h>
#include <GL/glut.h>

void Crosshair(){
//...
}
void Wall1(){
//..
}

void Wall2(){
//..
}
void Mouse_Actions(int x,int y){
//..
}
void Visible(){
glClearColor(0.0,0.0,0.0,1.0);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
Crosshair();
Mouse_Actions();
Wall1();
Wall2;
glTranslatef(0.0,0.0,-5.0);
glFlush();
}
void Settings(int width,int height){
glViewport(0,0,(GLsizei)with,(GLsizei)height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(105,(float)width/(float)height,1.0,100.0);
glMatrixMode(GL_MODELVIEW);
}

int main(int argc,char *argv[]){
glutInit(&amp;argc,argv);
glutInitWindowSize(640,480);
glutInitWindowPosition(50,150);
glutCreateWindow("Try Crosshair On The Walls");

glutInitDisplayMode(0);
glutDisplayFunc(Visible);
glutIdleFunc(Visible);
glutReshapeFunc(Settings);
gluPassiveMotionFunc(Mouse_Actions);
glutMainLoop();
}


I can fix my crosshair.But my crosshair is staying behind my walls.How can i take my crosshair front my walls?

mobeen
12-16-2011, 09:31 PM
hi,
Two solutions.
1) Change the order in which u r drawing the things and draw the crosshair last or
2) Enable depth test.

Helegurbann
12-16-2011, 09:45 PM
Hi.Thank u