2

此测试程序应创建一个空白窗口,该窗口会一直保持打开状态,直到您修改完毕。我从 SDL 的文档中复制了它以确保它是正确的。可以在这里找到。

// 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、、SDL2mainSDL2。任何帮助是极大的赞赏。谢谢!

4

0 回答 0