diff --git a/.gitignore b/.gitignore index 3aa1c8e..e757c80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # Build system +build/ _build/ _deps/ _dist/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 31aea05..327f14f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,12 +7,10 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_ROOT_DIR}) enable_language(ASM) -include(ConfigureTarget) - ######################################### #### Options option(BUILD_SHARED_LIBS "Build using shared libraries" ON) # default cmake -option(NIOTSO_BUILD_EXAMPLES "Build the render demos" OFF) +option(NIOTSO_BUILD_EXAMPLES "Build the render demos" ON) option(NIOTSO_BUILD_TOOLS "Build niotso tools" ON) if(WIN32) diff --git a/Tools/CMakeLists.txt b/Tools/CMakeLists.txt index 06ce7b5..325361c 100644 --- a/Tools/CMakeLists.txt +++ b/Tools/CMakeLists.txt @@ -1,4 +1,5 @@ add_subdirectory(far-extract) +add_subdirectory(vitaboy-parse) #add_subdirectory(FARDive) #add_subdirectory(hitutils) diff --git a/Tools/vitaboy-parse/CMakeLists.txt b/Tools/vitaboy-parse/CMakeLists.txt new file mode 100644 index 0000000..a4120bc --- /dev/null +++ b/Tools/vitaboy-parse/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.6...3.29) +project(vitaboy-parse) + +include_directories(${vitaboy_SOURCE_DIR} ${filehandler_SOURCE_DIR}) + +add_executable(vbparse vbparse.cpp) +target_link_libraries(vbparse libvitaboy FileHandler) + +set_target_properties(vbparse PROPERTIES FOLDER tools) \ No newline at end of file diff --git a/niotso/libvitaboy/vbparse.cpp b/Tools/vitaboy-parse/vbparse.cpp similarity index 99% rename from niotso/libvitaboy/vbparse.cpp rename to Tools/vitaboy-parse/vbparse.cpp index 2a84f22..44c6b3e 100644 --- a/niotso/libvitaboy/vbparse.cpp +++ b/Tools/vitaboy-parse/vbparse.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include "libvitaboy.hpp" diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..47d63bd --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,5 @@ +add_subdirectory(gldemo) +add_subdirectory(rlgldemo) + +#TODO: +# Set Properties -> Debugging -> Working Directory from $(ProjectDir) to $(Outdir) \ No newline at end of file diff --git a/examples/gldemo/CMakeLists.txt b/examples/gldemo/CMakeLists.txt index 4e5c3f5..9ea3ee4 100644 --- a/examples/gldemo/CMakeLists.txt +++ b/examples/gldemo/CMakeLists.txt @@ -2,21 +2,16 @@ cmake_minimum_required(VERSION 2.6...3.29) project(libgldemo) if(WIN32) - set(GLDEMO_EXE WIN32) - set(GLDEMO_LINK mingw32 libgldemo_static opengl32 glu32) -else() - set(GLDEMO_EXE "") - set(GLDEMO_LINK libgldemo_static Xxf86vm rt Xext X11 GL GLU) -endif() - -if(WIN32) - set(LIBGLDEMO_SOURCES wgl.c) + set(LIBGLDEMO_SOURCES WIN32 wgl.c) + set(GLDEMO_LINK libvitaboy FileHandler opengl32 glu32) else() set(LIBGLDEMO_SOURCES glx.c) + set(GLDEMO_LINK libvitaboy FileHandler Xxf86vm rt Xext X11 GL GLU) add_definitions(-D_POSIX_C_SOURCE=200112) endif() -add_library(libgldemo_static STATIC ${LIBGLDEMO_SOURCES}) -set_target_properties(libgldemo_static PROPERTIES - OUTPUT_NAME "gldemo" - CLEAN_DIRECT_OUTPUT 1) +include_directories(${libvitaboy_SOURCE_DIR} ${filehandler_SOURCE_DIR}) +add_executable(libgldemo ${LIBGLDEMO_SOURCES} Renderer.cpp) +target_link_libraries(libgldemo ${GLDEMO_LINK}) + +set_target_properties(libgldemo PROPERTIES FOLDER examples) diff --git a/niotso/libvitaboy/Renderer.cpp b/examples/gldemo/Renderer.cpp similarity index 64% rename from niotso/libvitaboy/Renderer.cpp rename to examples/gldemo/Renderer.cpp index 23fcbd6..8ebb58a 100644 --- a/niotso/libvitaboy/Renderer.cpp +++ b/examples/gldemo/Renderer.cpp @@ -46,11 +46,20 @@ n: Animate the character F11: Enter/leave fullscreen */ +#ifdef _WIN32 + #include + #include + #include +#else + #define APIENTRY + #include + #include +#endif #include #include -#include -#include "libvitaboy.hpp" +#include "libgldemo.h" +#include static float zoom = -10; struct BasicVertex_t { @@ -60,21 +69,21 @@ struct CharacterPlacement_t { BasicVertex_t Translation; BasicVertex_t Rotation; }; -static CharacterPlacement_t Character = {{0,-3,0}, {0,0,0}}; +static CharacterPlacement_t Character = { {0,-3,0}, {0,0,0} }; static Skeleton_t Skeleton; static const unsigned TextureCount = 3; static unsigned texture[3]; enum { Texture_Body, Texture_Head, Texture_Hand }; -static const char* const TexturePaths[] = {"body.jpg", "head.jpg", "hand.jpg"}; +static const char* const TexturePaths[] = { "body.jpg", "head.jpg", "hand.jpg" }; static const unsigned MeshCount = 4; static Mesh_t Meshes[4]; enum { Mesh_Body, Mesh_Head, Mesh_LHand, Mesh_RHand }; -static const char* const MeshPaths[] = {"body.mesh", "head.mesh", "lhand.mesh", "rhand.mesh" }; +static const char* const MeshPaths[] = { "body.mesh", "head.mesh", "lhand.mesh", "rhand.mesh" }; static const unsigned Mesh_UseTexture[] = { Texture_Body, Texture_Head, Texture_Hand, Texture_Hand }; -static const char* const MeshActivate[] = {NULL, "HEAD", "L_HAND", "R_HAND"}; +static const char* const MeshActivate[] = { NULL, "HEAD", "L_HAND", "R_HAND" }; static Animation_t Animation; static float AnimationTime = 0; @@ -84,9 +93,9 @@ static bool ShowSkeleton = true; static bool PressedQ = false; -static void DisplayFileError(const char * Filename){ - const char * Message; - switch(File::Error){ +static void DisplayFileError(const char* Filename) { + const char* Message; + switch (File::Error) { case FERR_NOT_FOUND: Message = "%s does not exist."; break; @@ -114,15 +123,15 @@ static void DisplayFileError(const char * Filename){ static int LoadTextures() { glGenTextures(3, texture); - for(int i=0; i<3; i++){ - Image_t * Image = File::ReadImageFile(TexturePaths[i]); - if(!Image){ + for (int i = 0; i < 3; i++) { + Image_t* Image = File::ReadImageFile(TexturePaths[i]); + if (!Image) { DisplayFileError(TexturePaths[i]); return false; } glBindTexture(GL_TEXTURE_2D, texture[i]); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, Image->Width, Image->Height, 0, GL_BGR, GL_UNSIGNED_BYTE, Image->Data); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, Image->Width, Image->Height, 0, GL_BGR_EXT, GL_UNSIGNED_BYTE, Image->Data); free(Image->Data); free(Image); @@ -136,7 +145,7 @@ static int LoadTextures() static int InitGL() { - if(!LoadTextures()) + if (!LoadTextures()) return false; glShadeModel(GL_SMOOTH); @@ -144,7 +153,7 @@ static int InitGL() glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); - glEnable(GL_RESCALE_NORMAL); + glEnable(GL_NORMALIZE); glDisable(GL_BLEND); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); @@ -160,7 +169,7 @@ static int ResizeScene(uint16_t width, uint16_t height) glLoadIdentity(); // Calculate The Aspect Ratio Of The Window - gluPerspective(45.0f, (GLfloat)width/(GLfloat)height, 0.1f, 100.0f); + gluPerspective(45.0f, (GLfloat)width / (GLfloat)height, 0.1f, 100.0f); // glScalef(-1.0f, 1.0f, 1.0f); glMatrixMode(GL_MODELVIEW); @@ -178,20 +187,20 @@ static void TransformVertices(Bone_t& Bone) unsigned MeshIndex = 0; unsigned BoneIndex; - for(unsigned i=1; i 1){ - for(unsigned i=0; i 1) { + for (unsigned i = 0; i < Bone.ChildrenCount; i++) { glPushMatrix(); TransformVertices(*Bone.Children[i]); glPopMatrix(); @@ -230,28 +240,27 @@ static void TransformVertices(Bone_t& Bone) static void BlendVertices() { - for(unsigned i=0; i 1){ - for(unsigned i=0; i 1) { + for (unsigned i = 0; i < Bone.ChildrenCount; i++) { glPushMatrix(); DrawBonesSkeleton(*Bone.Children[i]); glPopMatrix(); @@ -354,37 +364,38 @@ static void DrawSkeleton() static int DrawScene(float TimeDelta, uint8_t keys[256]) { //Handle user interaction - if(keys['A']) /*{if(zoom <=-1.0f) zoom+=0.05f; }*/ zoom+=3*TimeDelta; - if(keys['S']) /*{if(zoom >=-10.0f) zoom-=0.05f; }*/ zoom-=3*TimeDelta; - if(keys[KEY_UP]){ if((Character.Rotation.x-=60*TimeDelta) <=-360) Character.Rotation.x+=360; } - if(keys[KEY_DOWN]){ if((Character.Rotation.x+=60*TimeDelta) >=360) Character.Rotation.x-=360; } - if(keys[KEY_LEFT]){ if((Character.Rotation.y-=60*TimeDelta) <=-360) Character.Rotation.y+=360; } - if(keys[KEY_RIGHT]){ if((Character.Rotation.y+=60*TimeDelta) >=360) Character.Rotation.y-=360; } - if(keys['X']){ if((Character.Rotation.z-=60*TimeDelta) <=-360) Character.Rotation.z+=360; } - if(keys['Z']){ if((Character.Rotation.z+=60*TimeDelta) >=360) Character.Rotation.z-=360; } - if(keys['K']){ Character.Translation.y-=3*TimeDelta; } - if(keys['I']){ Character.Translation.y+=3*TimeDelta; } - if(keys['J']){ Character.Translation.x-=3*TimeDelta; } - if(keys['L']){ Character.Translation.x+=3*TimeDelta; } - if(keys['Q']){ if(!PressedQ){ PressedQ = 1; ShowSkeleton = !ShowSkeleton; }} else PressedQ = 0; - if(keys['N']){ AdvanceFrame(Skeleton, Animation, TimeDelta); } + if (keys['A']) /*{if(zoom <=-1.0f) zoom+=0.05f; }*/ zoom += 3 * TimeDelta; + if (keys['S']) /*{if(zoom >=-10.0f) zoom-=0.05f; }*/ zoom -= 3 * TimeDelta; + if (keys[KEY_UP]) { if ((Character.Rotation.x -= 60 * TimeDelta) <= -360) Character.Rotation.x += 360; } + if (keys[KEY_DOWN]) { if ((Character.Rotation.x += 60 * TimeDelta) >= 360) Character.Rotation.x -= 360; } + if (keys[KEY_LEFT]) { if ((Character.Rotation.y -= 60 * TimeDelta) <= -360) Character.Rotation.y += 360; } + if (keys[KEY_RIGHT]) { if ((Character.Rotation.y += 60 * TimeDelta) >= 360) Character.Rotation.y -= 360; } + if (keys['X']) { if ((Character.Rotation.z -= 60 * TimeDelta) <= -360) Character.Rotation.z += 360; } + if (keys['Z']) { if ((Character.Rotation.z += 60 * TimeDelta) >= 360) Character.Rotation.z -= 360; } + if (keys['K']) { Character.Translation.y -= 3 * TimeDelta; } + if (keys['I']) { Character.Translation.y += 3 * TimeDelta; } + if (keys['J']) { Character.Translation.x -= 3 * TimeDelta; } + if (keys['L']) { Character.Translation.x += 3 * TimeDelta; } + if (keys['Q']) { if (!PressedQ) { PressedQ = 1; ShowSkeleton = !ShowSkeleton; } } + else PressedQ = 0; + if (keys['N']) { AdvanceFrame(Skeleton, Animation, TimeDelta); } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the screen and the depth buffer glLoadIdentity(); glTranslatef(Character.Translation.x, Character.Translation.y, zoom + Character.Translation.z); - glRotatef(Character.Rotation.x,1.0f,0.0f,0.0f); - glRotatef(Character.Rotation.y,0.0f,1.0f,0.0f); - glRotatef(Character.Rotation.z,0.0f,0.0f,1.0f); + glRotatef(Character.Rotation.x, 1.0f, 0.0f, 0.0f); + glRotatef(Character.Rotation.y, 0.0f, 1.0f, 0.0f); + glRotatef(Character.Rotation.z, 0.0f, 0.0f, 1.0f); - if(ShowMesh){ + if (ShowMesh) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glColor3f(1.0, 1.0, 1.0); DrawMeshes(); } - if(ShowSkeleton){ + if (ShowSkeleton) { glClear(GL_DEPTH_BUFFER_BIT); DrawSkeleton(); } @@ -392,9 +403,9 @@ static int DrawScene(float TimeDelta, uint8_t keys[256]) return true; } -static bool Read(const char * Filename, uint8_t ** InData){ +static bool Read(const char* Filename, uint8_t** InData) { *InData = File::ReadFile(Filename); - if(*InData != NULL){ + if (*InData != NULL) { VBFile.set(*InData, File::FileSize); return true; } @@ -405,21 +416,21 @@ static bool Read(const char * Filename, uint8_t ** InData){ static int Startup() { - uint8_t * InData; + uint8_t* InData; - if(!Read("skeleton.skel", &InData)) + if (!Read("skeleton.skel", &InData)) return 0; ReadSkeleton(Skeleton); free(InData); - for(unsigned i=0; i #include -#include +#ifdef _WIN32 + #include +#else + #define APIENTRY + #include +#endif typedef struct { const char *__restrict Title; diff --git a/examples/gldemo/wgl.c b/examples/gldemo/wgl.c index f70e0c1..689ed98 100644 --- a/examples/gldemo/wgl.c +++ b/examples/gldemo/wgl.c @@ -15,7 +15,8 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - +#include +#include #include "libgldemo.h" static HWND hWnd = NULL; diff --git a/examples/rlgldemo/CMakeLists.txt b/examples/rlgldemo/CMakeLists.txt index 8a6fb61..4f20776 100644 --- a/examples/rlgldemo/CMakeLists.txt +++ b/examples/rlgldemo/CMakeLists.txt @@ -4,9 +4,6 @@ project(rlgldemo) # Adding Raylib include(FetchContent) set(FETCHCONTENT_QUIET FALSE) -set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples -set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # don't build the supplied example games - #set raylib settings add_compile_definitions(SUPPORT_FILEFORMAT_JPG) @@ -17,20 +14,18 @@ FetchContent_Declare( GIT_PROGRESS TRUE ) FetchContent_MakeAvailable(raylib) +set_target_properties(raylib PROPERTIES FOLDER examples/deps) +set_target_properties(glfw PROPERTIES FOLDER examples/deps) +set_target_properties(update_mappings PROPERTIES FOLDER examples/deps) -include_directories(${FILEHANDLER_INCLUDE}) -include_directories(${VITABOY_INCLUDE}) +include_directories(${filehandler_SOURCE_DIR}) +include_directories(${libvitaboy_SOURCE_DIR}) # Adding our source files -file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/*.cpp") # Define PROJECT_SOURCES as a list of all source files -set(PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/*.h") # Define PROJECT_INCLUDE to be the path to the include directory of the project +set(RLGL_DEMO_SOURCES main.cpp) # Declaring our executable -add_executable(${PROJECT_NAME}) -target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES}) -target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_INCLUDE}) -target_link_libraries(${PROJECT_NAME} PRIVATE raylib libvitaboy_static FileHandler_static) +add_executable(rlgldemo ${RLGL_DEMO_SOURCES}) +target_link_libraries(rlgldemo PRIVATE raylib libvitaboy FileHandler) -# Setting ASSETS_PATH -target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets/") # Set the asset path macro to the absolute path on the dev machine -#target_compile_definitions(${PROJECT_NAME} PUBLIC ASSETS_PATH="./assets") # Set the asset path macro in release mode to a relative path that assumes the assets folder is in the same directory as the game executable \ No newline at end of file +set_target_properties(rlgldemo PROPERTIES FOLDER examples) diff --git a/examples/rlgldemo/main.cpp b/examples/rlgldemo/main.cpp index e66d17b..73329c0 100644 --- a/examples/rlgldemo/main.cpp +++ b/examples/rlgldemo/main.cpp @@ -37,8 +37,8 @@ #include "rlgl.h" #include -#include -#include "../libvitaboy/libvitaboy.hpp" +#include +#include #define SCREEN_WIDTH (800) #define SCREEN_HEIGHT (600) diff --git a/niotso/CMakeLists.txt b/niotso/CMakeLists.txt index 58b02df..b076052 100644 --- a/niotso/CMakeLists.txt +++ b/niotso/CMakeLists.txt @@ -1,3 +1,4 @@ add_subdirectory(archive) add_subdirectory(format) add_subdirectory(filehandler) +add_subdirectory(libvitaboy) diff --git a/niotso/filehandler/CMakeLists.txt b/niotso/filehandler/CMakeLists.txt index 6b16c55..8ade1f7 100644 --- a/niotso/filehandler/CMakeLists.txt +++ b/niotso/filehandler/CMakeLists.txt @@ -17,6 +17,6 @@ if(WIN32) endif() include_directories(${format_SOURCE_DIR} ${zlib_SOURCE_DIR} ${libpng_SOURCE_DIR} ${jpeg_SOURCE_DIR}) -add_library(FileHandler SHARED ${FILEHANDLER_SOURCES} ${FILEHANDLER_HEADERS}) # remove shared, cmake should handle this +add_library(FileHandler STATIC ${FILEHANDLER_SOURCES} ${FILEHANDLER_HEADERS}) # remove shared, cmake should handle this target_link_libraries(FileHandler format far iff zlib libpng jpegturbo) diff --git a/niotso/filehandler/FileHandler.hpp b/niotso/filehandler/FileHandler.hpp index ca268a1..cdcf590 100644 --- a/niotso/filehandler/FileHandler.hpp +++ b/niotso/filehandler/FileHandler.hpp @@ -66,22 +66,21 @@ struct Sound_t { uint8_t * Data; }; -namespace File { +namespace File +{ + inline size_t GetFileSize(FILE * hFile){ + fseek(hFile, 0, SEEK_END); + size_t FileSize = ftell(hFile); + fseek(hFile, 0, SEEK_SET); + return FileSize; + } -inline size_t GetFileSize(FILE * hFile){ - fseek(hFile, 0, SEEK_END); - size_t FileSize = ftell(hFile); - fseek(hFile, 0, SEEK_SET); - return FileSize; -} - -fhexport extern int Error; -fhexport extern size_t FileSize; - -fhexport uint8_t * ReadFile(const char * Filename); -fhexport Image_t * ReadImageFile(const char * Filename); -fhexport Sound_t * ReadSoundFile(const char * Filename); + extern int Error; + extern size_t FileSize; + uint8_t * ReadFile(const char * Filename); + Image_t * ReadImageFile(const char * Filename); + Sound_t * ReadSoundFile(const char * Filename); } #endif \ No newline at end of file diff --git a/niotso/format/CMakeLists.txt b/niotso/format/CMakeLists.txt index 8e5b56e..8bfd5b9 100644 --- a/niotso/format/CMakeLists.txt +++ b/niotso/format/CMakeLists.txt @@ -21,4 +21,3 @@ set(FORMAT_SOURCES add_library(format SHARED ${FORMAT_SOURCES} ${FORMAT_HEADERS}) # don't specify shared, cmake settings should take care of that target_include_directories(format PUBLIC ${FORMAT_HEADERS}) -set_target_properties(format PROPERTIES FOLDER format) diff --git a/niotso/libvitaboy/CHANGES b/niotso/libvitaboy/CHANGES index 9ad471a..03ef88b 100644 --- a/niotso/libvitaboy/CHANGES +++ b/niotso/libvitaboy/CHANGES @@ -1,3 +1,9 @@ +libvitaboy 1.0.2 (2024-05-13) jip boesenkool + + * Reorganized the file structure, split tools into seperate tools folder and added + * Rewrote cmake + * pulled GL1 renderer into the demo that uses it + libvitaboy 1.0.1 (2012-03-10) Fatbag * Corrected the BlendVertices function; blend vertices tug real vertices, not the other way around diff --git a/niotso/libvitaboy/CMakeLists.txt b/niotso/libvitaboy/CMakeLists.txt index 5a6a108..d25ad66 100644 --- a/niotso/libvitaboy/CMakeLists.txt +++ b/niotso/libvitaboy/CMakeLists.txt @@ -1,10 +1,6 @@ cmake_minimum_required(VERSION 2.6...3.29) project(libvitaboy) -set(LIBVITABOY_SERIES 0) -set(LIBVITABOY_MAJOR 0) -set(LIBVITABOY_MINOR 1) - set(LIBVITABOY_SOURCES anim.cpp apr.cpp @@ -16,36 +12,20 @@ set(LIBVITABOY_SOURCES oft.cpp po.cpp skel.cpp + Log.hpp + config.h ) + +set(LIBVITABOY_HEADERS + libvitaboy.hpp +) + if(WIN32) set(LIBVITABOY_SOURCES ${LIBVITABOY_SOURCES} resource.rc) else() add_definitions(-Dstricmp=strcasecmp) endif() -include_directories(${LIBGLDEMO_INCLUDE} ${FILEHANDLER_INCLUDE}) - -#### Static library (uncomment to build) -#add_library(libvitaboy_static STATIC ${LIBVITABOY_SOURCES}) -#set_target_properties(libvitaboy_static PROPERTIES -# OUTPUT_NAME "vitaboy" -# CLEAN_DIRECT_OUTPUT 1) - -add_library(libvitaboy_shared SHARED ${LIBVITABOY_SOURCES}) -if(WIN32) - set_target_properties(libvitaboy_shared PROPERTIES OUTPUT_NAME "vitaboy${LIBVITABOY_SERIES}") -else() - set_target_properties(libvitaboy_shared PROPERTIES OUTPUT_NAME "vitaboy") -endif() -set_target_properties(libvitaboy_shared PROPERTIES - COMPILE_FLAGS "-fvisibility=default" - VERSION ${LIBVITABOY_SERIES}.${LIBVITABOY_MAJOR}.${LIBVITABOY_MINOR} - PREFIX "lib" - IMPORT_PREFIX "lib" - CLEAN_DIRECT_OUTPUT 1) - -add_executable(vbparse vbparse.cpp) -target_link_libraries(vbparse libvitaboy_shared FileHandler_shared) - -add_executable(Renderer ${GLDEMO_EXE} Renderer.cpp) -target_link_libraries(Renderer libvitaboy_shared ${GLDEMO_LINK} FileHandler_shared m) +include_directories(${vitaboy_SOURCE_DIR} ${filehandler_SOURCE_DIR}) +add_library(libvitaboy STATIC ${LIBVITABOY_SOURCES} ${LIBVITABOY_HEADERS}) # don't specify shared, cmake settings should take care of that +target_include_directories(libvitaboy PUBLIC ${LIBVITABOY_HEADERS}) diff --git a/niotso/libvitaboy/Log.hpp b/niotso/libvitaboy/Log.hpp new file mode 100644 index 0000000..de2ecff --- /dev/null +++ b/niotso/libvitaboy/Log.hpp @@ -0,0 +1,10 @@ +#ifndef LIBVITABOY_LOG_HPP +#define LIBVITABOY_LOG_HPP + +#ifdef NDEBUG + #define vita_printf(...) +#else + #define vita_printf(...) printf(__VA_ARGS__) +#endif + +#endif \ No newline at end of file diff --git a/niotso/libvitaboy/anim.cpp b/niotso/libvitaboy/anim.cpp index 612cb8a..1f51105 100644 --- a/niotso/libvitaboy/anim.cpp +++ b/niotso/libvitaboy/anim.cpp @@ -17,34 +17,35 @@ */ #include "libvitaboy.hpp" +#include "Log.hpp" static unsigned motionnumber = 0; void ReadAnimation(Animation_t& Animation){ - printf("===== Animation =====\n"); + vita_printf("===== Animation =====\n"); Animation.Version = VBFile.readint32(); - printf("Version: %u\n", Animation.Version); + vita_printf("Version: %u\n", Animation.Version); Animation.Name = VBFile.readstring2(); - printf("Name: %s\n", Animation.Name); + vita_printf("Name: %s\n", Animation.Name); Animation.Duration = VBFile.readfloat(); - printf("Duration: %g\n", Animation.Duration/1000); + vita_printf("Duration: %g\n", Animation.Duration/1000); Animation.Distance = VBFile.readfloat(); - printf("Distance: %g\n", Animation.Distance); + vita_printf("Distance: %g\n", Animation.Distance); Animation.IsMoving = VBFile.readint8(); - printf("IsMoving: %u\n", Animation.IsMoving); + vita_printf("IsMoving: %u\n", Animation.IsMoving); Animation.TranslationsCount = VBFile.readint32(); - printf("TranslationsCount: %u\n", Animation.TranslationsCount); + vita_printf("TranslationsCount: %u\n", Animation.TranslationsCount); Animation.TranslationsOffset = VBFile.getpos(); VBFile.seekto(Animation.TranslationsOffset + 12*Animation.TranslationsCount); Animation.RotationsCount = VBFile.readint32(); - printf("RotationsCount: %u\n", Animation.RotationsCount); + vita_printf("RotationsCount: %u\n", Animation.RotationsCount); Animation.RotationsOffset = VBFile.getpos(); VBFile.seekto(Animation.RotationsOffset + 16*Animation.RotationsCount); Animation.MotionsCount = VBFile.readint32(); - printf("MotionsCount: %u\n", Animation.MotionsCount); + vita_printf("MotionsCount: %u\n", Animation.MotionsCount); Animation.Motions = (Motion_t*) malloc(Animation.MotionsCount * sizeof(Motion_t)); for(unsigned i=0; i #include "libvitaboy.hpp" +#include "Log.hpp" VBFile_t VBFile; void ReadAsset(Asset_t& Asset, bool ReadGroup){ Asset.Group = (ReadGroup) ? VBFile.readint32() : 0xA96F6D42; - printf(" | Group: %u\n", Asset.Group); + vita_printf(" | Group: %u\n", Asset.Group); Asset.File = VBFile.readint32(); - printf(" | File: %u\n", Asset.File); + vita_printf(" | File: %u\n", Asset.File); Asset.Type = VBFile.readint32(); - printf(" | Type: %u\n", Asset.Type); + vita_printf(" | Type: %u\n", Asset.Type); } void ReadPropEntry(KeyValuePair_t& Entry){ Entry.Key = VBFile.readstring(); - printf(" | | | | | Key: %s\n", Entry.Key); + vita_printf(" | | | | | Key: %s\n", Entry.Key); Entry.Value = VBFile.readstring(); - printf(" | | | | | Value: %s\n", Entry.Value); + vita_printf(" | | | | | Value: %s\n", Entry.Value); } void ReadPropEntries(Prop_t& Prop){ unsigned count = Prop.EntriesCount = VBFile.readint32(); - printf(" | | | | EntriesCount: %u\n", Prop.EntriesCount); + vita_printf(" | | | | EntriesCount: %u\n", Prop.EntriesCount); Prop.Entries = (KeyValuePair_t*) malloc(count * sizeof(KeyValuePair_t)); for(unsigned i=0; i