diff --git a/doomclassic/doom/i_sound_openal.cpp b/doomclassic/doom/i_sound_openal.cpp index 554ae2fc..9ee0015e 100644 --- a/doomclassic/doom/i_sound_openal.cpp +++ b/doomclassic/doom/i_sound_openal.cpp @@ -53,8 +53,8 @@ If you have questions concerning this license or the applicable additional terms #include "w_wad.h" #include "d_main.h" #include "doomdef.h" -#include "../timidity/timidity.h" -#include "../timidity/controls.h" +#include "libs/timidity/timidity.h" +#include "libs/timidity/controls.h" #include "sound/snd_local.h" diff --git a/neo/CMakeLists.txt b/neo/CMakeLists.txt index 48c3a01c..f23b877b 100644 --- a/neo/CMakeLists.txt +++ b/neo/CMakeLists.txt @@ -21,6 +21,15 @@ option(FFMPEG option(ONATIVE "Optimize for the host CPU" OFF) +option(USE_SYSTEM_ZLIB + "Use the system zlib instead of the bundled one" OFF) + +option(USE_SYSTEM_LIBPNG + "Use the system libpng instead of the bundled one" OFF) + +option(USE_SYSTEM_LIBJPEG + "Use the system libjpeg instead of the bundled one" OFF) + if(UNIX) set(OPENAL TRUE) endif() @@ -183,6 +192,44 @@ endif() # add_definitions(-DSTANDALONE) #endif() +if (USE_SYSTEM_ZLIB) + find_package(ZLIB REQUIRED) +endif(USE_SYSTEM_ZLIB) + +if (ZLIB_FOUND) + include_directories(${ZLIB_INCLUDE_DIRS}) + set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) +else (ZLIB_FOUND) + include_directories("libs/zlib") + set(ZLIB_LIBRARY "" ) +endif (ZLIB_FOUND) + +if(USE_SYSTEM_LIBPNG) +find_package(PNG REQUIRED) +endif (USE_SYSTEM_LIBPNG) + +if (PNG_FOUND) + include_directories(${PNG_INCLUDE_DIRS}) + set(PNG_LIBRARY ${PNG_LIBRARIES}) +else (PNG_FOUND) + include_directories("libs/png") + set(PNG_LIBRARY "" ) +endif (PNG_FOUND) + + +if(USE_SYSTEM_LIBJPEG) +find_package(JPEG REQUIRED) +endif(USE_SYSTEM_LIBJPEG) + +if (JPEG_FOUND) + include_directories(${JPEG_INCLUDE_DIRS}) + set(JPEG_LIBRARY ${JPEG_LIBRARIES}) + add_definitions(-DUSE_NEWER_JPEG) +else (JPEG_FOUND) + include_directories("libs/jpeg-6") + set(JPEG_LIBRARY "" ) +endif (JPEG_FOUND) + add_subdirectory(idlib) file(GLOB AAS_INCLUDES aas/*.h) @@ -316,75 +363,91 @@ file(GLOB RENDERER_OPENGL_SOURCES renderer/OpenGL/*.cpp) file(GLOB IRRXML_INCLUDES libs/irrxml/src/*.h) file(GLOB IRRXML_SOURCES libs/irrxml/src/*.cpp) - -set(JPEG_INCLUDES - libs/jpeg-6/jchuff.h - libs/jpeg-6/jconfig.h - libs/jpeg-6/jdct.h - libs/jpeg-6/jdhuff.h - libs/jpeg-6/jerror.h - libs/jpeg-6/jinclude.h - libs/jpeg-6/jmemsys.h - libs/jpeg-6/jmorecfg.h - libs/jpeg-6/jpegint.h - libs/jpeg-6/jpeglib.h - libs/jpeg-6/jversion.h) - -set(JPEG_SOURCES - libs/jpeg-6/jcapimin.cpp - libs/jpeg-6/jcapistd.cpp - libs/jpeg-6/jccoefct.cpp - libs/jpeg-6/jccolor.cpp - libs/jpeg-6/jcdctmgr.cpp - libs/jpeg-6/jchuff.cpp - libs/jpeg-6/jcinit.cpp - libs/jpeg-6/jcmainct.cpp - libs/jpeg-6/jcmarker.cpp - libs/jpeg-6/jcmaster.cpp - libs/jpeg-6/jcomapi.cpp - libs/jpeg-6/jcparam.cpp - libs/jpeg-6/jcphuff.cpp - libs/jpeg-6/jcprepct.cpp - libs/jpeg-6/jcsample.cpp - libs/jpeg-6/jctrans.cpp - libs/jpeg-6/jdapimin.cpp - libs/jpeg-6/jdapistd.cpp - libs/jpeg-6/jdatadst.cpp - libs/jpeg-6/jdatasrc.cpp - libs/jpeg-6/jdcoefct.cpp - libs/jpeg-6/jdcolor.cpp - libs/jpeg-6/jddctmgr.cpp - libs/jpeg-6/jdhuff.cpp - libs/jpeg-6/jdinput.cpp - libs/jpeg-6/jdmainct.cpp - libs/jpeg-6/jdmarker.cpp - libs/jpeg-6/jdmaster.cpp - libs/jpeg-6/jdmerge.cpp - libs/jpeg-6/jdphuff.cpp - libs/jpeg-6/jdpostct.cpp - libs/jpeg-6/jdsample.cpp - libs/jpeg-6/jdtrans.cpp - libs/jpeg-6/jerror.cpp - libs/jpeg-6/jfdctflt.cpp - libs/jpeg-6/jfdctfst.cpp - libs/jpeg-6/jfdctint.cpp - libs/jpeg-6/jidctflt.cpp - libs/jpeg-6/jidctfst.cpp - libs/jpeg-6/jidctint.cpp - libs/jpeg-6/jidctred.cpp - #libs/jpeg-6/jload.cpp - libs/jpeg-6/jmemmgr.cpp - libs/jpeg-6/jmemnobs.cpp - #libs/jpeg-6/jpegtran.cpp - libs/jpeg-6/jquant1.cpp - libs/jpeg-6/jquant2.cpp - libs/jpeg-6/jutils.cpp) -file(GLOB PNG_INCLUDES libs/png/*.h) -file(GLOB PNG_SOURCES libs/png/*.c) +if (NOT JPEG_FOUND) + set(JPEG_INCLUDES + libs/jpeg-6/jchuff.h + libs/jpeg-6/jconfig.h + libs/jpeg-6/jdct.h + libs/jpeg-6/jdhuff.h + libs/jpeg-6/jerror.h + libs/jpeg-6/jinclude.h + libs/jpeg-6/jmemsys.h + libs/jpeg-6/jmorecfg.h + libs/jpeg-6/jpegint.h + libs/jpeg-6/jpeglib.h + libs/jpeg-6/jversion.h) + set(JPEG_SOURCES + libs/jpeg-6/jcapimin.cpp + libs/jpeg-6/jcapistd.cpp + libs/jpeg-6/jccoefct.cpp + libs/jpeg-6/jccolor.cpp + libs/jpeg-6/jcdctmgr.cpp + libs/jpeg-6/jchuff.cpp + libs/jpeg-6/jcinit.cpp + libs/jpeg-6/jcmainct.cpp + libs/jpeg-6/jcmarker.cpp + libs/jpeg-6/jcmaster.cpp + libs/jpeg-6/jcomapi.cpp + libs/jpeg-6/jcparam.cpp + libs/jpeg-6/jcphuff.cpp + libs/jpeg-6/jcprepct.cpp + libs/jpeg-6/jcsample.cpp + libs/jpeg-6/jctrans.cpp + libs/jpeg-6/jdapimin.cpp + libs/jpeg-6/jdapistd.cpp + libs/jpeg-6/jdatadst.cpp + libs/jpeg-6/jdatasrc.cpp + libs/jpeg-6/jdcoefct.cpp + libs/jpeg-6/jdcolor.cpp + libs/jpeg-6/jddctmgr.cpp + libs/jpeg-6/jdhuff.cpp + libs/jpeg-6/jdinput.cpp + libs/jpeg-6/jdmainct.cpp + libs/jpeg-6/jdmarker.cpp + libs/jpeg-6/jdmaster.cpp + libs/jpeg-6/jdmerge.cpp + libs/jpeg-6/jdphuff.cpp + libs/jpeg-6/jdpostct.cpp + libs/jpeg-6/jdsample.cpp + libs/jpeg-6/jdtrans.cpp + libs/jpeg-6/jerror.cpp + libs/jpeg-6/jfdctflt.cpp + libs/jpeg-6/jfdctfst.cpp + libs/jpeg-6/jfdctint.cpp + libs/jpeg-6/jidctflt.cpp + libs/jpeg-6/jidctfst.cpp + libs/jpeg-6/jidctint.cpp + libs/jpeg-6/jidctred.cpp + #libs/jpeg-6/jload.cpp + libs/jpeg-6/jmemmgr.cpp + libs/jpeg-6/jmemnobs.cpp + #libs/jpeg-6/jpegtran.cpp + libs/jpeg-6/jquant1.cpp + libs/jpeg-6/jquant2.cpp + libs/jpeg-6/jutils.cpp) +else (NOT JPEG_FOUND) + set(JPEG_INCLUDES "") + set(JPEG_SOURCES "") +endif (NOT JPEG_FOUND) + +if (NOT PNG_FOUND) + file(GLOB PNG_INCLUDES libs/png/*.h) + file(GLOB PNG_SOURCES libs/png/*.c) +else (NOT PNG_FOUND) + set(PNG_INCLUDES "") + set(PNG_SOURCES "") +endif (NOT PNG_FOUND) + +if (NOT ZLIB_FOUND) file(GLOB ZLIB_INCLUDES libs/zlib/*.h) file(GLOB ZLIB_SOURCES libs/zlib/*.c) +else (NOT ZLIB_FOUND) + set(ZLIB_INCLUDES "") + set(ZLIB_SOURCES "") +endif (NOT ZLIB_FOUND) + file(GLOB MINIZIP_INCLUDES libs/zlib/minizip/*.h) file(GLOB MINIZIP_SOURCES libs/zlib/minizip/*.c libs/zlib/minizip/*.cpp) @@ -1138,7 +1201,7 @@ include_directories( #libs/openal/include libs/glew/include #libs/freetype/include - libs/zlib) + ) #link_directories( # ${CMAKE_CURRENT_SOURCE_DIR}/libs/curl/lib @@ -1318,6 +1381,9 @@ if(MSVC) wsock32.lib ${OpenAL_LIBRARIES} ${FFmpeg_LIBRARIES} + ${ZLIB_LIBRARY} + ${PNG_LIBRARY} + ${JPEG_LIBRARY} ) #CMAKE_BINARY_DIR @@ -1479,6 +1545,9 @@ else() ${SDLx_LIBRARY} ${OPENAL_LIBRARY} ${FFMPEG_LIBRARIES} + ${ZLIB_LIBRARY} + ${PNG_LIBRARY} + ${JPEG_LIBRARY} ) endif() diff --git a/neo/framework/File_SaveGame.h b/neo/framework/File_SaveGame.h index ef3f9cd4..497df898 100644 --- a/neo/framework/File_SaveGame.h +++ b/neo/framework/File_SaveGame.h @@ -28,7 +28,7 @@ If you have questions concerning this license or the applicable additional terms #ifndef __FILE_SAVEGAME_H__ #define __FILE_SAVEGAME_H__ -#include "../libs/zlib/zlib.h" +#include // Listing of the types of files within a savegame package enum saveGameType_t diff --git a/neo/framework/Zip.h b/neo/framework/Zip.h index 2a90f9db..092bb503 100644 --- a/neo/framework/Zip.h +++ b/neo/framework/Zip.h @@ -28,10 +28,10 @@ If you have questions concerning this license or the applicable additional terms #ifndef __ZIP_H__ #define __ZIP_H__ -#include "../libs/zlib/zlib.h" +#include // DG: all the zip access stuff from minizip is now in minizip/zip.h -#include "minizip/zip.h" +#include "libs/zlib/minizip/zip.h" /* diff --git a/neo/renderer/Cinematic.cpp b/neo/renderer/Cinematic.cpp index 71f618a4..02567cb1 100644 --- a/neo/renderer/Cinematic.cpp +++ b/neo/renderer/Cinematic.cpp @@ -36,7 +36,7 @@ extern idCVar s_noSound; #define JPEG_INTERNALS //extern "C" { -#include "../libs/jpeg-6/jpeglib.h" +#include //} #include "tr_local.h" @@ -2046,8 +2046,12 @@ struct jpeg_error_mgr jerr; * the front of the buffer rather than discarding it. */ - -METHODDEF boolean fill_input_buffer( j_decompress_ptr cinfo ) +#ifdef USE_NEWER_JPEG +METHODDEF(boolean) +#else +METHODDEF boolean +#endif +fill_input_buffer( j_decompress_ptr cinfo ) { my_src_ptr src = ( my_src_ptr ) cinfo->src; int nbytes; @@ -2078,8 +2082,12 @@ METHODDEF boolean fill_input_buffer( j_decompress_ptr cinfo ) * before any data is actually read. */ - -METHODDEF void init_source( j_decompress_ptr cinfo ) +#ifdef USE_NEWER_JPEG +METHODDEF(void) +#else +METHODDEF void +#endif +init_source( j_decompress_ptr cinfo ) { my_src_ptr src = ( my_src_ptr ) cinfo->src; @@ -2102,7 +2110,11 @@ METHODDEF void init_source( j_decompress_ptr cinfo ) * buffer is the application writer's problem. */ +#ifdef USE_NEWER_JPEG +METHODDEF(void) +#else METHODDEF void +#endif skip_input_data( j_decompress_ptr cinfo, long num_bytes ) { my_src_ptr src = ( my_src_ptr ) cinfo->src; @@ -2138,14 +2150,22 @@ skip_input_data( j_decompress_ptr cinfo, long num_bytes ) * for error exit. */ +#ifdef USE_NEWER_JPEG +METHODDEF(void) +#else METHODDEF void +#endif term_source( j_decompress_ptr cinfo ) { cinfo = cinfo; /* no work necessary here */ } +#ifdef USE_NEWER_JPEG +GLOBAL(void) +#else GLOBAL void +#endif jpeg_memory_src( j_decompress_ptr cinfo, byte* infile, int size ) { my_src_ptr src; diff --git a/neo/renderer/Image_files.cpp b/neo/renderer/Image_files.cpp index 30dda498..9392860b 100644 --- a/neo/renderer/Image_files.cpp +++ b/neo/renderer/Image_files.cpp @@ -49,7 +49,8 @@ void R_LoadImage( const char *name, byte **pic, int *width, int *height, bool ma * You may also wish to include "jerror.h". */ -#include "../libs/jpeg-6/jpeglib.h" +#include +#include // hooks from jpeg lib to our system @@ -453,7 +454,8 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int* unsigned char* out; byte* fbuffer; byte* bbuf; - + int len; + /* In this example we want to open the input file before doing anything else, * so that the setjmp() error recovery below can assume the file is open. * VERY IMPORTANT: use "b" option to fopen() if you are on a machine that @@ -467,7 +469,6 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int* *pic = NULL; // until proven otherwise } { - int len; idFile* f; f = fileSystem->OpenFileRead( filename ); @@ -505,8 +506,11 @@ static void LoadJPG( const char* filename, unsigned char** pic, int* width, int* /* Step 2: specify data source (eg, a file) */ - jpeg_stdio_src( &cinfo, fbuffer ); - +#ifdef USE_NEWER_JPEG + jpeg_mem_src( &cinfo, fbuffer, len ); +#else + jpeg_stdio_src( &cinfo, fbuffer ); +#endif /* Step 3: read file parameters with jpeg_read_header() */ jpeg_read_header( &cinfo, true ); @@ -617,7 +621,7 @@ PNG LOADING extern "C" { -#include "../libs/png/png.h" +#include static void png_Error( png_structp pngPtr, png_const_charp msg ) diff --git a/neo/swf/SWF_Image.cpp b/neo/swf/SWF_Image.cpp index 1ad593ca..267e7722 100644 --- a/neo/swf/SWF_Image.cpp +++ b/neo/swf/SWF_Image.cpp @@ -29,7 +29,7 @@ If you have questions concerning this license or the applicable additional terms #include "precompiled.h" #include "../renderer/Image.h" //#include "../../renderer/ImageTools/ImageProcess.h" -#include "../libs/jpeg-6/jpeglib.h" +#include /* ======================== diff --git a/neo/swf/SWF_Zlib.cpp b/neo/swf/SWF_Zlib.cpp index 4dd86484..e3ed8d6a 100644 --- a/neo/swf/SWF_Zlib.cpp +++ b/neo/swf/SWF_Zlib.cpp @@ -27,7 +27,7 @@ If you have questions concerning this license or the applicable additional terms */ #pragma hdrstop #include "precompiled.h" -#include "../libs/zlib/zlib.h" +#include /* ========================