PDA

View Full Version : SDL



DarkSSJ
13-11-2002, 12:09 PM
Hi all,
I'm interested in SDL developing on Delphi/Kylix.
Anyone use SDL?
Any tip?
Any good site?
Thanks... :wink:

savage
13-11-2002, 05:38 PM
If you have a look at http://www.DelphiGamer.com I occasionally post news about people who are usin it for game development.

The official site is http://www.libsdl.org, they also have a mailing list, but it mainly C/C++ people who post on there.

BlueCat
06-12-2002, 03:01 PM
I've just started using SDL and it's excellent. I 'ported' my game engine to it in just an hour, it was using a TPanel, TTimer, TThis, TThat, now not one VCL component in sight, not even a TObject :lol: :lol:

savage
06-12-2002, 10:20 PM
Glad to hear you have found it usefull.

Any chance of seeing a demo on Windows or Linux?

BlueCat
08-12-2002, 02:11 PM
Glad to hear you have found it usefull.

Any chance of seeing a demo on Windows or Linux?

Yes, I'm planning on using SDL from now to develop my game and I'll upload a new demo in a couple of days to the usual address (the url for dgdev without the dgdev bit :D ).

I've had trouble with window resizing. Unfortunately my engine uses lots of display lists. I use SDL_SetVideoMode to resize the window (or switch to fullscreen) but in the process the OpenGL context is destroyed and a new one created. The problem is, this also destroys my display lists (which reside in an octree). It takes 20 seconds or so on my 1.2GHz machine to recreate the display lists, much longer on slower machines.

Does anyone know how I can change video modes without destroying the OpenGL context? I know that might be impossible, so if not any other tricks? :twisted: :twisted: :twisted:

BlueCat
08-12-2002, 07:32 PM
Also, I want to set up a timer.

Can anyone give me some example code showing SDL_AddTimer with a callback function? That would help sooo much. :wink:

savage
08-12-2002, 07:55 PM
Also, I want to set up a timer.

Can anyone give me some example code showing SDL_AddTimer with a callback function? That would help sooo much. :wink:

The SMpegPlayer.dpr demo shows you how to set up and use SDL_AddTimer.
The documentation ( sdladdtimer.html ) also has some additional info on SDL_AddTimer.


I hope this helps.

savage
08-12-2002, 07:59 PM
Glad to hear you have found it usefull.

Any chance of seeing a demo on Windows or Linux?

Yes, I'm planning on using SDL from now to develop my game and I'll upload a new demo in a couple of days to the usual address (the url for dgdev without the dgdev bit :D ).

I've had trouble with window resizing. Unfortunately my engine uses lots of display lists. I use SDL_SetVideoMode to resize the window (or switch to fullscreen) but in the process the OpenGL context is destroyed and a new one created. The problem is, this also destroys my display lists (which reside in an octree). It takes 20 seconds or so on my 1.2GHz machine to recreate the display lists, much longer on slower machines.

Does anyone know how I can change video modes without destroying the OpenGL context? I know that might be impossible, so if not any other tricks? :twisted: :twisted: :twisted:

I will find out if there are any tricks that could speed this process up.

BlueCat
08-12-2002, 09:09 PM
Thanks!

Could you give me a link for the mpeg demo? Not being lazy just can't seem to find it (it's been a long day :? )

Cheers

savage
09-12-2002, 05:54 AM
[quote="BlueCat"]Thanks!

Could you give me a ]

It should be part of the JEDI-SDL distribution under...
JEDI-SDL\smpeg\demos\SMpegPlayer\

If not, I can send it to you or you can grab it from the JEDI-SDL CVS on sourceforge @
http://sourceforge.net/cvs/?group_id=43805
where all the latest cutting edge code can be found.

PS. I recenly uploaded to the CVS a demo that uses OpenGL, SDL, and ODE ( http://www.q12.org/ode/ ). It's not perfect yet but it is a start for anyone who is interested in using a free 3rd party physics engine.

BlueCat
09-12-2002, 10:54 AM
Many thanks for your help :)

OK I've found it and the TimerTest project, but I can't compile it :cry:

This is from TimerTest:

Timer1 := SDL_AddTimer(500, CallTimer1, @Param1);


gives me this error:

[Error] Main.pas(86): Incompatible types: 'TSDL_TimerID' and 'PSDL_TimerID'

Timer1 is a PSDL_TimerID but the function returns a TSDL_TimerID.

Am I doing something wrong here? :roll:

savage
09-12-2002, 11:28 AM
gives me this error:

[Error] Main.pas(86): Incompatible types: 'TSDL_TimerID' and 'PSDL_TimerID'

Timer1 is a PSDL_TimerID but the function returns a TSDL_TimerID.

Am I doing something wrong here? :roll:

In my version of SDL.pas SDL_AddTimer is defined as

function SDL_AddTimer(interval: UInt32; callback: TSDL_NewTimerCallback; param
: Pointer): PSDL_TimerID; cdecl; external LibName;

Where did you grab your JEDI-SDL distribution?

If you have the time, I would recommend grabbing the latest of everything from CVS. If you need help gettting started, just yell.

BlueCat
09-12-2002, 11:39 AM
Savage you are sooooo helpful, got the *cough* correct *ahem* version of SDL.pas and it worked first time.

Just goes to show, check you have the latest stuff or you end up wasting several hours trying to make it work :roll: :roll: :roll: :roll:

Thanks for all your help.

I'll get the demo ready now and you'll be able to see the timer in action :lol: :lol: :lol: :lol:

savage
09-12-2002, 08:07 PM
Glad to hear you have found it usefull.

Any chance of seeing a demo on Windows or Linux?

Yes, I'm planning on using SDL from now to develop my game and I'll upload a new demo in a couple of days to the usual address (the url for dgdev without the dgdev bit :D ).

I've had trouble with window resizing. Unfortunately my engine uses lots of display lists. I use SDL_SetVideoMode to resize the window (or switch to fullscreen) but in the process the OpenGL context is destroyed and a new one created. The problem is, this also destroys my display lists (which reside in an octree). It takes 20 seconds or so on my 1.2GHz machine to recreate the display lists, much longer on slower machines.

Does anyone know how I can change video modes without destroying the OpenGL context? I know that might be impossible, so if not any other tricks? :twisted: :twisted: :twisted:

I posted your question on the main SDL mailing list and this is the response I got from a guy called Glenn Maynard...
"
I wrote a hack for the Windows implementation to allow changing some
window settings (everything except bit depth, I believe, which needs a
new context anyway), but only in Windows; I haven't implemented it on
anything else yet.

I'll attach it. It moves some stuff, so it's a little large. The code
to use it looks like this:

#ifndef SDL_HAS_CHANGEVIDEOMODE
/* We can't change the video mode without nuking the GL context. */
need_reload = true;
#endif

if( bpp != g_CurrentBPP )
need_reload = true; /* can't do this with SDL_SM_ChangeVideoMode_OpenGL */

if(need_reload) {
if(TEXTUREMAN) TEXTUREMAN->InvalidateTextures();
}

if(!g_screen || need_reload) {
g_screen = SDL_SetVideoMode(width, height, bpp, g_flags);
if(!g_screen)
throw RageException("SDL_SetVideoMode failed: %s", SDL_GetError());

SDL_WM_SetCaption("StepMania", "StepMania");
}
#ifdef SDL_HAS_CHANGEVIDEOMODE
else
{
SDL_SM_ChangeVideoMode_OpenGL(g_flags, g_screen, width, height);
}
#endif

You'll need to massage the patch (remove the refresh rate stuff, add a
prototype and the SDL_HAS_CHANGEVIDEOMODE #define) if you want to use it.
(Sorry, I didn't clean it up because diffing is a bit of a pain for me at
the moment ...)

I think this is something the SDL really needs to handle; nuking the GL
context to change video settings is definitely not good. I'm not sure of
a good general-purpose way to handle it, though, considering that some
archs may not be able to do certain things without a context recreation.

-- Glenn Maynard"

Sorry that it is C code, but I hope it proves useful

BTW you can join the main JEDI-SDL mailing list @
http://groups.yahoo.com/group/JEDI-SDL/join

BlueCat
09-12-2002, 11:16 PM
That might help I'll look into it, thanks for asking the question on the mailing list.

I've uploaded a demo, it's version 0.05 on the downloads page at http://terraqueous.f2o.org.

I have a feeling I've forgotten to include something crucial in the zip file :o

If someone could test it for me I'd be grateful. :D :D