Back to my Tips and Tricks page
/* This first function sets up the screen for any type of
 * overlay,   including the mouse pointer, a console panel, etc.
 */
void BeginOverlay(void)
{
	glPushAttrib(GL_ENABLE_BIT | GL_VIEWPORT_BIT | GL_TRANSFORM_BIT);
	glDisable(GL_LIGHTING);
	glDisable(GL_FOG);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_CULL_FACE);
	glDisable(GL_BLEND);
	glMatrixMode(GL_PROJECTION);
	glPushMatrix();

	glLoadIdentity();
	gluOrtho2D(0.0, Engine.w, 0.0, Engine.h);
	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	glLoadIdentity();
}

/* Now, you can draw the mouse pointer. You will need to
 * provide some sort of callback that updates the Mouse global
 * variables.
 */
void DrawCursor(void)
{
	int x = Mouse.x;
	int y = screen.h - Mouse.y;

	glDisable(GL_TEXTURE_2D);
	glColor3f(1.0f, 1.0f, 1.0f);

	glBegin(GL_TRIANGLES);
	glVertex2i( x, y);
	glVertex2i( x + 13, y - 4);
	glVertex2i( x + 4, y - 13);

	glVertex2i( x + 8, y - 3);
	glVertex2i( x + 17, y - 12);
	glVertex2i( x + 12, y - 17);

	glVertex2i( x + 12, y - 17);
	glVertex2i( x + 3, y - 8);
	glVertex2i( x + 8, y - 3);
	glEnd();

	glColor3f(0.0f, 0.0f, 0.0f);

	glBegin(GL_TRIANGLES);
	glVertex2i(x + 1, y - 1);
	glVertex2i(x + 11, y - 4);
	glVertex2i(x + 4, y - 11);

	glVertex2i(x + 8, y - 5);
	glVertex2i(x + 15, y - 12);
	glVertex2i(x + 12, y - 15);

	glVertex2i(x + 12, y - 15);
	glVertex2i(x + 5, y - 8);
	glVertex2i(x + 8, y - 5);
	glEnd();
}

/* Now after you are done with all overlays, put the screen
 * settings back.
 */
void EndOverlay(void)
{
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glPopAttrib();
}
Back to my Tips and Tricks page

This page hosted by GeoCities Get your own Free Home Page