opengl added to engine
This commit is contained in:
parent
d8378484a7
commit
706a519452
31 changed files with 490 additions and 68 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#include "arc/engine/engine.h"
|
||||
#include <SDL_video.h>
|
||||
#include <stdlib.h>
|
||||
#include "arc/engine/state.h"
|
||||
#include "arc/graphics/window.h"
|
||||
|
|
@ -12,11 +11,19 @@
|
|||
//NOTE: some of this file is temporary, mostly to get smthn running so I can test out different ideas
|
||||
#ifdef ARC_SDL
|
||||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
#include "arc/graphics/sdl/window.h"
|
||||
#include "arc/graphics/sdl/renderer.h"
|
||||
#include "arc/input/sdl/mouse.h"
|
||||
#include "arc/input/sdl/keyboard.h"
|
||||
#endif // ARC_SDL
|
||||
#elif ARC_OPENGL
|
||||
#include "arc/graphics/opengl/window.h"
|
||||
#include "arc/graphics/opengl/renderer.h"
|
||||
#ifdef ARC_GLFW
|
||||
#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));
|
||||
|
|
@ -35,6 +42,8 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
|
||||
#ifdef ARC_SDL
|
||||
windowInfo = (ARC_WindowInfo){ "title", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, (*data)->windowSize.x, (*data)->windowSize.y, 0 };
|
||||
#elif ARC_GLFW
|
||||
windowInfo = (ARC_WindowInfo){ "title", (*data)->windowSize.x, (*data)->windowSize.y };
|
||||
#endif // ARC_SDL
|
||||
|
||||
ARC_Window_Create(&((*data)->window), &windowInfo);
|
||||
|
|
@ -44,7 +53,9 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
}
|
||||
|
||||
#ifdef ARC_SDL
|
||||
renderInfo = (ARC_RenderInfo){ (SDL_Window *)(*data)->window->window, -1, SDL_RENDERER_ACCELERATED };
|
||||
renderInfo = (ARC_RenderInfo){ (SDL_Window *)(*data)->window, -1, SDL_RENDERER_ACCELERATED };
|
||||
#elif ARC_GLFW
|
||||
renderInfo = (ARC_RenderInfo){ (GLFWwindow *)(*data)->window };
|
||||
#endif // ARC_SDL
|
||||
|
||||
ARC_Renderer_Create(&((*data)->renderer), &renderInfo);
|
||||
|
|
@ -57,10 +68,12 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
SDL_Event *event = (SDL_Event *)malloc(sizeof(SDL_Event));
|
||||
mouseInfo = (ARC_MouseInfo ){ event };
|
||||
keyboardInfo = (ARC_KeyboardInfo){ event };
|
||||
#elif ARC_GLFW
|
||||
mouseInfo = (ARC_MouseInfo ){ (GLFWwindow *)(*data)->window };
|
||||
keyboardInfo = (ARC_KeyboardInfo){ (GLFWwindow *)(*data)->window };
|
||||
#endif // ARC_SDL
|
||||
|
||||
ARC_Mouse_Create(&((*data)->mouse), &mouseInfo);
|
||||
|
||||
ARC_Mouse_Create (&((*data)->mouse) , &mouseInfo );
|
||||
ARC_Keyboard_Create(&((*data)->keyboard), &keyboardInfo);
|
||||
}
|
||||
|
||||
|
|
@ -83,11 +96,10 @@ void ARC_Engine_Run(ARC_EngineData *data){
|
|||
|
||||
#ifdef ARC_SDL
|
||||
SDL_Event *event = data->mouse->event;
|
||||
double lastTime = 0, currentTime;
|
||||
data->dt = 0;
|
||||
#endif // ARC_SDL
|
||||
|
||||
double lastTime = 0, currentTime;
|
||||
|
||||
data->dt = 0;
|
||||
data->running = 0;
|
||||
|
||||
while(!data->running){
|
||||
|
|
@ -97,8 +109,10 @@ void ARC_Engine_Run(ARC_EngineData *data){
|
|||
lastTime = currentTime;
|
||||
|
||||
SDL_PollEvent(data->mouse->event);
|
||||
if(event->type == SDL_QUIT){ return; }
|
||||
if(event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_ESCAPE){ return; }
|
||||
if(event->type == SDL_QUIT){ data->running = 1; }
|
||||
#elif ARC_GLFW
|
||||
glfwPollEvents();
|
||||
data->running = glfwWindowShouldClose((GLFWwindow *)data->window);
|
||||
#endif // ARC_SDL
|
||||
|
||||
ARC_Mouse_Update(data->mouse);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue