58 lines
1.3 KiB
C
58 lines
1.3 KiB
C
#include <SDL2/SDL.h>
|
|
#include <SDL2/SDL_events.h>
|
|
#include <SDL2/SDL_pixels.h>
|
|
#include <SDL2/SDL_rect.h>
|
|
#include <SDL2/SDL_render.h>
|
|
#include <SDL2/SDL_surface.h>
|
|
#include <SDL2/SDL_video.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
int main()
|
|
{
|
|
|
|
SDL_Rect displayBounds;
|
|
displayBounds.w = 800;
|
|
displayBounds.h = 800;
|
|
SDL_Window *window = SDL_CreateWindow("titre test",
|
|
SDL_WINDOWPOS_CENTERED,
|
|
SDL_WINDOWPOS_CENTERED,
|
|
displayBounds.w, displayBounds.h,
|
|
SDL_WINDOW_SHOWN);
|
|
|
|
int running = 1;
|
|
SDL_Event event;
|
|
while (running)
|
|
{
|
|
while(SDL_PollEvent(&event))
|
|
{
|
|
if (event.type ==SDL_QUIT)
|
|
{
|
|
running = 0;
|
|
}
|
|
}
|
|
|
|
|
|
SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED);
|
|
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
|
|
SDL_RenderClear(renderer);
|
|
|
|
SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);
|
|
|
|
SDL_Rect rect;
|
|
rect.x = 100;
|
|
rect.y = 100;
|
|
rect.h = 100;
|
|
rect.w = 150;
|
|
SDL_RenderDrawRect(renderer, &rect);
|
|
rect.x = 300;
|
|
rect.y = 300;
|
|
SDL_RenderFillRect(renderer, &rect);
|
|
SDL_UpdateWindowSurface(window);
|
|
}
|
|
|
|
SDL_DestroyWindow(window);
|
|
SDL_Quit();
|
|
return 0;
|
|
}
|