这个测试程序应该创建一个空白窗口,在你x-out-out之前保持打开状态。我从SDL的文档中复制了它以确保它是正确的。它可以找到here。
// Example program:
// Using SDL2 to create an application window
#include "SDL.h"
#include <stdio.h>
int main(int argc, char* argv[]) {
SDL_Window *window; // Declare a pointer
SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2
// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);
// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
//game loop, quitGame to quit
bool quitGame = false;
//var for checking events
SDL_Event event;
while(!quitGame) {
//Update particles
//Draw particles
//Check for events
while(SDL_PollEvent(&event)) {
if(event.type == SDL_QUIT)
quitGame = true;
}
}
// Close and destroy the window
SDL_DestroyWindow(window);
// Clean up
SDL_Quit();
return 0;
}
它不会创建一个窗口并立即终止,但不会出错。
我正在使用Eclipse,mingw32和SDL2的最新稳定版本。 SDL2的库和标头位于我的C盘中的文件中。我使用的是64位系统。我包含了SDL2头文件的整个文件夹。我链接的唯一库文件夹是SDL2文件夹的64位部分。我链接的库是HolyBlackCat建议的库(按此顺序)mingw32
,SDL2main
和SDL2
。任何帮助是极大的赞赏。谢谢!