Eric Wing Wrote:
…
Keep in mind that that SDL_Surface coordinate
systems
(y increases downwards) are inverted from OpenGL
coordinate systems (y increases upwards), so if
you
follow standard OpenGL texture coordinate
conventions,
your images are going to be upside down.
…
Actually it depends on how you define your
Orthographic projection. In
my sprite engine I initialize it as follows so that
top-left
corresponds to 0,0:
glOrtho(0, screen->w, screen->w, 0, -1.0, 1.0);
Actually you’re only partially correct. That ortho
trick is unusable in many situations. But first, I
said “if” you follow standard OpenGL conventions it
will be an issue. If you don’t care, it’s not an
issue. It’s a convention. Conventions are arbitrary,
but they may have consequences if you don’t conform
with the majority of the community.
OpenGL has been around for awhile so there is a lot of
legacy code available. If you try to use some if it
you might be in for some nasty surprises. Or consider
if you are working with other engineers that are
following the standard conventions. When you interface
your code, you may have issues.
So consider the following examples:
-
You are not using an orthographic projection. You
are placing textures on 3d models or terrains that
require a perspective mode projection. You won’t be
able to use that ortho trick
-
In #1, you could get around the issue by changing
the placement of your glTexCoords, but consider what
if you had taken a complicated model loader somebody
else had written. The model loader might use platform
specific image loaders, so you replace that section
with an SDL_image loader. But most likely your
conventions are inverted and your model is going to
look really messed up with the inverted textures. You
could change the TexCoords everywhere in the code
(assuming you have access to it), but it would be much
easier to just flip your image. And it woold save you
grief if you later require another outside module
which has the same problem.
-
You are a one of many engineers on a project. You
are responsible for writing a module for the program,
but you are not allow to touch certain OpenGL states
such as the projection matrix. All the other engineers
are following standard OpenGL conventions, so you’re
stuff is will be inverted.
But as I said, it’s only a convention. SDL follows
conventions from most 2D APIs (y is done to make it
easier to think about how it is stored in memory) and
OpenGL follows the conventions of most 3D APIs (y is
done to follow standard mathematical conventions), but
now that SDL supports both 2D and 3D, one of the
conventions had to be pushed aside.
So if you’re writing all your own code, and you never
have to deal with any other OpenGL engineers or
interface with outside OpenGL code, then you’re
probably safe. But it’s something to think about.
-Eric__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software