my code :
#include <stdio.h>
#include "SDL.h"
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) != 0)
{
printf("Error: %s\n", SDL_GetError());
return -1;
}
SDL_Window *window = SDL_CreateWindow("My",
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
640, 480, SDL_WINDOW_SHOWN);
if (!window)
{
printf("Error: %s\n", SDL_GetError());
return -1;
}
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, 0); // 创建渲染器
if (renderer == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_RENDER, "Couldn't create renderer: %s", SDL_GetError());
return 1;
}
//Set colour of renderer
SDL_SetRenderDrawColor( renderer, 255, 0, 0, 255 );
//Clear the screen to the set colour
SDL_RenderClear( renderer );
//Show all the has been done behind the scenes
SDL_RenderPresent( renderer );
SDL_Delay(10000);
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}
My program has been successfully compiled, but i can not see any window in Ubuntu 22.04 when i run, There are no errors, who can tell me why ?