1

我正在学习 SDL 并尝试设置一个红色背景的窗口。遵循此代码,但得到的结果与预期的不同。

#include <stdio.h>
#include "SDL2/SDL.h"

int main(int argc, char const *argv[]) {

    if(SDL_Init(SDL_INIT_EVERYTHING) != 0) {
        SDL_Log(SDL_GetError());
        return -1;
    }

    SDL_Window* wnd = SDL_CreateWindow("Test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 300, 300, SDL_WINDOW_OPENGL);
    SDL_Renderer* renderer = SDL_CreateRenderer(wnd, 0, SDL_RENDERER_ACCELERATED);

    SDL_SetRenderDrawColor(renderer, 255, 255, 255 , 255);
    SDL_RenderClear(renderer);
    SDL_RenderPresent(renderer);

    SDL_Delay(6000);

    SDL_Quit();
    return 0;
}

透明窗口

4

1 回答 1

1

通过 // 循环而不是大的 'ole main-thread-blocking 处理SDL_WaitEvent()OS事件队列SDL_PollEvent()SDL_PumpEvents()SDL_Delay()

于 2018-09-06T15:42:11.357 回答