weston的SDL_CreateWindow上没有窗口显示

问题描述

我有以下简单的代码可以打开SDL窗口:

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

#define WIDTH 800
#define HEIGHT 600

int main (int argc,char **argv)
{
    SDL_Window *window = NULL;
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
      fprintf(stderr,"SDL Failed to initialise: %s\n",SDL_GetError());
      return 1;
    }
    window = SDL_CreateWindow("SDL Example",SDL_WINDOWPOS_UNDEFINED,WIDTH,HEIGHT,0);
    printf("%s\n",SDL_GetError());
    SDL_Event e;
    unsigned int c = 0;
    while (1){
        while (SDL_PollEvent(&e)){
            if (e.type == SDL_QUIT){
                break;
            }
        }
    }
    /*return code */
    ...

我在Weston 8.0.0版上运行此程序,但没有显示任何窗口。不过,它可以在GNOME Wayland上正常运行。 SDL_GetError()不返回任何错误。 SDL2版本为2.0.12 知道为什么吗?

解决方法

我发现了。除非绘制了内容,否则它什么也不会显示,例如使用SDL_CreateRenderer。