• Advertisement

Archived

This topic is now archived and is closed to further replies.

SDL Help!

This topic is 5032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Confused

this:
int main(int argc,char** argv) {
SDL_Surface *video = NULL;
SDL_Init(SDL_INIT_VIDEO);
video = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE);
if (!video) {
SDL_Quit();
return 1;
}
SDL_Quit();
return 0;
}
Gives me mucho errors, but changed the last argument of SDL_SetVideoMode is soemthing like SDL_SWSURFACE | SDL_NOFRAME gives me like 3 lines of errors instead of about 50.
I really have no clue what I''m doing. I even noticed that the main function is redefined as SDL_main, which causes the compiler to spout that it can''t find main. So I define main before I include the SDL header and then do main again below it. This is probably my problem, don''t know why I didn''t tell y''all that before. If anyone knows why my programs mess up I would love to know so I can get into some fun programming.

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

Share this post


Link to post
Share on other sites
Sdl usually finds and replaces your main afaik.
It should look like that:
int main ( int argc, char* argv[] )  

Maybe that is the problem?

What did you add to the linker? I have to add -lSDLmain and -lSDL
Not sure how that works on a mac running os x though.

Can you post the new error messages?
And maybe add "----" above your signature?

[edited by - Clueless on May 10, 2004 4:15:05 PM]

Share this post


Link to post
Share on other sites
char** argv and char* argv[] are essentially the same.

And, judging from his error messages, there doesn''t seem to be any issues with included libraries or header files, since everything''s related to unreleased objects.

Frankly, you could just add SDL_Quit() before the return 0 in your original program and it should work fine.

Share this post


Link to post
Share on other sites
sadly,

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

does NOT work fine.

It generates the following errors:

2004-05-10 16:28:44.658 test[18558] *** _NSAutoreleaseNoPool(): Object 0x33dd00 of class NSCFString autoreleased with no pool in place - just leaking
2004-05-10 16:28:44.658 test[18558] *** _NSAutoreleaseNoPool(): Object 0x33dd30 of class NSException autoreleased with no pool in place - just leaking
2004-05-10 16:28:44.658 test[18558] *** Uncaught exception: Error (1002) creating CGSWindow

test has exited due to signal 5 (SIGTRAP).


Also, I still don''t know why SDL is not giving my compiler a main method of its own. If I remove my main method before the SDL include it doesn''t run, exiting due to an unknown symbol _main error.

Totally confused but still hopeful.

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

Share this post


Link to post
Share on other sites
Are you using XCode/Project Builder? It''s somehow including Cocoa stuff and running it. I kinda doubt that SDL makes Cocoa calls internally so I''d have to guess that either your SDL framework is screwed up or you started a Cocoa project (accidentally) ?

Share this post


Link to post
Share on other sites
Im using xcode and I start a standard tool project, then include the SDL framework. Like I mentioned above, the main method is screwed up and I use an override main method before the SDL header to make it even run as far as it does. I''m beginning to think the SDL framework IS screwed up. What version is the last one that worked with xcode? I downloaded the 1.2 version. I think it was 1.2, not sure.

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

Share this post


Link to post
Share on other sites
It sounds like you''re not including the right headers and/or libraries. Basically, the header renames your main() function to SDL_main() which is then called by the "real" main() in the library. You must link to both SDL and SDLmain libraries for it to work.

Share this post


Link to post
Share on other sites
What kind of library are we talking about? When I installed SDL, it put a .framework file in my ~/Library/Frameworks folder. I include that in my little test SDL program and include which, when I did the same thing with the glut framework includes the header from the library SDL. Is there another framework I need or am I missing something?

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

Share this post


Link to post
Share on other sites
Totally forgot about this post, but if anyone still cares, I found the problem!
Apparently the mac version of the sdl headers, when overwriting main, uses a lot of objective c calls, even some cocoa references to loading nibs and such. I was not running with the cocoa framework. I now have an app that runs under objective c using cocoa and the sdl libraries. I was wondering, is there any way to get around this and use c++ without cocoa, or am I stuck?

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

Share this post


Link to post
Share on other sites
Ask the SDL people, they have a mailing list with people who would know the answer to this question.

Share this post


Link to post
Share on other sites

  • Advertisement