[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
OpenGL orthographic projection
- To: linuxgames@sunsite.dk
- Subject: OpenGL orthographic projection
- From: Gregor Mückl <GregorMueckl@gmx.de>
- Date: Sun, 25 Jul 2004 15:05:53 +0200
- Delivered-to: archiver@seul.org
- Delivered-to: mailing list linuxgames@sunsite.dk
- Delivery-date: Sun, 25 Jul 2004 09:14:52 -0400
- Mailing-list: contact linuxgames-help@sunsite.dk; run by ezmlm
- Reply-to: linuxgames@sunsite.dk
- User-agent: KMail/1.6.82
Hi!
I'm trying to draw a mouse cursor using OpenGL, but I have come across a
series of problems and don't find any reason for them. The code I use to draw
the mouse cursor is pasted below. The problem I have is the orthographic
projection: If I enable it, the mouse cursor will disappear without any
reason apparent to me. The glOrtho() call should actually look like this:
glOrtho(-1,1,1,-1,-1,1)
I have enlarged the region for testing purposes, but to no avail. Does any one
of you OpenGL gurus see something strange in my code?
Gregor
void Renderer::DrawMouseCursor()
{
float mouseCursorWidth, mouseCursorHeight;
// We define a fixed mouse cursor size because it's size on screen
shouldn't depend on screen resolution
mouseCursorWidth=0.01;
mouseCursorHeight=0.01;
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_COLOR,GL_ONE_MINUS_SRC_COLOR);
glBindTexture(GL_TEXTURE_2D,mouseCursor.GetTextureID());
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
glOrtho(-3,3,3,-3,-20,20);
/*
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex2f(mouseCursorPosX+mouseCursorWidth,mouseCursorPosY+mouseCursorHeight);
glTexCoord2f(0,1);
glVertex2f(mouseCursorPosX-mouseCursorWidth,mouseCursorPosY+mouseCursorHeight);
glTexCoord2f(1,1);
glVertex2f(mouseCursorPosX-mouseCursorWidth,mouseCursorPosY-mouseCursorHeight);
glTexCoord2f(1,0);
glVertex2f(mouseCursorPosX+mouseCursorWidth,mouseCursorPosY-mouseCursorHeight);
glEnd();
*/
glBegin(GL_QUADS);
glTexCoord2f(0,0);
glVertex3f(mouseCursorPosX+mouseCursorWidth,mouseCursorPosY+mouseCursorHeight,-1.0);
glTexCoord2f(0,1);
glVertex3f(mouseCursorPosX-mouseCursorWidth,mouseCursorPosY+mouseCursorHeight,-1.0);
glTexCoord2f(1,1);
glVertex3f(mouseCursorPosX-mouseCursorWidth,mouseCursorPosY-mouseCursorHeight,-1.0);
glTexCoord2f(1,0);
glVertex3f(mouseCursorPosX+mouseCursorWidth,mouseCursorPosY-mouseCursorHeight,-1.0);
glEnd();
glPopMatrix();
glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D);
}