First, you should load an image once and use the resulting texture object
(i.e. glGenTextures() once.) You will probably run out of texture memory /
texture names after just a few seconds of running this program, at which
point OpenGL will just give you error codes instead of doing what you want
it to do. Even if you fixed the real problem (discussed below), you wouldn’t
see the results of it until you fix this. Move the code to load a texture
into the initialization area.
You /load/ with
glTexParameteri( … );
You /render/ with:
glBindTexture(GL_TEXTURE_2D, … );
glBegin( … );
Second, you’ve specified vertex coordinates that are too small. Since you
have used glOrtho(), you have an orthographic view that is effectively a 2D
grid nearly representing pixels (I say nearly since OpenGL uses “pixel
centers” not “pixel edges”, read up on this if you are doing 2D in OpenGL
and want pixel-perfect art).
The calls to glVertex2d() give approximately a 1x1 pixel box. I think what
you are looking for are coordinates nearly the size of your texture, thus if
you have a 128x64 texture, you would use glVertex2d(128.0, 0.0) for
something that is furthest along the x/s axis.–
I don’t mean to sound too critical, but it seems like you aren’t really sure
how OpenGL works. OpenGL is a very complex beast indeed, and you’d do well
to find a good resource on learning how it works. The most popular (albeit
messy, in my opinion) resource to learn OpenGL is called “NeHe” OpenGL
tutorials. I recommend instead purchasing a book on it – “The OpenGL
SuperBible” has quite a bit of information that covers from the absolute
basics all the way to advanced graphics techniques.
On Tue, Jun 14, 2011 at 8:19 PM, greno wrote:
I created a small SDL 1.3 GL test program from various bits of examples I
The program loads a BMP image and displays it. Very simple That’s it.
Only problem is it won’t display the image.
Can someone check my GL code? I must be missing something but I’ve not
found what yet.
I posted the code here: http://greno-misc.googlecode.com/files/sdltest.zip
SDL mailing list
SDL at lists.libsdl.org