Ho appena portato il mio gioco C++ su OS X e la prima volta che viene eseguito ottengo la seguente eccezione quando provo a chiamare SDL_SetVideoMode
.SDL Video Init causa Eccezioni su Mac OS X 10.8
2012/09/28 15: 01: 05,437 SCRAsteroids [28595: 707] * di terminazione app a causa di eccezione non identificata 'NSInternalInconsistencyException', la ragione: 'Errore (1000) creando CGSWindow on line 259' * primo tiro stack di chiamate: ( 0 CoreFoundation 0x00007fff8b53b716 __exceptionPreprocess + 198 1 libobjc.A.dylib 0x00007fff90e30470 objc_exception_throw + 43 2 CoreFoundation 0x00007fff8b53b4ec + [NSException raise formato:] + 204 3 AppKit 0x00007fff8a26a579 _NSCreateWindowWithOpaqueShape2 + 655 4 AppKit 0x00007fff8a268d70 - [ NSWindow _commonAwake] + 2002 5 AppKit 0x00007fff8a2277e2 - [NSWindow _commonInitFrame: styleMask: supporto: rinviare:] + 1.763 6 AppKit 0x00007fff8a22692f - [NSWindow _initContent: styleMask: supporto: rinviare: contentView:] + 1.568 7 AppKit 0x00007fff8a2262ff - [NSWindow initWithContentRect: styleMask: supporto : Defer:] + 45 8 libSDL-1.2.0.dylib 0x0000000107c228f6 - [SDL_QuartzWindow initWithContentRect: styleMask: supporto: Defer:] + 294 9 libSDL-1.2.0.dylib 0x0000000107c20505 QZ_SetVideoMode + 2837 10 libSDL-1.2.0 .dylib 0x0000000107c17af5 SDL_SetVideoMode + 917 11 SCRAsteroids 0x0000000107be60fb _ZN11SDLGraphics4initEP6IWorldii + 291 ) libC++ abi.dylib: terminare chiamato un'eccezione trappola Abort: 6
Il mio codice di inizializzazione è simile al seguente:
if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
return false;
const SDL_VideoInfo *videoInfo = SDL_GetVideoInfo();
if (!videoInfo) {
fprintf(stderr, "Video query failed: %s\n",
SDL_GetError());
return false;
}
/* the flags to pass to SDL_SetVideoMode */
videoFlags = SDL_OPENGL; /* Enable OpenGL in SDL */
videoFlags |= SDL_GL_DOUBLEBUFFER; /* Enable double buffering */
videoFlags |= SDL_HWPALETTE; /* Store the palette in hardware */
/* This checks to see if surfaces can be stored in memory */
if (videoInfo->hw_available)
videoFlags |= SDL_HWSURFACE;
else
videoFlags |= SDL_SWSURFACE;
if (w == 0) {
widthViewport = videoInfo->current_w;
heightViewport = videoInfo->current_h;
cout << "Will use full screen resolution of ";
videoFlags |= SDL_FULLSCREEN;
} else {
cout << "Will use full user supplied resolution of ";
widthViewport = w;
heightViewport = h;
videoFlags |= SDL_RESIZABLE; /* Enable window resizing */
}
cout << widthViewport << "x" << heightViewport << "\n";
/* This checks if hardware blits can be done */
if (videoInfo->blit_hw)
videoFlags |= SDL_HWACCEL;
/* Sets up OpenGL double buffering */
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
/* get a SDL surface */
surface = SDL_SetVideoMode(widthViewport, heightViewport,
SCREEN_BPP, videoFlags);
Si ottiene in quella ultima chiamata SDL e genera l'eccezione di cui sopra. L'ho provato sia a schermo intero che in modalità finestra ridimensionabile, stessa cosa.
Costruisco la mia app vecchia scuola, sulla riga di comando, anziché utilizzare Xcode.
Il vostro file principale includono SDL.h? In tal caso, il tuo main() viene rinominato per te! – ScrollerBlaster