added some opengl files TODO: fix up using glew as optional
This commit is contained in:
parent
c614c679a9
commit
d170a64a41
24 changed files with 164 additions and 93 deletions
|
|
@ -22,14 +22,12 @@
|
|||
#include <SDL.h>
|
||||
#include <SDL_video.h>
|
||||
#include <SDL2/SDL_ttf.h>
|
||||
#elif ARC_OPENGL
|
||||
#include "arc/graphics/opengl/window.h"
|
||||
#include "arc/graphics/opengl/renderer.h"
|
||||
#ifdef ARC_GLFW
|
||||
#endif
|
||||
|
||||
#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));
|
||||
|
|
@ -52,7 +50,7 @@ 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
|
||||
#elif ARC_GLFW_WINDOW
|
||||
windowInfo = (ARC_WindowInfo){ "title", (*data)->windowSize.x, (*data)->windowSize.y };
|
||||
#endif // ARC_SDL
|
||||
|
||||
|
|
@ -64,7 +62,7 @@ void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanf
|
|||
|
||||
#ifdef ARC_SDL
|
||||
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
|
||||
|
||||
|
|
@ -122,7 +120,7 @@ void ARC_Engine_Run(ARC_EngineData *data){
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
#ifdef ARC_OPENGL
|
||||
#ifdef ARC_GLFW_WINDOW
|
||||
|
||||
#include <stdio.h>
|
||||
#include "arc/std/config.h"
|
||||
#include "arc/std/string.h"
|
||||
#include "arc/std/errno.h"
|
||||
|
||||
#include "arc/graphics/opengl/renderer.h"
|
||||
#include "arc/graphics/glfw/renderer.h"
|
||||
|
||||
|
||||
void ARC_GraphicsConfig_Init(ARC_Config *config, ARC_Renderer *renderer){
|
||||
}
|
||||
|
||||
#endif // ARC_OPENGL
|
||||
#endif // ARC_OPENGL_GRAPHICS
|
||||
|
|
@ -1,15 +1,13 @@
|
|||
#ifdef ARC_OPENGL
|
||||
#ifdef ARC_GLFW_WINDOW
|
||||
#include "arc/graphics/renderer.h"
|
||||
#include "arc/graphics/opengl/renderer.h"
|
||||
#include "arc/graphics/glfw/renderer.h"
|
||||
|
||||
#ifdef ARC_GLEW
|
||||
// #ifdef ARC_GLEW
|
||||
#define GLEW_STATIC
|
||||
#include <GL/glew.h>
|
||||
#endif // ARC_GLEW
|
||||
// #endif // ARC_GLEW
|
||||
|
||||
#ifdef ARC_GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
#endif
|
||||
|
||||
#include "arc/graphics/window.h"
|
||||
#include "arc/std/errno.h"
|
||||
|
|
@ -22,18 +20,17 @@ void ARC_Renderer_Create(ARC_Renderer **renderer, ARC_RenderInfo *info){
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef ARC_GLFW
|
||||
// #ifdef ARC_GLEW
|
||||
*renderer = (ARC_Renderer *)malloc(sizeof(ARC_Renderer));
|
||||
(*renderer)->window = info->window;
|
||||
|
||||
|
||||
glewExperimental = GL_TRUE;
|
||||
if(glewInit() != GLEW_OK){
|
||||
ARC_DEBUG_ERR("ARC_Renderer_Create(**renderer, info), GLEW failed to init");
|
||||
glfwTerminate();
|
||||
arc_errno = ARC_ERRNO_INIT;
|
||||
}
|
||||
#endif // ARC_GLEW
|
||||
// #endif // ARC_GLEW
|
||||
|
||||
glClearColor(0.23f, 0.38f, 0.47f, 1.0f);
|
||||
}
|
||||
|
|
@ -47,9 +44,9 @@ void ARC_Renderer_Clear(ARC_Renderer *renderer){
|
|||
}
|
||||
|
||||
void ARC_Renderer_Render(ARC_Renderer *renderer){
|
||||
#ifdef ARC_GLFW
|
||||
// #ifdef ARC_GLEW
|
||||
glfwSwapBuffers(renderer->window);
|
||||
#endif // ARC_GLEW
|
||||
// #endif // ARC_GLEW
|
||||
}
|
||||
|
||||
#endif //ARC_SDL
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#ifdef ARC_GLFW
|
||||
#ifdef ARC_GLFW_WINDOW
|
||||
#include "arc/graphics/window.h"
|
||||
#include "arc/graphics/opengl/window.h"
|
||||
#include "arc/graphics/glfw/window.h"
|
||||
|
||||
#include "arc/std/errno.h"
|
||||
#include <GLFW/glfw3.h>
|
||||
10
src/graphics/opengl/circle.c
Normal file
10
src/graphics/opengl/circle.c
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
|
||||
#include "arc/graphics/circle.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ARC_Circle_Render(ARC_Circle *circle, ARC_Renderer *renderer, ARC_Color *color){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
#endif // !ARC_OPENGL_GRAPHICS
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
#ifdef ARC_OPENGL
|
||||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
#include "arc/graphics/line.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void ARC_Line_Render(int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2, ARC_Renderer *renderer, ARC_Color *color){
|
||||
}
|
||||
|
||||
#endif // ARC_OPENGL
|
||||
#endif // ARC_OPENGL_GRAPHICS
|
||||
14
src/graphics/opengl/obround.c
Normal file
14
src/graphics/opengl/obround.c
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
|
||||
#include "arc/graphics/obround.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ARC_Obround_Render(ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color *color){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
void ARC_FObround_Render(ARC_FObround *obround, ARC_Renderer *renderer, ARC_Color *color){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
#endif // ARC_OPENGL_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_OPENGL
|
||||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
#include "arc/graphics/rectangle.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
|
@ -8,4 +8,4 @@ void ARC_Rect_Render(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color){
|
|||
void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color){
|
||||
}
|
||||
|
||||
#endif // ARC_OPENGL
|
||||
#endif // ARC_OPENGL_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_OPENGL
|
||||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
#include "arc/graphics/sprite.h"
|
||||
#include "arc/math/point.h"
|
||||
#include "arc/math/rectangle.h"
|
||||
|
|
@ -26,4 +26,4 @@ ARC_Rect *ARC_Sprite_GetBounds(ARC_Sprite *sprite){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#endif // ARC_OPENGL
|
||||
#endif // ARC_OPENGL_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_OPENGL
|
||||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
#include "arc/graphics/spritesheet.h"
|
||||
#include "arc/math/point.h"
|
||||
#include <stdlib.h>
|
||||
|
|
@ -14,4 +14,4 @@ uint32_t *ARC_Spritesheet_GetTileSize(ARC_Spritesheet *spritesheet){
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#endif // ARC_OPENGL
|
||||
#endif // ARC_OPENGL_GRAPHICS
|
||||
26
src/graphics/opengl/text.c
Normal file
26
src/graphics/opengl/text.c
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#ifdef ARC_OPENGL_GRAPHICS
|
||||
|
||||
#include "arc/graphics/text.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void ARC_Text_Create(ARC_Text **text, ARC_String *path, int32_t size, ARC_Color color){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
void ARC_Text_Destroy(ARC_Text *font){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
void ARC_Text_SetString(ARC_Text *text, ARC_Renderer *renderer, ARC_String *string){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
void ARC_Text_Render(ARC_Text *text, ARC_Renderer *renderer){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
void ARC_Text_SetPos(ARC_Text *text, ARC_Point pos){
|
||||
printf("OpenGL Backend Selected\n");
|
||||
}
|
||||
|
||||
#endif // !ARC_OPENGL_GRAPHICS
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_GLFW
|
||||
#ifdef ARC_GLFW_INPUT
|
||||
#include "arc/input/glfw/keyboard.h"
|
||||
#include "arc/input/keyboard.h"
|
||||
#include "arc/math/point.h"
|
||||
|
|
@ -19,4 +19,4 @@ ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, enum ARC_Keyboar
|
|||
return ARC_KEY_NONE;
|
||||
}
|
||||
|
||||
#endif // ARC_GLFW
|
||||
#endif // ARC_GLFW_INPUT
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#ifdef ARC_GLFW
|
||||
#ifdef ARC_GLFW_INPUT
|
||||
#include "arc/input/glfw/mouse.h"
|
||||
#include "arc/input/mouse.h"
|
||||
#include "arc/math/point.h"
|
||||
|
|
@ -30,4 +30,4 @@ int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse){
|
|||
return mouse->scrollY;
|
||||
}
|
||||
|
||||
#endif // ARC_SDL
|
||||
#endif // ARC_SDL_INPUT
|
||||
Loading…
Add table
Add a link
Reference in a new issue