Graphics with SDL - they won't work

Hi list

I’m trying to use the SDL graphics on my powerBook G4, with MacOSX (10.2.8).
Initialization goes fine, and I can test to make sure a certain video mode is
okay. When I run the SDL_SetVideoMode() everything comes crashin’ down, and I
get a nasty error, that you probably know:

2004-05-18 23:04:21.474 Skvulp[4986] _initWithWindowNumber: error creating
graphics ctxt object for ctxt:0, window:-1
kCGErrorFailure : CGContextResetClip: invalid context
kCGErrorFailure : CGContextReplaceTopGState: invalid context
[…]

That’s for trying the SDL_HWSURFACE and SWSURFACE. with SDL_FULLSCREEN i simply
get:

Fatal signal: Bus Error (SDL Parachute Deployed)

I should mention, that I use what I strongly believe is a hack… Right before
my main function, I go #undef main…

Hope you can help me, and huge thanks in advance!

  • Andreas

Hi there,

I’m trying to use the SDL graphics on my powerBook G4, with MacOSX (10.2.8).

I should mention, that I use what I strongly believe is a hack… Right before
my main function, I go #undef main…

Um, can you give us the reason for this hack? If I understand correctly,
it should be a miracle that you can even link your program. I’m no OS X
programmer, so I haven’t been following the relevant postings, but I’m
pretty sure that’s not good under any operating system…

Bye,
Ben

I actually do the same thing. I’m not sure how to get the system to figure out which main to use otherwise (VC++). If I don’t remove the define (or don’t undefine), I get linker errors no matter what I do (it seems). When I do remove it I easily link and start from the main I want to. I was really confused about the purpose of that define.
I’m not sure if it’s a console or win32 project. I know win32 is what you’re supposed to use but naturally console is preferable (I like consoles).> I should mention, that I use what I strongly believe is a hack… Right before
> my main function, I go #undef main…

>Um, can you give us the reason for this hack? If I understand correctly, 
>it should be a miracle that you can even link your program. I'm no OS X 
>programmer, so I haven't been following the relevant postings, but I'm 
>pretty sure that's not good under any operating system... 

>Bye, 
>   Ben 

_

-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Type: application/ms-tnef
Size: 4458 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040519/5d24e96f/attachment.bin

Hey Brian, do you declare your main like this?

int main(int argc,char **argv)

if not i bet that’s the problem, could be the problem for the OS X guy too.> ----- Original Message -----

From: bjc9019@rit.edu (Brian Cody)
To: "A list for developers using the SDL library. (includes SDL-announce)"

Sent: Wednesday, May 19, 2004 8:17 AM
Subject: RE: [SDL] Graphics with SDL - they won’t work

I actually do the same thing. I’m not sure how to get the system to
figure out which main to use otherwise (VC++). If I don’t remove the define
(or don’t undefine), I get linker errors no matter what I do (it seems).
When I do remove it I easily link and start from the main I want to. I was
really confused about the purpose of that define.
I’m not sure if it’s a console or win32 project. I know win32 is what
you’re supposed to use but naturally console is preferable (I like
consoles).

I should mention, that I use what I strongly believe is a hack… Right
before

my main function, I go #undef main…

Um, can you give us the reason for this hack? If I understand correctly,
it should be a miracle that you can even link your program. I’m no OS X
programmer, so I haven’t been following the relevant postings, but I’m
pretty sure that’s not good under any operating system…

Bye,
Ben

_




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

Hi,

I should mention, that I use what I strongly believe is a hack… Right before
my main function, I go #undef main…

Um, can you give us the reason for this hack? If I understand correctly,
it should be a miracle that you can even link your program. I’m no OS X
programmer, so I haven’t been following the relevant postings, but I’m
pretty sure that’s not good under any operating system…

I actually do the same thing. I’m not sure how to get the system to figure out which main to use otherwise (VC++). If I don’t remove the define (or don’t undefine), I get linker errors no matter what I do (it seems). When I do remove it I easily link and start from the main I want to. I was really confused about the purpose of that define.
I’m not sure if it’s a console or win32 project. I know win32 is what you’re supposed to use but naturally console is preferable (I like consoles).

Well, if there were two mains, your program wouldn’t link, at least not
with any sane linker. If I understand correctly, SDL includes an actual
main symbol or equivalent. This does some OS-specific initialization,
and then calls the “SDL_main” function. If you leave the “#define main
SDL_main” macro alone, your main function automatically becomes the
SDL_main function, effectively wrapping the OS-dependent main around
your now platform-independent main.

Under Windows, for example, non-console applications have this whole
WinMain entry point thing. I mainly program under Linux or MinGW, so I’m
not so familiar with the Windows API. So if you generate a "console"
project, I presume, the entry point of your program becomes a nice
POSIX-compliant (I guess) main() function. Unfortunately, due to the
#define, there is none (SDL should provide WinMain), so the linker
should rightfully complain.

If you switch to a win32-type project, WinMain is now the entry point,
and since SDL provides it, the linker is happy, and your code (as it is)
should still compile fine on all SDL-supported platforms.

I’m very sure the MacOS X version of SDL has exactly the same mechanism,
which might cause the aforementioned errors. If you can’t get it to
link without the #undef, I’d guess you’re missing the library that
provides the main symbol or its equivalent. But probably a Mac
programmer will know more.

Hope this helps,

Ben

Under Windows, for example, non-console applications have this whole
WinMain entry point thing. I mainly program under Linux or MinGW, so
I’m not so familiar with the Windows API.

WinMain is freakin’ EVIL! I started programming on a mac several years
ago, and when I switched to windows ('cause they make more games sooner
for windows), I was haunted by the prospect of the WinMain function!
Thanks to SDL, I don’t need to WORRY about windows being stupid like
that! (It takes about 20-60 lines of code through WinMain to do what
SDL and its affiliates do in about 2 lines. They’re just wrapping the
WinMain, but still, it’s MUCH more natural to use SDL. Thanks again!)

–Scott

PS: Sorry for the OT tangent. I just NEEDED to voice my disgust at
WinMain.