I've only done a few modification to the code:
- replace "SDL.h" by <SDL2/SDL.h>
- replace struct context{}; by typedef struct context{}context;
As you can see, instead of clearing the window the renderer of the "Hello World" SDL Window does nothing. And all we see it everything that is behind the SDL Window. I moved the SDL "Hello World" window before taking the screenshot. That's why things look like they are out of place.
Here is the code for the simple SDL Hello World app:
Code: Select all
#include <SDL2/SDL.h>
int main(int argc, char *argv[]) {
SDL_Window *win = NULL;
SDL_Renderer *renderer = NULL;
int posX = 100, posY = 100, width = 640, height = 480;
SDL_Init(SDL_INIT_VIDEO);
win = SDL_CreateWindow("Hello World", posX, posY, width, height, 0);
renderer = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED);
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
while (1) {
SDL_Event e;
if (SDL_PollEvent(&e)) {
if (e.type == SDL_QUIT) {
break;
}
}
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
}
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(win);
SDL_Quit();
return 0;
}
Also note that I am running everything on the Kano OS (some kind of fork of the Raspbian OS from Kano ) on a Raspberry Pi 3.
Thanks in advance!