Skip to main content

How to use SDL2 on URVEPi

sudo apt-get install -y libsdl2-dev build-essential nano
nano sdltest.c
#include <SDL2/SDL.h>

int main(int argc, char* argv[]) {
    SDL_Window* window = NULL;
    SDL_Renderer* renderer = NULL;

    SDL_Init(SDL_INIT_VIDEO);
    window = SDL_CreateWindow("Hello World", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 480, SDL_WINDOW_SHOWN);
    renderer = SDL_CreateRenderer(window, -1, 0);

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

    SDL_DestroyWindow(window);
    SDL_DestroyRenderer(renderer);
    SDL_Quit();

    return 0;
} 
gcc -o sdltest sdltest.c `sdl2-config --cflags --libs`
gcc -o sdltest sdltest.c -lSDL2 -lGLESv2
./program

SDL_VIDEO_GL_DRIVER=/usr/lib/aarch64-linux-gnu/libGL.so ./sdltest

Run: cmake -S . -B build && cmake --build build && cmake --install build

libsdl2-2.0-0

apt-get install libsdl2-dev