glSDL backend

Hi,

We (David Olofson and me) finally got the glSDL backend into a state
that works and has recieved enough testing for a first beta. The
resulting patch is there (not posted to the list because of the mailing
list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

This patch also includes :

  • the hardware accelerated alpha blits fix discussed some months ago
  • an internal change to the semantics of the SDL_OPENGL flag : backends
    now use SDL_INTERNALOPENGL to tell the difference between an OpenGL mode
    and a normal mode. This incurs no change to the applications which still
    use and query the SDL_OPENGL flag. The SDL_OPENGL flag previously meant
    two things : “the window is handled by OpenGL” and “the application uses
    an OpenGL window”, and for a glSDL backend we needed to split this. Now
    it simply means “the application uses an OpenGL window” and
    SDL_INTERNALOPENGL means “the window is handled by OpenGL”.

Testing is welcome of course !

When running stock applications, those might be veeeery slow.
Application tuning for performance in general and for glSDL in
particular is described there :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl.html

Stephane

Application tuning for performance in general and for glSDL in
particular is described there :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl.html

This is a great article. Almost all the info there is equally pertinent
for any use of hardware accelerated surfaces on any platform.

Congrats!
-Sam Lantinga, Software Engineer, Blizzard Entertainment

We (David Olofson and me) finally got the glSDL backend into
a state that works and has recieved enough testing for a
first beta. The resulting patch is there (not posted to the
list because of the mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Are there any plans for a binary (dll/so) release?
I ask, because I am writing my game in Pascal and I would like to avoid
patching and building SDL on my own. I don’t even have a C compiler
installed on my Windows system.

Thanks,
Michael

It’s hard or impossible to do properly, since glSDL is a backend to
SDL, and SDL does not support “backend plugins” or the like. The
alternatives to building it into SDL is the wrapper approach of the
original glSDL (on my site), or implementing it as an add-on library
with a separate API.

A wrapper means you have to compile glSDL into your application rather
than the SDL library, and a separate API means your application won’t
build or run without an extra library. Both are hard to get right
without modifying the SDL library, since glSDL requires some intimate
interaction with SDL, such as piggy-backing extra information onto
all SDL surfaces. (glSDL/wrapper does that by abusing the "unused1"
field of the SDL_Surface struct.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Friday 24 December 2004 08.16, Michael Kastner wrote:

We (David Olofson and me) finally got the glSDL backend into
a state that works and has recieved enough testing for a
first beta. The resulting patch is there (not posted to the
list because of the mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Are there any plans for a binary (dll/so) release?

So… what is the right way to use glSDL?

Could you explain to us or give an example?

I used glSDL as wrapper (v0.71) and it worked for me perfectly :), but now,
I don’t know if there are new improves and changes since v0.71 or not.

Anyway…glSDL is a fantastic project, congratulations to do it! and thanks
in advance

Happy Christmas!!> ----- Original Message -----

From: david@olofson.net (David Olofson)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Friday, December 24, 2004 1:35 PM
Subject: Re: [SDL] glSDL backend

On Friday 24 December 2004 08.16, Michael Kastner wrote:

We (David Olofson and me) finally got the glSDL backend into
a state that works and has recieved enough testing for a
first beta. The resulting patch is there (not posted to the
list because of the mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Are there any plans for a binary (dll/so) release?

It’s hard or impossible to do properly, since glSDL is a backend to
SDL, and SDL does not support “backend plugins” or the like. The
alternatives to building it into SDL is the wrapper approach of the
original glSDL (on my site), or implementing it as an add-on library
with a separate API.

A wrapper means you have to compile glSDL into your application rather
than the SDL library, and a separate API means your application won’t
build or run without an extra library. Both are hard to get right
without modifying the SDL library, since glSDL requires some intimate
interaction with SDL, such as piggy-backing extra information onto
all SDL surfaces. (glSDL/wrapper does that by abusing the "unused1"
field of the SDL_Surface struct.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se


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

Stephane Marchesin wrote:

Hi,

We (David Olofson and me) finally got the glSDL backend into a state
that works and has recieved enough testing for a first beta. The
resulting patch is there (not posted to the list because of the mailing
list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Hi,

I wanted to test it but I don’t understand how patch the SDL source :
I’m under Windows with VC.NET so I’ve downloaded the exe patch from
www.sf.net/projects/gnuwin32 and, of course, the source of SDL 1.2.8
(from the zip)

I’ve tried from the directory which contains SDL.1.2.8 with patch <
glsdl-final.patch and I’ve got that :

E:\Prog\SDL>patch < glsdl-final.patch
can’t find file to patch at input line 4
Perhaps you should have used the -p or --strip option?
The text leading up to this was:--------------------------
|diff -Naur SDL12.orig/configure.in SDL12/configure.in
|— SDL12.orig/configure.in 2004-12-18 17:03:48.000000000 +0100

+++ SDL12/configure.in 2004-12-18 17:06:04.000000000 +0100

I’ve also tried in the directory SDL.1.2.8/ and I’ve got this message
E:\Prog\SDL\SDL-1.2.8>patch < …/glsdl-final.patch
patching file configure.in
Assertion failed: hunk, file patch.c, line 343

abnormal program termination

What are those directories SDL12.orig and SDL12 ?
I’ve created a empty directory SDL12 and renamed the SDL-1.2.8\ with
SDL12.orig but I’ve got sames errors

so maybe I’ve forgot to set options but I don’t know which…

Have a good day
Murlock

So… what is the right way to use glSDL?

The right way is to use a patched SDL library, until glSDL is included
in the official releases.

Could you explain to us or give an example?

http://icps.u-strasbg.fr/~marchesin/sdl/glsdl.html

(Most of that applies to SDL in general, since it’s basically about
taking the steps required to take advantage of any form of hardware
acceleration when available.)

Oh, and note that my SDL examples aren’t all that well behaved WRT
glSDL, since they were all developed on Linux before glSDL and
without other accelerated backends. Shame on me…! :smiley:

I used glSDL as wrapper (v0.71) and it worked for me perfectly :),
but now, I don’t know if there are new improves and changes since
v0.71 or not.

The most important difference to end users is that the SDL library
with the glSDL backend compiled in should be able to accelerate any
carefully written application without recompiling the application
itself.

Other differences include fully SDL compatible clipping, two-way
tiling (surface size not restricted by OpenGL texture size limits in
any way), better flags and information API compatibility and various
other fixes.

Anyway…glSDL is a fantastic project, congratulations to do it!
and thanks in advance

Happy Christmas!!

Thanks - and my special thanks to Stephane, who did the actual work on
the backend version of glSDL. :slight_smile:

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Friday 24 December 2004 15.43, Roberto Prieto wrote:

We (David Olofson and me) finally got the glSDL backend into a state
that works and has recieved enough testing for a first beta. The
resulting patch is there (not posted to the list because of the
mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Are there any plans for a binary (dll/so) release?

It’s hard or impossible to do properly, since glSDL is a
backend to SDL, and SDL does not support “backend plugins” or
the like.

If I understood everything correctly then in order to use the new glSDL you
have to

  1. download the SDL source code and the glSDL patch
  2. patch SDL
  3. possibly enable the glSDL backend with some configuration option
  4. build the patched and configured SDL
  5. link your program to the patched SDL statically/dynamically
  6. tell SDL to use the glSDL backend alternatively to the already existing
    ones (x11, dga, directx, windib, …)

Because it would save me a lot time to skip steps 1 to 4 (and replace it by
"download a sdl.dll/libsdl.o containing the glSDL patch"), I was curious if
there are plans to release compiled dynamic libraries - either in the next
official SDL version or seperated from the official SDL releases.
Now that I think about it, I realize that this might be too much to ask for,
since glSDL is still in a beta stage.
Nevertheless it would be interesting to know if there are plans to integrate
glSDL into future official binary releases of SDL and when this would
roughly happen.

Michael

We (David Olofson and me) finally got the glSDL backend into
a state that works and has recieved enough testing for a
first beta. The resulting patch is there (not posted to the
list because of the mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

I have applied the patch tho the 1.2.8 release of SDL and it did not
worked for me. First I tried BlobWars with SDL_VIDEODRIVER set to x11,
and only a black screen with the cursor appeared, I had to restart X to
quit. Same thing occured with glSDL. So I tried Neverwinter Nights
(which I was playing right before recompile SDL), and did not work,
either: with SDL_VIDEODRIVER=glSDL I got “glSDL videoinit” on the
console and quit, with SDL_VIDEODRIVER=x11 the screen turns black for a
moment and quit with the message:

X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 89 (X_StoreColors)
Value in failed request: 0xffffffff
Serial number of failed request: 28
Current serial number in output stream: 29

I have a Linux Slackware with kernel 2.4.26, X.Org 6.7.0, nVidia GeForce
4 video card (nvidia driver). How can I get more info about the problem?–
Lucas Clemente Vella
@Lucas_Clemente_Vella

glSDL doesn’t change the x11 backend, so if no programs work anymore
with it, you probably didn’t build your SDL correctly.
If you don’t patch it before compiling and installing, does it work ?

Yes, it worked. I rebuilt it without the patch and it worked just as
before. I have not tried the patch just once, I decompressed, patched
and built the source at least two times.

Btw, NWN is a 3d game so it’s not supposed to work with glSDL. glSDL
only supports 2D.

So I believed, but I tried to see what would happen. Was it supposed to
do that?> Stephane


Lucas Clemente Vella
@Lucas_Clemente_Vella

Lucas Clemente Vella wrote:

We (David Olofson and me) finally got the glSDL backend into
a state that works and has recieved enough testing for a
first beta. The resulting patch is there (not posted to the
list because of the mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

I have applied the patch tho the 1.2.8 release of SDL and it did not
worked for me. First I tried BlobWars with SDL_VIDEODRIVER set to x11,
and only a black screen with the cursor appeared, I had to restart X
to quit. Same thing occured with glSDL. So I tried Neverwinter Nights
(which I was playing right before recompile SDL), and did not work,
either: with SDL_VIDEODRIVER=glSDL I got “glSDL videoinit” on the
console and quit, with SDL_VIDEODRIVER=x11 the screen turns black for
a moment and quit with the message:

X Error of failed request: BadValue (integer parameter out of range
for operation)
Major opcode of failed request: 89 (X_StoreColors)
Value in failed request: 0xffffffff
Serial number of failed request: 28
Current serial number in output stream: 29

I have a Linux Slackware with kernel 2.4.26, X.Org 6.7.0, nVidia
GeForce 4 video card (nvidia driver). How can I get more info about
the problem?

glSDL doesn’t change the x11 backend, so if no programs work anymore
with it, you probably didn’t build your SDL correctly.
If you don’t patch it before compiling and installing, does it work ?

Btw, NWN is a 3d game so it’s not supposed to work with glSDL. glSDL
only supports 2D.

Stephane

Murlock wrote:

Stephane Marchesin wrote:

Hi,

We (David Olofson and me) finally got the glSDL backend into a state
that works and has recieved enough testing for a first beta. The
resulting patch is there (not posted to the list because of the
mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Hi,

I wanted to test it but I don’t understand how patch the SDL source :
I’m under Windows with VC.NET so I’ve downloaded the exe patch from
www.sf.net/projects/gnuwin32 and, of course, the source of SDL 1.2.8
(from the zip)

I’ve tried from the directory which contains SDL.1.2.8 with patch <
glsdl-final.patch and I’ve got that :

E:\Prog\SDL>patch < glsdl-final.patch
can’t find file to patch at input line 4
Perhaps you should have used the -p or --strip option?

So, as stated in the error messasge, use patch -p1. That said, I don’t
know how well patch works under windows.

Stephane

Lucas Clemente Vella wrote:

glSDL doesn’t change the x11 backend, so if no programs work anymore
with it, you probably didn’t build your SDL correctly.
If you don’t patch it before compiling and installing, does it work ?

Yes, it worked. I rebuilt it without the patch and it worked just as
before. I have not tried the patch just once, I decompressed, patched
and built the source at least two times.

Well, considering that glSDL doesn’t change the x11 backend, there is
probably another problem.
If you compile it but don’t set the environment variable, does it work ?

Btw, NWN is a 3d game so it’s not supposed to work with glSDL. glSDL
only supports 2D.

So I believed, but I tried to see what would happen. Was it supposed
to do that?

Well, we (in glSDL) set the error message and return an error. How
applications decide (or not for that matter) to handle it is out of our
scope.

Stephane

David Olofson wrote:

Anyway…glSDL is a fantastic project, congratulations to do it!
and thanks in advance

Happy Christmas!!

Thanks - and my special thanks to Stephane, who did the actual work on
the backend version of glSDL. :slight_smile:

While we are on congratulations, I’d like to add that you deserve a
special mention for mostly everything else (including writing the tiling
code :).

Stephane

Michael Kastner wrote:

We (David Olofson and me) finally got the glSDL backend into a state
that works and has recieved enough testing for a first beta. The
resulting patch is there (not posted to the list because of the
mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Are there any plans for a binary (dll/so) release?

It’s hard or impossible to do properly, since glSDL is a
backend to SDL, and SDL does not support “backend plugins” or
the like.

If I understood everything correctly then in order to use the new glSDL you
have to

  1. download the SDL source code and the glSDL patch
  2. patch SDL
  3. possibly enable the glSDL backend with some configuration option
  4. build the patched and configured SDL
  5. link your program to the patched SDL statically/dynamically
  6. tell SDL to use the glSDL backend alternatively to the already existing
    ones (x11, dga, directx, windib, …)

Because it would save me a lot time to skip steps 1 to 4 (and replace it by
"download a sdl.dll/libsdl.o containing the glSDL patch"), I was curious if
there are plans to release compiled dynamic libraries - either in the next
official SDL version or seperated from the official SDL releases.
Now that I think about it, I realize that this might be too much to ask for,
since glSDL is still in a beta stage.

Well, I think I have removed all the bugs I could find. So while it’s
the first public"beta" it shouldn’t really be that buggy.

Nevertheless it would be interesting to know if there are plans to integrate
glSDL into future official binary releases of SDL and when this would
roughly happen.

I really hope that it will end in the SDL tree. I have no plans
maintaining a 100kb patch against a moving cvs tree :slight_smile:
Even if it’s just disabled by default for a start.

Stephane

Stephane Marchesin wrote:

Well, considering that glSDL doesn’t change the x11 backend, there is
probably another problem.
If you compile it but don’t set the environment variable, does it work ?

I give up on blobwars. Even with unpatched SDL, I need to restart my X11
once to get it working (I have no idea why), but after restarting X11,
it works with unpatched SDL and with glSDL (withoud sound in both, I
belive it is a bug of my version of blobwars with SDL-1.2.8).
Now, with nq-sdl(software render), form QuakeForge, worked with no
problem without setting SDL_VIDEODRIVER, setting it to glSDL, dga and x11.
With nq-sgl (OpenGL), without setting SDL_VIDEODRIVER, I got almost the
same thing that I got with Neverwinter Nights:

NWN:
X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 89 (X_StoreColors)
Value in failed request: 0xffffffff
Serial number of failed request: 28
Current serial number in output stream: 29

nq-sgl:
X Error of failed request: BadValue (integer parameter out of range for
operation)
Major opcode of failed request: 89 (X_StoreColors)
Value in failed request: 0xffffffff
Serial number of failed request: 29
Current serial number in output stream: 30–
Lucas Clemente Vella
@Lucas_Clemente_Vella

Stephane Marchesin wrote:

Murlock wrote:

Stephane Marchesin wrote:

Hi,

We (David Olofson and me) finally got the glSDL backend into a state
that works and has recieved enough testing for a first beta. The
resulting patch is there (not posted to the list because of the
mailing list size filter) :
http://icps.u-strasbg.fr/~marchesin/sdl/glsdl-final.patch

Hi,

I wanted to test it but I don’t understand how patch the SDL source :
I’m under Windows with VC.NET so I’ve downloaded the exe patch from
www.sf.net/projects/gnuwin32 and, of course, the source of SDL 1.2.8
(from the zip)

I’ve tried from the directory which contains SDL.1.2.8 with patch <
glsdl-final.patch and I’ve got that :

E:\Prog\SDL>patch < glsdl-final.patch
can’t find file to patch at input line 4
Perhaps you should have used the -p or --strip option?

So, as stated in the error messasge, use patch -p1. That said, I don’t
know how well patch works under windows.

Stephane

Hi,

after digging, I’ve found that the problem occurs with EOL Unix. I’ve
converted all files to DOS format and patch -p1 runs fines.

I’ve also compiled with VC7++ (littles fixs was required) :
SDL_glsdl.c:
#include <unistd.h>, line 38, removed
in glDL_LockHWurface,line 1377 and 1379
a cast must be add to convert the void* pixels in unsigned char*

now, my game runs but I don’t know if GLSDL is used or not :
13:12:17 2005 : Video driver : windib
13:12:17 2005 : display : 1152 x 864 x 16 ( 75 Hz )
13:12:17 2005 : SDL_SetVideoMode( 320, 200, 0, SDL_HWSURFACE);
13:12:17 2005 : Info about SDL_Surface retrivied : SDL_SWSURFACE
13:12:17 2005 : SDL Compiled version : 1.2.8
13:12:17 2005 : SDL Linked version: 1.2.8

screen->flags & SDL_OPENGL => 0
screen->flags & SDL_INTERNALOPENGL => 0

I’ll make more test this week

Cheers,
Murlock

Murlock wrote:

Hi,

after digging, I’ve found that the problem occurs with EOL Unix. I’ve
converted all files to DOS format and patch -p1 runs fines.

Ah, well. That’s the kind of problems I expected from a windows version
of patch.

I’ve also compiled with VC7++ (littles fixs was required) :
SDL_glsdl.c:
#include <unistd.h>, line 38, removed
in glDL_LockHWurface,line 1377 and 1379
a cast must be add to convert the void* pixels in unsigned char*

Ok.

now, my game runs but I don’t know if GLSDL is used or not :
13:12:17 2005 : Video driver : windib

Video driver should be “glSDL”, not “windib”.

Stephane

Lucas Clemente Vella wrote:

Stephane Marchesin wrote:

Well, considering that glSDL doesn’t change the x11 backend, there is
probably another problem.
If you compile it but don’t set the environment variable, does it work ?

I give up on blobwars. Even with unpatched SDL, I need to restart my X11
once to get it working (I have no idea why), but after restarting X11,
it works with unpatched SDL and with glSDL (withoud sound in both, I
belive it is a bug of my version of blobwars with SDL-1.2.8).

Well, sometimes using glSDL makes bug appear in other software.
Usually programs that assume specific pixel formats or such.

Now, with nq-sdl(software render), form QuakeForge, worked with no
problem without setting SDL_VIDEODRIVER, setting it to glSDL, dga and
x11.
With nq-sgl (OpenGL), without setting SDL_VIDEODRIVER, I got almost
the same thing that I got with Neverwinter Nights:

NWN:
X Error of failed request: BadValue (integer parameter out of range
for operation)
Major opcode of failed request: 89 (X_StoreColors)
Value in failed request: 0xffffffff
Serial number of failed request: 28
Current serial number in output stream: 29

nq-sgl:
X Error of failed request: BadValue (integer parameter out of range
for operation)
Major opcode of failed request: 89 (X_StoreColors)
Value in failed request: 0xffffffff
Serial number of failed request: 29
Current serial number in output stream: 30

Please try with programs that are known to handle the failure
gracefully, like for example testgl from the SDL source distribution. As
I said, not all programs do that :slight_smile:

Here is what I get :
$ export SDL_VIDEODRIVER=glSDL
$ ./testgl
glSDL videoinit
Couldn’t set GL mode:

Stephane

Stephane Marchesin wrote:

Video driver should be “glSDL”, not “windib”.

Stephane

Arff… :wink:

It’s OK, slower than my other filters (eagle, sai2x, …) but my game
use a lot of small SDL_UpdateRect so I suppose that the time to upload
thoses to a new opengl texture consumes much times…

Otherwise, is it possible to use the capacities of OpenGl to change the
size of viewport without change of logical size of software ?

For anyone who want to test SDL 1.2.8 with glSDL, you can download it at
http://www.murlock.org/mom/sdl-1.2.8-glsdl-devel-win32.zip
don’t forget to set SDL_VIDEODRIVER=glSDL :wink:

Cheers,
Murlock