The GtkRadiant sources as originally released under the GPL license.

This commit is contained in:
Travis Bradshaw
2012-01-31 15:20:35 -06:00
commit 0991a5ce8b
1590 changed files with 431941 additions and 0 deletions

117
plugins/imageq2/imageq2.cpp Normal file
View File

@@ -0,0 +1,117 @@
/*
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 "imageq2.h"
#include "debugging/debugging.h"
#include "ifilesystem.h"
#include "iimage.h"
#include "wal.h"
#include "wal32.h"
#include "modulesystem/singletonmodule.h"
class ImageDependencies : public GlobalFileSystemModuleRef
{
};
class ImageWalAPI
{
_QERPlugImageTable m_imagewal;
public:
typedef _QERPlugImageTable Type;
STRING_CONSTANT(Name, "wal");
ImageWalAPI()
{
m_imagewal.loadImage = LoadWal;
}
_QERPlugImageTable* getTable()
{
return &m_imagewal;
}
};
typedef SingletonModule<ImageWalAPI, ImageDependencies> ImageWalModule;
ImageWalModule g_ImageWalModule;
////////////////////////////////////////////////////
class ImageM8API
{
_QERPlugImageTable m_imagem8;
public:
typedef _QERPlugImageTable Type;
STRING_CONSTANT(Name, "m8");
ImageM8API()
{
m_imagem8.loadImage = LoadM8;
}
_QERPlugImageTable* getTable()
{
return &m_imagem8;
}
};
typedef SingletonModule<ImageM8API, ImageDependencies> ImageM8Module;
ImageM8Module g_ImageM8Module;
////////////////////////////////////////////////////////
class ImageM32API
{
_QERPlugImageTable m_imagem32;
public:
typedef _QERPlugImageTable Type;
STRING_CONSTANT(Name, "m32");
ImageM32API()
{
m_imagem32.loadImage = LoadM32;
}
_QERPlugImageTable* getTable()
{
return &m_imagem32;
}
};
typedef SingletonModule<ImageM32API, ImageDependencies> ImageM32Module;
ImageM32Module g_ImageM32Module;
////////////////////////////////////////////////////////
extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server)
{
GlobalErrorStream::instance().setOutputStream(server.getErrorStream());
GlobalOutputStream::instance().setOutputStream(server.getOutputStream());
GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler());
GlobalModuleServer::instance().set(server);
g_ImageWalModule.selfRegister();
g_ImageM8Module.selfRegister();
g_ImageM32Module.selfRegister();
}

View File

@@ -0,0 +1,7 @@
; imageq2.def : Declares the module parameters for the DLL.
LIBRARY "ImageQ2"
EXPORTS
; Explicit exports can go here
Radiant_RegisterModules @1

25
plugins/imageq2/imageq2.h Normal file
View File

@@ -0,0 +1,25 @@
/*
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
*/
#if !defined(INCLUDED_IMAGEQ2_H)
#define INCLUDED_IMAGEQ2_H
#endif

View File

@@ -0,0 +1,213 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="imageq2"
ProjectGUID="{697E77F2-9E9E-4F12-973F-C1214494248C}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../include;../../libs;&quot;../../../STLPort-4.6/stlport&quot;;&quot;../../../gtk2-2.4/include/glib-2.0&quot;;&quot;../../../gtk2-2.4/lib/glib-2.0/include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;IMAGEQ2_EXPORTS"
StringPooling="TRUE"
MinimalRebuild="TRUE"
ExceptionHandling="FALSE"
BasicRuntimeChecks="0"
RuntimeLibrary="3"
BufferSecurityCheck="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
BrowseInformation="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"
DisableSpecificWarnings="4610;4510;4512;4505;4100;4127"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/imageq2.dll"
LinkIncremental="1"
AdditionalLibraryDirectories=""
IgnoreDefaultLibraryNames="msvcprtd.lib"
ModuleDefinitionFile="$(ProjectName).def"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/imageq2.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/imageq2.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)install\modules&quot;
copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)install\modules&quot;"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2"
WholeProgramOptimization="TRUE">
<Tool
Name="VCCLCompilerTool"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForWindowsApplication="FALSE"
AdditionalIncludeDirectories="../../include;../../libs;&quot;../../../STLPort-4.6/stlport&quot;;&quot;../../../gtk2-2.4/include/glib-2.0&quot;;&quot;../../../gtk2-2.4/lib/glib-2.0/include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;IMAGEQ2_EXPORTS"
StringPooling="TRUE"
ExceptionHandling="FALSE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
ForceConformanceInForLoopScope="TRUE"
UsePrecompiledHeader="0"
WarningLevel="4"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"
DisableSpecificWarnings="4610;4510;4512;4505;4100;4127"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/imageq2.dll"
LinkIncremental="1"
AdditionalLibraryDirectories=""
IgnoreDefaultLibraryNames="msvcprt.lib"
ModuleDefinitionFile="$(ProjectName).def"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/imageq2.lib"
TargetMachine="1"
FixedBaseAddress="0"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"
CommandLine="copy &quot;$(TargetPath)&quot; &quot;$(SolutionDir)install\modules&quot;
copy &quot;$(TargetDir)$(TargetName).pdb&quot; &quot;$(SolutionDir)install\modules&quot;"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="src"
Filter="">
<File
RelativePath=".\imageq2.cpp">
</File>
<File
RelativePath=".\imageq2.h">
</File>
<Filter
Name="modules"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\wal.cpp">
</File>
<File
RelativePath=".\wal.h">
</File>
<File
RelativePath=".\wal32.cpp">
</File>
<File
RelativePath=".\wal32.h">
</File>
</Filter>
</Filter>
<File
RelativePath="..\..\debug.py">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
CommandLine="python &quot;$(SolutionDir)debug.py&quot;"
AdditionalDependencies="&quot;$(SolutionDir)install\modules\$(TargetName).pdb&quot;"
Outputs="&quot;$(TargetDir)$(TargetName).pdb&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCustomBuildTool"
CommandLine="python &quot;$(SolutionDir)debug.py&quot;"
AdditionalDependencies="&quot;$(SolutionDir)install\modules\$(TargetName).pdb&quot;"
Outputs="&quot;$(TargetDir)$(TargetName).pdb&quot;"/>
</FileConfiguration>
</File>
<File
RelativePath=".\imageq2.def">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
CommandLine="python &quot;$(SolutionDir)touch.py&quot; &quot;$(TargetPath)&quot;
"
AdditionalDependencies="&quot;$(SolutionDir)install\modules\$(TargetFileName)&quot;"
Outputs="&quot;$(TargetPath)&quot;"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCustomBuildTool"
CommandLine="python &quot;$(SolutionDir)touch.py&quot; &quot;$(TargetPath)&quot;
"
AdditionalDependencies="&quot;$(SolutionDir)install\modules\$(TargetFileName)&quot;"
Outputs="&quot;$(TargetPath)&quot;"/>
</FileConfiguration>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

157
plugins/imageq2/wal.cpp Normal file
View File

@@ -0,0 +1,157 @@
/*
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 "wal.h"
#include "ifilesystem.h"
#include "os/path.h"
#include "stream/stringstream.h"
#include "bytestreamutils.h"
#include "imagelib.h"
#define QUAKE2_WAL 0
#define HERETIC2_M8 1
typedef unsigned char byte;
struct pcx_header_t
{
char manufacturer;
char version;
char encoding;
char bits_per_pixel;
};
void LoadPCXPalette(const char *filename, byte palette[768])
{
byte* buffer;
int length = vfsLoadFile (filename, (void **)&buffer);
if(buffer == 0)
return;
const pcx_header_t* pcx = reinterpret_cast<const pcx_header_t*>(buffer);
if (pcx->manufacturer != 0x0a
|| pcx->version != 5
|| pcx->encoding != 1
|| pcx->bits_per_pixel != 8)
return;
memcpy(palette, buffer + length - 768, 768);
vfsFreeFile(buffer);
}
const int WAL_NAME_LENGTH = 32;
const int WAL_MIPMAP_COUNT = 4;
struct wal_header_t
{
char name[WAL_NAME_LENGTH];
unsigned width, height;
unsigned offsets[WAL_MIPMAP_COUNT]; // four mip maps stored
char animname[WAL_NAME_LENGTH]; // next frame in animation chain
int flags;
int contents;
int value;
};
const int M8_NAME_LENGTH = 32;
const int M8_MIPMAP_COUNT = 16;
struct m8_header_t
{
int version;
char name[M8_NAME_LENGTH];
unsigned width[M8_MIPMAP_COUNT], height[M8_MIPMAP_COUNT]; // width and height of each mipmap
unsigned offsets[M8_MIPMAP_COUNT]; // 16 mip maps stored
char animname[M8_NAME_LENGTH]; // next frame in animation chain
byte palette[768]; // palette stored in m8
int flags;
int contents;
int value;
};
Image* LoadMipTex(byte* buffer, byte TypeofTex)
{
int w, h, offset, flags, contents, value;
byte palette[768];
byte* source;
PointerInputStream inputStream(buffer);
if ( TypeofTex == HERETIC2_M8 )
{
inputStream.seek(4 + M8_NAME_LENGTH); // version, name
w = istream_read_int32_le(inputStream);
inputStream.seek(4 * (M8_MIPMAP_COUNT - 1)); // remaining widths
h = istream_read_int32_le(inputStream);
inputStream.seek(4 * (M8_MIPMAP_COUNT - 1)); // remaining heights
offset = istream_read_int32_le(inputStream);
inputStream.seek(4 * (M8_MIPMAP_COUNT - 1)); // remaining offsets
inputStream.seek(M8_NAME_LENGTH); // animname
inputStream.read(palette, 768);
flags = istream_read_int32_le(inputStream);
contents = istream_read_int32_le(inputStream);
value = istream_read_int32_le(inputStream);
source = buffer + offset;
}
else
{
LoadPCXPalette("pics/colormap.pcx", palette);
inputStream.seek(WAL_NAME_LENGTH); // name
w = istream_read_int32_le(inputStream);
h = istream_read_int32_le(inputStream);
offset = istream_read_int32_le(inputStream);
inputStream.seek(4 * (WAL_MIPMAP_COUNT - 1)); // remaining offsets
inputStream.seek(WAL_NAME_LENGTH); // animname
flags = istream_read_int32_le(inputStream);
contents = istream_read_int32_le(inputStream);
value = istream_read_int32_le(inputStream);
source = buffer + offset;
}
RGBAImageFlags* image = new RGBAImageFlags(w, h, flags, contents, value);
byte* dest = image->getRGBAPixels();
byte* end = source + (w * h);
for(; source != end; ++source, dest += 4)
{
*(dest + 0) = palette[*source * 3 + 0];
*(dest + 1) = palette[*source * 3 + 1];
*(dest + 2) = palette[*source * 3 + 2];
*(dest + 3) = 255;
}
return image;
}
Image* LoadWal(ArchiveFile& file)
{
ScopedArchiveBuffer buffer(file);
return LoadMipTex( buffer.buffer, QUAKE2_WAL );
}
Image* LoadM8(ArchiveFile& file)
{
ScopedArchiveBuffer buffer(file);
return LoadMipTex( buffer.buffer, HERETIC2_M8 );
}

32
plugins/imageq2/wal.h Normal file
View File

@@ -0,0 +1,32 @@
/*
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
*/
#if !defined (INCLUDED_WAL_H)
#define INCLUDED_WAL_H
class Image;
class ArchiveFile;
Image* LoadWal(ArchiveFile& file);
Image* LoadM8(ArchiveFile& file);
#endif

92
plugins/imageq2/wal32.cpp Normal file
View File

@@ -0,0 +1,92 @@
/*
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 "wal32.h"
#include "ifilesystem.h"
#include "bytestreamutils.h"
#include "imagelib.h"
typedef unsigned char byte;
const int M32_NAME_LENGTH = 128;
const int M32_MIPMAP_COUNT = 16;
typedef struct m32_header_t
{
int version;
char name[M32_NAME_LENGTH];
char altname[M32_NAME_LENGTH]; // texture substitution
char animname[M32_NAME_LENGTH]; // next frame in animation chain
char damagename[M32_NAME_LENGTH]; // image that should be shown when damaged
unsigned width[M32_MIPMAP_COUNT], height[M32_MIPMAP_COUNT];
unsigned offsets[M32_MIPMAP_COUNT];
int flags;
int contents;
int value;
float scale_x, scale_y;
int mip_scale;
// detail texturing info
char dt_name[M32_NAME_LENGTH]; // detailed texture name
float dt_scale_x, dt_scale_y;
float dt_u, dt_v;
float dt_alpha;
int dt_src_blend_mode, dt_dst_blend_mode;
int unused[20]; // future expansion to maintain compatibility with h2
} m32_header_t;
Image* LoadM32Buff(byte* buffer)
{
PointerInputStream inputStream(buffer);
inputStream.seek(4 // version
+ M32_NAME_LENGTH // name
+ M32_NAME_LENGTH // altname
+ M32_NAME_LENGTH // animname
+ M32_NAME_LENGTH); // damagename
int w = istream_read_uint32_le(inputStream);
inputStream.seek(4 * (M32_MIPMAP_COUNT - 1)); // remaining widths
int h = istream_read_uint32_le(inputStream);
inputStream.seek(4 * (M32_MIPMAP_COUNT - 1)); // remaining heights
int offset = istream_read_uint32_le(inputStream);
inputStream.seek(4 * (M32_MIPMAP_COUNT - 1)); // remaining offsets
int flags = istream_read_uint32_le(inputStream);
int contents = istream_read_uint32_le(inputStream);
int value = istream_read_uint32_le(inputStream);
RGBAImageFlags* image = new RGBAImageFlags(w, h, flags, contents, value);
const byte* source = buffer + offset;
std::copy(source, source + (w * h * 4), image->getRGBAPixels());
return image;
}
Image* LoadM32(ArchiveFile& file)
{
ScopedArchiveBuffer buffer(file);
return LoadM32Buff(buffer.buffer);
}

31
plugins/imageq2/wal32.h Normal file
View File

@@ -0,0 +1,31 @@
/*
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
*/
#if !defined (INCLUDED_WAL32_H)
#define INCLUDED_WAL32_H
class Image;
class ArchiveFile;
Image* LoadM32(ArchiveFile& file);
#endif