Sdl+opengl 2d?

Hi!

Does anyone could give me a link to a tutorial on managing 2d stuff with opengl?

I’ve already done a small sprite library with sdl, but i want to use hardware alpha blending etc under windows and the sdl directx driver seems to support no hw alphablending.

Thanks in advance, Florian Hufsky

There’s a basic example of how to setup an OpenGL window included with the SDL documentation.
Really it’s just OpenGL with all the window and input management handled via SDL.
I don’t think there’s any need for a specific tutorial regarding ‘SDL + OpenGL’.
A tutorial for people interested in doing 2D operations with OpenGL, and how to manage this, would be a good idea, I think, though :).----- Original Message -----
From: Florian Hufsky
To: sdl at libsdl.org
Sent: Wednesday, June 25, 2003 6:02 AM
Subject: [SDL] sdl+opengl 2d?

Hi!

Does anyone could give me a link to a tutorial on managing 2d stuff with opengl?

I’ve already done a small sprite library with sdl, but i want to use hardware alpha blending etc under windows and the sdl directx driver seems to support no hw alphablending.

Thanks in advance, Florian Hufsky

Hi,

Does anyone could give me a link to a tutorial on managing 2d stuff with
opengl?

my experiences with 2d OpenGL were not that good, as "glDrawPixels()"
seems to always transfer the pixel data from main memory to the
video card and DisplayList doesn’t help you with that. What could
help would be to have the image as a texture and then draw a rectangle
with that texture.
I don’t know if a texture could be used in 2D graphics.

I’ve already done a small sprite library with sdl, but i want to use
hardware alpha blending etc under windows and the sdl directx driver seems
to support no hw alphablending.

That doesn’t sound good, i wanted to use that.

I’d be also interested in a fast solution.

Best regards,
Torsten.

Quoth Torsten Mohr , on Tue 24 Jun 2003:

my experiences with 2d OpenGL were not that good, as "glDrawPixels()"
seems to always transfer the pixel data from main memory to the
video card and DisplayList doesn’t help you with that.

That’s why you don’t use glDrawPixels so often.

What could
help would be to have the image as a texture and then draw a rectangle
with that texture.

Yes.

I don’t know if a texture could be used in 2D graphics.

Yes, they can, just as in 3D. Really the only difference is in the
projection (and theoretically possibly other implementation-defined
non-interface-changing stuff, but I’m ignoring that). Use gluOrtho2D
to set up the 2D, then draw rectangles (or other polygons, but I think
rectangles are the most common) with appropriate texture settings and
coordinates.

—> Drake Wilson
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20030624/e794cab6/attachment.pgp

my experiences with 2d OpenGL were not that good, as "glDrawPixels()"
seems to always transfer the pixel data
from main memory to the video card and DisplayList doesn’t help you
with that. What could help would be to have
the image as a texture and then draw a rectangle with that texture. I
don’t know if a texture could be used in
2D graphics.

What I did and works fine : cover the screen with 64x64 patches. Each
patch has an associated SDL_Surface created in the same format as an
OpenGL texture, and an OpenGL texture index. When I want to blit()
something into the screen, I blit() over each of the intersecting
patches, mark them as dirty, and add to a refcount field. When I delete
a sprite, I decrement the refcount.

Then, in each frame; for each dirty patch, re-upload the texture from
the SDL_Surface, and clear dirty flag; go to ortho mode; for each patch
with refcount > 0 (ie there is something visible in it), draw the
textured quad; go back to perspective mode, and you’re done.

Lic. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy


Yes, they can, just as in 3D. Really the only difference is in the
projection (and theoretically possibly other implementation-defined
non-interface-changing stuff, but I’m ignoring that). Use gluOrtho2D
to set up the 2D, then draw rectangles (or other polygons, but I think
rectangles are the most common) with appropriate texture settings and
coordinates.

i already thought about that, i experimented with this code: https://sourceforge.net/projects/opensl/, but i just get a white rectangle where the picture should be.

i tried to write a library on my own (starting with the 2d image code from nehe zelda (nehe.gamedev.net) ), but it’s not commented, so i’m quite lost…

do you know any resources on texture loading?

thanks!