#### Archived

This topic is now archived and is closed to further replies.

# Drawing a 2d image in 3d mode

This topic is 5748 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I was wondering if someone could tell me how to simply draw an image to the 2D window before I begin 3D drawing without setting orthographic mode? What I want to do is like a skybox but simpler, just clipping an image onto the screen then drawing polygons over it. Is there a way to draw to the window using OGL before any polygons are drawn? This would hopefully also eliminate a need to clear the color buffer. I''m supposing that setting orthographic mode and drawing into that and then changing back to projection would lose any data drawn in orthographic and/or be very slow. Could someone give me any tips?

##### Share on other sites
>>I was wondering if someone could tell me how to simply draw an image to the 2D window before I begin 3D drawing without setting orthographic mode? What I want to do is like a skybox but simpler, just clipping an image onto the screen then drawing polygons over it.<<

it is much simplier to just setup an orthographic view.

>>Is there a way to draw to the window using OGL before any polygons are drawn? This would hopefully also eliminate a need to clear the color buffer.<<

this is how q3/UT + other older engines done things
start of render loop
dont clear screen
in 3d just draw the skybox (it will cover everything)

but nowadays with fast clears youre better off,
clearingthe screen, drawing the scene + then drawing the skybox last!

>>I''m supposing that setting orthographic mode and drawing into that and then changing back to projection would lose any data drawn in orthographic<<

no

>>and/or be very slow. Could someone give me any tips? <<

its very quick. drawing one triangle is far slower than changing from 3d->2d->3d.
quake3 (+ all other commerical engines do thuis)

http://uk.geocities.com/sloppyturds/kea/kea.html
http://uk.geocities.com/sloppyturds/gotterdammerung.html

##### Share on other sites
May be evil, but doesn''t need to.

  void DrawSprite(void * pSprite, unsigned short usX, unsigned short usY){  sprite_info_t * pInfo = (sprite_info_t *) pSprite;  double dX = (double) usX, dY = (double) usY;  glMatrixMode(GL_PROJECTION);	glPushMatrix();		{		glLoadIdentity();		glOrtho(0.0, 1024.0, 768.0, 0.0, -0.01, 100.0);    gluLookAt(.0f, .0f, -5.0f, .0f, .0f, .0f, .0f, 1.0f, .0f);    SelectTexture(pInfo->nTexture);		    glBegin(GL_QUADS);		{			glTexCoord2f(.0f, 1.0f);			glVertex2d(dX, dY + (double) pInfo->usHeight);			glTexCoord2f(1.0f, 1.0f);			glVertex2d(dX + (double) pInfo->usWidth, dY + (double) pInfo->usHeight);			glTexCoord2f(1.0f, .0f);			glVertex2d(dX + (double) pInfo->usWidth, dY);			glTexCoord2f(.0f, .0f);			glVertex2d(dX, dY);		}		glEnd();	}	glPopMatrix();	glMatrixMode(GL_MODELVIEW);}

##### Share on other sites
Thank you everyone for your help. I wanted to use a skybox but it seems to not work. I position the camera using a few rotates and a translate then I draw a world using quads. If I use gluLookAt the skybox works when I draw it but the vertices of the quads aren''t drawn right, and if I use the translate and rotates the vertices are drawn right but not the skybox. Can anyone help me with this? I''m loading quads from a file with the xyz and texture coords and then drawing them from arrays. I know the vertices are correct but the way it''s drawn seems dependent on how I position the camera. I want to use a skybox, can someone help me with this?

And thank you blacklight for your code example!

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
18
5. 5

• 9
• 9
• 33
• 13
• 13
• ### Forum Statistics

• Total Topics
632586
• Total Posts
3007220

×