IDE:代码::块编译器:MinGW
我正确安装了 SDL 和 SDL_image(它在构建时不会出现任何错误)。一切都编译得很好,但是当我运行它时,SDL 窗口出现了,但图像从不闪烁,窗口。我使用 SDL_image 所以我可以加载 PNG 图像(或者我希望如此)。
编码:
#include <cstdlib>
#include <iostream>
#include "SDL_image.h"
#include <SDL/SDL.h>
int main ( int argc, char** argv )
{
SDL_Surface* test = NULL;
SDL_Surface* screen = NULL;
//Start SDL
SDL_Init( SDL_INIT_EVERYTHING );
//Name the window
SDL_WM_SetCaption( "Test-1", NULL );
//Set up screen
screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );
//Load image
test = IMG_Load("Test.png");
//Apply image to screen
SDL_BlitSurface( test, NULL, screen, NULL );
//Update Screen
SDL_Flip( screen );
//Pause
SDL_Delay( 2000 );
//Free the loaded image
SDL_FreeSurface( test );
//Quit SDL
SDL_Quit();
return 0;
}