C, SDL2 on Linux
/* rectangle-sdl - Draw a yellow rectangle. */
/* main.cpp /
/* Released into the Public Domain on Mar 17 2018 by Tilman Kranz . */
#include <SDL2/SDL.h>
#include <stdio.h>
#include <stdlib.h>
void doWait() {
SDL_Event event;
while(1) {
while(SDL_WaitEvent(&event)){
switch(event.type){
case SDL_KEYDOWN:
return;
default:
break;
}
}
fprintf(stderr, "ERROR: SDL_WaitEvent(): %s\n", SDL_GetError());
}
}
int main (int argc, char** argv) {
int rv;
SDL_Window* window = NULL;
window = SDL_CreateWindow("A Yellow Rectangle", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN);
rv = SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
if(rv!=0) {
fprintf(stderr, "ERROR: SDL_SetWindowFullscreen(): %s\n", SDL_GetError());
exit(1);
}
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
SDL_RenderClear(renderer);
SDL_Rect r = {10, 20, 100, 75};
SDL_SetRenderDrawColor(renderer, 255, 255, 0, 255);
SDL_RenderFillRect(renderer, &r);
SDL_RenderPresent(renderer);
doWait();
SDL_DestroyWindow(window);
SDL_Quit();
return 0;
}