f***ed up and needed to rework packages

This commit is contained in:
herbglitch 2024-05-20 03:46:04 -06:00
parent f4592ae8d0
commit b43ab1702f
73 changed files with 194 additions and 2045 deletions

View file

@ -1,12 +0,0 @@
#ifndef ARC_SDL_AUDIO_H_
#define ARC_SDL_AUDIO_H_
#ifdef ARC_SDL
#include <SDL2/SDL_mixer.h>
typedef struct ARC_Audio {
Mix_Chunk *chunk;
} ARC_Audio;
#endif // !ARC_SDL
#endif // !ARC_SDL_AUDIO_H_

View file

@ -7,37 +7,51 @@ extern "C" {
#include "arc/graphics/window.h"
#include "arc/graphics/renderer.h"
#include "arc/input/input.h"
#include "arc/input/mouse.h"
#include "arc/input/keyboard.h"
#include "arc/std/handler.h"
#include "arc/math/point.h"
#include "arc/std/bool.h"
#include "arc/std/handler.h"
typedef struct ARC_EngineData {
ARC_Window *window;
ARC_Renderer *renderer;
ARC_Handler *state;
ARC_Input *input;
ARC_Mouse *mouse;
ARC_Keyboard *keyboard;
double dt;
uint32_t running;
ARC_Bool running;
ARC_Point windowSize;
} ARC_EngineData;
//NOTE: most work below is temp, and will change once I figure out a better way to write this header
void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanfn, ARC_Point windowSize);
/**
* @breif creates an ARC_EngineData type to be used when running an ARC_Engine
*
* @param data the ARC_EngineData to create
* @param cleanFn the state cleanup function
* @param windowSIze the size of window to create passed as an ARC_Point
*/
void ARC_EngineData_Create(ARC_EngineData **data, ARC_Handler_CleanDataFn cleanFn, ARC_Point windowSize);
/**
* @breif destroys an ARC_EngineData type
*
* @param data the ARC_EngineData to destroy
*/
void ARC_EngineData_Destroy(ARC_EngineData *data);
/**
* @brief runs ARC_Engine
* @brief runs ARC_Engine with an uncapped framerate
*
* @note data must be created before this function
* @note data should be destroyed after this function
*
* @param data engine data that will be used
* data must be created before this function
* and must be destroyed after this function
*/
void ARC_Engine_Run(ARC_EngineData *data);
void ARC_Engine_RunUncapped(ARC_EngineData *data);
#ifdef __cplusplus
}

View file

@ -1,29 +0,0 @@
#ifndef ARC_OPENGL_RENDERER_H_
#define ARC_OPENGL_RENDERER_H_
#ifdef ARC_GLFW_WINDOW
#define GLEW_STATIC
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "arc/graphics/renderer.h"
#include "arc/graphics/window.h"
typedef struct ARC_RendererType {
GLFWwindow *window;
} ARC_RendererType;
/**
* @brief struct for info needed to create glfw renderer
*
* @note this is what needs to be passed into the data parameter for ARC_Renderer_Create
*/
struct ARC_RenderInfo {
GLFWwindow *window;
};
#endif // !ARC_GLFW_WINDOW
#endif // !ARC_OPENGL_RENDERER_H_

View file

@ -1,27 +0,0 @@
#ifndef ARC_OPENGL_WINDOW_H_
#define ARC_OPENGL_WINDOW_H_
#ifdef ARC_GLFW_WINDOW
#define GLEW_STATIC
#include <GL/glew.h>
#include "arc/graphics/window.h"
#include <GLFW/glfw3.h>
typedef GLFWwindow ARC_WindowType;
/**
* @brief struct for info needed to create a GLFWwindow
*
* @note this is what needs to be passed into the data parameter for ARC_Window_Create
*/
struct ARC_WindowInfo {
char *title;
int w;
int h;
};
#endif // !ARC_GLFW_WINDOW
#endif // !ARC_GLFW_WINDOW_H_

View file

@ -1,13 +1,11 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/renderer.h"
//#include "arc/graphics/renderer.h"
#ifndef ARC_NONE_RENDERER_H_
#define ARC_NONE_RENDERER_H_
typedef void ARC_RendererType;
struct ARC_RenderInfo {};
//typedef void ARC_RendererType;
#endif // !ARC_NONE_RENDERER_H_

View file

@ -3,12 +3,10 @@
#ifndef ARC_NONE_WINDOW_H_
#define ARC_NONE_WINDOW_H_
#include "arc/graphics/window.h"
//#include "arc/graphics/window.h"
typedef void ARC_WindowType;
struct ARC_WindowInfo {};
//typedef void ARC_WindowType;
#endif // !ARC_SDL_WINDOW_H_
#endif // !ARC_NONE_WINDOW
#endif // !ARC_NONE_WINDOW

View file

@ -1,13 +0,0 @@
#ifndef ARC_OPENGL_SPRITE_H_
#define ARC_OPENGL_SPRITE_H_
#ifdef ARC_OPENGL_GRAPHICS
#include "arc/graphics/sprite.h"
struct ARC_Sprite {
};
#endif // !ARC_OPENGL_GRAPHICS
#endif // !ARC_OPENGL_SPRITE_H_

View file

@ -1,13 +0,0 @@
#ifndef ARC_OPENGL_SPRITESHEET_H_
#define ARC_OPENGL_SPRITESHEET_H_
#ifdef ARC_OPENGL_GRAPHICS
#include "arc/graphics/spritesheet.h"
struct ARC_Spritesheet {
};
#endif // !ARC_OPENGL_GRAPHICS
#endif // !ARC_OPENGL_SPRITESHEET_H_

View file

@ -1,14 +0,0 @@
#ifndef ARC_OPENGL_TEXT_H_
#define ARC_OPENGL_TEXT_H_
#include "arc/std/string.h"
#include "arc/graphics/color.h"
#include "arc/math/rectangle.h"
#ifdef ARC_OPENGL_GRAPHICS
typedef struct ARC_Text {} ARC_Text;
#endif // !ARC_OPENGL_GRAPHICS
#endif // !ARC_OPENGL_TEXT_H_

View file

@ -5,23 +5,26 @@
extern "C" {
#endif
/**
* @brief predefien ARC_EngineData so as not to get circular reference
*/
typedef struct ARC_EngineData ARC_EngineData;
/**
* @note ARC_RendererType is determined by which window library you are using
*/
typedef struct ARC_RendererType ARC_Renderer;
typedef struct ARC_RenderInfo ARC_RenderInfo;
/**
* @brief creates ARC_Renderer type
* @brief creates ARC_Renderer type with ARC_EngineData
*
* @note the parameter data is determined by which graphics library you are using
* please refer to the graphics library section to see what needs to be passed
*
* @param renderer ARC_Renderer to initialize
* @param info Info on how to create ARC_Window
* @param data the engine data to create from
*/
void ARC_Renderer_Create(ARC_Renderer **renderer, ARC_RenderInfo *info);
void ARC_Renderer_CreateWithEngineData(ARC_Renderer **renderer, ARC_EngineData *data);
/**
* @brief destroys ARC_Renderer type
@ -30,8 +33,20 @@ void ARC_Renderer_Create(ARC_Renderer **renderer, ARC_RenderInfo *info);
*/
void ARC_Renderer_Destroy(ARC_Renderer *renderer);
/**
* @breif clears the renderer
*
* @param renderer the renderer to clear
*/
void ARC_Renderer_Clear(ARC_Renderer *renderer);
/**
* @brief renders the renderer
*
* @note the renderer will most likely be drawn to from ARC_EngineData
*
* @param renderer the renderer to render
*/
void ARC_Renderer_Render(ARC_Renderer *renderer);
#ifdef __cplusplus

View file

@ -1,25 +0,0 @@
#ifndef ARC_SDL_RENDERER_H_
#define ARC_SDL_RENDERER_H_
#ifdef ARC_SDL2_GRAPHICS
#include "arc/graphics/renderer.h"
#include "arc/graphics/window.h"
#include <SDL.h>
typedef SDL_Renderer ARC_RendererType;
/**
* @brief struct for info needed to create SDL_Renderer
*
* @note this is what needs to be passed into the data parameter for ARC_Renderer_Create
*/
struct ARC_RenderInfo {
SDL_Window *window;
int index;
Uint32 flags;
};
#endif // !ARC_SDL2_GRAPHICS
#endif // !ARC_SDL_RENDERER_H_

View file

@ -1,18 +0,0 @@
#ifndef ARC_SDL_SPRITE_H_
#define ARC_SDL_SPRITE_H_
#ifdef ARC_SDL2_GRAPHICS
#include "arc/graphics/sprite.h"
#include <SDL.h>
struct ARC_Sprite {
ARC_Spritesheet *spritesheet;
ARC_Array *frames;
uint32_t *frameIndex;
//TODO: temp
uint8_t opacity;
};
#endif // !ARC_SDL2_GRAPHICS
#endif // !ARC_SDL_SPRITE_H_

View file

@ -1,15 +0,0 @@
#ifndef ARC_SDL_SPRITESHEET_H_
#define ARC_SDL_SPRITESHEET_H_
#ifdef ARC_SDL2_GRAPHICS
#include "arc/graphics/spritesheet.h"
#include <SDL.h>
struct ARC_Spritesheet {
SDL_Texture *texture;
uint32_t *size;
};
#endif // !ARC_SDL2_GRPAHCIS
#endif // !ARC_SDL_SPRITESHEET_H_

View file

@ -1,23 +0,0 @@
#ifndef ARC_SDL_TEXT_H_
#define ARC_SDL_TEXT_H_
#include "arc/std/string.h"
#include "arc/graphics/color.h"
#include "arc/math/rectangle.h"
#ifdef ARC_SDL2_GRAPHICS
#include <SDL.h>
typedef struct ARC_Text {
ARC_String *name;
int32_t size;
ARC_Color color;
SDL_Texture *texture;
ARC_Rect bounds;
} ARC_Text;
#endif // !ARC_SDL2_Graphics
#endif // !ARC_SDL_TEXT_H_

View file

@ -1,26 +0,0 @@
#ifndef ARC_SDL_WINDOW_H_
#define ARC_SDL_WINDOW_H_
#ifdef ARC_SDL2_GRAPHICS
#include "arc/graphics/window.h"
#include <SDL.h>
typedef SDL_Window ARC_WindowType;
/**
* @brief struct for info needed to create SDL_Window
*
* @note this is what needs to be passed into the data parameter for ARC_Window_Create
*/
struct ARC_WindowInfo {
char *title;
int x;
int y;
int w;
int h;
Uint32 flags;
};
#endif // !ARC_SDL2_GRAPHICS
#endif // !ARC_SDL_WINDOW_H_

View file

@ -5,12 +5,21 @@
extern "C" {
#endif
#include <stdint.h>
/**
* @note ARC_WindowType is determined by which window library you are using
* @note ARC_WindowType is determined by which window backend you are using
*/
typedef struct ARC_WindowType ARC_Window;
typedef struct ARC_WindowInfo ARC_WindowInfo;
/**
* @note certain parts of ARC_WindowInfo may not be used by your selected backend
*/
typedef struct ARC_WindowInfo {
char *title;
int32_t w;
int32_t h;
} ARC_WindowInfo;
/**
* @brief creates ARC_Window type

View file

@ -1,21 +0,0 @@
#ifndef ARC_GLFW_KEYBOARD_H_
#define ARC_GLFW_KEYBOARD_H_
#ifdef ARC_GLFW_INPUT
#include <GLFW/glfw3.h>
#include "arc/input/keyboard.h"
struct ARC_Keyboard {
GLFWwindow *window;
ARC_KeyboardState *keys;
ARC_KeyboardState *released;
};
struct ARC_KeyboardInfo {
GLFWwindow *window;
};
#endif // !ARC_GLFW_INPUT
#endif // !ARC_GLFW_KEYBOARD_H_

View file

@ -1,25 +0,0 @@
#ifndef ARC_GLFW_MOUSE_H_
#define ARC_GLFW_MOUSE_H_
#ifdef ARC_GLFW_INPUT
#include <GLFW/glfw3.h>
#include "arc/input/mouse.h"
#include "arc/math/point.h"
struct ARC_Mouse {
GLFWwindow *window;
ARC_Point *coords;
int32_t *scrollY;
ARC_MouseState *buttons;
uint8_t *buttonsReleased;
};
struct ARC_MouseInfo {
GLFWwindow *window;
};
#endif // !ARC_GLFW_INPUT
#endif // !ARC_GLFW_MOUSE_H_

View file

@ -7,6 +7,11 @@ extern "C" {
#include <stdint.h>
/**
* @brief predefien ARC_Input so as not to get circular reference
*/
typedef struct ARC_Input ARC_Input;
typedef struct ARC_Keyboard ARC_Keyboard;
typedef struct ARC_KeyboardInfo ARC_KeyboardInfo;
@ -19,7 +24,8 @@ typedef enum ARC_KeyboardState {
#define ARC_KEYBOARD_BUTTON_NUM 239
void ARC_Keyboard_Create(ARC_Keyboard **keyboard, ARC_KeyboardInfo *info);
void ARC_Keyboard_CreateWithInput(ARC_Keyboard **keyboard, ARC_Input *input);
void ARC_Keyboard_Destroy(ARC_Keyboard *keyboard);
void ARC_Keyboard_Update(ARC_Keyboard *keyboard);

View file

@ -8,9 +8,12 @@ extern "C" {
#include "arc/math/point.h"
#include <stdint.h>
typedef struct ARC_Mouse ARC_Mouse;
/**
* @brief predefien ARC_Input so as not to get circular reference
*/
typedef struct ARC_Input ARC_Input;
typedef struct ARC_MouseInfo ARC_MouseInfo;
typedef struct ARC_Mouse ARC_Mouse;
typedef enum ARC_MouseState {
ARC_MOUSE_NONE,
@ -28,7 +31,8 @@ typedef enum ARC_MouseButton {
#define ARC_MOUSE_BUTTON_NUM 5
void ARC_Mouse_Create(ARC_Mouse **mouse, ARC_MouseInfo *info);
void ARC_Mouse_CreateWithInput(ARC_Mouse **mouse, ARC_Input *input);
void ARC_Mouse_Destroy(ARC_Mouse *mouse);
void ARC_Mouse_Update(ARC_Mouse *mouse);
ARC_Point *ARC_Mouse_GetCoords(ARC_Mouse *mouse);
@ -39,4 +43,4 @@ int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse);
}
#endif
#endif // !ARC_GRAPHICS_MOUSE_H_
#endif // !ARC_GRAPHICS_MOUSE_H_

View file

@ -1,21 +0,0 @@
#ifndef ARC_SDL_KEYBOARD_H_
#define ARC_SDL_KEYBOARD_H_
#ifdef ARC_SDL2_INPUT
#include "arc/input/keyboard.h"
#include <SDL.h>
struct ARC_Keyboard {
SDL_Event *event;
ARC_KeyboardState *keys;
ARC_KeyboardState *released;
};
struct ARC_KeyboardInfo {
SDL_Event *event;
};
#endif // ARC_SDL2_INPUT
#endif // !ARC_SDL_KEYBOARD_H_

View file

@ -1,24 +0,0 @@
#ifndef ARC_SDL_MOUSE_H_
#define ARC_SDL_MOUSE_H_
#ifdef ARC_SDL2_INPUT
#include <SDL.h>
#include "arc/input/mouse.h"
#include "arc/math/point.h"
struct ARC_Mouse {
SDL_Event *event;
ARC_Point *coords;
int32_t *scrollY;
ARC_MouseState *buttons;
uint8_t *buttonsReleased;
};
struct ARC_MouseInfo {
SDL_Event *event;
};
#endif // ARC_SDL2_INPUT
#endif // !ARC_SDL_MOUSE_H_

View file

@ -3,12 +3,13 @@
#include <stdint.h>
#define ARC_ERRNO_NULL -0x01
#define ARC_ERRNO_DATA -0x02
#define ARC_ERRNO_COPY -0x03
#define ARC_ERRNO_EXISTS -0x04
#define ARC_ERRNO_OVERFLOW -0x05
#define ARC_ERRNO_INIT -0x06
#define ARC_ERRNO_NULL -0x01
#define ARC_ERRNO_DATA -0x02
#define ARC_ERRNO_COPY -0x03
#define ARC_ERRNO_EXISTS -0x04
#define ARC_ERRNO_OVERFLOW -0x05
#define ARC_ERRNO_INIT -0x06
#define ARC_ERRNO_CONNECTION -0x07
#ifdef __cplusplus
extern "C" {

View file

@ -84,7 +84,7 @@ void ARC_Handler_Remove(ARC_Handler *handler, void *data, ARC_Handler_CompareDat
* @param handler ARC_Handler to remove from
* @param index index of data that is being removed
*/
void ARC_Handler_RemoveIndex(ARC_Handler *handler, uint32_t *index);
void ARC_Handler_RemoveIndex(ARC_Handler *handler, uint32_t index);
/**
* @brief calls provided function on each element in handler
@ -115,7 +115,7 @@ void ARC_Handler_Clean(ARC_Handler *handler);
*
* @param handler ARC_handler to get size from
*/
uint32_t *ARC_Handler_Size(ARC_Handler *handler);
uint32_t ARC_Handler_Size(ARC_Handler *handler);
#ifdef __cplusplus
}

View file

@ -57,7 +57,7 @@ void ARC_Vector_Remove(ARC_Vector *vector, void *data, ARC_Vector_CompareDataFn
* @param vector ARC_Vector to remove from
* @param index index of data that is being removed
*/
void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t *index);
void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t index);
/**
* @brief gets size of vector
@ -66,7 +66,7 @@ void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t *index);
*
* @return the pointer of the vectors size, TODO: don't pass as a pointer
*/
uint32_t *ARC_Vector_Size(ARC_Vector *vector);
uint32_t ARC_Vector_Size(ARC_Vector *vector);
/**
* @brief gets data from ARC_Vector at position index
@ -76,7 +76,7 @@ uint32_t *ARC_Vector_Size(ARC_Vector *vector);
*
* @return pointer to data on success, NULL on fail
*/
void *ARC_Vector_Get(ARC_Vector *vector, uint32_t *index);
void *ARC_Vector_Get(ARC_Vector *vector, uint32_t index);
#ifdef __cplusplus
}