2D and/or 3D?

Is it possible to do openGL and bitmap drawing at the same time with
SDL? Actually, not exactly at the same time; I want to alternate between
bitmap drawing and openGL.–
Marc Lavall?e

Is it possible to do openGL and bitmap drawing at the same time with
SDL? Actually, not exactly at the same time; I want to alternate between
bitmap drawing and openGL.

Use a textured quad for bitmap drawing, since gl*Pixel routines are usually
horribly slow. Or you could switch between OpenGL mode and SDL native mode
manually, just call SDL_SetVideoMode() with flags |= SDL_OPENGL when you
want opengl mode.

Ex.

{
/* Switch to menu mode */
SDL_SetVideoMode( 640, 480, 0, SDL_FULLSCREEN | SDL_DOUBLEBUF );

/* Draw bitmaps with normal sdl functions and surfaces, eg a menu */

/* Ok, user pressed menu button "Start cool game" */
SDL_SetVideoMode( 640, 480, 0, SDL_FULLSCREEN | SDL_DOUBLEBUF |

SDL_OPENGL );

/* Use normal opengl commands to present cool game */

};

/J

Is it possible to do openGL and bitmap drawing at the same time with
SDL? Actually, not exactly at the same time; I want to alternate between
bitmap drawing and openGL.

Use a textured quad for bitmap drawing, since gl*Pixel routines are usually
horribly slow. Or you could switch between OpenGL mode and SDL native mode
manually, just call SDL_SetVideoMode() with flags |= SDL_OPENGL when you
want opengl mode.

If you want to speed it up a bit more, use triangle strips instead of quads.
Some cards will convert the quad into triangles and some won’t, which will
be a lot slower.–

Jens Lindblad @Jens_Lindblad
Black holes are where God divided by zero

If you want to speed it up a bit more, use triangle strips instead of quads.
Some cards will convert the quad into triangles and some won’t, which will
be a lot slower.

Someone PLEASE correct me if i’m wrong, but i’ll side with him. I’m pretty sure that Carmack uses strips in the q3 engine for stuff like that too…—
You were expecting someone else? - DrEvil

If you want to speed it up a bit more, use triangle strips instead of
quads.

Some cards will convert the quad into triangles and some won’t, which
will

be a lot slower.

Someone PLEASE correct me if i’m wrong, but i’ll side with him. I’m pretty
sure that Carmack uses strips in the q3 engine for stuff like that too…

Just to point out that the original issue was to draw bitmaps on the screen,
ie 2 textured triangles. I personally think it’s a moot issue to optimize
the triangle setup so that it uses tri-strips instead of two single
triangles, since the no of bitmaps drawn on the screen will probably never
be much compared to what the gfx card will be able to handle ( assuming you
have a decent 3dcard of course ).

Of course, for “normal” geometry, indexed tri-strips are the fastest way to
do it, if you do it right that is, eg for geforce cards, try to reuse the
vertices in the vertex cache for speedup. And - it’s easy to mess things up,
I recently benchmarked drawing a landscape with good old bintriangles.
First, I made separate GL_TRIANGLES calls into a display list, then a
GL_TRI_STRIP call.

With GL_TRIANGLES 3.6 MTri/s
WIth GL_TRI_STRIP 3.1 MTri/s

The throughput actually degraded after the tristripper munched through the
triangle list :slight_smile: In the case with GL_TRIANGLES the triangles were picked in
a clever order, wheras the tri stripper pretty much trashed the vertex
cache. Nvidia have some code for creating optimized triangle strips on their
website, I haven’t checked it out but I think it will strips that make sure
their vertex cache is happy :slight_smile:

/J

Jim Tilander a ?crit :

Or you could switch between OpenGL mode and SDL native
mode manually, just call SDL_SetVideoMode() with flags
|= SDL_OPENGL when you want opengl mode.

Ex.

{
/* Switch to menu mode */
SDL_SetVideoMode( 640, 480, 0, SDL_FULLSCREEN |
SDL_DOUBLEBUF );

/* Draw bitmaps with normal sdl functions and surfaces,
eg a menu */

/* Ok, user pressed menu button “Start cool game” */
SDL_SetVideoMode( 640, 480, 0, SDL_FULLSCREEN |
SDL_DOUBLEBUF | SDL_OPENGL );

/* Use normal opengl commands to present cool game */

};

I tried and it crashed my test application. Here’s the error message:

X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 129 (XFree86-DRI)
Minor opcode of failed request: 9 ()
Value in failed request: 0x45
Serial number of failed request: 34
Current serial number in output stream: 34

Are you sure it’s possible to switch the video mode?–
Marc Lavall?e

The discussion on this 2D/3D thing is getting too complicated, so I’ll
explain what I’m trying to do.

I’m working on a simple multimedia project that involve bitmaps
manipulations. Since I’m new to graphic programming, I started to play
with some of the SDL examples and demos. At some point, I discovered
openGL and texture mapping, and how my 3D card could accelerate some 2D
manipulations.

The particular effect I need is a smooth crossfade between 2 bitmaps.
It’s quite simple to do with plain SDL, but it’s very slow at 640x480.
Maybe there’s a way to do it with openGL?–
Marc Lavall?e

Jim Tilander a ?crit :

Or you could switch between OpenGL mode and SDL native
mode manually, just call SDL_SetVideoMode() with flags
|= SDL_OPENGL when you want opengl mode.

Ex.

{
/* Switch to menu mode */
SDL_SetVideoMode( 640, 480, 0, SDL_FULLSCREEN |
SDL_DOUBLEBUF );

/* Draw bitmaps with normal sdl functions and surfaces,
eg a menu */

/* Ok, user pressed menu button “Start cool game” */
SDL_SetVideoMode( 640, 480, 0, SDL_FULLSCREEN |
SDL_DOUBLEBUF | SDL_OPENGL );

/* Use normal opengl commands to present cool game */

};

I tried and it crashed my test application. Here’s the error message:

X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 129 (XFree86-DRI)
Minor opcode of failed request: 9 ()
Value in failed request: 0x45
Serial number of failed request: 34
Current serial number in output stream: 34

Are you sure it’s possible to switch the video mode?

Oh, I haven’t really tried it under X11, as I’m developing on Win2K right
now. But I can imagine a whole slew of problems arising under X. Have you
tried to do away with the fullscreen flag? That one will certainly make
things harder. It works perfectly under win2k though :slight_smile: Small solace…

Anyone else who can say weather it’s possible or not, feel free to jump in
:slight_smile: Sam?

/J

[…]

I tried and it crashed my test application. Here’s the error
message:

X Error of failed request: BadValue (integer parameter out of
range for operation)
Major opcode of failed request: 129 (XFree86-DRI)
Minor opcode of failed request: 9 ()
Value in failed request: 0x45
Serial number of failed request: 34
Current serial number in output stream: 34

Are you sure it’s possible to switch the video mode?

Oh, I haven’t really tried it under X11, as I’m developing on Win2K
right now. But I can imagine a whole slew of problems arising under
X. Have you tried to do away with the fullscreen flag? That one
will certainly make things harder. It works perfectly under win2k
though :slight_smile: Small solace…

Anyone else who can say weather it’s possible or not, feel free to
jump in

Some Linux games do it under X, both modes full screen, and it works
with Utah-GLX h/w acceleration, so it looks possbile to me. Don’t
know if these games use SDL for video, though (they could be using
SDL only for input, sound etc), but I think so…

//David

.- M u C o S -------------------------. .- David Olofson --------.
| A Free/Open Source | | Audio Hacker |
| Plugin and Integration Standard | | Linux Advocate |
| for | | Open Source Advocate |
| Professional and Consumer | | Singer |
| Multimedia | | Songwriter |
-----> http://www.linuxdj.com/mucos -'—> david at linuxdj.com -'On Sunday 26 November 2000 22:27, Jim Tilander wrote:

I tried and it crashed my test application. Here’s the error message:

X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 129 (XFree86-DRI)
Minor opcode of failed request: 9 ()
Value in failed request: 0x45
Serial number of failed request: 34
Current serial number in output stream: 34

Are you sure it’s possible to switch the video mode?

Sounds like a bug in DRI. Have you tested with the latest CVS versions
of SDL and DRI? I believe a bug that sounds very much like this was fixed
about three weeks ago.

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

This looks very familiar… I get this when I build and reinstall
some OpenGL related package (can’t remember which one…), which
replaces some of the GL libs.

The fix is to remove all GL libs (libGL, libGLU, libglut) and
reinstall the OpenGL driver package, then run ldconfig, unless the
install script does so.

In my cases (two Red Hat 7.0 systems with XFree86 3.3.6 + Utah-GLX
0.10-pre1) a ‘make install’ of Utah-GLX with the GLU and GLUT libs
(ported from Mesa and included with Utah-GLX) + copying the glx.so to
the right place [the install script fails to do that for some reason]
fixes the problem.

//David

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Saturday 16 December 2000 13:46, Sam Lantinga wrote:

I tried and it crashed my test application. Here’s the error
message:

X Error of failed request: BadValue (integer parameter out of
range for operation)
Major opcode of failed request: 129 (XFree86-DRI)
Minor opcode of failed request: 9 ()
Value in failed request: 0x45
Serial number of failed request: 34
Current serial number in output stream: 34

Are you sure it’s possible to switch the video mode?