SDL Help!

Started by
18 comments, last by Venerable Vampire 19 years, 11 months ago
I just got SDL installed on my mac running os x and i''ve been playing around looking up how to get pretty pictures on the screen. I have a full screen window, but I can''t seem to get a windowed window to work, it pumps a bunch of stuff the terminal and dies. Also, events seem to not want to work. Am I missing some initialization steps here? Could someone post VERY simple working source code? Thanks in advance. Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Advertisement
Thats just too bad. That is what you get for not using windows.............*evil nerdy laugh*.......Mwahahahaha!!!

Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.
Jehovah is viewed by Gnostics as fundamentally evil, jealous, rigid, lacking in compassion and prone to genocide.
Care to elaborate on what gets posted on the terminal? Maybe it holds an answer to what you''re doing wrong, and seeing as we''re not mind-readers, it''s hard to tell what could''ve gone wrong.

But yes, there''s a tiny bit of initialization that must be done. Wether you''ve done it right or not is hard to tell. Do you have some source you can post for us to have a look at?
The console has this posted to it

2004-05-09 17:58:12.217 test[17578] *** _NSAutoreleaseNoPool(): Object 0x301470 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.217 test[17578] *** _NSAutoreleaseNoPool(): Object 0x302920 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.217 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cc10 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.217 test[17578] *** _NSAutoreleaseNoPool(): Object 0x3014d0 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.218 test[17578] *** _NSAutoreleaseNoPool(): Object 0x302a60 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.218 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cc70 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.218 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cc90 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.218 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33ccb0 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.218 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cd00 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.218 test[17578] *** _NSAutoreleaseNoPool(): Object 0x3021a0 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.219 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cd20 of class NSPathStore2 autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.219 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cd80 of class NSPathStore2 autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.219 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cdb0 of class NSPathStore2 autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.219 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33ce80 of class NSPathStore2 autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.219 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cec0 of class NSCFDictionary autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.220 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cf80 of class NSIdEnumerator autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.220 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce8c4 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.220 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33cfe0 of class NSCFArray autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.220 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce8d4 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.221 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce924 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.221 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce8a4 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.221 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce864 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.221 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce8f4 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.221 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce884 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.222 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dce854 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.222 test[17578] *** _NSAutoreleaseNoPool(): Object 0x30eda0 of class NSCFNumber autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.224 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33e280 of class NSCFData autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.229 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dcb070 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.231 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33ecc0 of class _NSCachedBitmapImageRep autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.232 test[17578] *** _NSAutoreleaseNoPool(): Object 0x329a00 of class NSImage autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.233 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33f5b0 of class _NSCachedBitmapImageRep autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.233 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33f490 of class NSImage autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.233 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33bff0 of class _NSThemeCloseWidget autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.234 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dcb070 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.234 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33fbd0 of class _NSCachedBitmapImageRep autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.234 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33fa20 of class NSImage autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.235 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33fa70 of class _NSCachedBitmapImageRep autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.235 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33fc60 of class NSImage autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.235 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33f7a0 of class _NSThemeWidget autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.235 test[17578] *** _NSAutoreleaseNoPool(): Object 0xa2dcb070 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.236 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33ebb0 of class _NSCachedBitmapImageRep autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.236 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33c0c0 of class NSImage autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.236 test[17578] *** _NSAutoreleaseNoPool(): Object 0x32aa20 of class _NSCachedBitmapImageRep autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.236 test[17578] *** _NSAutoreleaseNoPool(): Object 0x32c130 of class NSImage autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.236 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33ff40 of class _NSThemeWidget autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.238 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33f8c0 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.238 test[17578] *** _NSAutoreleaseNoPool(): Object 0x33adc0 of class NSException autoreleased with no pool in place - just leaking
2004-05-09 17:58:12.238 test[17578] *** Uncaught exception: Error (1002) creating CGSWindow


My code is

int main(int argc,char** argv) {
SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
SDL_Surface *video = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
return 0;
}

Life would be so much easier if we could just get the source code.

[edited by - Venerable Vampire on May 9, 2004 6:05:46 PM]
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Well, I don''t code on a Mac, but it looks to me from your source as though you never deinitialize.

You need to release the surface and then kill SDL (SDL_Quit). You REALLY, REALLY, REALLY should NOT do what you''re doing with the surface for safety reasons, because if it fails to initialize video you have no way of knowing and it''ll crash when you try to free the surface. Instead, try this.
SDL_Surface *video = NULL;(your code...)video = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);if(!video){  //something went wrong  SDL_Quit();  return 1;}(your code...)if(video) SDL_FreeSurface(video); video = NULL;SDL_Quit(); 
OK, I tried what you suggested, RuneLancer, but I get the same thing. I had a peice of code looking like this:

int main(int argc,char** argv) {
SDL_Surface *video = NULL;
video = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
printf("%i\n",!video);
if (!video) {
SDL_Quit();
return 1;
}
if (video) {
SDL_FreeSurface(video);
video = NULL;
}
SDL_Quit();
return 0;
}

The thing is, the program crashes and floods my terminal *before* reaching the printf. That printf never gets executed! So the actual setting up of the surface crashes it. Please, anyone with similar problems help!

Life would be so much easier if we could just get the source code.
--------------------------------------------------------Life would be so much easier if we could just get the source code.
Isn''t SDL_Init missing?

SDL_Init( SDL_INIT_VIDEO ); 
Writing errors since 10/25/2003 2:25:56 AM
Well, y''know, I wasn''t giving you the source code, just showing you how to manage a surface.

Notice: there is no SDL_Init in there.
Those are all Cocoa errors, which is a little weird. If your SDL program is correct, I'd guess your SDL install isn't.

Edit: Also, don't call SDL_FreeSurface on the video surface. SDL_Quit does that for you.

[edited by - bobstevens on May 10, 2004 9:48:19 AM]
quote:Original post by bobstevens
Edit: Also, don''t call SDL_FreeSurface on the video surface. SDL_Quit does that for you.


My bad, that''s right. The video surface is freed automatically when SDL_Quit is called. I mixed it up with an offscreen buffer I was using in the program I copied that code from.

This topic is closed to new replies.

Advertisement