merged?
This commit is contained in:
commit
0625a9c825
24 changed files with 174 additions and 106 deletions
|
|
@ -18,15 +18,11 @@
|
|||
#include "arc/graphics/sdl/renderer.h"
|
||||
#include "arc/input/sdl/mouse.h"
|
||||
#include "arc/input/sdl/keyboard.h"
|
||||
#ifdef ARC_SDL
|
||||
#elif ARC_OPENGL
|
||||
#include "arc/graphics/opengl/window.h"
|
||||
#include "arc/graphics/opengl/renderer.h"
|
||||
#ifdef ARC_GLFW
|
||||
|
||||
#include "arc/graphics/glfw/window.h"
|
||||
#include "arc/graphics/glfw/renderer.h"
|
||||
#include "arc/input/glfw/mouse.h"
|
||||
#include "arc/input/glfw/keyboard.h"
|
||||
#endif // ARC_GLFW
|
||||
#endif
|
||||
|
||||
void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanfn, ARC_Point windowSize){
|
||||
*data = (ARC_EngineData *)malloc(sizeof(ARC_EngineData));
|
||||
|
|
@ -44,14 +40,14 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
(*data)->windowSize = windowSize;
|
||||
//TEMP
|
||||
#ifdef ARC_SDL
|
||||
TTF_Init();
|
||||
Mix_Init(0);
|
||||
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
|
||||
// TTF_Init();
|
||||
// Mix_Init(0);
|
||||
// Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
|
||||
#endif
|
||||
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_WINDOW
|
||||
windowInfo = (ARC_WindowInfo){ "title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (*data)->windowSize.x, (*data)->windowSize.y, 0 };
|
||||
#elif ARC_GLFW
|
||||
#elif ARC_GLFW_WINDOW
|
||||
windowInfo = (ARC_WindowInfo){ "title", (*data)->windowSize.x, (*data)->windowSize.y };
|
||||
#endif // ARC_SDL
|
||||
|
||||
|
|
@ -61,9 +57,9 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_WINDOW
|
||||
renderInfo = (ARC_RenderInfo){ (SDL_Window *)(*data)->window, -1, SDL_RENDERER_ACCELERATED };
|
||||
#elif ARC_GLFW
|
||||
#elif ARC_GLFW_WINDOW
|
||||
renderInfo = (ARC_RenderInfo){ (GLFWwindow *)(*data)->window };
|
||||
#endif // ARC_SDL
|
||||
|
||||
|
|
@ -73,7 +69,7 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
free(data);
|
||||
}
|
||||
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_INPUT
|
||||
SDL_Event *event = (SDL_Event *)malloc(sizeof(SDL_Event));
|
||||
mouseInfo = (ARC_MouseInfo ){ event };
|
||||
keyboardInfo = (ARC_KeyboardInfo){ event };
|
||||
|
|
@ -87,10 +83,10 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
}
|
||||
|
||||
void ARC_EngineData_Destroy(ARC_EngineData *data){
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_INPUT
|
||||
free(data->mouse->event);
|
||||
TTF_Quit();
|
||||
Mix_Quit();
|
||||
// TTF_Quit();
|
||||
// Mix_Quit();
|
||||
#endif // ARC_SDL
|
||||
|
||||
ARC_Mouse_Destroy(data->mouse);
|
||||
|
|
@ -105,8 +101,7 @@ void ARC_Engine_Run(ARC_EngineData *data){
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef ARC_SDL
|
||||
|
||||
#ifdef ARC_SDL2_INPUT
|
||||
SDL_Event *event = data->mouse->event;
|
||||
double lastTime = 0, currentTime;
|
||||
data->dt = 0;
|
||||
|
|
@ -115,14 +110,14 @@ void ARC_Engine_Run(ARC_EngineData *data){
|
|||
data->running = 0;
|
||||
|
||||
while(!data->running){
|
||||
#ifdef ARC_SDL
|
||||
#ifdef ARC_SDL2_INPUT
|
||||
currentTime = SDL_GetTicks();
|
||||
data->dt = currentTime - lastTime;
|
||||
lastTime = currentTime;
|
||||
|
||||
SDL_PollEvent(data->mouse->event);
|
||||
if(event->type == SDL_QUIT){ data->running = 1; }
|
||||
#elif ARC_GLFW
|
||||
#elif ARC_GLFW_WINDOW
|
||||
glfwPollEvents();
|
||||
data->running = glfwWindowShouldClose((GLFWwindow *)data->window);
|
||||
#endif // ARC_SDL
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue