Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL+GL=bugs

Started by Pipo DeClown Nov 27, 2004 at 4:52 PM 12 replies 3.1k views
Original Post
Pipo DeClown
Pipo DeClown
When I use OpenGL with SDL, I find a lot of strange bugs: 1) The Win32 MessageBox() doesn't work. (Even when it returns S_OK, I just hear a bumpbeep) 2) fprintf() crashes with a writing exception at 0000000010. Something like that. (Only when I delete the code, it doesn't crash. It even crashes when commented out) I use VC++.NET and SDL-1.2.7. (Tried the real OpenGL headers instead of SDL_opengl.h, still the same bugs)
fiskbil
fiskbil
Have you tried fiddling with the choice of runtime libraries? I think SDL requires that you use Multithreaded DLL, but that's just some distant thing in the back of my head. It's in code generation in C/C++ folder in the project settings.
Nairb
Nairb
Also, are you running in fullscreen? That might be the reason the Win32 Message Box isn't showing up. In my experience, mixing Win32 stuff with OGL/DX is asking for trouble.

Check your code around yuor fprintf. I would suspect the error there is with something else, and not your OGL code. What are you printing out?

In all likelihood, you're already compiling using the Multithreaded DLL option (I don't think an SDL program will even compile without it).

Hope that helps,
--Brian

graveyard filla
graveyard filla
aren't you not supposed to touch any Win32 functions if your using SDL? i would bet that's why its not working. why do you even need to use it? SDL should handle everything for you..

plus, it un-cross-platformizes (lol) your code.
FTA, my 2D futuristic action MMORPG
ImperfectFreak
ImperfectFreak
Yeah why are you doing that, the reason to combine SDL and OpenGL is to make is cross platform, if you are using the WinAPI might as well ditch SDL. . .
ImperfectFreak
ImperfectFreak
By the way. . .SDL_opengl.h. . .what use

#include
#include
#include

(Only when I delete the code, it doesn't crash. It even crashes when commented out) that doesnt make any sense. . .
Ainokea
Ainokea
One reason to use win32 message boxes is if you have an error and you want your user to see it. You can use that temporarily until you make a gui or implement on the other systems you are using your game/app on. Or if its only for the developer.
______________With the flesh of a cow.
Drew_Benton
Drew_Benton
I have had bugs such as these before. THe only solution I have is to create a Win32 console app, instead of a Win32 App, so you can use printf to help you track erros.

[Edited by - Drew_Benton on January 3, 2006 4:04:01 AM]
Kelly G
Kelly G
If you use printf in a win32 app with SDL, the output should automatically be directed to a text file which you can read when your program finishes.

Edit: oh sorry, you said fprintf

[Edited by - Kelly G on November 28, 2004 6:35:58 AM]
wind3f
wind3f
i want to know too.and i dont know where i can download the SDL!
Pipo DeClown
Pipo DeClown
Quote:
Original post by fiskbil
Have you tried fiddling with the choice of runtime libraries? I think SDL requires that you use Multithreaded DLL, but that's just some distant thing in the back of my head. It's in code generation in C/C++ folder in the project settings.


Thanks, but I use exactly the same setting that worked with 'normal' SDL.

Quote:
Original post by Nairb
Also, are you running in fullscreen? That might be the reason the Win32 Message Box isn't showing up. In my experience, mixing Win32 stuff with OGL/DX is asking for trouble.

Check your code around yuor fprintf. I would suspect the error there is with something else, and not your OGL code. What are you printing out?

In all likelihood, you're already compiling using the Multithreaded DLL option (I don't think an SDL program will even compile without it).

Hope that helps,
--Brian


I am using windowed. It's really strange, because OpenGL and DirectX work greatly with Win32. Even 'normal' SDL does. But when I use SDL-OpenGL, things just stop working.
And yes, I use the correct SDL-projectsettings.

Quote:
Original post by graveyard filla
aren't you not supposed to touch any Win32 functions if your using SDL? i would bet that's why its not working. why do you even need to use it? SDL should handle everything for you..

plus, it un-cross-platformizes (lol) your code.


I know.. But it's for debugging purposes only. [wink]

Quote:
Original post by ImperfectFreak
By the way. . .SDL_opengl.h. . .what use

#include
#include
#include

(Only when I delete the code, it doesn't crash. It even crashes when commented out) that doesnt make any sense. . .


Yes, I tried both using just SDL_opengl.h (which compiles!!) AND the real OpenGL headers. The same result!!
And yes, it doesn't make sense. But it's true.

Quote:
Original post by Drew_Benton
I have had bugs such as these before. THe only solution I have is to create a Win32 console app, instead of a Win32 App, so you can use printf to help you track erros.


Yeah that's a working alternative. If I can't get this to work, I'll try it. Thanks!

Quote:
Original post by Kelly G
If you use printf in a win32 app with SDL, the output should automatically be directed to a text file which you can read when your program finishes.


I thought that was fprintf(), and I fear that it would work pretty much like fprintf() and crash.


Since it's part of a bigger project, I can't show you the code. (I haven't written much of SDL-OpenGL yet, just initializing)
I'll keep you updated!
Pipo DeClown
Pipo DeClown
Okay, I just found out that the MessageBox bug is when I use OpenGL in Debug or Release mode. The fprintf() bug is when I use Debug mode, although that used to work. I have no clue why it doesn't anymore.
Pipo DeClown
Pipo DeClown
I fixed the MessageBox() bug, by putting a:
while(SDL_PollEvent(&event));
.. right after SDL_SetVideoMode().

I guess the window needed some events, to complete it's construction, which was needed before MessageBox() could be called.

fprintf() is still open for anyone who knows why it crashes in Debug mode..

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.