From 1213f32d0e6beab4247d91a653a0615b21edb679 Mon Sep 17 00:00:00 2001 From: Luke Street Date: Wed, 27 Jul 2022 15:15:23 -0400 Subject: [PATCH] Update submodules; add (very) simple example --- CMakeLists.txt | 5 +- examples/CMakeLists.txt | 2 + examples/simple.c | 89 +++++++++++++++++++++++++++++++++ extern/fmt | 2 +- extern/imgui | 2 +- include/dolphin/gx/GXGeometry.h | 1 + lib/dolphin/GXGeometry.cpp | 4 +- 7 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 examples/CMakeLists.txt create mode 100644 examples/simple.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cc5577..a03f228 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,8 +79,11 @@ if (DAWN_ENABLE_NULL) target_sources(aurora PRIVATE lib/dawn/NullBinding.cpp) endif () -# Optional add_library(aurora_main STATIC lib/main.cpp) target_include_directories(aurora_main PUBLIC include) target_link_libraries(aurora_main PUBLIC SDL2::SDL2main) add_library(aurora::main ALIAS aurora_main) + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + add_subdirectory(examples) +endif () diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..e7315dc --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,2 @@ +add_executable(simple simple.c) +target_link_libraries(simple PRIVATE aurora::aurora aurora::main) diff --git a/examples/simple.c b/examples/simple.c new file mode 100644 index 0000000..4a1fd11 --- /dev/null +++ b/examples/simple.c @@ -0,0 +1,89 @@ +#include +#include +#include +#include + +#include +#include +#include + +static void log_callback(AuroraLogLevel level, const char* message, unsigned int len) { + const char* levelStr; + FILE* out = stdout; + switch (level) { + case LOG_DEBUG: + levelStr = "DEBUG"; + break; + case LOG_INFO: + levelStr = "INFO"; + break; + case LOG_WARNING: + levelStr = "WARNING"; + break; + case LOG_ERROR: + levelStr = "ERROR"; + out = stderr; + break; + case LOG_FATAL: + levelStr = "FATAL"; + out = stderr; + break; + } + fprintf(out, "[%s: %s]\n", levelStr, message); + if (level == LOG_FATAL) { + fflush(out); + abort(); + } +} + +static void draw() { + GXSetCopyClear( + (GXColor){ + .r = 0, + .g = 0, + .b = 100, + .a = 255, + }, + GX_MAX_Z24); +} + +int main(int argc, char* argv[]) { + const AuroraConfig config = { + .appName = "Demo", + .logCallback = &log_callback, + }; + AuroraInfo initInfo = aurora_initialize(argc, argv, &config); + + bool exiting = false; + bool paused = false; + while (!exiting) { + const AuroraEvent* event = aurora_update(); + while (event != NULL && event->type != AURORA_NONE) { + switch (event->type) { + case AURORA_EXIT: + exiting = true; + break; + case AURORA_PAUSED: + paused = true; + break; + case AURORA_UNPAUSED: + paused = false; + break; + case AURORA_WINDOW_RESIZED: + initInfo.windowSize = event->windowSize; + break; + default: + break; + } + ++event; + } + if (exiting || paused || !aurora_begin_frame()) { + continue; + } + draw(); + aurora_end_frame(); + } + + aurora_shutdown(); + return 0; +} diff --git a/extern/fmt b/extern/fmt index 81f1cc7..c4ee726 160000 --- a/extern/fmt +++ b/extern/fmt @@ -1 +1 @@ -Subproject commit 81f1cc74a776581cdef8659d176049d3aeb743c6 +Subproject commit c4ee726532178e556d923372f29163bd206d7732 diff --git a/extern/imgui b/extern/imgui index e99c4fc..9aae45e 160000 --- a/extern/imgui +++ b/extern/imgui @@ -1 +1 @@ -Subproject commit e99c4fc6688e218a0e5da50f56638aebab45da9b +Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889 diff --git a/include/dolphin/gx/GXGeometry.h b/include/dolphin/gx/GXGeometry.h index 27de27a..d9da66c 100644 --- a/include/dolphin/gx/GXGeometry.h +++ b/include/dolphin/gx/GXGeometry.h @@ -23,6 +23,7 @@ void GXSetArray(GXAttr attr, const void* data, u32 size, u8 stride); #else void GXSetArray(GXAttr attr, const void* data, u8 stride); #endif +void GXInvalidateVtxCache(void); static inline void GXSetTexCoordGen(GXTexCoordID dst_coord, GXTexGenType func, GXTexGenSrc src_param, u32 mtx) { GXSetTexCoordGen2(dst_coord, func, src_param, mtx, GX_FALSE, GX_PTIDENTITY); diff --git a/lib/dolphin/GXGeometry.cpp b/lib/dolphin/GXGeometry.cpp index f01b1e0..d8714e4 100644 --- a/lib/dolphin/GXGeometry.cpp +++ b/lib/dolphin/GXGeometry.cpp @@ -52,7 +52,9 @@ void GXSetTexCoordGen2(GXTexCoordID dst, GXTexGenType type, GXTexGenSrc src, u32 void GXSetNumTexGens(u8 num) { update_gx_state(g_gxState.numTexGens, num); } -// TODO GXInvalidateVtxCache +void GXInvalidateVtxCache() { + // TODO +} void GXSetLineWidth(u8 width, GXTexOffset offs) { // TODO