OpenGL "1 to 1" Pixel Setup?

Okay, I’m new so forgive if this is a stupid question.

I’ve been playing around with OpenGL trying to use it for some really basic
2D stuff for now (until I get better) but I can’t seem to find a way to set
up OGL so that when I draw a GL_QUADS using points (-1, 1), (1, 1), (1, -1),
and (-1, -1), it fills up ONLY a 2x2 pixel square… This code:

glBegin(GL_QUADS);
glVertex2f(-1, 1);
glVertex2f(1, 1);
glVertex2f(1, -1);
glVertex2f(-1, -1);
glEnd();

Fills the entire space with the polygon. I don’t want to have to say
something like "glVertex3f((spriteX/screenW), (spriteY/screenH),
(spriteLayer/maxDepth)); in order to get my exact positioning.

Anyhow, help would be appreciated.

–Scott

You should check the glOrtho function to setup an orthogonal view in
your projection matrix.

HTH

Marc

Scott Harper wrote:> Okay, I’m new so forgive if this is a stupid question.

I’ve been playing around with OpenGL trying to use it for some really basic
2D stuff for now (until I get better) but I can’t seem to find a way to set
up OGL so that when I draw a GL_QUADS using points (-1, 1), (1, 1), (1, -1),
and (-1, -1), it fills up ONLY a 2x2 pixel square… This code:

glBegin(GL_QUADS);
glVertex2f(-1, 1);
glVertex2f(1, 1);
glVertex2f(1, -1);
glVertex2f(-1, -1);
glEnd();

Fills the entire space with the polygon. I don’t want to have to say
something like "glVertex3f((spriteX/screenW), (spriteY/screenH),
(spriteLayer/maxDepth)); in order to get my exact positioning.

Anyhow, help would be appreciated.

–Scott


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

look into “glViewport” and “glOrtho”…> ----- Original Message -----

From: lareon@comcast.net (Scott Harper)
To:
Sent: Monday, May 10, 2004 6:39 PM
Subject: [SDL] OpenGL “1 to 1” Pixel Setup?

Okay, I’m new so forgive if this is a stupid question.

I’ve been playing around with OpenGL trying to use it for some really
basic
2D stuff for now (until I get better) but I can’t seem to find a way to
set
up OGL so that when I draw a GL_QUADS using points (-1, 1), (1, 1),
(1, -1),
and (-1, -1), it fills up ONLY a 2x2 pixel square… This code:

glBegin(GL_QUADS);
glVertex2f(-1, 1);
glVertex2f(1, 1);
glVertex2f(1, -1);
glVertex2f(-1, -1);
glEnd();

Fills the entire space with the polygon. I don’t want to have to say
something like "glVertex3f((spriteX/screenW), (spriteY/screenH),
(spriteLayer/maxDepth)); in order to get my exact positioning.

Anyhow, help would be appreciated.

–Scott


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl