Running SDL game in a big thread

Hi there,

what I’m trying to do is to change a given game using SDL into a DLL.

Why? Because I want to use it as a Plugin for another application.

So that’s my problem:

To avoid hanging the host application I have to run my game in a big thread:

thread = SDL_CreateThread(thread_func, NULL );

Everything works out perfectly. I can run the game and unload the dll again.

But if I try to reload the DLL (without restarting the host application)
everthing

crashes.

I traced the problem and found out that the SDL_SetVideoMode method causes

the crash. any ideas? Or is it impossible to do this that way? Any
suggestions?

Thanks and best regards,

                    Florian

        (Stuttgart, Germany)

Hi.
Yes there is a bug in the way SDL handles windowclasses. Im working on
a fix, which will be posted here, in this week.
Also I have a workaround that you can try:

  1. Make sure to call SDL_QuitSubsystem(INIT_VIDEO) before the dll is unloaded.

  2. When the DllMian is called with PROCESS_DETACH, check for a
    existing windowclass with the name “SDL_app” and the handle of your
    mainprogram. Like this:

HMODULE MainHandle = GetModuleHandle(NULL):
WNDCLASS PendingWinClass;
if (GetClassInfo(MainHandle, “SDL_app”, &PendingWinClass) {
unregisterclass(MainHandle, “SDL_app”)
}

I had the same problem, which only occurs when the dll is unloaded
between SDL-runs.

If you cant make it work, drop a line and you can see my code, when I
get to work tomorrow.
Good luck

-MartinOn Tue, 1 Feb 2005 20:11:30 +0100, Florian Geyer wrote:

Hi there,

what I’m trying to do is to change a given game using SDL into a DLL.

Why? Because I want to use it as a Plugin for another application.

So that’s my problem:

To avoid hanging the host application I have to run my game in a big thread:

thread = SDL_CreateThread(thread_func, NULL ); 

Everything works out perfectly? I can run the game and unload the dll again.

But if I try to reload the DLL (without restarting the host application)
everthing

crashes?

I traced the problem and found out that the SDL_SetVideoMode method causes

the crash? any ideas? Or is it impossible to do this that way? Any
suggestions?

Thanks and best regards,

                    Florian 

        (Stuttgart, Germany) 

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

Thanks very much!!!
Number 2 did the trick for me!
Great…

Thanks and greetings,
Florian
(Stuttgart, Germany)

-----Urspr?ngliche Nachricht-----Von: sdl-bounces+florian-geyer=web.de at libsdl.org
[mailto:sdl-bounces+florian-geyer=web.de at libsdl.org] Im Auftrag von Martin
Lange
Gesendet: Dienstag, 1. Februar 2005 20:51
An: A list for developers using the SDL library. (includes SDL-announce)
Betreff: Re: [SDL] Running SDL game in a big thread…

Hi.
Yes there is a bug in the way SDL handles windowclasses. Im working on
a fix, which will be posted here, in this week.
Also I have a workaround that you can try:

  1. Make sure to call SDL_QuitSubsystem(INIT_VIDEO) before the dll is
    unloaded.

  2. When the DllMian is called with PROCESS_DETACH, check for a
    existing windowclass with the name “SDL_app” and the handle of your
    mainprogram. Like this:

HMODULE MainHandle = GetModuleHandle(NULL):
WNDCLASS PendingWinClass;
if (GetClassInfo(MainHandle, “SDL_app”, &PendingWinClass) {
unregisterclass(MainHandle, “SDL_app”)
}

I had the same problem, which only occurs when the dll is unloaded
between SDL-runs.

If you cant make it work, drop a line and you can see my code, when I
get to work tomorrow.
Good luck

-Martin

On Tue, 1 Feb 2005 20:11:30 +0100, Florian Geyer <@Florian_Geyer> wrote:

Hi there,

what I’m trying to do is to change a given game using SDL into a DLL.

Why? Because I want to use it as a Plugin for another application.

So that’s my problem:

To avoid hanging the host application I have to run my game in a big
thread:

thread = SDL_CreateThread(thread_func, NULL ); 

Everything works out perfectly
I can run the game and unload the dll
again.

But if I try to reload the DLL (without restarting the host application)
everthing

crashes

I traced the problem and found out that the SDL_SetVideoMode method causes

the crash
any ideas? Or is it impossible to do this that way? Any
suggestions?

Thanks and best regards,

                    Florian 

        (Stuttgart, Germany) 

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


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