OpenGL-surface + "2D-surface"

I am programming a Risk-game (standard-tile 2D-game) for training
bots, however I want to make a mini-map in the lower left corner made by
a rendered opengl-sphere, with the map as a texture. All this I have
already coded, however my problem is finding a way to add the
opengl-sphere to the background-surface, which is used by a lot of
pictures blitted onto by a blitting function and then added using
SDL_flip. First adding the opengl-rendering the application crashed when
using the SDL_flip. Then I found that using the bit SDL_OPENGLBLIT in the
SDL_surface made the problem disappear. But at no time could I see the
2D-graphics any longer… To make it short (too late, but still) - Can I
render an opengl-sphere with a texture on a 2D-blitted surface? … Can i
capture the opengl-output somewhere in the “background” and blit it onto
the surface as 2D? … please help!

/DarkJedi

I am programming a Risk-game (standard-tile 2D-game) for training
bots, however I want to make a mini-map in the lower left corner made
by a rendered opengl-sphere, with the map as a texture.

IMHO, it’s very hard to motivate the use of OpenGL for something like
that in an application that doesn’t require OpenGL for anything else…

Besides, if you end up with software OpenGL, it’s going to be very
slow.

All this I have
already coded, however my problem is finding a way to add the
opengl-sphere to the background-surface, which is used by a lot of
pictures blitted onto by a blitting function and then added using
SDL_flip. First adding the opengl-rendering the application crashed
when using the SDL_flip. Then I found that using the bit SDL_OPENGLBLIT
in the SDL_surface made the problem disappear.

No!!! Don’t use that. Use OpenGL directly for all rendering, or
possibly use glSDL for the 2D stuff.

But at no time could I
see the 2D-graphics any longer… To make it short (too late, but
still) - Can I render an opengl-sphere with a texture on a 2D-blitted
surface? …

Well, yes, but unless you feel like doing a deep SDL hack that relies on
the driver and accelerator supporting rendering into whatever memory area
you specify, you’ll have to use Mesa or some other software OpenGL
implementation.

Can i capture the opengl-output somewhere in the
"background" and blit it onto the surface as 2D?

AFAIK, it should be possible to render into textures on most reasonably
modern 3D cards, but I’m not sure about the availability of OpenGL
support for that feature. Anyway, you’ll probably still need to use
OpenGL for rendering the whole screen, which basically eliminates SDL
surfaces from the picture; you’ll have OpenGL rendering that texture as
another quad to the screne, along with the rest of the graphics.

IMHO, you should seriously consider a software lens/sphere effect filter.
It’s very simple in theory (just a table of read/write offsets,
basically), and these days you can probably implement it with
interpolation (or oversampling, to avoid multiplications) and a simple
lightmap without it getting too slow. I’m quite sure a sphere with
software OpenGL will be much slower - and still, the OpenGL sphere will
be constructed out of polygons, while a sphere filter can be perfectly
pixel accurate.

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 18 September 2002 13:16, Andreas Schou Vaerge wrote:

To make it short (too late, but still) - Can I
render an opengl-sphere with a texture on a 2D-blitted surface? … Can i
capture the opengl-output somewhere in the “background” and blit it onto
the surface as 2D? … please help!

I guess I haven’t understood completely what you intend to do, but maybe
it helps if you think “the other way round”.
First - I guess it’s not possible to render on a surface, BUT you could
do the following: Switch over to OepnGl, meaning not drawing with SDL,
but OpenGl. Build your Main SDL_Surface as usual and than map it as a
texture on a Quad (2D Quad, no Cube, just 2 Triangles building a quad)
which fit’s the entire screen. After this do the Sphere Stuff and add it
just in Front of the Quad.

To do so, I would recommend you to use an orthogonal view, because your
objects don’t grow smaller in the Distance. This will be easier for the
adding of your sphere.

Ciao
Arne

well cant help you too much but heres a tutorial on rendering to surfaces:

http://cone3d.gamedev.net/cgi-bin/index.pl?page=tutorials/ogladv/tut5> ----- Original Message -----

From: andreas@cs.auc.dk (Andreas Schou Vaerge)
Newsgroups: loki.open-source.sdl
To:
Sent: Wednesday, September 18, 2002 4:16 AM
Subject: [SDL] OpenGL-surface + “2D-surface”

I am programming a Risk-game (standard-tile 2D-game) for training
bots, however I want to make a mini-map in the lower left corner made by
a rendered opengl-sphere, with the map as a texture. All this I have
already coded, however my problem is finding a way to add the
opengl-sphere to the background-surface, which is used by a lot of
pictures blitted onto by a blitting function and then added using
SDL_flip. First adding the opengl-rendering the application crashed when
using the SDL_flip. Then I found that using the bit SDL_OPENGLBLIT in the
SDL_surface made the problem disappear. But at no time could I see the
2D-graphics any longer… To make it short (too late, but still) - Can I
render an opengl-sphere with a texture on a 2D-blitted surface? … Can i
capture the opengl-output somewhere in the “background” and blit it onto
the surface as 2D? … please help!

/DarkJedi


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl