huge core redesign

This commit is contained in:
herbglitch 2024-01-12 19:48:17 -07:00
parent 85d0bad350
commit c614c679a9
23 changed files with 457 additions and 0 deletions

41
cmake/archeus_none.cmake Normal file
View file

@ -0,0 +1,41 @@
set(ARCHEUS_STD_NONE_WINDOW_SOURCES
)
set(ARCHEUS_STD_NONE_INPUT_SOURCES
src/input/none/keyboard.c
src/input/none/mouse.c
)
set(ARCHEUS_STD_NONE_GRAPHICS_SOURCES
src/graphics/none/circle.c
src/graphics/none/config.c
src/graphics/none/line.c
src/graphics/none/obround.c
src/graphics/none/rectangle.c
src/graphics/none/renderer.c
src/graphics/none/sprite.c
src/graphics/none/spritesheet.c
src/graphics/none/text.c
src/graphics/none/window.c
)
function(none_check_and_init_needed _ARCHEUS_STD_FLAGS _ARCHEUS_STD_SOURCES ARCHEUS_STD_WINDOW_BACKEND ARCHEUS_STD_INPUT_BACKEND ARCHEUS_STD_GRAPHICS_BACKEND)
#add matching files for the selected backends
if(${ARCHEUS_STD_WINDOW_BACKEND} STREQUAL "NONE")
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_NONE_WINDOW ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_NONE_WINDOW_SOURCES})
endif()
if(${ARCHEUS_STD_INPUT_BACKEND} STREQUAL "NONE")
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_NONE_INPUT ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_NONE_INPUT_SOURCES})
endif()
if(${ARCHEUS_STD_GRAPHICS_BACKEND} STREQUAL "NONE")
string(APPEND ${_ARCHEUS_STD_FLAGS} "-DARC_NONE_GRAPHICS ")
list(APPEND ${_ARCHEUS_STD_SOURCES} ${ARCHEUS_STD_NONE_GRAPHICS_SOURCES})
endif()
set(${_ARCHEUS_STD_FLAGS} ${${_ARCHEUS_STD_FLAGS}} PARENT_SCOPE)
set(${_ARCHEUS_STD_SOURCES} ${${_ARCHEUS_STD_SOURCES}} PARENT_SCOPE)
endfunction()

View file

64
cmake/archeus_sdl2.cmake Normal file
View file

@ -0,0 +1,64 @@
set(ARCHEUS_STD_SDL2_WINDOW_SOURCES
)
set(ARCHEUS_STD_SDL2_INPUT_SOURCES
src/input/sdl/keyboard.c
src/input/sdl/mouse.c
)
set(ARCHEUS_STD_SDL2_GRAPHICS_SOURCES
src/graphics/sdl/circle.c
src/graphics/sdl/config.c
src/graphics/sdl/line.c
src/graphics/sdl/obround.c
src/graphics/sdl/rectangle.c
src/graphics/sdl/renderer.c
src/graphics/sdl/sprite.c
src/graphics/sdl/spritesheet.c
src/graphics/sdl/text.c
src/graphics/sdl/window.c
)
function(sdl2_check_and_init_needed ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ARCHEUS_STD_WINDOW_BACKEND ARCHEUS_STD_INPUT_BACKEND ARCHEUS_STD_GRAPHICS_BACKEND)
#if no backend uses sdl return
if(NOT ARCHEUS_STD_WINDOW_BACKEND STREQUAL "SDL2" AND NOT ARCHEUS_STD_INPUT_BACKEND STREQUAL "SDL2" AND NOT ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL "SDL2")
return()
endif()
string(APPEND ARCHEUS_STD_FLAGS "-DARC_SDL ")
#get needed libraries for backends
find_package(SDL2 REQUIRED)
if(ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL "SDL2")
if(NOT PNG AND WIN32 AND NOT MSVC)
set(PNG_LIBRARY "C:/Program Files(x86)/libpng")
set(PNG_PNG_INCLUDE_DIR "C:/Program Files(x86)/libpng/include")
endif()
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
endif()
#add matching files for the selected backends
if(ARCHEUS_STD_INPUT_BACKEND STREQUAL "SDL2")
list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL2_INPUT_SOURCES})
endif()
if(ARCHEUS_STD_INPUT_BACKEND STREQUAL "SDL2")
list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL2_INPUT_SOURCES})
endif()
if(ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL "SDL2")
list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL2_GRAPHICS_SOURCES})
endif()
target_include_directories(archeus_std
PRIVATE ${SDL2_INCLUDE_DIRS}
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
)
target_link_libraries(archeus_std PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf)
return(ARCHEUS_STD_SDL2_SOURCES)
endfunction()

View file

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

View file

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

View file

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

View file

@ -0,0 +1,12 @@
#ifdef ARC_NONE_GRAPHICS
#ifndef ARC_NONE_TEXT_H_
#define ARC_NONE_TEXT_H_
#include "arc/graphics/text.h"
struct ARC_Text {};
#endif // !ARC_NONE_TEXT_H_
#endif // !ARC_NONE_GRAPHICS

View file

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

View file

@ -0,0 +1,14 @@
#ifdef ARC_NONE_INPUT
#ifndef ARC_NONE_KEYBOARD_H_
#define ARC_NONE_KEYBOARD_H_
#include "arc/input/keyboard.h"
struct ARC_Keyboard {};
struct ARC_KeyboardInfo {};
#endif // !ARC_NONE_KEYBOARD_H_
#endif // !ARC_NONE_INPUT

View file

@ -0,0 +1,14 @@
#ifdef ARC_NONE_INPUT
#ifndef ARC_NONE_MOUSE_H_
#define ARC_NONE_MOUSE_H_
#include "arc/input/mouse.h"
struct ARC_Mouse {};
struct ARC_MouseInfo {};
#endif // !ARC_NONE_MOUSE_H_
#endif // !ARC_NONE_INPUT

View file

@ -0,0 +1,10 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/circle.h"
#include <stdio.h>
void ARC_Circle_Render(ARC_Circle *circle, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
#endif // !ARC_NONE_GRAPHICS

View file

@ -0,0 +1,10 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/config.h"
#include <stdio.h>
void ARC_GraphicsConfig_Init(ARC_Config *config, ARC_Renderer *renderer){
printf("No Graphics Backend Selected\n");
}
#endif //ARC_NONE_GRAPHICS

10
src/graphics/none/line.c Normal file
View file

@ -0,0 +1,10 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/line.h"
#include <stdio.h>
void ARC_Line_Render(int32_t *x1, int32_t *y1, int32_t *x2, int32_t *y2, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
#endif // !ARC_NONE_GRAPHICS

View file

@ -0,0 +1,14 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/obround.h"
#include <stdio.h>
void ARC_Obround_Render(ARC_Obround *obround, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
void ARC_FObround_Render(ARC_FObround *obround, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
#endif // ARC_NONE_GRAPHICS

View file

@ -0,0 +1,22 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/rectangle.h"
#include <stdio.h>
void ARC_Rect_Render(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
void ARC_Rect_RenderFill(ARC_Rect *rect, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
void ARC_FRect_Render(ARC_FRect *rect, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
void ARC_FRect_RenderFill(ARC_FRect *rect, ARC_Renderer *renderer, ARC_Color *color){
printf("No Graphics Backend Selected\n");
}
#endif // !ARC_NONE_GRAPHICS

View file

@ -0,0 +1,22 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/renderer.h"
#include <stdio.h>
void ARC_Renderer_Create(ARC_Renderer **renderer, ARC_RenderInfo *info){
printf("No Graphics Backend Selected\n");
}
void ARC_Renderer_Destroy(ARC_Renderer *renderer){
printf("No Graphics Backend Selected\n");
}
void ARC_Renderer_Clear(ARC_Renderer *renderer){
printf("No Graphics Backend Selected\n");
}
void ARC_Renderer_Render(ARC_Renderer *renderer){
printf("No Graphics Backend Selected\n");
}
#endif // !ARC_NONE_GRAPHICS

View file

@ -0,0 +1,48 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/sprite.h"
#include <stdio.h>
void ARC_Sprite_Create(ARC_Sprite **sprite, ARC_Spritesheet *spritesheet, ARC_Array *frames){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_Destroy(ARC_Sprite *sprite){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_Copy(ARC_Sprite **newSprite, ARC_Sprite *oldSprite){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_Render(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Rect *renderBounds){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_RenderFlip(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Rect *renderBounds, enum ARC_Sprite_Axis axis){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_RenderRotated(ARC_Sprite *sprite, ARC_Renderer *renderer, ARC_Rect *renderBounds, ARC_Point *center, double angle){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_SetFrameIndex(ARC_Sprite *sprite, uint32_t index){
printf("No Graphics Backend Selected\n");
}
void ARC_Sprite_IterateFrame(ARC_Sprite *sprite){
printf("No Graphics Backend Selected\n");
}
ARC_Rect *ARC_Sprite_GetBounds(ARC_Sprite *sprite){
printf("No Graphics Backend Selected\n");
return NULL;
}
ARC_Array *ARC_Sprite_GetAllBounds(ARC_Sprite *sprite){
printf("No Graphics Backend Selected\n");
return NULL;
}
#endif // !ARC_NONE_GRAPHICS

View file

@ -0,0 +1,21 @@
#ifdef ARC_NONE_GRAPHICS
#include "arc/graphics/spritesheet.h"
#include "arc/math/point.h"
#include <stdio.h>
void ARC_Spritesheet_RenderArea(ARC_Spritesheet *spritesheet, ARC_Rect *sheetBounds, ARC_Renderer *renderer, ARC_Rect *renderBounds){
printf("No Graphics Backend Selected\n");
}
ARC_Point ARC_Spritesheet_GetSize(ARC_Spritesheet *spritesheet){
printf("No Graphics Backend Selected\n");
return (ARC_Point){ 0, 0 };
}
uint32_t *ARC_Spritesheet_GetTileSize(ARC_Spritesheet *spritesheet){
printf("No Graphics Backend Selected\n");
return NULL;
}
#endif // !ARC_NONE_GRAPHICS

26
src/graphics/none/text.c Normal file
View file

@ -0,0 +1,26 @@
#ifdef ARC_NONE_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("No Graphics Backend Selected\n");
}
void ARC_Text_Destroy(ARC_Text *font){
printf("No Graphics Backend Selected\n");
}
void ARC_Text_SetString(ARC_Text *text, ARC_Renderer *renderer, ARC_String *string){
printf("No Graphics Backend Selected\n");
}
void ARC_Text_Render(ARC_Text *text, ARC_Renderer *renderer){
printf("No Graphics Backend Selected\n");
}
void ARC_Text_SetPos(ARC_Text *text, ARC_Point pos){
printf("No Graphics Backend Selected\n");
}
#endif // !ARC_NONE_GRAPHICS

View file

@ -0,0 +1,14 @@
#ifdef ARC_NONE_WINDOW
#include "arc/graphics/window.h"
#include <stdio.h>
void ARC_Window_Create(ARC_Window **window, ARC_WindowInfo *info){
printf("No Window Backend Selected\n");
}
void ARC_Window_Destroy(ARC_Window *window){
printf("No Window Backend Selected\n");
}
#endif // !ARC_NONE_WINDOW

23
src/input/none/keyboard.c Normal file
View file

@ -0,0 +1,23 @@
#ifdef ARC_NONE_INPUT
#include "arc/input/keyboard.h"
#include <stdio.h>
void ARC_Keyboard_Create(ARC_Keyboard **keyboard, ARC_KeyboardInfo *info){
printf("No Input Backend Selected\n");
}
void ARC_Keyboard_Destroy(ARC_Keyboard *keyboard){
printf("No Input Backend Selected\n");
}
void ARC_Keyboard_Update(ARC_Keyboard *keyboard){
printf("No Input Backend Selected\n");
}
ARC_KeyboardState ARC_Keyboard_GetState(ARC_Keyboard *keyboard, enum ARC_KeyboardKey key){
printf("No Input Backend Selected\n");
return ARC_KEY_NONE;
}
#endif // !ARC_NONE_INPUT

37
src/input/none/mouse.c Normal file
View file

@ -0,0 +1,37 @@
#ifdef ARC_NONE_INPUT
#include "arc/input/mouse.h"
#include <stdio.h>
void ARC_Mouse_Create(ARC_Mouse **mouse, ARC_MouseInfo *info){
printf("No Input Backend Selected\n");
}
void ARC_Mouse_Destroy(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
}
void ARC_Mouse_UpdateButton(ARC_Mouse *mouse, uint8_t button, uint32_t *buttons, uint32_t mask){
printf("No Input Backend Selected\n");
}
void ARC_Mouse_Update(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
}
ARC_Point *ARC_Mouse_GetCoords(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
return NULL;
}
ARC_MouseState ARC_Mouse_GetState(ARC_Mouse *mouse, ARC_MouseButton button){
printf("No Input Backend Selected\n");
return ARC_MOUSE_NONE;
}
int32_t *ARC_Mouse_GetScrollY(ARC_Mouse *mouse){
printf("No Input Backend Selected\n");
return NULL;
}
#endif // !ARC_INPUT_NONE

3
src/std/errno.c Normal file
View file

@ -0,0 +1,3 @@
#include "arc/std/errno.h"
int32_t arc_errno = 0;