Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	demo/CMakeLists.txt
#	demo/demo_mixed_mode.c
#	include/ldk/common.h
#	include/ldk/maths.h
#	src/CMakeLists.txt
#	src/asset/mesh.c
#	src/maths.c
#	src/module/graphics.c
  • Loading branch information
marciovmf committed Oct 24, 2024
2 parents dcd29c9 + 065e307 commit 682f007
Show file tree
Hide file tree
Showing 12 changed files with 1,337 additions and 2,586 deletions.
26 changes: 16 additions & 10 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
cmake_minimum_required(VERSION 3.9)
project("demo")


# --- PURE_OS_MODE DEMO --------------------------
add_executable(demo_pure_os_mode demo_pure_os_mode.c)
target_link_libraries(demo_pure_os_mode PRIVATE ldk)
target_compile_definitions(demo_pure_os_mode PRIVATE
$<$<BOOL:${OPTION_BUILD_EDITOR}>:LDK_EDITOR>
$<$<BOOL:${OPTION_LDKSHAREDLIB}>:LDK_SHAREDLIB>
)

# --- MIXED_MODE DEMO ----------------------------
add_executable(demo_mixed_mode demo_mixed_mode.c)
target_link_libraries(demo_mixed_mode PRIVATE ldk)
target_compile_definitions(demo_mixed_mode PRIVATE
$<$<BOOL:${OPTION_BUILD_EDITOR}>:LDK_EDITOR>
$<$<BOOL:${OPTION_LDKSHAREDLIB}>:LDK_SHAREDLIB>
)

# --- PURE_ENGINE DEMO ---------------------------
add_executable(demo main.c)
target_link_libraries(demo PRIVATE ldk)
target_compile_definitions(demo PRIVATE
$<$<BOOL:${OPTION_BUILD_EDITOR}>:LDK_EDITOR>
$<$<BOOL:${OPTION_LDKSHAREDLIB}>:LDK_SHAREDLIB>
)


# --- MAKE RUTREE SYMLINK ------------------------
add_custom_command(
TARGET demo POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove "${OUTPUT_DIR}/assets/"
COMMAND ${CMAKE_COMMAND} -E remove "${OUTPUT_DIR}/ldk.cfg"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${RUNTREE_DIR}/assets/" "${OUTPUT_DIR}/assets/"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${RUNTREE_DIR}/ldk.cfg" "${OUTPUT_DIR}/ldk.cfg"
)

if (OPTION_BUILD_EDITOR)
target_compile_definitions(demo PRIVATE LDK_EDITOR)
target_compile_definitions(demo_mixed_mode PRIVATE LDK_EDITOR)
target_compile_definitions(demo_mixed_mode PRIVATE LDK_EDITOR)
endif()
)

1 change: 1 addition & 0 deletions demo/demo_mixed_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ int mixedModeApplication()
ldkEngineInitialize();
ldkGraphicsViewportTitleSet("LDK");
ldkGraphicsViewportIconSet("assets/ldk.ico");

glClearColor(0, 0, 255, 0);

bool running = true;
Expand Down
2 changes: 1 addition & 1 deletion include/ldk/asset/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
uint16* indices;
LDKHAsset* materials;
LDKSurface* surfaces;
LDKBoundingBox boundingBox;
LDKAABB aabb;
LDKBoundingSphere boundingSphere;
uint32 numVertices;
uint32 numIndices;
Expand Down
15 changes: 11 additions & 4 deletions include/ldk/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@
* Common macros, functions and types used across the whole engine.
*
* Important defines:
* LDK_EXPORT_API :should be set when building the engine; not set when building games
* LDK_AS_SHARED_LIB :should be set when building LDK as a dll.
* LDK_ENGINE :should be set when building the engine
* LDK_SHAREDLIB :should be set when building LDK as a dll.
*/

#ifndef LDK_COMMON_H
#define LDK_COMMON_H


#ifdef __cplusplus
extern "C" {
#endif

// OS Detection macros

#if defined(_WIN32) || defined(_WIN64)
Expand Down Expand Up @@ -108,9 +110,14 @@ extern "C" {
#include <stdbool.h>
#endif

#ifdef LDK_AS_SHARED_LIB
#ifndef LDK_ENGINE
#define LDK_GAME
#endif

// @build-tweak
#ifdef LDK_SHAREDLIB
#ifdef LDK_COMPILER_MSVC
#ifdef LDK_EXPORT_API
#ifdef LDK_ENGINE
#define LDK_API __declspec(dllexport)
#else
#define LDK_API __declspec(dllimport)
Expand Down
2,560 changes: 1,285 additions & 1,275 deletions include/ldk/gl.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion include/ldk/ldk.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*
* ldk.h
*
* This is the main public include for projects using this engine.
* This is the main include for projects using the engine.
*
*/

Expand Down
10 changes: 4 additions & 6 deletions include/ldk/maths.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extern "C" {
LDK_API int32 floatIsGreaterThanOrEqualEpsilon(float a, float b, float epsilon);
LDK_API int32 floatIsLessThanOrEqualEpsilon(float a, float b, float epsilon);
LDK_API int32 floatsAreAlmostEqualRelativeEpsilon(float a, float b, float relativeEpsilon);
LDK_API bool floatIsMultipleEpsilon(double a, double b, float epsilon);
LDK_API bool floatIsMultipleEpsilon(float a, float b, float epsilon);



Expand Down Expand Up @@ -372,11 +372,9 @@ extern "C" {

typedef struct
{
float minX;
float minY;
float maxX;
float maxY;
}LDKBoundingBox;
Vec3 min;
Vec3 max;
}LDKAABB;

typedef struct
{
Expand Down
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ list(APPEND SOURCE
${INCLUDE_DIR}/asset/config.h asset/config.c
)

# Use this list when building games

if (OPTION_BUILD_EDITOR)
list(APPEND SOURCE ${INCLUDE_DIR}/module/editor.h module/editor.c)
endif()
Expand Down Expand Up @@ -102,13 +104,13 @@ if (OPTION_BUILD_EDITOR)
add_library(ldk ${LIBTYPE} ${SOURCE})

target_compile_definitions(ldk PRIVATE
LDK_ENGINE
$<$<CONFIG:Release>:${Release_DEFINITIONS}>
$<$<CONFIG:RelWithDebInfo>:${RelWithDebInfo_DEFINITIONS}>
$<$<CONFIG:Debug>:${Debug_DEFINITIONS}>
$<$<CONFIG:MinSizeRel>:${MinSizeRel_DEFINITIONS}>
$<$<BOOL:${OPTION_BUILD_EDITOR}>:LDK_EDITOR>
$<$<BOOL:${OPTION_LDKSHAREDLIB}>:LDK_EXPORT_API>
$<$<BOOL:${OPTION_LDKSHAREDLIB}>:LDK_AS_SHARED_LIB>
$<$<BOOL:${OPTION_LDKSHAREDLIB}>:LDK_SHAREDLIB>
LDK_BUILD_TYPE="$<CONFIG>"
)

Expand Down
16 changes: 10 additions & 6 deletions src/asset/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool ldkAssetMeshLoadFunc(const char* path, LDKAsset asset)
mesh->numIndices = 0;
mesh->numSurfaces = 0;
mesh->numMaterials = 0;
memset(&mesh->boundingBox, 0, sizeof(LDKBoundingBox));
memset(&mesh->aabb, 0, sizeof(LDKAABB));
memset(&mesh->boundingSphere, 0, sizeof(LDKBoundingSphere));

bool error = false;
Expand Down Expand Up @@ -326,12 +326,16 @@ bool ldkAssetMeshLoadFunc(const char* path, LDKAsset asset)
{
char* minX = rhs;
char* minY = strtok_r(NULL, SPACE_OR_TAB, &context);
char* minZ = strtok_r(NULL, SPACE_OR_TAB, &context);
char* maxX = strtok_r(NULL, SPACE_OR_TAB, &context);
char* maxY = strtok_r(NULL, SPACE_OR_TAB, &context);
s_parseFloat(path, lineNumber, minX, &mesh->boundingBox.minX);
s_parseFloat(path, lineNumber, minY, &mesh->boundingBox.minY);
s_parseFloat(path, lineNumber, maxX, &mesh->boundingBox.maxX);
s_parseFloat(path, lineNumber, maxY, &mesh->boundingBox.maxY);
char* maxZ = strtok_r(NULL, SPACE_OR_TAB, &context);
s_parseFloat(path, lineNumber, minX, &mesh->aabb.min.x);
s_parseFloat(path, lineNumber, minY, &mesh->aabb.min.y);
s_parseFloat(path, lineNumber, minZ, &mesh->aabb.min.z);
s_parseFloat(path, lineNumber, maxX, &mesh->aabb.max.x);
s_parseFloat(path, lineNumber, maxY, &mesh->aabb.max.y);
s_parseFloat(path, lineNumber, maxZ, &mesh->aabb.max.z);
}
}
line = strtok_r(NULL, LINEBREAK, &lineBreakContext);
Expand Down Expand Up @@ -364,7 +368,7 @@ bool ldkAssetMeshLoadFunc(const char* path, LDKAsset asset)
LDKMesh* ldkQuadMeshCreate(LDKHAsset material)
{
LDKMesh* mesh = ldkAssetNew(LDKMesh);
memset(&mesh->boundingBox, 0, sizeof(LDKBoundingBox));
memset(&mesh->aabb, 0, sizeof(LDKAABB));
memset(&mesh->boundingSphere, 0, sizeof(LDKBoundingSphere));

// Indices
Expand Down
Loading

0 comments on commit 682f007

Please sign in to comment.