Sign in to follow this  

glOrtho, textures upside down, on some drivers not? (NOT SOLVED)

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I had some code displaying textured quads in glOrtho. I re-did my computer, and now, they showed upside down! So I turned them all so they displayed OK. Problem no is: I sent an example to my friend, and there the textures are displayed correctly, upside-down. (I hope everybody can follow me...) So is it a driver problem or does someone know another solution? [Edited by - LordMyth on January 3, 2005 1:24:00 PM]

Share this post


Link to post
Share on other sites
That is quite odd - I see what you are saying: They appeared upside down to you - so you flip them - but when you give to friends - they are upside down. I do not know why that would be the case. Maybe you should upgrade your drivers. Give that a try first.

Share this post


Link to post
Share on other sites
that's in fact what I don't want...I downloaded older drivers to use instead of the new drivers from nvidia, because those are very bad, especially when you only have an old FX 5200 and an old computer (OK, 700 Mhz Athlon is not that bad but if you play Rome: Total War it is. And in fact RTW crashes with the newest drivers, but not with the old ones). Wait, I'll try quake, I'll see if it displays the textures OK.
edit: yep, they still display OK.

[Edited by - LordMyth on January 2, 2005 4:09:39 AM]

Share this post


Link to post
Share on other sites
ild say its a problem in your code and not the drivers, textures that got flipped somehow from one driver version to the next is a very obvious error that would of gotten picked up (if not we would of heard 20million posts about it before)
check your
texture loading code
how your setting up the ortho frustum
also see if u havent got a scale(1,-1,1) in there somewhere as well

Share this post


Link to post
Share on other sites
I'm not sure how well this applies to OpenGL, but it's recommended for D3D that you don't rely on any default state in the API. If you expect a default state then you should explicitly set it on application startup. It used to be the case that many drivers forgot to initialise certain values when the API was initialised, so you could get varying results depending on the order of doing things and suchlike.

As I say, not sure how that compares to GL drivers, but it's worth keeping in mind sometimes.

Share this post


Link to post
Share on other sites
This is how I set my ortho-mode, before I had it like this: gluOrtho2D(0, WindowWidth, 0, WindowHeight); and with a Scale(1,-1,1);. Textures are loaded with DevIL and I don't think problems could be there.

GLvoid Set2D ( GLvoid ) {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluOrtho2D(0, WindowWidth, WindowHeight, 0);
glMatrixMode(GL_MODELVIEW);
glFrontFace( GL_CW );
}




[EDIT]What about having the choice to flip the texture matrix?
[EDIT2] This is my window setup code

GLvoid InitWindow( GLuint _width, GLuint _height ) {
WindowWidth = _width; WindowHeight = _height;
//Sets the OpenGL settings
if( SDL_Init(SDL_INIT_VIDEO) <0 ){
Quit();
}
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 8 );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 32 );
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, 32 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if( SDL_SetVideoMode( _width,_height,32,SDL_OPENGL/*|SDL_FULLSCREEN*/) == 0 ) {
Quit();
}
GLfloat ratio = (GLfloat) _width / (GLfloat) _height;
glShadeModel( GL_SMOOTH );
glEnable(GL_BLEND);
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glCullFace( GL_BACK );
glFrontFace( GL_CCW );
glEnable( GL_CULL_FACE );
glClearColor( 0, 0, 0, 0 );
glViewport( 0, 0, _width, _height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
gluPerspective( 60.0, ratio, 1.0, 1024.0 );
}



[Edited by - LordMyth on January 4, 2005 2:35:30 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Gooberius
I'm not sure how well this applies to OpenGL, but it's recommended for D3D that you don't rely on any default state in the API. If you expect a default state then you should explicitly set it on application startup. It used to be the case that many drivers forgot to initialise certain values when the API was initialised, so you could get varying results depending on the order of doing things and suchlike.

As I say, not sure how that compares to GL drivers, but it's worth keeping in mind sometimes.


...and I quote Gooberius :)...

Share this post


Link to post
Share on other sites
I presume your GL init is OK otherwise you will see nothing.
I think the problem is in your rendering function...can you post a short code fragment in which you describe how you draw a textured quad?
And if you change

gluOrtho2D(0, WindowWidth, WindowHeight, 0);

to

gluOrtho2D(0, WindowWidth, 0, WindowHeight); ?

( gluOrtho2D(left,right,bottom,top) )

Share this post


Link to post
Share on other sites
then the coordinates do not start on top left anymore you know... but I'll see what it does.
[EDIT:] yep, everything is just flipped upside down, as it should, nothing changed

[Edited by - LordMyth on January 5, 2005 9:59:02 AM]

Share this post


Link to post
Share on other sites
try using a replacement for gluOrtho2D, something like this:

glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glOrtho( 0, width, height, 0, -1, 1 );
glMatrixMode( GL_MODELVIEW );
glLoadIdentity( );

Share this post


Link to post
Share on other sites
Another one on this forum had similar problems. His was due to different versions(or somtheing) of the DevIL library.
If you are using DevIL, put this after your init-code (before you load anything):
	ilOriginFunc(IL_ORIGIN_UPPER_LEFT);
ilEnable(IL_ORIGIN_SET);

If you don't use DevIL.. well, I would still check the loading code,
good luck!

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this