mirror of
https://github.com/simtactics/mysimulation.git
synced 2025-07-09 16:10:31 -04:00
Fixed the build system for Linux
This commit is contained in:
parent
aa50ab78ec
commit
6393955683
11 changed files with 103 additions and 43 deletions
|
@ -28,7 +28,7 @@ if(WIN32)
|
|||
set(FILEHANDLER_SOURCES ${FILEHANDLER_SOURCES} resource.rc)
|
||||
endif()
|
||||
|
||||
include_directories(${FILEHANDLER_INCLUDE_DIR} ${LIBMPG123_INCLUDE_DIR} ${LIBJPEGTURBO_INCLUDE_DIR} ${LIBPNG_INCLUDE_DIR})
|
||||
include_directories(${FILEHANDLER_INCLUDE} ${LIBMPG123_INCLUDE} ${LIBJPEGTURBO_INCLUDE} ${LIBPNG_INCLUDE})
|
||||
|
||||
#### Static library (uncomment to build)
|
||||
#add_library(FileHandler_static STATIC ${FILEHANDLER_SOURCES})
|
||||
|
@ -38,12 +38,15 @@ include_directories(${FILEHANDLER_INCLUDE_DIR} ${LIBMPG123_INCLUDE_DIR} ${LIBJPE
|
|||
# CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
add_library(FileHandler_shared SHARED ${FILEHANDLER_SOURCES})
|
||||
if(WIN32)
|
||||
set_target_properties(FileHandler_shared PROPERTIES OUTPUT_NAME "FileHandler${FILEHANDLER_SERIES}")
|
||||
else()
|
||||
set_target_properties(FileHandler_shared PROPERTIES OUTPUT_NAME "FileHandler")
|
||||
endif()
|
||||
set_target_properties(FileHandler_shared PROPERTIES
|
||||
OUTPUT_NAME "FileHandler${FILEHANDLER_SERIES}"
|
||||
VERSION ${FILEHANDLER_SERIES}${FILEHANDLER_MAJOR}.${FILEHANDLER_MINOR}.0
|
||||
SOVERSION ${FILEHANDLER_SERIES}${FILEHANDLER_MAJOR}
|
||||
VERSION ${FILEHANDLER_SERIES}.${FILEHANDLER_MAJOR}.${FILEHANDLER_MINOR}
|
||||
PREFIX ""
|
||||
IMPORT_PREFIX ""
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
|
||||
target_link_libraries(FileHandler_shared far_static iff_static jpegturbo_static libmpg123_static libpng_static zlib_static m)
|
||||
target_link_libraries(FileHandler_shared far_static iff_static ${LIBJPEG_LINK} ${LIBMPG123_LINK} ${LIBPNG_LINK} ${ZLIB_LINK} m)
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
*/
|
||||
|
||||
#include "FileHandler.hpp"
|
||||
#include <setjmp.h> //Used by libpng
|
||||
#include <setjmp.h> //Used for libpng
|
||||
#include <jpeglib.h>
|
||||
#include <jerror.h>
|
||||
#include <png.h>
|
||||
#include "bmp/read_bmp.h"
|
||||
|
||||
|
@ -117,13 +118,44 @@ static uint8_t * ReadBMP(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
|||
return OutData;
|
||||
}
|
||||
|
||||
|
||||
// libjpeg-turbo v6 doesn't support jpeg_mem_src, so we have to implement it here
|
||||
static void term_source(j_decompress_ptr){}
|
||||
static int fill_mem_input_buffer(j_decompress_ptr cinfo){
|
||||
ERREXIT(cinfo, JERR_FILE_READ);
|
||||
return FALSE;
|
||||
}
|
||||
static void skip_input_data(j_decompress_ptr cinfo, long bytes)
|
||||
{
|
||||
struct jpeg_source_mgr * src = cinfo->src;
|
||||
|
||||
if(bytes > (long) src->bytes_in_buffer){
|
||||
ERREXIT(cinfo, JERR_FILE_READ);
|
||||
return;
|
||||
}
|
||||
src->next_input_byte += bytes;
|
||||
src->bytes_in_buffer -= bytes;
|
||||
}
|
||||
static uint8_t * ReadJPG(Image_t * Image, const uint8_t * InData, size_t FileSize){
|
||||
//Initialize
|
||||
jpeg_decompress_struct cinfo;
|
||||
jpeg_error_mgr jerr;
|
||||
cinfo.err = jpeg_std_error(&jerr);
|
||||
jpeg_create_decompress(&cinfo);
|
||||
jpeg_mem_src(&cinfo, (unsigned char*) InData, FileSize);
|
||||
|
||||
if (cinfo.src == NULL)
|
||||
cinfo.src = (jpeg_source_mgr *)
|
||||
(*cinfo.mem->alloc_small)((j_common_ptr) &cinfo, JPOOL_PERMANENT, sizeof(jpeg_source_mgr));
|
||||
|
||||
jpeg_source_mgr *src = cinfo.src;
|
||||
src->init_source = term_source;
|
||||
src->fill_input_buffer = fill_mem_input_buffer;
|
||||
src->skip_input_data = skip_input_data;
|
||||
src->resync_to_restart = jpeg_resync_to_restart;
|
||||
src->term_source = term_source;
|
||||
src->bytes_in_buffer = FileSize;
|
||||
src->next_input_byte = InData;
|
||||
|
||||
if(jpeg_read_header(&cinfo, TRUE) != JPEG_HEADER_OK){
|
||||
jpeg_destroy_decompress(&cinfo);
|
||||
return NULL;
|
||||
|
@ -174,8 +206,8 @@ struct pngdata_t {
|
|||
static void user_read_data(png_structp png_ptr, png_bytep data, png_size_t length){
|
||||
pngdata_t *pngdata = (pngdata_t *) png_get_io_ptr(png_ptr);
|
||||
if(length > pngdata->size) png_error(png_ptr, "");
|
||||
memcpy(data, pngdata->buffer, length);
|
||||
pngdata->buffer += length;
|
||||
memcpy(data, pngdata->buffer, length);
|
||||
pngdata->buffer += length;
|
||||
pngdata->size -= length;
|
||||
}
|
||||
static uint8_t * ReadPNG(Image_t * Image, const uint8_t * InData, size_t FileSize){
|
||||
|
@ -230,4 +262,4 @@ static uint8_t * ReadCUR(Image_t * Image, const uint8_t * InData, size_t FileSiz
|
|||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -264,8 +264,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
/* Find the timedelta */
|
||||
QueryPerformanceCounter(&CurrentTime);
|
||||
TimeDelta = (float)(CurrentTime.QuadPart-PreviousTime.QuadPart)/ClockFreq.QuadPart;
|
||||
if(TimeDelta < 0) TimeDelta = 0; /* Safe-guard in case of system delay */
|
||||
PreviousTime = CurrentTime;
|
||||
if(TimeDelta < 0 || TimeDelta > 5) /* Safe-guard in case of system delay */
|
||||
continue;
|
||||
|
||||
/* Draw */
|
||||
Demo.DrawScene(TimeDelta, keys);
|
||||
|
@ -275,6 +276,6 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
QueryPerformanceCounter(&CurrentTime);
|
||||
TimeDelta = (float)(CurrentTime.QuadPart-PreviousTime.QuadPart)/ClockFreq.QuadPart;
|
||||
TimeDelta = (FramePeriod - TimeDelta) * 1000;
|
||||
if(TimeDelta > 1) Sleep((unsigned) TimeDelta);
|
||||
if(TimeDelta > 1 && TimeDelta < 100) Sleep((unsigned) TimeDelta);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ else()
|
|||
add_definitions(-Dstricmp=strcasecmp)
|
||||
endif()
|
||||
|
||||
include_directories(${LIBGLDEMO_INCLUDE_DIR})
|
||||
include_directories(${FILEHANDLER_INCLUDE_DIR})
|
||||
include_directories(${LIBGLDEMO_INCLUDE} ${FILEHANDLER_INCLUDE})
|
||||
|
||||
#### Static library (uncomment to build)
|
||||
#add_library(libvitaboy_static STATIC ${LIBVITABOY_SOURCES})
|
||||
|
@ -33,18 +32,20 @@ include_directories(${FILEHANDLER_INCLUDE_DIR})
|
|||
# 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"
|
||||
OUTPUT_NAME "vitaboy${LIBVITABOY_SERIES}"
|
||||
VERSION ${LIBVITABOY_SERIES}.${LIBVITABOY_MAJOR}.${LIBVITABOY_MINOR}
|
||||
SOVERSION ${LIBVITABOY_SERIES}
|
||||
# msvc does not prepend 'lib' - do it here to have consistent name
|
||||
PREFIX "lib"
|
||||
IMPORT_PREFIX "lib"
|
||||
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_LIBS} FileHandler_shared m)
|
||||
target_link_libraries(Renderer libvitaboy_shared ${GLDEMO_LINK} FileHandler_shared m)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue