From: Thomas Debesse Date: Sun, 28 Oct 2018 21:24:54 +0000 (+0100) Subject: make crunch build optional and disabled by default X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=6acf8cb198eebecef02e507d14468d4dc90d91a5;p=xonotic%2Fnetradiant.git make crunch build optional and disabled by default --- diff --git a/CMakeLists.txt b/CMakeLists.txt index aa1028d6..fb4a34c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") project(NetRadiant C CXX) option(BUILD_RADIANT "Build the GUI" ON) +option(BUILD_CRUNCH "Build Crunch image support" OFF) if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "..." FORCE) diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index 6fdcc0b2..633b965f 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -1,6 +1,8 @@ add_subdirectory(cmdlib) add_subdirectory(container) -add_subdirectory(crnrgba) +if (BUILD_CRUNCH) + add_subdirectory(crnrgba) +endif () add_subdirectory(ddslib) add_subdirectory(debugging) add_subdirectory(etclib) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index a41ed780..d6c7f075 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -17,6 +17,11 @@ add_subdirectory(archivewad) add_subdirectory(archivezip) add_subdirectory(entity) add_subdirectory(image) + +if(BUILD_CRUNCH) + add_subdirectory(imagecrn) +endif() + add_subdirectory(imagehl) add_subdirectory(imagepng) add_subdirectory(imageq2) diff --git a/plugins/image/CMakeLists.txt b/plugins/image/CMakeLists.txt index 5182f833..bea548ee 100644 --- a/plugins/image/CMakeLists.txt +++ b/plugins/image/CMakeLists.txt @@ -6,10 +6,9 @@ radiant_plugin(image ktx.cpp ktx.h pcx.cpp pcx.h tga.cpp tga.h - crn.cpp crn.h ) find_package(JPEG REQUIRED) -target_include_directories(image PRIVATE ${JPEG_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/libs/crnrgba) -target_link_libraries(image PRIVATE crnrgba ddslib etclib ${JPEG_LIBRARIES}) +target_include_directories(image PRIVATE ${JPEG_INCLUDE_DIR}) +target_link_libraries(image PRIVATE ddslib etclib ${JPEG_LIBRARIES}) target_compile_options(image PRIVATE -fexceptions) diff --git a/plugins/image/crn.cpp b/plugins/image/crn.cpp deleted file mode 100644 index 85e1e5cb..00000000 --- a/plugins/image/crn.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2018, Unvanquished Developers - All Rights Reserved. - - This file is part of NetRadiant. - - NetRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - NetRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with NetRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "crn.h" - -#include - -#include "ifilesystem.h" -#include "iarchive.h" -#include "idatastream.h" - -#include "crn_rgba.h" -#include "ddslib.h" -#include "imagelib.h" - -Image *LoadCRNBuff(const byte *buffer, int length) -{ - int width, height; - if (!GetCRNImageSize(buffer, length, &width, &height)) { - globalErrorStream() << "ERROR: Error getting crn imag dimensions.\n"; - return nullptr; - } - RGBAImage *image = new RGBAImage(width, height); - if (!ConvertCRNtoRGBA(buffer, length, width * height, image->getRGBAPixels())) { - globalErrorStream() << "ERROR: Error decoding crn image.\n"; - image->release(); - return nullptr; - } - return image; -} - -Image *LoadCRN(ArchiveFile &file) -{ - ScopedArchiveBuffer buffer(file); - return LoadCRNBuff(buffer.buffer, buffer.length); -} diff --git a/plugins/image/crn.h b/plugins/image/crn.h deleted file mode 100644 index 4e97556e..00000000 --- a/plugins/image/crn.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - Copyright (C) 2018, Unvanquished Developers - All Rights Reserved. - - This file is part of NetRadiant. - - NetRadiant is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - NetRadiant is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with NetRadiant; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#if !defined( INCLUDED_CRN_H ) -#define INCLUDED_CRN_H - -class Image; - -class ArchiveFile; - -Image *LoadCRN(ArchiveFile &file); - -#endif - diff --git a/plugins/image/image.cpp b/plugins/image/image.cpp index 574e4fab..f7f73522 100644 --- a/plugins/image/image.cpp +++ b/plugins/image/image.cpp @@ -28,7 +28,6 @@ #include "pcx.h" #include "dds.h" #include "ktx.h" -#include "crn.h" #include "modulesystem/singletonmodule.h" @@ -174,29 +173,6 @@ typedef SingletonModule ImageKTXModule; ImageKTXModule g_ImageKTXModule; -class ImageCRNAPI { - _QERPlugImageTable m_imagecrn; -public: - typedef _QERPlugImageTable Type; - - STRING_CONSTANT(Name, "crn"); - - ImageCRNAPI() - { - m_imagecrn.loadImage = LoadCRN; - } - - _QERPlugImageTable *getTable() - { - return &m_imagecrn; - } -}; - -typedef SingletonModule ImageCRNModule; - -ImageCRNModule g_ImageCRNModule; - - extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server) { initialiseModule(server); @@ -207,5 +183,4 @@ extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server) g_ImagePCXModule.selfRegister(); g_ImageDDSModule.selfRegister(); g_ImageKTXModule.selfRegister(); - g_ImageCRNModule.selfRegister(); } diff --git a/plugins/imagecrn/CMakeLists.txt b/plugins/imagecrn/CMakeLists.txt new file mode 100644 index 00000000..fd455528 --- /dev/null +++ b/plugins/imagecrn/CMakeLists.txt @@ -0,0 +1,7 @@ +radiant_plugin(imagecrn + imagecrn.cpp + crn.cpp crn.h + ) + +target_include_directories(imagecrn PRIVATE ${CMAKE_SOURCE_DIR}/libs/crnrgba) +target_link_libraries(imagecrn PRIVATE crnrgba) diff --git a/plugins/imagecrn/crn.cpp b/plugins/imagecrn/crn.cpp new file mode 100644 index 00000000..85e1e5cb --- /dev/null +++ b/plugins/imagecrn/crn.cpp @@ -0,0 +1,55 @@ +/* + Copyright (C) 2018, Unvanquished Developers + All Rights Reserved. + + This file is part of NetRadiant. + + NetRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + NetRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with NetRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include "crn.h" + +#include + +#include "ifilesystem.h" +#include "iarchive.h" +#include "idatastream.h" + +#include "crn_rgba.h" +#include "ddslib.h" +#include "imagelib.h" + +Image *LoadCRNBuff(const byte *buffer, int length) +{ + int width, height; + if (!GetCRNImageSize(buffer, length, &width, &height)) { + globalErrorStream() << "ERROR: Error getting crn imag dimensions.\n"; + return nullptr; + } + RGBAImage *image = new RGBAImage(width, height); + if (!ConvertCRNtoRGBA(buffer, length, width * height, image->getRGBAPixels())) { + globalErrorStream() << "ERROR: Error decoding crn image.\n"; + image->release(); + return nullptr; + } + return image; +} + +Image *LoadCRN(ArchiveFile &file) +{ + ScopedArchiveBuffer buffer(file); + return LoadCRNBuff(buffer.buffer, buffer.length); +} diff --git a/plugins/imagecrn/crn.h b/plugins/imagecrn/crn.h new file mode 100644 index 00000000..4e97556e --- /dev/null +++ b/plugins/imagecrn/crn.h @@ -0,0 +1,32 @@ +/* + Copyright (C) 2018, Unvanquished Developers + All Rights Reserved. + + This file is part of NetRadiant. + + NetRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + NetRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with NetRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#if !defined( INCLUDED_CRN_H ) +#define INCLUDED_CRN_H + +class Image; + +class ArchiveFile; + +Image *LoadCRN(ArchiveFile &file); + +#endif + diff --git a/plugins/imagecrn/imagecrn.cpp b/plugins/imagecrn/imagecrn.cpp new file mode 100644 index 00000000..4516f061 --- /dev/null +++ b/plugins/imagecrn/imagecrn.cpp @@ -0,0 +1,61 @@ +/* + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. + + This file is part of GtkRadiant. + + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "ifilesystem.h" +#include "iimage.h" + +#include "crn.h" + + +#include "modulesystem/singletonmodule.h" + +class ImageDependencies : public GlobalFileSystemModuleRef { +}; + +class ImageCRNAPI { + _QERPlugImageTable m_imagecrn; +public: + typedef _QERPlugImageTable Type; + + STRING_CONSTANT(Name, "crn"); + + ImageCRNAPI() + { + m_imagecrn.loadImage = LoadCRN; + } + + _QERPlugImageTable *getTable() + { + return &m_imagecrn; + } +}; + +typedef SingletonModule ImageCRNModule; + +ImageCRNModule g_ImageCRNModule; + + +extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer &server) +{ + initialiseModule(server); + + g_ImageCRNModule.selfRegister(); +} diff --git a/plugins/imagecrn/imagecrn.def b/plugins/imagecrn/imagecrn.def new file mode 100644 index 00000000..df815fa8 --- /dev/null +++ b/plugins/imagecrn/imagecrn.def @@ -0,0 +1,7 @@ +; imagepng.def : Declares the module parameters for the DLL. + +LIBRARY "IMAGECRN" + +EXPORTS + ; Explicit exports can go here + Radiant_RegisterModules @1 diff --git a/tools/quake3/CMakeLists.txt b/tools/quake3/CMakeLists.txt index 87605128..2dfc9ef9 100644 --- a/tools/quake3/CMakeLists.txt +++ b/tools/quake3/CMakeLists.txt @@ -121,6 +121,16 @@ radiant_tool(q3map2 q3map2/writebsp.c ) +if (BUILD_CRUNCH) + set(OPTIONAL_IMAGE_LIBRARIES crnrgba) + set(OPTIONAL_IMAGE_DEFINES BUILD_CRUNCH=1) +endif () + +target_compile_definitions(q3map2 + PRIVATE + ${OPTIONAL_IMAGE_DEFINES} + ) + target_link_libraries(q3map2 ${GLIB_LIBRARIES} ${JPEG_LIBRARIES} @@ -128,7 +138,7 @@ target_link_libraries(q3map2 ${LIBXML2_LIBRARIES} ${Minizip_LIBRARIES} ${ZLIB_LIBRARIES} - crnrgba + ${OPTIONAL_IMAGE_LIBRARIES} ddslib etclib filematch diff --git a/tools/quake3/q3map2/image.c b/tools/quake3/q3map2/image.c index 4bf1ec0e..1732867b 100644 --- a/tools/quake3/q3map2/image.c +++ b/tools/quake3/q3map2/image.c @@ -86,6 +86,7 @@ static void LoadDDSBuffer( byte *buffer, int size, byte **pixels, int *width, in DDSDecompress( (ddsBuffer_t*) buffer, *pixels ); } +#ifdef BUILD_CRUNCH /* LoadCRNBuffer loads a crn image into a valid rgba image @@ -106,6 +107,7 @@ void LoadCRNBuffer( byte *buffer, int size, byte **pixels, int *width, int *heig return; } } +#endif // BUILD_CRUNCH /* @@ -457,6 +459,7 @@ image_t *ImageLoad( const char *filename ){ if ( size > 0 ) { LoadKTXBufferFirstImage( buffer, size, &image->pixels, &image->width, &image->height ); } + #ifdef BUILD_CRUNCH else { /* attempt to load crn */ @@ -467,6 +470,7 @@ image_t *ImageLoad( const char *filename ){ LoadCRNBuffer( buffer, size, &image->pixels, &image->width, &image->height ); } } + #endif // BUILD_CRUNCH } } }