Update submodules; add (very) simple example

This commit is contained in:
Luke Street 2022-07-27 15:15:23 -04:00
parent 9a725c89cf
commit 1213f32d0e
7 changed files with 101 additions and 4 deletions

View File

@ -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 ()

2
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,2 @@
add_executable(simple simple.c)
target_link_libraries(simple PRIVATE aurora::aurora aurora::main)

89
examples/simple.c Normal file
View File

@ -0,0 +1,89 @@
#include <aurora/aurora.h>
#include <aurora/event.h>
#include <aurora/main.h>
#include <dolphin/gx.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
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;
}

2
extern/fmt vendored

@ -1 +1 @@
Subproject commit 81f1cc74a776581cdef8659d176049d3aeb743c6
Subproject commit c4ee726532178e556d923372f29163bd206d7732

2
extern/imgui vendored

@ -1 +1 @@
Subproject commit e99c4fc6688e218a0e5da50f56638aebab45da9b
Subproject commit 9aae45eb4a05a5a1f96be1ef37eb503a12ceb889

View File

@ -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);

View File

@ -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