私は自分のC++ゲームをOS Xに移植しました。初めて実行したときには、SDL_SetVideoMode
を呼び出すときに次の例外が発生します。Mac OS X 10.8でSDL Video Initが例外を引き起こします
2012年9月28日15:01:05.437 SCRAsteroids [28595:707] *キャッチされない例外により 'NSInternalInconsistencyException'、理由にアプリを終了: 'エラー(1000)ライン259上CGSWindowを作成する' *まず投げますコールスタック: ( 0 CoreFoundationの0x00007fff8b53b716 __exceptionPreprocess + 198 1 libobjc.A.dylib 0x00007fff90e30470 objc_exception_throw + 43 2 CoreFoundationの0x00007fff8b53b4ec + [NSExceptionレイズ:フォーマット:] + 204 3のAppKit 0x00007fff8a26a579 _NSCreateWindowWithOpaqueShape2 + 655 4のAppKit 0x00007fff8a268d70 - [ NSWindow _commonAwake] + 2002 5のAppKit 0x00007fff8a2277e2 - [NSWindowの_commonInitFrame:styleMask:バッキング:延期:] + 1763 6のAppKitの0x00007fff8a22692f - [NSWindowの_initContent:styleMask:バッキング:延期:contentView:] + 1568 7のAppKitの0x00007fff8a2262ff - [NSWindowのinitWithContentRect:styleMask:バッキング:延期:] + 45 8 libSDL-1.2.0.dylib 0x0000000107c228f6 - [SDL_QuartzWindow initWithContentRect:styleMask:バッキング:延期:] + 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:例外 中止トラップを投げると呼ば終了:6
私の初期化コードは次のようになります。
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);
それはその最後のSDLの呼び出しに取得し、上記の例外がスローされます。私はフルスクリーンとサイズ変更可能なウィンドウモードの両方で同じことを試みました。
Xcodeを使用するのではなく、コマンドラインで自分のアプリの古い学校をビルドします。
は、あなたのメインのファイルがSDL.hが含まれています、あなたのメインの方法で最初にそれを呼び出す必要がありますか?もしそうなら、main()の名前が変更されています! – ScrollerBlaster