|
|
@ -1,5 +1,8 @@ |
|
|
|
#include "main.h" |
|
|
|
#include "main.h" |
|
|
|
#include "queue.h" |
|
|
|
#include "queue.h" |
|
|
|
|
|
|
|
#include <SDL2/SDL_render.h> |
|
|
|
|
|
|
|
#include <SDL2/SDL_stdinc.h> |
|
|
|
|
|
|
|
#include <SDL2/SDL_timer.h> |
|
|
|
|
|
|
|
|
|
|
|
int keyboardstate[322] = {}; // 322 is the number of SDLK_DOWN events
|
|
|
|
int keyboardstate[322] = {}; // 322 is the number of SDLK_DOWN events
|
|
|
|
int exitnow = 0; |
|
|
|
int exitnow = 0; |
|
|
@ -64,7 +67,7 @@ leave: |
|
|
|
int main(int argc, char **argv) { |
|
|
|
int main(int argc, char **argv) { |
|
|
|
|
|
|
|
|
|
|
|
SDL_Window * win = make_window(); |
|
|
|
SDL_Window * win = make_window(); |
|
|
|
ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED); |
|
|
|
ren = SDL_CreateRenderer(win, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); |
|
|
|
SDL_RenderSetLogicalSize(ren, B_INTERNAL_HEIGHT, B_INTERNAL_HEIGHT); |
|
|
|
SDL_RenderSetLogicalSize(ren, B_INTERNAL_HEIGHT, B_INTERNAL_HEIGHT); |
|
|
|
|
|
|
|
|
|
|
|
SDL_Rect r; |
|
|
|
SDL_Rect r; |
|
|
@ -75,9 +78,12 @@ int main(int argc, char **argv) { |
|
|
|
|
|
|
|
|
|
|
|
SDL_Thread *input_thread = SDL_CreateThread(input_loop, "input", (void *)NULL); |
|
|
|
SDL_Thread *input_thread = SDL_CreateThread(input_loop, "input", (void *)NULL); |
|
|
|
struct colour c = get_random_color(); |
|
|
|
struct colour c = get_random_color(); |
|
|
|
|
|
|
|
double elapsed; |
|
|
|
|
|
|
|
Uint64 start, end; |
|
|
|
|
|
|
|
|
|
|
|
while (!exitnow) { |
|
|
|
while (!exitnow) { |
|
|
|
/* clear the view */ |
|
|
|
/* clear the view */ |
|
|
|
|
|
|
|
start = SDL_GetPerformanceCounter(); |
|
|
|
SDL_SetRenderDrawColor(ren, 0, 0, 0, 255); |
|
|
|
SDL_SetRenderDrawColor(ren, 0, 0, 0, 255); |
|
|
|
SDL_RenderClear(ren); |
|
|
|
SDL_RenderClear(ren); |
|
|
|
|
|
|
|
|
|
|
@ -90,8 +96,16 @@ int main(int argc, char **argv) { |
|
|
|
SDL_SetRenderDrawColor(ren, c.r, c.g, c.b, c.a); |
|
|
|
SDL_SetRenderDrawColor(ren, c.r, c.g, c.b, c.a); |
|
|
|
SDL_RenderFillRect(ren, &r); |
|
|
|
SDL_RenderFillRect(ren, &r); |
|
|
|
|
|
|
|
|
|
|
|
/* update the view */ |
|
|
|
|
|
|
|
SDL_RenderPresent(ren); |
|
|
|
SDL_RenderPresent(ren); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
end = SDL_GetPerformanceCounter(); |
|
|
|
|
|
|
|
double el = (1000 * (end - start) / SDL_GetPerformanceFrequency()); |
|
|
|
|
|
|
|
if (el > 0) { |
|
|
|
|
|
|
|
elapsed = 1000 / el; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
printf("framerate: %f\r", elapsed); |
|
|
|
|
|
|
|
fflush(stdout); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
SDL_Quit(); |
|
|
|
SDL_Quit(); |
|
|
|