découverte de SDL2
This commit is contained in:
parent
3bd50b2ab5
commit
f15aad0c2e
1
code/SDL2/.gitignore
vendored
Normal file
1
code/SDL2/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
strangebug
|
4
code/SDL2/Makefile
Normal file
4
code/SDL2/Makefile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
|
strangebug: strangebug.c Makefile
|
||||||
|
gcc -Wall $< -lSDL2 -o $@
|
11
code/SDL2/README.md
Normal file
11
code/SDL2/README.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Simple DirectMedia Layer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
The *[Simple DirectMedia Layer](https://libsdl.org/)
|
||||||
|
is a cross-platform development library designed
|
||||||
|
to provide low level access to audio, keyboard, mouse, joystick, and
|
||||||
|
graphics hardware via OpenGL/Direct3D/Metal/Vulkan.*
|
||||||
|
|
||||||
|
Paf, premier essai, [premier souci](strangebug.md) **:)**
|
||||||
|
|
40
code/SDL2/strangebug.c
Normal file
40
code/SDL2/strangebug.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Strange Bug ?
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
SDL_Window *win;
|
||||||
|
SDL_Renderer *rend;
|
||||||
|
int idx, idy;
|
||||||
|
|
||||||
|
if(SDL_CreateWindowAndRenderer(256, 256, SDL_WINDOW_SHOWN, &win, &rend))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Err SDL_CreateWindowAndRenderer : %s", SDL_GetError());
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
SDL_SetRenderDrawColor(rend, 255, 0, 0, 0);
|
||||||
|
SDL_RenderClear(rend);
|
||||||
|
SDL_RenderPresent(rend);
|
||||||
|
|
||||||
|
for (idx=0; idx<256; idx++) {
|
||||||
|
for (idy=0; idy<256; idy++) {
|
||||||
|
SDL_SetRenderDrawColor(rend, 127, idx, idy, 0);
|
||||||
|
SDL_RenderDrawPoint(rend, idx, idy);
|
||||||
|
}
|
||||||
|
SDL_RenderPresent(rend);
|
||||||
|
// SDL_Delay(50); /* Is the bug here ? */
|
||||||
|
}
|
||||||
|
SDL_RenderPresent(rend);
|
||||||
|
sleep(30);
|
||||||
|
|
||||||
|
SDL_DestroyRenderer(rend);
|
||||||
|
SDL_DestroyWindow(win);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
11
code/SDL2/strangebug.md
Normal file
11
code/SDL2/strangebug.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# `strangebug`, ou le bug étrange
|
||||||
|
|
||||||
|
Pour mes premiers pas dans la sdl, j'ai voulu faire un gradient de couleur
|
||||||
|
dans une petite fenêtre, quelque chose de vraiment simple, me diriez-vous,
|
||||||
|
mais qui cache une chose étrange...
|
||||||
|
|
||||||
|
Voici le [Code source](strangebug.c). Si vous décommentez la ligne
|
||||||
|
marquée, seul une colonne sur deux est correctement tracée...
|
||||||
|
|
||||||
|
*Please explain*.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user