我有一个我在xcode中制作的SDL应用程序。
int main( int argc, char* args[] )
{
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//The images
SDL_Surface* hello = NULL;
SDL_Window* screen = NULL;
SDL_Renderer *sdlRenderer = NULL;
//Set up screen
screen = SDL_CreateWindow("My Game Window",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
640, 480,
SDL_WINDOW_OPENGL);
//Create Renderer
sdlRenderer = SDL_CreateRenderer(screen, -1, 0);
//Load image
hello = SDL_LoadBMP( "hello.bmp" );
//Create texture from the surface
SDL_Texture* hello_texture = SDL_CreateTextureFromSurface(sdlRenderer, hello);
//copy texture to the renderer's buffer.
SDL_RenderCopy(sdlRenderer, hello_texture, NULL, NULL);
//Update Screen
SDL_RenderPresent(sdlRenderer);
//Pause
SDL_Delay( 5000 );
//Quit SDL
SDL_Quit();
return 0;
}
所以一切都很好,但没有图像出现。调试后,我发现load_bmp返回null。所以我试图通过这个找出正确的文件路径:
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyBundleURL(mainBundle);
CFStringRef str = CFURLCopyFileSystemPath( resourcesURL, kCFURLPOSIXPathStyle );
resourcesURL = CFBundleCopyResourceURL(
mainBundle,
CFSTR("hello.bmp"),
NULL,
NULL
);
但是这也没有给我任何东西所以好像好像hello.bmp没有被正确地复制到捆绑包中?有没有其他人遇到这个而没有什么需要做的?