Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build
package-lock.json
node_modules
.vscode
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.11)
project(raylib-umka
DESCRIPTION "raylib-umka: Umka bindings for raylib."
HOMEPAGE_URL "https://github.com/robloach/raylib-umka"
VERSION 0.0.3
VERSION 0.0.4
LANGUAGES C
)

Expand All @@ -21,9 +21,11 @@ else()
set(RAYLIB_UMKA_IS_MAIN FALSE)
endif()
option(RAYLIB_UMKA_BUILD_BIN "Binary" ${RAYLIB_UMKA_IS_MAIN})
option(RAYLIB_UMKA_BUILD_UMI "UMI" ${RAYLIB_UMKA_IS_MAIN})

# raylib-umka
if (RAYLIB_UMKA_BUILD_BIN)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(bin)

# Testing
Expand All @@ -43,3 +45,9 @@ if (RAYLIB_UMKA_BUILD_BIN)
)
endif()
endif()

# raylib.umi
if (RAYLIB_UMKA_BUILD_UMI)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_subdirectory(umi)
endif()
39 changes: 19 additions & 20 deletions bin/raylib-umka.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ void *umka;
* Emscripten update callback.
*/
void umkaUpdate(void* userData) {
int* updateCall = (int*)userData;
umkaCall(umka, *updateCall, 0, NULL, NULL);
umkaCall(umka, (UmkaFuncContext*)userData);
}

/**
Expand All @@ -44,9 +43,9 @@ EMSCRIPTEN_KEEPALIVE bool runCode(const char* fileName, const char* sourceString
#endif

// Call the close function if needed.
int closeCall = umkaGetFunc(umka, NULL, "close");
if (closeCall != -1) {
umkaCall(umka, closeCall, 0, NULL, NULL);
UmkaFuncContext closeCall;
if (umkaGetFunc(umka, NULL, "close", &closeCall)) {
umkaCall(umka, &closeCall);
}

// Close the window if the application didn't do it.
Expand Down Expand Up @@ -86,20 +85,20 @@ EMSCRIPTEN_KEEPALIVE bool runCode(const char* fileName, const char* sourceString

if (result) {
// main()
int mainCall = umkaGetFunc(umka, NULL, "main");
if (mainCall != -1) {
result = umkaCall(umka, mainCall, 0, NULL, NULL);
UmkaFuncContext mainCall;
if (umkaGetFunc(umka, NULL, "main", &mainCall)) {
umkaCall(umka, &mainCall);
}

// init()
int initCall = umkaGetFunc(umka, NULL, "init");
if (initCall != -1) {
umkaCall(umka, initCall, 0, NULL, NULL);
UmkaFuncContext initCall;
if (umkaGetFunc(umka, NULL, "init", &initCall)) {
umkaCall(umka, &initCall);
}

// update()
int updateCall = umkaGetFunc(umka, NULL, "update");
if (updateCall != -1) {
UmkaFuncContext updateCall;
if (umkaGetFunc(umka, NULL, "update", &updateCall)) {
// Start the Game Loop
#if defined(PLATFORM_WEB)
// TODO: Figure out desired FPS?
Expand All @@ -108,22 +107,22 @@ EMSCRIPTEN_KEEPALIVE bool runCode(const char* fileName, const char* sourceString
#else
// Stop running if the Window or App have been told to close.
while (!WindowShouldClose()) {
umkaCall(umka, updateCall, 0, NULL, NULL);
//umkaCall(umka, updateCall);
umkaCall(umka, &updateCall);
}
#endif
}

// close()
int closeCall = umkaGetFunc(umka, NULL, "close");
if (closeCall != -1) {
umkaCall(umka, closeCall, 0, NULL, NULL);
UmkaFuncContext closeCall;
if (umkaGetFunc(umka, NULL, "close", &closeCall)) {
umkaCall(umka, &closeCall);
}
}

if (!result) {
UmkaError error;
umkaGetError(umka, &error);
TraceLog(LOG_ERROR, "UMKA: %s (%d, %d): %s\n", error.fileName, error.line, error.pos, error.msg);
UmkaError* error = umkaGetError(umka);
TraceLog(LOG_ERROR, "UMKA: %s (%d, %d): %s\n", error->fileName, error->line, error->pos, error->msg);
}

umkaFree(umka);
Expand Down
7 changes: 4 additions & 3 deletions cmake/Findraylib.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# RAYLIB_VERSION
# todo: Switch to FindPackageHandleStandardArgs
if (NOT RAYLIB_VERSION)
set(RAYLIB_VERSION "4.2.0")
set(RAYLIB_VERSION "5.5")
endif()

include(FetchContent)
FetchContent_Declare(
raylib
GIT_REPOSITORY https://github.com/raysan5/raylib.git
GIT_TAG ${RAYLIB_VERSION}
#GIT_TAG ${RAYLIB_VERSION}
GIT_TAG 7b1096dc537b926f8509a5e84fb248bd55ee1b06
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED)
Expand All @@ -17,4 +18,4 @@ if (NOT raylib_POPULATED)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
set(BUILD_GAMES OFF CACHE BOOL "" FORCE)
add_subdirectory(${raylib_SOURCE_DIR} ${raylib_BINARY_DIR})
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/Findumka.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# UMKA_VERSION
# todo: Switch to FindPackageHandleStandardArgs
if (NOT UMKA_VERSION)
set(UMKA_VERSION "f8db6843ef7e2211c120751af7b40ed97e24cb23")
set(UMKA_VERSION "v1.5.5")
endif()

# Options
Expand Down
Loading