Created
February 19, 2018 15:53
-
-
Save MacDue/0b020efcec05ea4d24062151f6868b87 to your computer and use it in GitHub Desktop.
OpenGL crosshair
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void draw_crosshair() { | |
/* Draws a crosshair in the center of the screen */ | |
glDisable(GL_DEPTH_TEST); | |
glDisable(GL_LIGHTING); | |
glMatrixMode(GL_PROJECTION); | |
glPushMatrix(); | |
glLoadIdentity(); | |
gluOrtho2D(0, width, height, 0); | |
glMatrixMode(GL_MODELVIEW); | |
glLoadIdentity(); | |
// Draw a (colour) inverted cross (not satanic) | |
glEnable(GL_COLOR_LOGIC_OP); | |
glLogicOp(GL_INVERT); | |
glTranslatef(width/2-10,height/2-10, 0); | |
glLineWidth(2); | |
glBegin(GL_LINES); | |
glVertex3f(10.0f, 20.0f, 0.0f); | |
glVertex3f(10.0f, 0.0f, 0.0f); | |
glVertex3f(0, 10, 0.0f); | |
glVertex3f(20, 10, 0.0f); | |
glEnd(); | |
glDisable(GL_COLOR_LOGIC_OP); | |
glMatrixMode(GL_PROJECTION); | |
glPopMatrix(); | |
glEnable(GL_DEPTH_TEST); | |
glEnable(GL_LIGHTING); | |
glMatrixMode(GL_MODELVIEW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment