CPPFLAGS_PNG ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libpng --cflags $(STDERR_TO_DEVNULL))
LIBS_PNG ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libpng --libs-only-L $(STDERR_TO_DEVNULL)) \
$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libpng --libs-only-l $(STDERR_TO_DEVNULL))
+CPPFLAGS_WEBP ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libwebp --cflags $(STDERR_TO_DEVNULL))
+LIBS_WEBP ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libwebp --libs-only-L $(STDERR_TO_DEVNULL)) \
+ $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) libwebp --libs-only-l $(STDERR_TO_DEVNULL))
CPPFLAGS_GTK ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --cflags $(STDERR_TO_DEVNULL))
LIBS_GTK ?= $(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --libs-only-L $(STDERR_TO_DEVNULL)) \
$(shell PKG_CONFIG_PATH=$(PKG_CONFIG_PATH) $(PKGCONFIG) gtk+-2.0 --libs-only-l $(STDERR_TO_DEVNULL))
checkheader libglib2.0-dev glib.h g_path_is_absolute "$(CPPFLAGS_GLIB)" "$(LIBS_GLIB)"; \
checkheader libxml2-dev libxml/xpath.h xmlXPathInit "$(CPPFLAGS_XML)" "$(LIBS_XML)"; \
checkheader libpng12-dev png.h png_create_read_struct "$(CPPFLAGS_PNG)" "$(LIBS_PNG)"; \
+ checkheader libwebp-dev webp/decode.h WebPGetInfo "$(CPPFLAGS_WEBP)" "$(LIBS_WEBP)"; \
checkheader "mesa-common-dev (or another OpenGL library)" GL/gl.h glClear "$(CPPFLAGS_GL)" "$(LIBS_GL)"; \
checkheader libgtk2.0-dev gtk/gtkdialog.h gtk_dialog_run "$(CPPFLAGS_GTK)" "$(LIBS_GTK)"; \
checkheader libpango1.0-dev pango/pangoft2.h pango_ft2_font_map_new "$(CPPFLAGS_PANGOFT2)" "$(LIBS_PANGOFT2)"; \
$(INSTALLDIR)/modules/image.$(DLL) \
$(INSTALLDIR)/modules/imagehl.$(DLL) \
$(INSTALLDIR)/modules/imagepng.$(DLL) \
+ $(INSTALLDIR)/modules/imagewebp.$(DLL) \
$(INSTALLDIR)/modules/imageq2.$(DLL) \
$(INSTALLDIR)/modules/mapq3.$(DLL) \
$(INSTALLDIR)/modules/mapxml.$(DLL) \
$(CC) $< $(CFLAGS) $(CFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(CPPFLAGS_COMMON) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@
-$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_JPEG) $(LIBS_ZLIB)
-$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) $(CPPFLAGS_JPEG) -Itools/quake3/common -Ilibs -Iinclude
+$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_JPEG) $(LIBS_WEBP) $(LIBS_ZLIB)
+$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) $(CPPFLAGS_JPEG) $(CPPFLAGS_WEBP) -Itools/quake3/common -Ilibs -Iinclude
$(INSTALLDIR)/q3map2.$(EXE): \
tools/quake3/common/cmdlib.o \
tools/quake3/common/imagelib.o \
$(INSTALLDIR)/modules/imagepng.$(DLL): \
plugins/imagepng/plugin.o \
+$(INSTALLDIR)/modules/imagewebp.$(DLL): LIBS_EXTRA := $(LIBS_WEBP)
+$(INSTALLDIR)/modules/imagewebp.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_WEBP) -Ilibs -Iinclude
+$(INSTALLDIR)/modules/imagewebp.$(DLL): \
+ plugins/imagewebp/plugin.o \
+
$(INSTALLDIR)/modules/mapq3.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) -Ilibs -Iinclude
$(INSTALLDIR)/modules/mapq3.$(DLL): \
plugins/mapq3/parse.o \
NetRadiant
==========
-The open source, cross platform level editor for idtech games (Radiant fork)
+![NetRadiant logo](setup/data/tools/bitmaps/splash.png)
+
+The open source, cross platform level editor for idtech games (Radiant fork).
# Getting the Sources
The git client can be obtained from the Git website:
http://git-scm.org
-To get a copy of the source using the commandline git client:
+To get a copy of the source using the command line git client:
+
```
git clone --recursive https://gitlab.com/xonotic/netradiant.git
cd netradiant
* GtkGLExt
* LibJpeg
* LibPng
+ * LibWebp
* Minizip
* ZLib
### 32 bit:
```
-pacman -S --needed base-devel mingw-w64-i686-{toolchain,cmake,make,gtk2,gtkglext}
+pacman -S --needed base-devel mingw-w64-i686-{toolchain,cmake,make,gtk2,gtkglexti,libwebp}
```
### 64 bit:
```
-pacman -S --needed base-devel mingw-w64-x86_64-{toolchain,cmake,make,gtk2,gtkglext}
+pacman -S --needed base-devel mingw-w64-x86_64-{toolchain,cmake,make,gtk2,gtkglext,libwebp}
```
## OS X:
```
brew install gtkglext
+brew install webp
brew install Caskroom/cask/xquartz
brew link --force gettext
```
# Submodules
- * Crunch
+ * Crunch (optional, disabled by default, only supported with CMake build)
-If you forgot to add `--recursive` option at `git clone` time, fetch it this way:
+If you have not used `--recursive` option at `git clone` time, you can fetch Crunch this way (run it whithin NetRadiant repository):
```
## More Compilation Details
options:
- * `DOWNLOAD_GAMEPACKS=ON`
+
+ * `DOWNLOAD_GAMEPACKS=ON`
Automatically download the gamepack data during the first compilation
- * `RADIANT_ABOUTMSG="Custom build"`
+ * `BUILD_CRUNCH=ON`
+ Enable crunch support
+ * `RADIANT_ABOUTMSG="Custom build"`
A message shown in the about dialog
targets:
+
* `radiant` Compiles the radiant core binary
* `modules` Compiles all modules (each module has its own target as well)
* `plugins` Compiles all plugins (each plugin has its own target as well)
## Note about Crunch
-The crnlib used to decode `.crn` files is the one from [Dæmon](http://github.com/DaemonEngine/Daemon) which is just the one by [Unity](https://github.com/Unity-Technologies/crunch/tree/unity) made cross-platform. Since Unity brokes compatibility with [BinomialLLC's legacy tree](https://github.com/BinomialLLC/crunch) it's required to use either crunch from Dæmon or the one from Unity to compress textures that have to be read by radiant or q3map2.
+The crnlib used to decode `.crn` files is the one from [Dæmon](http://github.com/DaemonEngine/Daemon) which is the one by [Unity](https://github.com/Unity-Technologies/crunch/tree/unity) made cross-platform and slightly improved. Since Unity brokes compatibility with [BinomialLLC's legacy tree](https://github.com/BinomialLLC/crunch) it's required to use either the `crunch` tool from Dæmon or the one from Unity to compress textures that have to be read by radiant or q3map2.
--- /dev/null
+# - Find WebP library
+# Find the native WebP headers and libraries.
+#
+# WEBP_INCLUDE_DIRS - where to find webp/decode.h, etc.
+# WEBP_LIBRARIES - List of libraries when using webp.
+# WEBP_FOUND - True if webp is found.
+
+#=============================================================================
+#Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+#All rights reserved.
+#
+#Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+#* Redistributions of source code must retain the above copyright notice,
+#this list of conditions and the following disclaimer.
+#
+#* Redistributions in binary form must reproduce the above copyright notice,
+#this list of conditions and the following disclaimer in the documentation
+#and/or other materials provided with the distribution.
+#
+#* Neither the names of Kitware, Inc., the Insight Software Consortium, nor
+#the names of their contributors may be used to endorse or promote products
+#derived from this software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+#AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+#IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+#ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+#LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+#CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+#SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+#INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+#CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+#ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+#POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+# Look for the header file.
+FIND_PATH(WEBP_INCLUDE_DIR NAMES webp/decode.h)
+MARK_AS_ADVANCED(WEBP_INCLUDE_DIR)
+
+# Look for the library.
+FIND_LIBRARY(WEBP_LIBRARY NAMES webp)
+MARK_AS_ADVANCED(WEBP_LIBRARY)
+
+# handle the QUIETLY and REQUIRED arguments and set WEBFOUND_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(WebP DEFAULT_MSG WEBP_LIBRARY WEBP_INCLUDE_DIR)
+
+SET(WEBP_LIBRARIES ${WEBP_LIBRARY})
+SET(WEBP_INCLUDE_DIRS ${WEBP_INCLUDE_DIR})
+
+SET(_WEBP_RQ_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
+
+if(NOT DEFINED _WEBP_COMPILATION_TEST)
+ INCLUDE (CheckCSourceCompiles)
+ SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${WEBP_INCLUDE_DIRS})
+ CHECK_C_SOURCE_COMPILES("#include <webp/decode.h>
+ int main(void) {
+ #if WEBP_DECODER_ABI_VERSION < 0x0200
+ error; // Deliberate compile-time error
+ #endif
+ return 0;
+ }"
+ _WEBP_COMPILATION_TEST)
+ SET(CMAKE_REQUIRED_INCLUDES ${_WEBP_RQ_INCLUDES})
+endif()
+
+if(NOT _WEBP_COMPILATION_TEST)
+ set( USE_INTERNAL_WEBP 1 )
+endif()
add_subdirectory(imagehl)
add_subdirectory(imagepng)
add_subdirectory(imageq2)
+add_subdirectory(imagewebp)
add_subdirectory(iqmmodel)
add_subdirectory(mapq3)
add_subdirectory(mapxml)
--- /dev/null
+radiant_plugin(imagewebp
+ plugin.cpp
+ )
+
+find_package(WebP REQUIRED)
+target_include_directories(imagewebp PRIVATE ${WEBP_INCLUDE_DIR})
+target_link_libraries(imagewebp PRIVATE ${WEBP_LIBRARIES})
--- /dev/null
+; imagewebp.def : Declares the module parameters for the DLL.
+
+LIBRARY "IMAGEWEBP"
+
+EXPORTS
+ ; Explicit exports can go here
+ Radiant_RegisterModules @1
--- /dev/null
+/*
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ 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 "plugin.h"
+#include "debugging/debugging.h"
+#include "ifilesystem.h"
+#include "iimage.h"
+
+#include "imagelib.h"
+
+// ====== WEBP loader functionality ======
+
+#include "webp/decode.h"
+
+Image* LoadWEBPBuff( unsigned char* buffer, size_t buffer_length ){
+ int image_width;
+ int image_height;
+
+ if ( !WebPGetInfo( (byte *) buffer, buffer_length, &image_width, &image_height) ){
+ globalErrorStream() << "libwebp error: WebPGetInfo: can't get image info\n";
+ return 0;
+ }
+
+ // allocate the pixel buffer
+ RGBAImage* image = new RGBAImage( image_width, image_height );
+ int out_stride = image_width *sizeof(RGBAPixel);
+ int out_size = image_height * out_stride;
+
+ if ( !WebPDecodeRGBAInto( (byte *) buffer, buffer_length, image->getRGBAPixels(), out_size, out_stride ) )
+ {
+ return 0;
+ }
+
+ return image;
+}
+
+Image* LoadWEBP( ArchiveFile& file ){
+ ScopedArchiveBuffer buffer( file );
+ return LoadWEBPBuff( buffer.buffer, buffer.length );
+}
+
+
+#include "modulesystem/singletonmodule.h"
+
+
+class ImageDependencies : public GlobalFileSystemModuleRef
+{
+};
+
+class ImageWEBPAPI
+{
+_QERPlugImageTable m_imagewebp;
+public:
+typedef _QERPlugImageTable Type;
+STRING_CONSTANT( Name, "webp" );
+
+ImageWEBPAPI(){
+ m_imagewebp.loadImage = LoadWEBP;
+}
+_QERPlugImageTable* getTable(){
+ return &m_imagewebp;
+}
+};
+
+typedef SingletonModule<ImageWEBPAPI, ImageDependencies> ImageWEBPModule;
+
+ImageWEBPModule g_ImageWEBPModule;
+
+
+extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules( ModuleServer& server ){
+ initialiseModule( server );
+
+ g_ImageWEBPModule.selfRegister();
+}
--- /dev/null
+/*
+ Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+ For a list of contributors, see the accompanying CONTRIBUTORS file.
+
+ 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_PLUGIN_H )
+#define INCLUDED_PLUGIN_H
+
+#endif
find_package(PNG REQUIRED)
include_directories(${PNG_INCLUDE_DIR})
+find_package(WebP REQUIRED)
+include_directories(${WEBP_INCLUDE_DIR})
+
find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR})
${GLIB_LIBRARIES}
${JPEG_LIBRARIES}
${PNG_LIBRARIES}
+ ${WEBP_LIBRARIES}
${LIBXML2_LIBRARIES}
${Minizip_LIBRARIES}
${ZLIB_LIBRARIES}
/* dependencies */
#include "q3map2.h"
-
+#include "webp/decode.h"
/* -------------------------------------------------------------------------------
+static void LoadWEBPBuffer( byte *buffer, int size, byte **pixels, int *width, int *height ){
+
+ int image_width;
+ int image_height;
+
+ if ( !WebPGetInfo( buffer, ( size_t) size, &image_width, &image_height ) )
+ {
+ Sys_Printf( "WARNING: An error occurred reading WEBP image info\n" );
+ return;
+ }
+
+ /* create image pixel buffer */
+ *pixels = safe_malloc( image_width * image_height * 4 );
+ *width = image_width;
+ *height = image_height;
+
+ int out_stride = image_width * 4;
+ int out_size = image_height * out_stride;
+
+ if ( !WebPDecodeRGBAInto( buffer, (size_t) size, *pixels, out_size, out_stride ) )
+ {
+ Sys_FPrintf( SYS_WRN, "WARNING: An error occurred reading WEBP image\n" );
+ return;
+ }
+}
+
+
+
/*
ImageInit()
implicitly called by every function to set up image list
size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
if ( size > 0 ) {
LoadTGABuffer( buffer, buffer + size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
}
- else
- {
- /* attempt to load png */
- StripExtension( name );
- strcat( name, ".png" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- LoadPNGBuffer( buffer, size, &image->pixels, &image->width, &image->height );
- }
- else
- {
- /* attempt to load jpg */
- StripExtension( name );
- strcat( name, ".jpg" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- if ( LoadJPGBuff( buffer, size, &image->pixels, &image->width, &image->height ) == -1 && image->pixels != NULL ) {
- // On error, LoadJPGBuff might store a pointer to the error message in image->pixels
- Sys_FPrintf( SYS_WRN, "WARNING: LoadJPGBuff: %s\n", (unsigned char*) image->pixels );
- }
- alphaHack = qtrue;
- }
- else
- {
- /* attempt to load dds */
- StripExtension( name );
- strcat( name, ".dds" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- LoadDDSBuffer( buffer, size, &image->pixels, &image->width, &image->height );
-
- /* debug code */
- #if 1
- {
- ddsPF_t pf;
- DDSGetInfo( (ddsBuffer_t*) buffer, NULL, NULL, &pf );
- Sys_Printf( "pf = %d\n", pf );
- if ( image->width > 0 ) {
- StripExtension( name );
- strcat( name, "_converted.tga" );
- WriteTGA( "C:\\games\\quake3\\baseq3\\textures\\rad\\dds_converted.tga", image->pixels, image->width, image->height );
- }
- }
- #endif
- }
- else
- {
- /* attempt to load ktx */
- StripExtension( name );
- strcat( name, ".ktx" );
- size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
- if ( size > 0 ) {
- LoadKTXBufferFirstImage( buffer, size, &image->pixels, &image->width, &image->height );
- }
- #ifdef BUILD_CRUNCH
- else
- {
- /* attempt to load crn */
- StripExtension( name );
- strcat( name, ".crn" );
- size = vfsLoadFile( ( const char* ) name, ( void** ) &buffer, 0 );
- if ( size > 0 ) {
- LoadCRNBuffer( buffer, size, &image->pixels, &image->width, &image->height );
- }
- }
- #endif // BUILD_CRUNCH
- }
- }
+
+ /* attempt to load png */
+ StripExtension( name );
+ strcat( name, ".png" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadPNGBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ /* attempt to load jpg */
+ StripExtension( name );
+ strcat( name, ".jpg" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ if ( LoadJPGBuff( buffer, size, &image->pixels, &image->width, &image->height ) == -1 && image->pixels != NULL ) {
+ // On error, LoadJPGBuff might store a pointer to the error message in image->pixels
+ Sys_FPrintf( SYS_WRN, "WARNING: LoadJPGBuff: %s\n", (unsigned char*) image->pixels );
}
+ alphaHack = qtrue;
+ goto image_load_success;
}
+ /* attempt to load dds */
+ StripExtension( name );
+ strcat( name, ".dds" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadDDSBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ /* attempt to load ktx */
+ StripExtension( name );
+ strcat( name, ".ktx" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadKTXBufferFirstImage( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ #ifdef BUILD_CRUNCH
+ /* attempt to load crn */
+ StripExtension( name );
+ strcat( name, ".crn" );
+ size = vfsLoadFile( ( const char* ) name, ( void** ) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadCRNBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+ #endif // BUILD_CRUNCH
+
+ /* attempt to load webp */
+ StripExtension( name );
+ strcat( name, ".webp" );
+ size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 );
+ if ( size > 0 ) {
+ LoadWEBPBuffer( buffer, size, &image->pixels, &image->width, &image->height );
+ goto image_load_success;
+ }
+
+ image_load_success:
+
/* free file buffer */
free( buffer );