|
|
|
@ -7,6 +7,7 @@
@@ -7,6 +7,7 @@
|
|
|
|
|
#include "vect.h" |
|
|
|
|
#include <SDL2/SDL_blendmode.h> |
|
|
|
|
#include <SDL2/SDL_gamecontroller.h> |
|
|
|
|
#include <SDL2/SDL_mutex.h> |
|
|
|
|
#include <SDL2/SDL_render.h> |
|
|
|
|
#include <SDL2/SDL_stdinc.h> |
|
|
|
|
#include <SDL2/SDL_thread.h> |
|
|
|
@ -22,6 +23,8 @@ Uint32 pixels[B_INTERNAL_HEIGHT][B_INTERNAL_WIDTH];
@@ -22,6 +23,8 @@ Uint32 pixels[B_INTERNAL_HEIGHT][B_INTERNAL_WIDTH];
|
|
|
|
|
struct object *scene_object; |
|
|
|
|
struct camera *camera; |
|
|
|
|
|
|
|
|
|
SDL_mutex *frame_mutex; |
|
|
|
|
|
|
|
|
|
struct SDL_Window* make_window(void) { |
|
|
|
|
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
|
|
|
|
|
printf("error initializing SDL: %s\n", SDL_GetError());
|
|
|
|
@ -96,7 +99,9 @@ int input_loop(void *ptr) {
@@ -96,7 +99,9 @@ int input_loop(void *ptr) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
SDL_Delay(50); |
|
|
|
|
SDL_LockMutex(frame_mutex); |
|
|
|
|
handle_inputs(); |
|
|
|
|
SDL_UnlockMutex(frame_mutex); |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
@ -161,6 +166,7 @@ int main(int argc, char **argv) {
@@ -161,6 +166,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
|
|
// use this to turn on antristroptic filtering
|
|
|
|
|
// SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
|
|
|
|
|
frame_mutex = SDL_CreateMutex(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
double elapsed; |
|
|
|
@ -179,6 +185,7 @@ int main(int argc, char **argv) {
@@ -179,6 +185,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
while (!exitnow) { |
|
|
|
|
/* clear the view */ |
|
|
|
|
start = SDL_GetPerformanceCounter(); |
|
|
|
|
SDL_LockMutex(frame_mutex); |
|
|
|
|
SDL_RenderClear(ren); |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < B_NUM_RAYMARCH_THREADS; i++) { |
|
|
|
@ -193,6 +200,7 @@ int main(int argc, char **argv) {
@@ -193,6 +200,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
SDL_WaitThread(threads[i], &status); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SDL_UnlockMutex(frame_mutex); |
|
|
|
|
SDL_UpdateTexture(texture, NULL, pixels, B_INTERNAL_WIDTH * sizeof(Uint32)); |
|
|
|
|
|
|
|
|
|
SDL_RenderCopy(ren, texture, NULL, NULL); |
|
|
|
|