PDA

View Full Version : how do i draw 2d textures on screen



enjoycrf
04-07-2011, 08:25 PM
can some one help me here
i just need to place textures on the screen that will stay in the same position and have no depth just screen size coordinates just like text

enjoycrf
04-08-2011, 02:20 AM
i think its like this but there is no details
do i have to make a polygon?

The simplest way to do this is to draw your scene normally, then switch to an orthographic projection, turn off depth testing and place the texture with screen coordinates

mobeen
04-08-2011, 02:54 AM
texture with screen coordinates
True only if you are working with rectangle textures otherwise u would need to issue normalized uv coordinates (0-1)
You will also have to draw a 2D quad on screen (two triangles will do).

enjoycrf
04-08-2011, 12:17 PM
but i dont want to then billboard the quads
cant i just have a flat texture on the screen
as if i was using photoshop

enjoycrf
04-08-2011, 12:53 PM
ok i got it
looked at how i was drawing text
copied that and placed a quad in there and it werks
plz let me know if i can take some code out from here, or optimize, modify something
as to me this code looks a bit funky

void DrawImage(void) {

glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, glutGet(GLUT_WINDOW_WIDTH), 0.0, glutGet(GLUT_WINDOW_HEIGHT), -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();


glLoadIdentity();
glDisable(GL_LIGHTING);


glColor3f(1,1,1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mark_textures[0].id);


// Draw a textured quad
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex3f(0, 0, 0);
glTexCoord2f(0, 1); glVertex3f(0, 100, 0);
glTexCoord2f(1, 1); glVertex3f(100, 100, 0);
glTexCoord2f(1, 0); glVertex3f(100, 0, 0);
glEnd();


glDisable(GL_TEXTURE_2D);
glPopMatrix();


glMatrixMode(GL_PROJECTION);
glPopMatrix();

glMatrixMode(GL_MODELVIEW);

}