Skip to main content
GameDev.net gamedev.net
🔒 Locked

Ortho mode

Started by Ilmater Nov 18, 2004 at 8:44 PM 7 replies 1.6k views
Original Post
Ilmater
Ilmater
Does anyone have any idea why this code wouldn't work? int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0,800,0,600,0,1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, g_Texture[0]); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(0, 0); glTexCoord2f(0.0f, 0.0f); glVertex2f(0, 600); glTexCoord2f(1.0f, 0.0f); glVertex2f(800, 600); glTexCoord2f(1.0f, 1.0f); glVertex2f(800, 0); glEnd(); glEnable(GL_DEPTH_TEST); glMatrixMode( GL_PROJECTION ); glPopMatrix(); glMatrixMode( GL_MODELVIEW ); return TRUE; } I am trying to take a texture, and put it across the entire screen in ortho mode.
Kalidor
Kalidor
Do you have back-face culling enabled? It looks to me like you are sending the coordinates in clockwise.
_the_phantom_
_the_phantom_
Nope, those verts are going in CCW, same order I've got mine on my own 2D quad drawing code, ditto with the texture coords

- As Raduprv says, texturing definately enabled and bound?
- I assume you do swap the buffers somewhere? [smile]
Ilmater
Ilmater
phantom: yes to both
smitty1276
smitty1276
Are you sure that your texture is loading correctly? What is it doing exactly?
overflowed_
overflowed_
I just ran that function w/o the texture code and it works fine. The problem lies with the texture.
-----BEGIN GEEK CODE BLOCK-----Version: 3.12GCS/M/S d->+(++) s+: a19? C++++ UL++ P+++ L+ !E W+++ N+ o++ K? w!O M-- V? !PS PE Y+ PGP t++ 5+++ X R tv+> b+(++)>+++ DI+++>+++++ D++G e>++++ h! r y?------END GEEK CODE BLOCK------
Ilmater
Ilmater
D'oh! I just found out what was wrong.

I was trying to load a texture that wasn't a power of 2 >.<

Got it working now. Thanks for the help
Kalidor
Kalidor
Okay, now I'm confused. How is that clockwise?

glOrtho(0,800,0,600,0,1); sets up an ortho mode with (0,0) at the bottom-left and (800,600) at the top-right. Right?


glVertex2f(0, 0);
glVertex2f(0, 600);
glVertex2f(800, 600);
glVertex2f(800, 0);

And this would be bottom-left, top-left, top-right, bottom-right, correct?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.