TetaTricks/code/SDL2/strangebug.c

47 lines
876 B
C
Raw Permalink Normal View History

2024-09-08 00:36:26 +11:00
/*
* Strange Bug ?
2024-09-10 21:01:00 +11:00
*
* gcc -Wall strangebug.c -lSDL2 -o strangebug
*
2024-09-08 00:36:26 +11:00
*/
#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;
2024-09-10 21:01:00 +11:00
int foo, idx, idy;
2024-09-08 00:36:26 +11:00
2024-09-10 21:01:00 +11:00
foo = SDL_CreateWindowAndRenderer(256, 256,
SDL_WINDOW_SHOWN, &win, &rend);
if (foo) {
fprintf(stderr,
"Err %d CreateWindowAndRenderer : %s",
foo, SDL_GetError());
2024-09-08 00:36:26 +11:00
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++) {
2024-09-10 21:01:00 +11:00
SDL_SetRenderDrawColor(rend,
127, idx, idy, 0);
2024-09-08 00:36:26 +11:00
SDL_RenderDrawPoint(rend, idx, idy);
}
SDL_RenderPresent(rend);
2024-09-10 21:01:00 +11:00
// SDL_Delay(50); /* Is the bug here ? */
2024-09-08 00:36:26 +11:00
}
SDL_RenderPresent(rend);
sleep(30);
SDL_DestroyRenderer(rend);
SDL_DestroyWindow(win);
return 0;
}