This commit is contained in:
2025-11-24 14:19:51 +05:30
commit f5c1412b28
6734 changed files with 1527575 additions and 0 deletions

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DXTCompressor", "DXTCompressor.vcxproj", "{5CBD4DE3-AB31-4800-BAE2-4FD13AD1ECD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5CBD4DE3-AB31-4800-BAE2-4FD13AD1ECD0}.Debug|Win32.ActiveCfg = Debug|Win32
{5CBD4DE3-AB31-4800-BAE2-4FD13AD1ECD0}.Debug|Win32.Build.0 = Debug|Win32
{5CBD4DE3-AB31-4800-BAE2-4FD13AD1ECD0}.Release|Win32.ActiveCfg = Release|Win32
{5CBD4DE3-AB31-4800-BAE2-4FD13AD1ECD0}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5CBD4DE3-AB31-4800-BAE2-4FD13AD1ECD0}</ProjectGuid>
<RootNamespace>DXTCompressor</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>External\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<OutputFile>$(OutDir)$(ProjectName).exe</OutputFile>
<AdditionalLibraryDirectories>External\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>External\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>External\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Src\DXTCompressor.cpp" />
<ClCompile Include="Src\main.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Src\DXTCompressor.h" />
<ClInclude Include="Src\FrameBufferRenderBuffer.hpp" />
<ClInclude Include="Src\OpenGLWindow.hpp" />
<ClInclude Include="Src\ShaderSource.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Src\DXTCompressor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Src\main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Src\DXTCompressor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Src\FrameBufferRenderBuffer.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Src\OpenGLWindow.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Src\ShaderSource.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,758 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _cg_h
#define _cg_h
/*************************************************************************/
/*** CG Run-Time Library API ***/
/*************************************************************************/
#define CG_VERSION_NUM 2200
#ifdef _WIN32
# ifndef APIENTRY /* From Win32's <windef.h> */
# define CG_APIENTRY_DEFINED
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
# ifndef WINGDIAPI /* From Win32's <wingdi.h> and <winnt.h> */
# define CG_WINGDIAPI_DEFINED
# define WINGDIAPI __declspec(dllimport)
# endif
#endif /* _WIN32 */
/* Set up CG_API for Win32 dllexport or gcc visibility */
#ifndef CG_API
# ifdef CG_EXPORTS
# ifdef _WIN32
# define CG_API __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__>=4
# define CG_API __attribute__ ((visibility("default")))
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# define CG_API __global
# else
# define CG_API
# endif
# else
# define CG_API
# endif
#endif
#ifndef CGENTRY
# ifdef _WIN32
# define CGENTRY __cdecl
# else
# define CGENTRY
# endif
#endif
/*************************************************************************/
/*** Data types and enumerants ***/
/*************************************************************************/
typedef int CGbool;
#define CG_FALSE ((CGbool)0)
#define CG_TRUE ((CGbool)1)
typedef struct _CGcontext *CGcontext;
typedef struct _CGprogram *CGprogram;
typedef struct _CGparameter *CGparameter;
typedef struct _CGobj *CGobj;
typedef struct _CGbuffer *CGbuffer;
typedef struct _CGeffect *CGeffect;
typedef struct _CGtechnique *CGtechnique;
typedef struct _CGpass *CGpass;
typedef struct _CGstate *CGstate;
typedef struct _CGstateassignment *CGstateassignment;
typedef struct _CGannotation *CGannotation;
typedef void *CGhandle;
/*!!! PREPROCESS BEGIN */
typedef enum
{
CG_UNKNOWN_TYPE,
CG_STRUCT,
CG_ARRAY,
CG_TYPELESS_STRUCT,
CG_TYPE_START_ENUM = 1024,
#define CG_DATATYPE_MACRO(name, compiler_name, enum_name, base_name, ncols, nrows, pc) \
enum_name ,
#include <Cg/cg_datatypes.h>
#undef CG_DATATYPE_MACRO
CG_TYPE_MAX
} CGtype;
typedef enum
{
# define CG_BINDLOCATION_MACRO(name,enum_name,compiler_name,\
enum_int,addressable,param_type) \
enum_name = enum_int,
#include <Cg/cg_bindlocations.h>
CG_UNDEFINED = 3256
} CGresource;
typedef enum
{
CG_PROFILE_START = 6144,
CG_PROFILE_UNKNOWN,
#define CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
CG_PROFILE_##compiler_id_caps = int_id,
#define CG_PROFILE_ALIAS(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile) \
CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt,int_id,vertex_profile)
#include <Cg/cg_profiles.h>
CG_PROFILE_MAX = 7100
} CGprofile;
typedef enum
{
#define CG_ERROR_MACRO(code, enum_name, message) \
enum_name = code,
#include <Cg/cg_errors.h>
CG_ERROR_MAX
} CGerror;
typedef enum
{
#define CG_ENUM_MACRO(enum_name, enum_val) \
enum_name = enum_val,
#include <Cg/cg_enums.h>
CG_ENUM_MAX
} CGenum;
/*!!! PREPROCESS END */
typedef enum
{
CG_PARAMETERCLASS_UNKNOWN = 0,
CG_PARAMETERCLASS_SCALAR,
CG_PARAMETERCLASS_VECTOR,
CG_PARAMETERCLASS_MATRIX,
CG_PARAMETERCLASS_STRUCT,
CG_PARAMETERCLASS_ARRAY,
CG_PARAMETERCLASS_SAMPLER,
CG_PARAMETERCLASS_OBJECT,
CG_PARAMETERCLASS_MAX
} CGparameterclass;
typedef enum
{
CG_UNKNOWN_DOMAIN = 0,
CG_FIRST_DOMAIN = 1,
CG_VERTEX_DOMAIN = 1,
CG_FRAGMENT_DOMAIN,
CG_GEOMETRY_DOMAIN,
CG_NUMBER_OF_DOMAINS,
CG_DOMAIN_MAX
} CGdomain;
typedef enum
{
CG_MAP_READ = 0,
CG_MAP_WRITE,
CG_MAP_READ_WRITE,
CG_MAP_WRITE_DISCARD,
CG_MAP_WRITE_NO_OVERWRITE,
CG_MAP_MAX
} CGbufferaccess;
typedef enum
{
CG_BUFFER_USAGE_STREAM_DRAW = 0,
CG_BUFFER_USAGE_STREAM_READ,
CG_BUFFER_USAGE_STREAM_COPY,
CG_BUFFER_USAGE_STATIC_DRAW,
CG_BUFFER_USAGE_STATIC_READ,
CG_BUFFER_USAGE_STATIC_COPY,
CG_BUFFER_USAGE_DYNAMIC_DRAW,
CG_BUFFER_USAGE_DYNAMIC_READ,
CG_BUFFER_USAGE_DYNAMIC_COPY,
CG_BUFFER_USAGE_MAX
} CGbufferusage;
#ifdef __cplusplus
extern "C" {
#endif
typedef CGbool (CGENTRY * CGstatecallback)(CGstateassignment);
typedef void (CGENTRY * CGerrorCallbackFunc)(void);
typedef void (CGENTRY * CGerrorHandlerFunc)(CGcontext ctx, CGerror err, void *data);
typedef void (CGENTRY * CGIncludeCallbackFunc)(CGcontext ctx, const char *filename);
/*************************************************************************/
/*** Functions ***/
/*************************************************************************/
#ifndef CG_EXPLICIT
/*** Library policy functions ***/
CG_API CGenum CGENTRY cgSetLockingPolicy(CGenum lockingPolicy);
CG_API CGenum CGENTRY cgGetLockingPolicy(void);
CG_API CGenum CGENTRY cgSetSemanticCasePolicy(CGenum casePolicy);
CG_API CGenum CGENTRY cgGetSemanticCasePolicy(void);
/*** Context functions ***/
CG_API CGcontext CGENTRY cgCreateContext(void);
CG_API void CGENTRY cgDestroyContext(CGcontext ctx);
CG_API CGbool CGENTRY cgIsContext(CGcontext ctx);
CG_API const char * CGENTRY cgGetLastListing(CGcontext ctx);
CG_API void CGENTRY cgSetLastListing(CGhandle handle, const char *listing);
CG_API void CGENTRY cgSetAutoCompile(CGcontext ctx, CGenum flag);
CG_API CGenum CGENTRY cgGetAutoCompile(CGcontext ctx);
CG_API void CGENTRY cgSetParameterSettingMode(CGcontext ctx, CGenum parameterSettingMode);
CG_API CGenum CGENTRY cgGetParameterSettingMode(CGcontext ctx);
/*** Inclusion ***/
CG_API void CGENTRY cgSetCompilerIncludeString(CGcontext ctx, const char *name, const char *source);
CG_API void CGENTRY cgSetCompilerIncludeFile(CGcontext ctx, const char *name, const char *filename);
CG_API void CGENTRY cgSetCompilerIncludeCallback(CGcontext ctx, CGIncludeCallbackFunc func);
CG_API CGIncludeCallbackFunc CGENTRY cgGetCompilerIncludeCallback(CGcontext ctx);
/*** Program functions ***/
CG_API CGprogram CGENTRY cgCreateProgram(CGcontext ctx,
CGenum program_type,
const char *program,
CGprofile profile,
const char *entry,
const char **args);
CG_API CGprogram CGENTRY cgCreateProgramFromFile(CGcontext ctx,
CGenum program_type,
const char *program_file,
CGprofile profile,
const char *entry,
const char **args);
CG_API CGprogram CGENTRY cgCopyProgram(CGprogram program);
CG_API void CGENTRY cgDestroyProgram(CGprogram program);
CG_API CGprogram CGENTRY cgGetFirstProgram(CGcontext ctx);
CG_API CGprogram CGENTRY cgGetNextProgram(CGprogram current);
CG_API CGcontext CGENTRY cgGetProgramContext(CGprogram prog);
CG_API CGbool CGENTRY cgIsProgram(CGprogram program);
CG_API void CGENTRY cgCompileProgram(CGprogram program);
CG_API CGbool CGENTRY cgIsProgramCompiled(CGprogram program);
CG_API const char * CGENTRY cgGetProgramString(CGprogram prog, CGenum pname);
CG_API CGprofile CGENTRY cgGetProgramProfile(CGprogram prog);
CG_API char const * const * CGENTRY cgGetProgramOptions(CGprogram prog);
CG_API void CGENTRY cgSetProgramProfile(CGprogram prog, CGprofile profile);
CG_API CGenum CGENTRY cgGetProgramInput(CGprogram program);
CG_API CGenum CGENTRY cgGetProgramOutput(CGprogram program);
CG_API void CGENTRY cgSetPassProgramParameters(CGprogram);
CG_API void CGENTRY cgUpdateProgramParameters(CGprogram program);
CG_API void CGENTRY cgUpdatePassParameters(CGpass pass);
/*** Parameter functions ***/
CG_API CGparameter CGENTRY cgCreateParameter(CGcontext ctx, CGtype type);
CG_API CGparameter CGENTRY cgCreateParameterArray(CGcontext ctx,
CGtype type,
int length);
CG_API CGparameter CGENTRY cgCreateParameterMultiDimArray(CGcontext ctx,
CGtype type,
int dim,
const int *lengths);
CG_API void CGENTRY cgDestroyParameter(CGparameter param);
CG_API void CGENTRY cgConnectParameter(CGparameter from, CGparameter to);
CG_API void CGENTRY cgDisconnectParameter(CGparameter param);
CG_API CGparameter CGENTRY cgGetConnectedParameter(CGparameter param);
CG_API int CGENTRY cgGetNumConnectedToParameters(CGparameter param);
CG_API CGparameter CGENTRY cgGetConnectedToParameter(CGparameter param, int index);
CG_API CGparameter CGENTRY cgGetNamedParameter(CGprogram prog, const char *name);
CG_API CGparameter CGENTRY cgGetNamedProgramParameter(CGprogram prog,
CGenum name_space,
const char *name);
CG_API CGparameter CGENTRY cgGetFirstParameter(CGprogram prog, CGenum name_space);
CG_API CGparameter CGENTRY cgGetNextParameter(CGparameter current);
CG_API CGparameter CGENTRY cgGetFirstLeafParameter(CGprogram prog, CGenum name_space);
CG_API CGparameter CGENTRY cgGetNextLeafParameter(CGparameter current);
CG_API CGparameter CGENTRY cgGetFirstStructParameter(CGparameter param);
CG_API CGparameter CGENTRY cgGetNamedStructParameter(CGparameter param,
const char *name);
CG_API CGparameter CGENTRY cgGetFirstDependentParameter(CGparameter param);
CG_API CGparameter CGENTRY cgGetArrayParameter(CGparameter aparam, int index);
CG_API int CGENTRY cgGetArrayDimension(CGparameter param);
CG_API CGtype CGENTRY cgGetArrayType(CGparameter param);
CG_API int CGENTRY cgGetArraySize(CGparameter param, int dimension);
CG_API int CGENTRY cgGetArrayTotalSize(CGparameter param);
CG_API void CGENTRY cgSetArraySize(CGparameter param, int size);
CG_API void CGENTRY cgSetMultiDimArraySize(CGparameter param, const int *sizes);
CG_API CGprogram CGENTRY cgGetParameterProgram(CGparameter param);
CG_API CGcontext CGENTRY cgGetParameterContext(CGparameter param);
CG_API CGbool CGENTRY cgIsParameter(CGparameter param);
CG_API const char * CGENTRY cgGetParameterName(CGparameter param);
CG_API CGtype CGENTRY cgGetParameterType(CGparameter param);
CG_API CGtype CGENTRY cgGetParameterBaseType(CGparameter param);
CG_API CGparameterclass CGENTRY cgGetParameterClass(CGparameter param);
CG_API int CGENTRY cgGetParameterRows(CGparameter param);
CG_API int CGENTRY cgGetParameterColumns(CGparameter param);
CG_API CGtype CGENTRY cgGetParameterNamedType(CGparameter param);
CG_API const char * CGENTRY cgGetParameterSemantic(CGparameter param);
CG_API CGresource CGENTRY cgGetParameterResource(CGparameter param);
CG_API CGresource CGENTRY cgGetParameterBaseResource(CGparameter param);
CG_API unsigned long CGENTRY cgGetParameterResourceIndex(CGparameter param);
CG_API CGenum CGENTRY cgGetParameterVariability(CGparameter param);
CG_API CGenum CGENTRY cgGetParameterDirection(CGparameter param);
CG_API CGbool CGENTRY cgIsParameterReferenced(CGparameter param);
CG_API CGbool CGENTRY cgIsParameterUsed(CGparameter param, CGhandle handle);
CG_API const double * CGENTRY cgGetParameterValues(CGparameter param,
CGenum value_type,
int *nvalues);
CG_API void CGENTRY cgSetParameterValuedr(CGparameter param, int n, const double *vals);
CG_API void CGENTRY cgSetParameterValuedc(CGparameter param, int n, const double *vals);
CG_API void CGENTRY cgSetParameterValuefr(CGparameter param, int n, const float *vals);
CG_API void CGENTRY cgSetParameterValuefc(CGparameter param, int n, const float *vals);
CG_API void CGENTRY cgSetParameterValueir(CGparameter param, int n, const int *vals);
CG_API void CGENTRY cgSetParameterValueic(CGparameter param, int n, const int *vals);
CG_API int CGENTRY cgGetParameterValuedr(CGparameter param, int n, double *vals);
CG_API int CGENTRY cgGetParameterValuedc(CGparameter param, int n, double *vals);
CG_API int CGENTRY cgGetParameterValuefr(CGparameter param, int n, float *vals);
CG_API int CGENTRY cgGetParameterValuefc(CGparameter param, int n, float *vals);
CG_API int CGENTRY cgGetParameterValueir(CGparameter param, int n, int *vals);
CG_API int CGENTRY cgGetParameterValueic(CGparameter param, int n, int *vals);
CG_API int CGENTRY cgGetParameterDefaultValuedr(CGparameter param, int n, double *vals);
CG_API int CGENTRY cgGetParameterDefaultValuedc(CGparameter param, int n, double *vals);
CG_API int CGENTRY cgGetParameterDefaultValuefr(CGparameter param, int n, float *vals);
CG_API int CGENTRY cgGetParameterDefaultValuefc(CGparameter param, int n, float *vals);
CG_API int CGENTRY cgGetParameterDefaultValueir(CGparameter param, int n, int *vals);
CG_API int CGENTRY cgGetParameterDefaultValueic(CGparameter param, int n, int *vals);
CG_API const char * CGENTRY cgGetStringParameterValue(CGparameter param);
CG_API void CGENTRY cgSetStringParameterValue(CGparameter param, const char *str);
CG_API int CGENTRY cgGetParameterOrdinalNumber(CGparameter param);
CG_API CGbool CGENTRY cgIsParameterGlobal(CGparameter param);
CG_API int CGENTRY cgGetParameterIndex(CGparameter param);
CG_API void CGENTRY cgSetParameterVariability(CGparameter param, CGenum vary);
CG_API void CGENTRY cgSetParameterSemantic(CGparameter param, const char *semantic);
CG_API void CGENTRY cgSetParameter1f(CGparameter param, float x);
CG_API void CGENTRY cgSetParameter2f(CGparameter param, float x, float y);
CG_API void CGENTRY cgSetParameter3f(CGparameter param, float x, float y, float z);
CG_API void CGENTRY cgSetParameter4f(CGparameter param,
float x,
float y,
float z,
float w);
CG_API void CGENTRY cgSetParameter1d(CGparameter param, double x);
CG_API void CGENTRY cgSetParameter2d(CGparameter param, double x, double y);
CG_API void CGENTRY cgSetParameter3d(CGparameter param,
double x,
double y,
double z);
CG_API void CGENTRY cgSetParameter4d(CGparameter param,
double x,
double y,
double z,
double w);
CG_API void CGENTRY cgSetParameter1i(CGparameter param, int x);
CG_API void CGENTRY cgSetParameter2i(CGparameter param, int x, int y);
CG_API void CGENTRY cgSetParameter3i(CGparameter param, int x, int y, int z);
CG_API void CGENTRY cgSetParameter4i(CGparameter param,
int x,
int y,
int z,
int w);
CG_API void CGENTRY cgSetParameter1iv(CGparameter param, const int *v);
CG_API void CGENTRY cgSetParameter2iv(CGparameter param, const int *v);
CG_API void CGENTRY cgSetParameter3iv(CGparameter param, const int *v);
CG_API void CGENTRY cgSetParameter4iv(CGparameter param, const int *v);
CG_API void CGENTRY cgSetParameter1fv(CGparameter param, const float *v);
CG_API void CGENTRY cgSetParameter2fv(CGparameter param, const float *v);
CG_API void CGENTRY cgSetParameter3fv(CGparameter param, const float *v);
CG_API void CGENTRY cgSetParameter4fv(CGparameter param, const float *v);
CG_API void CGENTRY cgSetParameter1dv(CGparameter param, const double *v);
CG_API void CGENTRY cgSetParameter2dv(CGparameter param, const double *v);
CG_API void CGENTRY cgSetParameter3dv(CGparameter param, const double *v);
CG_API void CGENTRY cgSetParameter4dv(CGparameter param, const double *v);
CG_API void CGENTRY cgSetMatrixParameterir(CGparameter param, const int *matrix);
CG_API void CGENTRY cgSetMatrixParameterdr(CGparameter param, const double *matrix);
CG_API void CGENTRY cgSetMatrixParameterfr(CGparameter param, const float *matrix);
CG_API void CGENTRY cgSetMatrixParameteric(CGparameter param, const int *matrix);
CG_API void CGENTRY cgSetMatrixParameterdc(CGparameter param, const double *matrix);
CG_API void CGENTRY cgSetMatrixParameterfc(CGparameter param, const float *matrix);
CG_API void CGENTRY cgGetMatrixParameterir(CGparameter param, int *matrix);
CG_API void CGENTRY cgGetMatrixParameterdr(CGparameter param, double *matrix);
CG_API void CGENTRY cgGetMatrixParameterfr(CGparameter param, float *matrix);
CG_API void CGENTRY cgGetMatrixParameteric(CGparameter param, int *matrix);
CG_API void CGENTRY cgGetMatrixParameterdc(CGparameter param, double *matrix);
CG_API void CGENTRY cgGetMatrixParameterfc(CGparameter param, float *matrix);
CG_API CGenum CGENTRY cgGetMatrixParameterOrder(CGparameter param);
CG_API CGparameter CGENTRY cgGetNamedSubParameter(CGparameter param, const char *name);
/*** Type Functions ***/
CG_API const char * CGENTRY cgGetTypeString(CGtype type);
CG_API CGtype CGENTRY cgGetType(const char *type_string);
CG_API CGtype CGENTRY cgGetNamedUserType(CGhandle handle, const char *name);
CG_API int CGENTRY cgGetNumUserTypes(CGhandle handle);
CG_API CGtype CGENTRY cgGetUserType(CGhandle handle, int index);
CG_API int CGENTRY cgGetNumParentTypes(CGtype type);
CG_API CGtype CGENTRY cgGetParentType(CGtype type, int index);
CG_API CGbool CGENTRY cgIsParentType(CGtype parent, CGtype child);
CG_API CGbool CGENTRY cgIsInterfaceType(CGtype type);
/*** Resource Functions ***/
CG_API const char * CGENTRY cgGetResourceString(CGresource resource);
CG_API CGresource CGENTRY cgGetResource(const char *resource_string);
/*** Enum Functions ***/
CG_API const char * CGENTRY cgGetEnumString(CGenum en);
CG_API CGenum CGENTRY cgGetEnum(const char *enum_string);
/*** Profile Functions ***/
CG_API const char * CGENTRY cgGetProfileString(CGprofile profile);
CG_API CGprofile CGENTRY cgGetProfile(const char *profile_string);
CG_API int CGENTRY cgGetNumSupportedProfiles(void);
CG_API CGprofile CGENTRY cgGetSupportedProfile(int index);
CG_API CGbool CGENTRY cgIsProfileSupported(CGprofile profile);
CG_API CGbool CGENTRY cgGetProfileProperty(CGprofile profile, CGenum query);
/*** ParameterClass Functions ***/
CG_API const char * CGENTRY cgGetParameterClassString(CGparameterclass pc);
CG_API CGparameterclass CGENTRY cgGetParameterClassEnum(const char * pString);
/*** Domain Functions ***/
CG_API const char * CGENTRY cgGetDomainString(CGdomain domain);
CG_API CGdomain CGENTRY cgGetDomain(const char *domain_string);
CG_API CGdomain CGENTRY cgGetProgramDomain(CGprogram program);
/*** Error Functions ***/
CG_API CGerror CGENTRY cgGetError(void);
CG_API CGerror CGENTRY cgGetFirstError(void);
CG_API const char * CGENTRY cgGetErrorString(CGerror error);
CG_API const char * CGENTRY cgGetLastErrorString(CGerror *error);
CG_API void CGENTRY cgSetErrorCallback(CGerrorCallbackFunc func);
CG_API CGerrorCallbackFunc CGENTRY cgGetErrorCallback(void);
CG_API void CGENTRY cgSetErrorHandler(CGerrorHandlerFunc func, void *data);
CG_API CGerrorHandlerFunc CGENTRY cgGetErrorHandler(void **data);
/*** Misc Functions ***/
CG_API const char * CGENTRY cgGetString(CGenum sname);
/*** CgFX Functions ***/
CG_API CGeffect CGENTRY cgCreateEffect(CGcontext, const char *code, const char **args);
CG_API CGeffect CGENTRY cgCreateEffectFromFile(CGcontext, const char *filename,
const char **args);
CG_API CGeffect CGENTRY cgCopyEffect(CGeffect effect);
CG_API void CGENTRY cgDestroyEffect(CGeffect);
CG_API CGcontext CGENTRY cgGetEffectContext(CGeffect);
CG_API CGbool CGENTRY cgIsEffect(CGeffect effect);
CG_API CGeffect CGENTRY cgGetFirstEffect(CGcontext);
CG_API CGeffect CGENTRY cgGetNextEffect(CGeffect);
CG_API CGprogram CGENTRY cgCreateProgramFromEffect(CGeffect effect,
CGprofile profile,
const char *entry,
const char **args);
CG_API CGtechnique CGENTRY cgGetFirstTechnique(CGeffect);
CG_API CGtechnique CGENTRY cgGetNextTechnique(CGtechnique);
CG_API CGtechnique CGENTRY cgGetNamedTechnique(CGeffect, const char *name);
CG_API const char * CGENTRY cgGetTechniqueName(CGtechnique);
CG_API CGbool CGENTRY cgIsTechnique(CGtechnique);
CG_API CGbool CGENTRY cgValidateTechnique(CGtechnique);
CG_API CGbool CGENTRY cgIsTechniqueValidated(CGtechnique);
CG_API CGeffect CGENTRY cgGetTechniqueEffect(CGtechnique);
CG_API CGpass CGENTRY cgGetFirstPass(CGtechnique);
CG_API CGpass CGENTRY cgGetNamedPass(CGtechnique, const char *name);
CG_API CGpass CGENTRY cgGetNextPass(CGpass);
CG_API CGbool CGENTRY cgIsPass(CGpass);
CG_API const char * CGENTRY cgGetPassName(CGpass);
CG_API CGtechnique CGENTRY cgGetPassTechnique(CGpass);
CG_API CGprogram CGENTRY cgGetPassProgram(CGpass pass, CGdomain domain);
CG_API void CGENTRY cgSetPassState(CGpass);
CG_API void CGENTRY cgResetPassState(CGpass);
CG_API CGstateassignment CGENTRY cgGetFirstStateAssignment(CGpass);
CG_API CGstateassignment CGENTRY cgGetNamedStateAssignment(CGpass, const char *name);
CG_API CGstateassignment CGENTRY cgGetNextStateAssignment(CGstateassignment);
CG_API CGbool CGENTRY cgIsStateAssignment(CGstateassignment);
CG_API CGbool CGENTRY cgCallStateSetCallback(CGstateassignment);
CG_API CGbool CGENTRY cgCallStateValidateCallback(CGstateassignment);
CG_API CGbool CGENTRY cgCallStateResetCallback(CGstateassignment);
CG_API CGpass CGENTRY cgGetStateAssignmentPass(CGstateassignment);
CG_API CGparameter CGENTRY cgGetSamplerStateAssignmentParameter(CGstateassignment);
CG_API const float * CGENTRY cgGetFloatStateAssignmentValues(CGstateassignment, int *nVals);
CG_API const int * CGENTRY cgGetIntStateAssignmentValues(CGstateassignment, int *nVals);
CG_API const CGbool * CGENTRY cgGetBoolStateAssignmentValues(CGstateassignment, int *nVals);
CG_API const char * CGENTRY cgGetStringStateAssignmentValue(CGstateassignment);
CG_API CGprogram CGENTRY cgGetProgramStateAssignmentValue(CGstateassignment);
CG_API CGparameter CGENTRY cgGetTextureStateAssignmentValue(CGstateassignment);
CG_API CGparameter CGENTRY cgGetSamplerStateAssignmentValue(CGstateassignment);
CG_API int CGENTRY cgGetStateAssignmentIndex(CGstateassignment);
CG_API int CGENTRY cgGetNumDependentStateAssignmentParameters(CGstateassignment);
CG_API CGparameter CGENTRY cgGetDependentStateAssignmentParameter(CGstateassignment, int index);
CG_API CGparameter CGENTRY cgGetConnectedStateAssignmentParameter(CGstateassignment);
CG_API CGstate CGENTRY cgGetStateAssignmentState(CGstateassignment);
CG_API CGstate CGENTRY cgGetSamplerStateAssignmentState(CGstateassignment);
CG_API CGstate CGENTRY cgCreateState(CGcontext, const char *name, CGtype);
CG_API CGstate CGENTRY cgCreateArrayState(CGcontext, const char *name, CGtype, int nelems);
CG_API void CGENTRY cgSetStateCallbacks(CGstate, CGstatecallback set, CGstatecallback reset,
CGstatecallback validate);
CG_API void CGENTRY cgSetStateLatestProfile(CGstate, CGprofile);
CG_API CGstatecallback CGENTRY cgGetStateSetCallback(CGstate);
CG_API CGstatecallback CGENTRY cgGetStateResetCallback(CGstate);
CG_API CGstatecallback CGENTRY cgGetStateValidateCallback(CGstate);
CG_API CGprofile CGENTRY cgGetStateLatestProfile(CGstate);
CG_API CGcontext CGENTRY cgGetStateContext(CGstate);
CG_API CGtype CGENTRY cgGetStateType(CGstate);
CG_API const char * CGENTRY cgGetStateName(CGstate);
CG_API CGstate CGENTRY cgGetNamedState(CGcontext, const char *name);
CG_API CGstate CGENTRY cgGetFirstState(CGcontext);
CG_API CGstate CGENTRY cgGetNextState(CGstate);
CG_API CGbool CGENTRY cgIsState(CGstate);
CG_API void CGENTRY cgAddStateEnumerant(CGstate, const char *name, int value);
CG_API CGstate CGENTRY cgCreateSamplerState(CGcontext, const char *name, CGtype);
CG_API CGstate CGENTRY cgCreateArraySamplerState(CGcontext, const char *name, CGtype, int nelems);
CG_API CGstate CGENTRY cgGetNamedSamplerState(CGcontext, const char *name);
CG_API CGstate CGENTRY cgGetFirstSamplerState(CGcontext);
CG_API CGstateassignment CGENTRY cgGetFirstSamplerStateAssignment(CGparameter);
CG_API CGstateassignment CGENTRY cgGetNamedSamplerStateAssignment(CGparameter, const char *);
CG_API void CGENTRY cgSetSamplerState(CGparameter);
CG_API CGparameter CGENTRY cgGetNamedEffectParameter(CGeffect, const char *);
CG_API CGparameter CGENTRY cgGetFirstLeafEffectParameter(CGeffect);
CG_API CGparameter CGENTRY cgGetFirstEffectParameter(CGeffect);
CG_API CGparameter CGENTRY cgGetEffectParameterBySemantic(CGeffect, const char *);
CG_API CGannotation CGENTRY cgGetFirstTechniqueAnnotation(CGtechnique);
CG_API CGannotation CGENTRY cgGetFirstPassAnnotation(CGpass);
CG_API CGannotation CGENTRY cgGetFirstParameterAnnotation(CGparameter);
CG_API CGannotation CGENTRY cgGetFirstProgramAnnotation(CGprogram);
CG_API CGannotation CGENTRY cgGetFirstEffectAnnotation(CGeffect);
CG_API CGannotation CGENTRY cgGetNextAnnotation(CGannotation);
CG_API CGannotation CGENTRY cgGetNamedTechniqueAnnotation(CGtechnique, const char *);
CG_API CGannotation CGENTRY cgGetNamedPassAnnotation(CGpass, const char *);
CG_API CGannotation CGENTRY cgGetNamedParameterAnnotation(CGparameter, const char *);
CG_API CGannotation CGENTRY cgGetNamedProgramAnnotation(CGprogram, const char *);
CG_API CGannotation CGENTRY cgGetNamedEffectAnnotation(CGeffect, const char *);
CG_API CGbool CGENTRY cgIsAnnotation(CGannotation);
CG_API const char * CGENTRY cgGetAnnotationName(CGannotation);
CG_API CGtype CGENTRY cgGetAnnotationType(CGannotation);
CG_API const float * CGENTRY cgGetFloatAnnotationValues(CGannotation, int *nvalues);
CG_API const int * CGENTRY cgGetIntAnnotationValues(CGannotation, int *nvalues);
CG_API const char * CGENTRY cgGetStringAnnotationValue(CGannotation);
CG_API const char * const * CGENTRY cgGetStringAnnotationValues(CGannotation, int *nvalues);
CG_API const CGbool * CGENTRY cgGetBoolAnnotationValues(CGannotation, int *nvalues);
CG_API const int * CGENTRY cgGetBooleanAnnotationValues(CGannotation, int *nvalues);
CG_API int CGENTRY cgGetNumDependentAnnotationParameters(CGannotation);
CG_API CGparameter CGENTRY cgGetDependentAnnotationParameter(CGannotation, int index);
CG_API void CGENTRY cgEvaluateProgram(CGprogram, float *, int ncomps, int nx, int ny, int nz);
/*** Cg 1.5 Additions ***/
CG_API CGbool CGENTRY cgSetEffectName(CGeffect, const char *name);
CG_API const char * CGENTRY cgGetEffectName(CGeffect);
CG_API CGeffect CGENTRY cgGetNamedEffect(CGcontext, const char *name);
CG_API CGparameter CGENTRY cgCreateEffectParameter(CGeffect, const char *name, CGtype);
CG_API CGtechnique CGENTRY cgCreateTechnique(CGeffect, const char *name);
CG_API CGparameter CGENTRY cgCreateEffectParameterArray(CGeffect, const char *name, CGtype type, int length);
CG_API CGparameter CGENTRY cgCreateEffectParameterMultiDimArray(CGeffect, const char *name, CGtype type, int dim, const int *lengths);
CG_API CGpass CGENTRY cgCreatePass(CGtechnique, const char *name);
CG_API CGstateassignment CGENTRY cgCreateStateAssignment(CGpass, CGstate);
CG_API CGstateassignment CGENTRY cgCreateStateAssignmentIndex(CGpass, CGstate, int index);
CG_API CGstateassignment CGENTRY cgCreateSamplerStateAssignment(CGparameter, CGstate);
CG_API CGbool CGENTRY cgSetFloatStateAssignment(CGstateassignment, float);
CG_API CGbool CGENTRY cgSetIntStateAssignment(CGstateassignment, int);
CG_API CGbool CGENTRY cgSetBoolStateAssignment(CGstateassignment, CGbool);
CG_API CGbool CGENTRY cgSetStringStateAssignment(CGstateassignment, const char *);
CG_API CGbool CGENTRY cgSetProgramStateAssignment(CGstateassignment, CGprogram);
CG_API CGbool CGENTRY cgSetSamplerStateAssignment(CGstateassignment, CGparameter);
CG_API CGbool CGENTRY cgSetTextureStateAssignment(CGstateassignment, CGparameter);
CG_API CGbool CGENTRY cgSetFloatArrayStateAssignment(CGstateassignment, const float *vals);
CG_API CGbool CGENTRY cgSetIntArrayStateAssignment(CGstateassignment, const int *vals);
CG_API CGbool CGENTRY cgSetBoolArrayStateAssignment(CGstateassignment, const CGbool *vals);
CG_API CGannotation CGENTRY cgCreateTechniqueAnnotation(CGtechnique, const char *name, CGtype);
CG_API CGannotation CGENTRY cgCreatePassAnnotation(CGpass, const char *name, CGtype);
CG_API CGannotation CGENTRY cgCreateParameterAnnotation(CGparameter, const char *name, CGtype);
CG_API CGannotation CGENTRY cgCreateProgramAnnotation(CGprogram, const char *name, CGtype);
CG_API CGannotation CGENTRY cgCreateEffectAnnotation(CGeffect, const char *name, CGtype);
CG_API CGbool CGENTRY cgSetIntAnnotation(CGannotation, int value);
CG_API CGbool CGENTRY cgSetFloatAnnotation(CGannotation, float value);
CG_API CGbool CGENTRY cgSetBoolAnnotation(CGannotation, CGbool value);
CG_API CGbool CGENTRY cgSetStringAnnotation(CGannotation, const char *value);
CG_API int CGENTRY cgGetNumStateEnumerants(CGstate);
CG_API const char * CGENTRY cgGetStateEnumerant(CGstate, int index, int* value);
CG_API const char * CGENTRY cgGetStateEnumerantName(CGstate, int value);
CG_API int CGENTRY cgGetStateEnumerantValue(CGstate, const char *name);
CG_API CGeffect CGENTRY cgGetParameterEffect(CGparameter param);
CG_API CGparameterclass CGENTRY cgGetTypeClass(CGtype type);
CG_API CGtype CGENTRY cgGetTypeBase(CGtype type);
CG_API CGbool CGENTRY cgGetTypeSizes(CGtype type, int *nrows, int *ncols);
CG_API void CGENTRY cgGetMatrixSize(CGtype type, int *nrows, int *ncols);
CG_API int CGENTRY cgGetNumProgramDomains( CGprogram program );
CG_API CGdomain CGENTRY cgGetProfileDomain( CGprofile profile );
CG_API CGprogram CGENTRY cgCombinePrograms( int n, const CGprogram *exeList );
CG_API CGprogram CGENTRY cgCombinePrograms2( const CGprogram exe1, const CGprogram exe2 );
CG_API CGprogram CGENTRY cgCombinePrograms3( const CGprogram exe1, const CGprogram exe2, const CGprogram exe3 );
CG_API CGprofile CGENTRY cgGetProgramDomainProfile(CGprogram program, int index);
CG_API CGprogram CGENTRY cgGetProgramDomainProgram(CGprogram program, int index);
/*** CGobj Functions ***/
CG_API CGobj CGENTRY cgCreateObj( CGcontext context, CGenum program_type, const char *source, CGprofile profile, const char **args );
CG_API CGobj CGENTRY cgCreateObjFromFile( CGcontext context, CGenum program_type, const char *source_file, CGprofile profile, const char **args );
CG_API void CGENTRY cgDestroyObj( CGobj obj );
CG_API long CGENTRY cgGetParameterResourceSize(CGparameter);
CG_API CGtype CGENTRY cgGetParameterResourceType(CGparameter);
CG_API const char* CGENTRY cgGetParameterResourceName(CGparameter param);
CG_API int CGENTRY cgGetParameterBufferIndex(CGparameter);
CG_API int CGENTRY cgGetParameterBufferOffset(CGparameter);
CG_API CGbuffer CGENTRY cgCreateBuffer(CGcontext, int size, const void *data, CGbufferusage bufferUsage);
CG_API void CGENTRY cgSetBufferData(CGbuffer, int size, const void *data);
CG_API void CGENTRY cgSetBufferSubData(CGbuffer, int offset, int size, const void *data);
CG_API void CGENTRY cgSetProgramBuffer(CGprogram program, int bufferIndex, CGbuffer buffer);
CG_API void * CGENTRY cgMapBuffer(CGbuffer buffer, CGbufferaccess access);
CG_API void CGENTRY cgUnmapBuffer(CGbuffer buffer);
CG_API void CGENTRY cgDestroyBuffer(CGbuffer buffer);
CG_API CGbuffer CGENTRY cgGetProgramBuffer(CGprogram, int bufferIndex);
CG_API int CGENTRY cgGetBufferSize(CGbuffer);
CG_API int CGENTRY cgGetProgramBufferMaxSize(CGprofile profile);
CG_API int CGENTRY cgGetProgramBufferMaxIndex(CGprofile profile);
#endif
#ifdef __cplusplus
}
#endif
#ifdef CG_APIENTRY_DEFINED
# undef CG_APIENTRY_DEFINED
# undef APIENTRY
#endif
#ifdef CG_WINGDIAPI_DEFINED
# undef CG_WINGDIAPI_DEFINED
# undef WINGDIAPI
#endif
#endif

View File

@ -0,0 +1,238 @@
/*
*
* Copyright (c) 2008-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __CGD3D10_H__
#define __CGD3D10_H__
#ifdef _WIN32
#pragma once
#include <windows.h>
#include <d3d10.h>
#include "Cg/cg.h"
// Set up for either Win32 import/export/lib.
#ifdef CGD3D10DLL_EXPORTS
#define CGD3D10DLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGD3D10DLL_API
#else
#define CGD3D10DLL_API __declspec(dllimport)
#endif
#ifndef CGD3D10ENTRY
# ifdef _WIN32
# define CGD3D10ENTRY __cdecl
# else
# define CGD3D10ENTRY
# endif
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef CGD3D10_EXPLICIT
/* ----- D3D Device Control ----- */
CGD3D10DLL_API ID3D10Device * CGD3D10ENTRY
cgD3D10GetDevice(
CGcontext Context
);
CGD3D10DLL_API HRESULT CGD3D10ENTRY
cgD3D10SetDevice(
CGcontext Context,
ID3D10Device * pDevice
);
/* ----- Texture Functions ----- */
CGD3D10DLL_API void CGD3D10ENTRY
cgD3D10SetTextureParameter(
CGparameter Parameter,
ID3D10Resource * pTexture
);
CGD3D10DLL_API void CGD3D10ENTRY
cgD3D10SetSamplerStateParameter(
CGparameter Parameter,
ID3D10SamplerState * pSamplerState
);
CGD3D10DLL_API void CGD3D10ENTRY
cgD3D10SetTextureSamplerStateParameter(
CGparameter Parameter,
ID3D10Resource * pTexture,
ID3D10SamplerState * pSamplerState
);
/* ----- Shader Management ----- */
CGD3D10DLL_API HRESULT CGD3D10ENTRY
cgD3D10LoadProgram(
CGprogram Program,
UINT Flags
);
CGD3D10DLL_API ID3D10Blob * CGD3D10ENTRY
cgD3D10GetCompiledProgram(
CGprogram Program
);
CGD3D10DLL_API ID3D10Blob * CGD3D10ENTRY
cgD3D10GetProgramErrors(
CGprogram Program
);
CGD3D10DLL_API CGbool CGD3D10ENTRY
cgD3D10IsProgramLoaded(
CGprogram Program
);
CGD3D10DLL_API HRESULT CGD3D10ENTRY
cgD3D10BindProgram(
CGprogram Program
);
CGD3D10DLL_API void CGD3D10ENTRY
cgD3D10UnloadProgram(
CGprogram Program
);
/* ----- Buffer Management ----- */
CGD3D10DLL_API ID3D10Buffer * CGD3D10ENTRY
cgD3D10GetBufferByIndex(
CGprogram Program,
UINT Index
);
/* ----- CgFX ----- */
CGD3D10DLL_API void CGD3D10ENTRY
cgD3D10RegisterStates(
CGcontext Context
);
CGD3D10DLL_API void CGD3D10ENTRY
cgD3D10SetManageTextureParameters(
CGcontext Context,
CGbool Flag
);
CGD3D10DLL_API CGbool CGD3D10ENTRY
cgD3D10GetManageTextureParameters(
CGcontext Context
);
CGD3D10DLL_API ID3D10Blob * CGD3D10ENTRY
cgD3D10GetIASignatureByPass(
CGpass Pass
);
/* ----- Profile Options ----- */
CGD3D10DLL_API CGprofile CGD3D10ENTRY
cgD3D10GetLatestVertexProfile();
CGD3D10DLL_API CGprofile CGD3D10ENTRY
cgD3D10GetLatestGeometryProfile();
CGD3D10DLL_API CGprofile CGD3D10ENTRY
cgD3D10GetLatestPixelProfile();
CGD3D10DLL_API CGbool CGD3D10ENTRY
cgD3D10IsProfileSupported(
CGprofile Profile
);
/* ----- Utility Functions ----- */
CGD3D10DLL_API DWORD CGD3D10ENTRY
cgD3D10TypeToSize(
CGtype Type
);
CGD3D10DLL_API HRESULT CGD3D10ENTRY
cgD3D10GetLastError();
CGD3D10DLL_API const char ** CGD3D10ENTRY
cgD3D10GetOptimalOptions(
CGprofile Profile
);
CGD3D10DLL_API const char * CGD3D10ENTRY
cgD3D10TranslateCGerror(
CGerror Error
);
CGD3D10DLL_API const char * CGD3D10ENTRY
cgD3D10TranslateHRESULT(
HRESULT hr
);
#endif // #ifndef CGD3D10_EXPLICIT
#ifdef __cplusplus
}; // extern "C"
#endif
#endif // #ifdef _WIN32
#endif // #ifndef __CGD3D10_H__

View File

@ -0,0 +1,279 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef CGD3D8_INCLUDED
#define CGD3D8_INCLUDED
#ifdef _WIN32
#pragma once
#include "cg.h"
#include <d3d8.h>
#include <d3dx8.h>
// Set up for either Win32 import/export/lib.
#include <windows.h>
#ifdef CGD3D8DLL_EXPORTS
#define CGD3D8DLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGD3D8DLL_API
#else
#define CGD3D8DLL_API __declspec(dllimport)
#endif
#ifndef CGD3D8ENTRY
# ifdef _WIN32
# define CGD3D8ENTRY __cdecl
# else
# define CGD3D8ENTRY
# endif
#endif
/*---------------------------------------------------------------------------
// CGerrors that will be fed to cgSetError
// Use cgD3D8TranslateCGerror() to translate these errors into strings.
---------------------------------------------------------------------------*/
enum cgD3D8Errors
{
cgD3D8Failed = 1000,
cgD3D8DebugTrace = 1001,
};
/*---------------------------------------------------------------------------
// HRESULTs specific to cgD3D8. When the CGerror is set to cgD3D8Failed
// cgD3D8GetLastError will return an HRESULT that could be one these.
// Use cgD3D8TranslateHRESULT() to translate these errors into strings.
---------------------------------------------------------------------------*/
static const HRESULT CGD3D8ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1);
static const HRESULT CGD3D8ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2);
static const HRESULT CGD3D8ERR_NOTSAMPLER = MAKE_HRESULT(1, 0x877, 3);
static const HRESULT CGD3D8ERR_INVALIDPROFILE = MAKE_HRESULT(1, 0x877, 4);
static const HRESULT CGD3D8ERR_NULLVALUE = MAKE_HRESULT(1, 0x877, 5);
static const HRESULT CGD3D8ERR_OUTOFRANGE = MAKE_HRESULT(1, 0x877, 6);
static const HRESULT CGD3D8ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7);
static const HRESULT CGD3D8ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8);
static const HRESULT CGD3D8ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9);
static const HRESULT CGD3D8ERR_INVALIDSAMPLERSTATE = MAKE_HRESULT(1, 0x877, 100);
static const HRESULT CGD3D8ERR_INVALIDVEREXDECL = MAKE_HRESULT(1, 0x877, 101);
/*---------------------------------------------------------------------------
// Other error return values
---------------------------------------------------------------------------*/
static const DWORD CGD3D8_INVALID_REG = 0xFFFFFFFF;
#ifdef __cplusplus
extern "C"
{
#endif
/*---------------------------------------------------------------------------
// Minimal Interface
---------------------------------------------------------------------------*/
CGD3D8DLL_API DWORD CGD3D8ENTRY
cgD3D8TypeToSize(
CGtype type
);
CGD3D8DLL_API DWORD CGD3D8ENTRY
cgD3D8ResourceToInputRegister(
CGresource resource
);
CGD3D8DLL_API CGbool CGD3D8ENTRY
cgD3D8GetVertexDeclaration(
CGprogram prog,
DWORD decl[MAX_FVF_DECL_SIZE]
);
CGD3D8DLL_API CGbool CGD3D8ENTRY
cgD3D8ValidateVertexDeclaration(
CGprogram prog,
const DWORD* decl
);
/*---------------------------------------------------------------------------
// Expanded Interface
---------------------------------------------------------------------------*/
/* ----- D3D Device Control ----------- */
CGD3D8DLL_API IDirect3DDevice8 * CGD3D8ENTRY
cgD3D8GetDevice();
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetDevice(
IDirect3DDevice8* pDevice
);
/* ----- Shader Management ----------- */
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8LoadProgram(
CGprogram prog,
CGbool paramShadowing,
DWORD assemFlags,
DWORD vshaderUsage,
const DWORD* vertexDecl
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8UnloadProgram(
CGprogram prog
);
CGD3D8DLL_API CGbool CGD3D8ENTRY
cgD3D8IsProgramLoaded(
CGprogram prog
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8BindProgram(
CGprogram prog
);
/* ----- Parameter Management ----------- */
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetUniform(
CGparameter param,
const void* floats
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetUniformArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const void* values
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetUniformMatrix(
CGparameter param,
const D3DMATRIX* matrix
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetUniformMatrixArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const D3DMATRIX* matrices
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetTexture(
CGparameter param,
IDirect3DBaseTexture8* tex
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetTextureStageState(
CGparameter param,
D3DTEXTURESTAGESTATETYPE type,
DWORD value
);
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8SetTextureWrapMode(
CGparameter param,
DWORD value
);
/* ----- Parameter Management (Shadowing) ----------- */
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8EnableParameterShadowing(
CGprogram prog,
CGbool enable
);
CGD3D8DLL_API CGbool CGD3D8ENTRY
cgD3D8IsParameterShadowingEnabled(
CGprogram prog
);
/* --------- Profile Options ----------------- */
CGD3D8DLL_API CGprofile CGD3D8ENTRY
cgD3D8GetLatestVertexProfile();
CGD3D8DLL_API CGprofile CGD3D8ENTRY
cgD3D8GetLatestPixelProfile();
CGD3D8DLL_API const char * CGD3D8ENTRY
cgD3D8GetOptimalOptions(
CGprofile profile
);
/* --------- Error reporting ----------------- */
CGD3D8DLL_API HRESULT CGD3D8ENTRY
cgD3D8GetLastError();
CGD3D8DLL_API const char * CGD3D8ENTRY
cgD3D8TranslateCGerror(
CGerror error
);
CGD3D8DLL_API const char * CGD3D8ENTRY
cgD3D8TranslateHRESULT(
HRESULT hr
);
CGD3D8DLL_API void CGD3D8ENTRY
cgD3D8EnableDebugTracing(
CGbool enable
);
#ifdef __cplusplus
};
#endif
#endif // _WIN32
#endif

View File

@ -0,0 +1,317 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef CGD3D9_INCLUDED
#define CGD3D9_INCLUDED
#ifdef _WIN32
#pragma once
#include "cg.h"
#include <d3d9.h>
#include <d3dx9.h>
// Set up for either Win32 import/export/lib.
#include <windows.h>
#ifdef CGD3D9DLL_EXPORTS
#define CGD3D9DLL_API __declspec(dllexport)
#elif defined (CG_LIB)
#define CGD3D9DLL_API
#else
#define CGD3D9DLL_API __declspec(dllimport)
#endif
#ifndef CGD3D9ENTRY
# ifdef _WIN32
# define CGD3D9ENTRY __cdecl
# else
# define CGD3D9ENTRY
# endif
#endif
/*---------------------------------------------------------------------------
// CGerrors that will be fed to cgSetError
// Use cgD3D9TranslateCGerror() to translate these errors into strings.
---------------------------------------------------------------------------*/
enum cgD3D9Errors
{
cgD3D9Failed = 1000,
cgD3D9DebugTrace = 1001,
};
/*---------------------------------------------------------------------------
// HRESULTs specific to cgD3D9. When the CGerror is set to cgD3D9Failed
// cgD3D9GetLastError will return an HRESULT that could be one these.
// Use cgD3D9TranslateHRESULT() to translate these errors into strings.
---------------------------------------------------------------------------*/
static const HRESULT CGD3D9ERR_NOTLOADED = MAKE_HRESULT(1, 0x877, 1);
static const HRESULT CGD3D9ERR_NODEVICE = MAKE_HRESULT(1, 0x877, 2);
static const HRESULT CGD3D9ERR_NOTSAMPLER = MAKE_HRESULT(1, 0x877, 3);
static const HRESULT CGD3D9ERR_INVALIDPROFILE = MAKE_HRESULT(1, 0x877, 4);
static const HRESULT CGD3D9ERR_NULLVALUE = MAKE_HRESULT(1, 0x877, 5);
static const HRESULT CGD3D9ERR_OUTOFRANGE = MAKE_HRESULT(1, 0x877, 6);
static const HRESULT CGD3D9ERR_NOTUNIFORM = MAKE_HRESULT(1, 0x877, 7);
static const HRESULT CGD3D9ERR_NOTMATRIX = MAKE_HRESULT(1, 0x877, 8);
static const HRESULT CGD3D9ERR_INVALIDPARAM = MAKE_HRESULT(1, 0x877, 9);
/*---------------------------------------------------------------------------
// Other error return values
---------------------------------------------------------------------------*/
static const DWORD CGD3D9_INVALID_USAGE = 0xFF;
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef CGD3D9_EXPLICIT
/*---------------------------------------------------------------------------
// Minimal Interface
---------------------------------------------------------------------------*/
CGD3D9DLL_API DWORD CGD3D9ENTRY
cgD3D9TypeToSize(
CGtype type
);
CGD3D9DLL_API BYTE CGD3D9ENTRY
cgD3D9ResourceToDeclUsage(
CGresource resource
);
CGD3D9DLL_API CGbool CGD3D9ENTRY
cgD3D9GetVertexDeclaration(
CGprogram prog,
D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH]
);
CGD3D9DLL_API CGbool CGD3D9ENTRY
cgD3D9ValidateVertexDeclaration(
CGprogram prog,
const D3DVERTEXELEMENT9* decl
);
/*---------------------------------------------------------------------------
// Expanded Interface
---------------------------------------------------------------------------*/
/* ----- D3D Device Control ----------- */
CGD3D9DLL_API IDirect3DDevice9 * CGD3D9ENTRY
cgD3D9GetDevice();
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetDevice(
IDirect3DDevice9* pDevice
);
/* ----- Shader Management ----------- */
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9LoadProgram(
CGprogram prog,
CGbool paramShadowing,
DWORD assemFlags
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9UnloadProgram(
CGprogram prog
);
CGD3D9DLL_API CGbool CGD3D9ENTRY
cgD3D9IsProgramLoaded(
CGprogram prog
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9BindProgram(
CGprogram prog
);
/* ----- Parameter Management ----------- */
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetUniform(
CGparameter param,
const void* floats
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetUniformArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const void* values
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetUniformMatrix(
CGparameter param,
const D3DMATRIX* matrix
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetUniformMatrixArray(
CGparameter param,
DWORD offset,
DWORD numItems,
const D3DMATRIX* matrices
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetTexture(
CGparameter param,
IDirect3DBaseTexture9* tex
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetSamplerState(
CGparameter param,
D3DSAMPLERSTATETYPE type,
DWORD value
);
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9SetTextureWrapMode(
CGparameter param,
DWORD value
);
/* ----- Parameter Management (Shadowing) ----------- */
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9EnableParameterShadowing(
CGprogram prog,
CGbool enable
);
CGD3D9DLL_API CGbool CGD3D9ENTRY
cgD3D9IsParameterShadowingEnabled(
CGprogram prog
);
/* --------- Profile Options ----------------- */
CGD3D9DLL_API CGprofile CGD3D9ENTRY
cgD3D9GetLatestVertexProfile();
CGD3D9DLL_API CGprofile CGD3D9ENTRY
cgD3D9GetLatestPixelProfile();
CGD3D9DLL_API const char * * CGD3D9ENTRY
cgD3D9GetOptimalOptions(
CGprofile profile
);
CGD3D9DLL_API CGbool CGD3D9ENTRY
cgD3D9IsProfileSupported(
CGprofile profile
);
/* --------- Error reporting ----------------- */
CGD3D9DLL_API HRESULT CGD3D9ENTRY
cgD3D9GetLastError();
CGD3D9DLL_API const char * CGD3D9ENTRY
cgD3D9TranslateCGerror(
CGerror error
);
CGD3D9DLL_API const char * CGD3D9ENTRY
cgD3D9TranslateHRESULT(
HRESULT hr
);
CGD3D9DLL_API void CGD3D9ENTRY
cgD3D9EnableDebugTracing(
CGbool enable
);
/* --------- CgFX support -------------------- */
CGD3D9DLL_API void CGD3D9ENTRY
cgD3D9RegisterStates(
CGcontext ctx
);
CGD3D9DLL_API void CGD3D9ENTRY
cgD3D9SetManageTextureParameters(
CGcontext ctx,
CGbool flag
);
CGD3D9DLL_API CGbool CGD3D9ENTRY
cgD3D9GetManageTextureParameters(
CGcontext ctx
);
CGD3D9DLL_API IDirect3DBaseTexture9 * CGD3D9ENTRY
cgD3D9GetTextureParameter(
CGparameter param
);
CGD3D9DLL_API void CGD3D9ENTRY
cgD3D9SetTextureParameter(
CGparameter param,
IDirect3DBaseTexture9 *tex
);
CGD3D9DLL_API void CGD3D9ENTRY
cgD3D9UnloadAllPrograms( void );
#endif
#ifdef __cplusplus
};
#endif
#endif // _WIN32
#endif

View File

@ -0,0 +1,427 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef _cggl_h
#define _cggl_h
#include <Cg/cg.h>
#ifdef _WIN32
# ifndef APIENTRY /* From Win32's <windef.h> */
# define CGGL_APIENTRY_DEFINED
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED) || defined(__BORLANDC__) || defined(__LCC__)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
# ifndef WINGDIAPI /* From Win32's <wingdi.h> and <winnt.h> */
# define CGGL_WINGDIAPI_DEFINED
# define WINGDIAPI __declspec(dllimport)
# endif
#endif /* _WIN32 */
/* Set up for either Win32 import/export/lib. */
#ifndef CGGL_API
# ifdef CGGL_EXPORTS
# ifdef _WIN32
# define CGGL_API __declspec(dllexport)
# elif defined(__GNUC__) && __GNUC__>=4
# define CGGL_API __attribute__ ((visibility("default")))
# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC)
# define CGGL_API __global
# else
# define CGGL_API
# endif
# else
# define CGGL_API
# endif
#endif
#ifndef CGGLENTRY
# ifdef _WIN32
# define CGGLENTRY __cdecl
# else
# define CGGLENTRY
# endif
#endif
#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*****************************************************************************/
/*** cgGL Type Definitions ***/
/*****************************************************************************/
typedef enum
{
CG_GL_MATRIX_IDENTITY = 0,
CG_GL_MATRIX_TRANSPOSE = 1,
CG_GL_MATRIX_INVERSE = 2,
CG_GL_MATRIX_INVERSE_TRANSPOSE = 3,
CG_GL_MODELVIEW_MATRIX,
CG_GL_PROJECTION_MATRIX,
CG_GL_TEXTURE_MATRIX,
CG_GL_MODELVIEW_PROJECTION_MATRIX,
CG_GL_VERTEX,
CG_GL_FRAGMENT,
CG_GL_GEOMETRY
} CGGLenum;
#ifndef CGGL_EXPLICIT
/******************************************************************************
*** Profile Functions
*****************************************************************************/
CGGL_API CGbool CGGLENTRY cgGLIsProfileSupported(CGprofile profile);
CGGL_API void CGGLENTRY cgGLEnableProfile(CGprofile profile);
CGGL_API void CGGLENTRY cgGLDisableProfile(CGprofile profile);
CGGL_API CGprofile CGGLENTRY cgGLGetLatestProfile(CGGLenum profile_type);
CGGL_API void CGGLENTRY cgGLSetOptimalOptions(CGprofile profile);
CGGL_API char const ** CGGLENTRY cgGLGetOptimalOptions(CGprofile profile);
/******************************************************************************
*** Program Managment Functions
*****************************************************************************/
CGGL_API void CGGLENTRY cgGLLoadProgram(CGprogram program);
CGGL_API void CGGLENTRY cgGLUnloadProgram(CGprogram program);
CGGL_API CGbool CGGLENTRY cgGLIsProgramLoaded(CGprogram program);
CGGL_API void CGGLENTRY cgGLBindProgram(CGprogram program);
CGGL_API void CGGLENTRY cgGLUnbindProgram(CGprofile profile);
CGGL_API GLuint CGGLENTRY cgGLGetProgramID(CGprogram program);
/******************************************************************************
*** Parameter Managment Functions
*****************************************************************************/
CGGL_API void CGGLENTRY cgGLSetParameter1f(CGparameter param,
float x);
CGGL_API void CGGLENTRY cgGLSetParameter2f(CGparameter param,
float x,
float y);
CGGL_API void CGGLENTRY cgGLSetParameter3f(CGparameter param,
float x,
float y,
float z);
CGGL_API void CGGLENTRY cgGLSetParameter4f(CGparameter param,
float x,
float y,
float z,
float w);
CGGL_API void CGGLENTRY cgGLSetParameter1fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter2fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter3fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter4fv(CGparameter param, const float *v);
CGGL_API void CGGLENTRY cgGLSetParameter1d(CGparameter param,
double x);
CGGL_API void CGGLENTRY cgGLSetParameter2d(CGparameter param,
double x,
double y);
CGGL_API void CGGLENTRY cgGLSetParameter3d(CGparameter param,
double x,
double y,
double z);
CGGL_API void CGGLENTRY cgGLSetParameter4d(CGparameter param,
double x,
double y,
double z,
double w);
CGGL_API void CGGLENTRY cgGLSetParameter1dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameter2dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameter3dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLSetParameter4dv(CGparameter param, const double *v);
CGGL_API void CGGLENTRY cgGLGetParameter1f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter2f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter3f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter4f(CGparameter param, float *v);
CGGL_API void CGGLENTRY cgGLGetParameter1d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLGetParameter2d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLGetParameter3d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLGetParameter4d(CGparameter param, double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray1f(CGparameter param,
long offset,
long nelements,
const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray2f(CGparameter param,
long offset,
long nelements,
const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray3f(CGparameter param,
long offset,
long nelements,
const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray4f(CGparameter param,
long offset,
long nelements,
const float *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray1d(CGparameter param,
long offset,
long nelements,
const double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray2d(CGparameter param,
long offset,
long nelements,
const double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray3d(CGparameter param,
long offset,
long nelements,
const double *v);
CGGL_API void CGGLENTRY cgGLSetParameterArray4d(CGparameter param,
long offset,
long nelements,
const double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray1f(CGparameter param,
long offset,
long nelements,
float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray2f(CGparameter param,
long offset,
long nelements,
float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray3f(CGparameter param,
long offset,
long nelements,
float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray4f(CGparameter param,
long offset,
long nelements,
float *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray1d(CGparameter param,
long offset,
long nelements,
double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray2d(CGparameter param,
long offset,
long nelements,
double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray3d(CGparameter param,
long offset,
long nelements,
double *v);
CGGL_API void CGGLENTRY cgGLGetParameterArray4d(CGparameter param,
long offset,
long nelements,
double *v);
CGGL_API void CGGLENTRY cgGLSetParameterPointer(CGparameter param,
GLint fsize,
GLenum type,
GLsizei stride,
const GLvoid *pointer);
CGGL_API void CGGLENTRY cgGLEnableClientState(CGparameter param);
CGGL_API void CGGLENTRY cgGLDisableClientState(CGparameter param);
/******************************************************************************
*** Matrix Parameter Managment Functions
*****************************************************************************/
CGGL_API void CGGLENTRY cgGLSetMatrixParameterdr(CGparameter param,
const double *matrix);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterfr(CGparameter param,
const float *matrix);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterdc(CGparameter param,
const double *matrix);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterfc(CGparameter param,
const float *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterdr(CGparameter param, double *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterfr(CGparameter param, float *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterdc(CGparameter param, double *matrix);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterfc(CGparameter param, float *matrix);
CGGL_API void CGGLENTRY cgGLSetStateMatrixParameter(CGparameter param,
CGGLenum matrix,
CGGLenum transform);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArrayfc(CGparameter param,
long offset,
long nelements,
const float *matrices);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArrayfr(CGparameter param,
long offset,
long nelements,
const float *matrices);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArraydc(CGparameter param,
long offset,
long nelements,
const double *matrices);
CGGL_API void CGGLENTRY cgGLSetMatrixParameterArraydr(CGparameter param,
long offset,
long nelements,
const double *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArrayfc(CGparameter param,
long offset,
long nelements,
float *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArrayfr(CGparameter param,
long offset,
long nelements,
float *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArraydc(CGparameter param,
long offset,
long nelements,
double *matrices);
CGGL_API void CGGLENTRY cgGLGetMatrixParameterArraydr(CGparameter param,
long offset,
long nelements,
double *matrices);
/******************************************************************************
*** Texture Parameter Managment Functions
*****************************************************************************/
CGGL_API void CGGLENTRY cgGLSetTextureParameter(CGparameter param, GLuint texobj);
CGGL_API GLuint CGGLENTRY cgGLGetTextureParameter(CGparameter param);
CGGL_API void CGGLENTRY cgGLEnableTextureParameter(CGparameter param);
CGGL_API void CGGLENTRY cgGLDisableTextureParameter(CGparameter param);
CGGL_API GLenum CGGLENTRY cgGLGetTextureEnum(CGparameter param);
CGGL_API void CGGLENTRY cgGLSetManageTextureParameters(CGcontext ctx, CGbool flag);
CGGL_API CGbool CGGLENTRY cgGLGetManageTextureParameters(CGcontext ctx);
CGGL_API void CGGLENTRY cgGLSetupSampler(CGparameter param, GLuint texobj);
CGGL_API void CGGLENTRY cgGLRegisterStates(CGcontext);
CGGL_API void CGGLENTRY cgGLEnableProgramProfiles( CGprogram program );
CGGL_API void CGGLENTRY cgGLDisableProgramProfiles( CGprogram program );
/******************************************************************************
*** Misc Functions
*****************************************************************************/
CGGL_API void CGGLENTRY cgGLSetDebugMode( CGbool debug );
/******************************************************************************
*** Buffer Functions
*****************************************************************************/
CGGL_API CGbuffer CGGLENTRY cgGLCreateBuffer(CGcontext context, int size, const void *data, GLenum bufferUsage);
CGGL_API GLuint CGGLENTRY cgGLGetBufferObject(CGbuffer buffer);
#endif
#ifdef __cplusplus
}
#endif
#ifdef CGGL_APIENTRY_DEFINED
# undef CGGL_APIENTRY_DEFINED
# undef APIENTRY
#endif
#ifdef CGGL_WINGDIAPI_DEFINED
# undef CGGL_WINGDIAPI_DEFINED
# undef WINGDIAPI
#endif
#endif

View File

@ -0,0 +1,75 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
CG_PROFILE_MACRO(Vertex,vp20,VP20,"vp20",6146,1)
CG_PROFILE_MACRO(Fragment20,fp20,FP20,"fp20",6147,0)
CG_PROFILE_MACRO(Vertex30,vp30,VP30,"vp30",6148,1)
CG_PROFILE_MACRO(Fragment,fp30,FP30,"fp30",6149,0)
CG_PROFILE_MACRO(ARBVertex,arbvp1,ARBVP1,"arbvp1",6150,1)
CG_PROFILE_MACRO(Fragment40,fp40,FP40,"fp40",6151,0)
CG_PROFILE_MACRO(ARBFragment,arbfp1,ARBFP1,"arbfp1",7000,0)
CG_PROFILE_MACRO(Vertex40,vp40,VP40,"vp40",7001,1)
CG_PROFILE_MACRO(GLSLVertex,glslv,GLSLV,"glslv",7007,1)
CG_PROFILE_MACRO(GLSLFragment,glslf,GLSLF,"glslf",7008,0)
CG_PROFILE_MACRO(GLSLGeometry,glslg,GLSLG,"glslg",7016,0)
CG_PROFILE_MACRO(GLSLCombined, glslc, GLSLC, "glslc", 7009, 0)
CG_PROFILE_MACRO(GPUFragment,gpu_fp,GPU_FP,"gp4fp",7010,0)
CG_PROFILE_MACRO(GPUVertex,gpu_vp,GPU_VP,"gp4vp",7011,1)
CG_PROFILE_MACRO(GPUGeometry,gpu_gp,GPU_GP,"gp4gp",7012,0)
CG_PROFILE_ALIAS(GPUFragment,gp4fp,GP4FP,"gp4fp",7010,0)
CG_PROFILE_ALIAS(GPUVertex,gp4vp,GP4VP,"gp4vp",7011,1)
CG_PROFILE_ALIAS(GPUGeometry,gp4gp,GP4GP,"gp4gp",7012,0)
#ifndef CG_IN_PROFILES_INCLUDE
# undef CG_PROFILE_MACRO
#endif

View File

@ -0,0 +1,382 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* The following macro invocations define the supported CG basic hardware
* bind locations.
*
* The macros have the form :
*
* CG_BINDLOCATION_MACRO(name, compiler_name, enum_int)
*
* name : The name of the location.
* enum_name : The C enumerant.
* compiler_name : The name of the location within the compiler syntax.
* int_id : Integer enumerant associated with this bind location.
* (3256 is reservered for CG_UNDEFINED)
* addressable : The bind location must have an integer address
* associated with it.
* ParamType : the cgParamType of this register.
*
*/
CG_BINDLOCATION_MACRO(TexUnit0,CG_TEXUNIT0,"texunit 0",2048,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit1,CG_TEXUNIT1,"texunit 1",2049,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit2,CG_TEXUNIT2,"texunit 2",2050,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit3,CG_TEXUNIT3,"texunit 3",2051,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit4,CG_TEXUNIT4,"texunit 4",2052,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit5,CG_TEXUNIT5,"texunit 5",2053,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit6,CG_TEXUNIT6,"texunit 6",2054,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit7,CG_TEXUNIT7,"texunit 7",2055,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit8,CG_TEXUNIT8,"texunit 8",2056,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit9,CG_TEXUNIT9,"texunit 9",2057,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit10,CG_TEXUNIT10,"texunit 10",2058,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit11,CG_TEXUNIT11,"texunit 11",2059,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit12,CG_TEXUNIT12,"texunit 12",2060,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit13,CG_TEXUNIT13,"texunit 13",2061,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit14,CG_TEXUNIT14,"texunit 14",2062,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(TexUnit15,CG_TEXUNIT15,"texunit 15",2063,0,CG_TEXOBJ_PARAM)
CG_BINDLOCATION_MACRO(Buffer0, CG_BUFFER0, "buffer[0]", 2064, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer1, CG_BUFFER1, "buffer[1]", 2065, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer2, CG_BUFFER2, "buffer[2]", 2066, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer3, CG_BUFFER3, "buffer[3]", 2067, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer4, CG_BUFFER4, "buffer[4]", 2068, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer5, CG_BUFFER5, "buffer[5]", 2069, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer6, CG_BUFFER6, "buffer[6]", 2070, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer7, CG_BUFFER7, "buffer[7]", 2071, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer8, CG_BUFFER8, "buffer[8]", 2072, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer9, CG_BUFFER9, "buffer[9]", 2073, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer10, CG_BUFFER10, "buffer[10]", 2074, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Buffer11, CG_BUFFER11, "buffer[11]", 2075, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Attr0,CG_ATTR0,"ATTR0",2113,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr1,CG_ATTR1,"ATTR1",2114,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr2,CG_ATTR2,"ATTR2",2115,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr3,CG_ATTR3,"ATTR3",2116,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr4,CG_ATTR4,"ATTR4",2117,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr5,CG_ATTR5,"ATTR5",2118,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr6,CG_ATTR6,"ATTR6",2119,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr7,CG_ATTR7,"ATTR7",2120,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr8,CG_ATTR8,"ATTR8",2121,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr9,CG_ATTR9,"ATTR9",2122,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr10,CG_ATTR10,"ATTR10",2123,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr11,CG_ATTR11,"ATTR11",2124,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr12,CG_ATTR12,"ATTR12",2125,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr13,CG_ATTR13,"ATTR13",2126,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr14,CG_ATTR14,"ATTR14",2127,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Attr15,CG_ATTR15,"ATTR15",2128,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(VertUniform,CG_C,"c",2178,1,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Tex0,CG_TEX0,"TEX0",2179,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex1,CG_TEX1,"TEX1",2180,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex2,CG_TEX2,"TEX2",2181,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex3,CG_TEX3,"TEX3",2192,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex4,CG_TEX4,"TEX4",2193,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex5,CG_TEX5,"TEX5",2194,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex6,CG_TEX6,"TEX6",2195,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tex7,CG_TEX7,"TEX7",2196,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(HPos,CG_HPOS,"HPOS",2243,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Col0,CG_COL0,"COL0",2245,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Col1,CG_COL1,"COL1",2246,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Col2,CG_COL2,"COL2",2247,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Col3,CG_COL3,"COL3",2248,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSiz,CG_PSIZ,"PSIZ",2309,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Clp0,CG_CLP0,"CLP0",2310,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Clp1,CG_CLP1,"CLP1",2311,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Clp2,CG_CLP2,"CLP2",2312,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Clp3,CG_CLP3,"CLP3",2313,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Clp4,CG_CLP4,"CLP4",2314,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Clp5,CG_CLP5,"CLP5",2315,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(WPos,CG_WPOS,"WPOS",2373,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PointCoord,CG_POINTCOORD,"POINTCOORD",2374,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position0,CG_POSITION0,"POSITION0",2437,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position1,CG_POSITION1,"POSITION1",2438,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position2,CG_POSITION2,"POSITION2",2439,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position3,CG_POSITION3,"POSITION3",2440,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position4,CG_POSITION4,"POSITION4",2441,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position5,CG_POSITION5,"POSITION5",2442,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position6,CG_POSITION6,"POSITION6",2443,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position7,CG_POSITION7,"POSITION7",2444,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position8,CG_POSITION8,"POSITION8",2445,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position9,CG_POSITION9,"POSITION9",2446,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position10,CG_POSITION10,"POSITION10",2447,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position11,CG_POSITION11,"POSITION11",2448,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position12,CG_POSITION12,"POSITION12",2449,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position13,CG_POSITION13,"POSITION13",2450,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position14,CG_POSITION14,"POSITION14",2451,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Position15,CG_POSITION15,"POSITION15",2452,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Diffuse0,CG_DIFFUSE0,"DIFFUSE0",2501,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent0,CG_TANGENT0,"TANGENT0",2565,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent1,CG_TANGENT1,"TANGENT1",2566,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent2,CG_TANGENT2,"TANGENT2",2567,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent3,CG_TANGENT3,"TANGENT3",2568,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent4,CG_TANGENT4,"TANGENT4",2569,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent5,CG_TANGENT5,"TANGENT5",2570,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent6,CG_TANGENT6,"TANGENT6",2571,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent7,CG_TANGENT7,"TANGENT7",2572,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent8,CG_TANGENT8,"TANGENT8",2573,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent9,CG_TANGENT9,"TANGENT9",2574,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent10,CG_TANGENT10,"TANGENT10",2575,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent11,CG_TANGENT11,"TANGENT11",2576,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent12,CG_TANGENT12,"TANGENT12",2577,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent13,CG_TANGENT13,"TANGENT13",2578,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent14,CG_TANGENT14,"TANGENT14",2579,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Tangent15,CG_TANGENT15,"TANGENT15",2580,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Specular0,CG_SPECULAR0,"SPECULAR0",2629,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices0,CG_BLENDINDICES0,"BLENDINDICES0",2693,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices1,CG_BLENDINDICES1,"BLENDINDICES1",2694,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices2,CG_BLENDINDICES2,"BLENDINDICES2",2695,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices3,CG_BLENDINDICES3,"BLENDINDICES3",2696,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices4,CG_BLENDINDICES4,"BLENDINDICES4",2697,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices5,CG_BLENDINDICES5,"BLENDINDICES5",2698,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices6,CG_BLENDINDICES6,"BLENDINDICES6",2699,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices7,CG_BLENDINDICES7,"BLENDINDICES7",2700,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices8,CG_BLENDINDICES8,"BLENDINDICES8",2701,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices9,CG_BLENDINDICES9,"BLENDINDICES9",2702,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices10,CG_BLENDINDICES10,"BLENDINDICES10",2703,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices11,CG_BLENDINDICES11,"BLENDINDICES11",2704,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices12,CG_BLENDINDICES12,"BLENDINDICES12",2705,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices13,CG_BLENDINDICES13,"BLENDINDICES13",2706,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices14,CG_BLENDINDICES14,"BLENDINDICES14",2707,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendIndices15,CG_BLENDINDICES15,"BLENDINDICES15",2708,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color0,CG_COLOR0,"COLOR0",2757,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color1,CG_COLOR1,"COLOR1",2758,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color2,CG_COLOR2,"COLOR2",2759,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color3,CG_COLOR3,"COLOR3",2760,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color4,CG_COLOR4,"COLOR4",2761,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color5,CG_COLOR5,"COLOR5",2762,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color6,CG_COLOR6,"COLOR6",2763,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color7,CG_COLOR7,"COLOR7",2764,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color8,CG_COLOR8,"COLOR8",2765,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color9,CG_COLOR9,"COLOR9",2766,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color10,CG_COLOR10,"COLOR10",2767,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color11,CG_COLOR11,"COLOR11",2768,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color12,CG_COLOR12,"COLOR12",2769,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color13,CG_COLOR13,"COLOR13",2770,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color14,CG_COLOR14,"COLOR14",2771,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Color15,CG_COLOR15,"COLOR15",2772,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize0,CG_PSIZE0,"PSIZE0",2821,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize1,CG_PSIZE1,"PSIZE1",2822,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize2,CG_PSIZE2,"PSIZE2",2823,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize3,CG_PSIZE3,"PSIZE3",2824,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize4,CG_PSIZE4,"PSIZE4",2825,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize5,CG_PSIZE5,"PSIZE5",2826,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize6,CG_PSIZE6,"PSIZE6",2827,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize7,CG_PSIZE7,"PSIZE7",2828,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize8,CG_PSIZE8,"PSIZE8",2829,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize9,CG_PSIZE9,"PSIZE9",2830,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize10,CG_PSIZE10,"PSIZE10",2831,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize11,CG_PSIZE11,"PSIZE11",2832,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize12,CG_PSIZE12,"PSIZE12",2833,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize13,CG_PSIZE13,"PSIZE13",2834,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize14,CG_PSIZE14,"PSIZE14",2835,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PSize15,CG_PSIZE15,"PSIZE15",2836,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal0,CG_BINORMAL0,"BINORMAL0",2885,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal1,CG_BINORMAL1,"BINORMAL1",2886,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal2,CG_BINORMAL2,"BINORMAL2",2887,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal3,CG_BINORMAL3,"BINORMAL3",2888,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal4,CG_BINORMAL4,"BINORMAL4",2889,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal5,CG_BINORMAL5,"BINORMAL5",2890,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal6,CG_BINORMAL6,"BINORMAL6",2891,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal7,CG_BINORMAL7,"BINORMAL7",2892,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal8,CG_BINORMAL8,"BINORMAL8",2893,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal9,CG_BINORMAL9,"BINORMAL9",2894,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal10,CG_BINORMAL10,"BINORMAL10",2895,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal11,CG_BINORMAL11,"BINORMAL11",2896,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal12,CG_BINORMAL12,"BINORMAL12",2897,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal13,CG_BINORMAL13,"BINORMAL13",2898,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal14,CG_BINORMAL14,"BINORMAL14",2899,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BiNormal15,CG_BINORMAL15,"BINORMAL15",2900,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG0,CG_FOG0,"FOG0",2917,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG1,CG_FOG1,"FOG1",2918,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG2,CG_FOG2,"FOG2",2919,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG3,CG_FOG3,"FOG3",2920,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG4,CG_FOG4,"FOG4",2921,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG5,CG_FOG5,"FOG5",2922,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG6,CG_FOG6,"FOG6",2923,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG7,CG_FOG7,"FOG7",2924,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG8,CG_FOG8,"FOG8",2925,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG9,CG_FOG9,"FOG9",2926,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG10,CG_FOG10,"FOG10",2927,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG11,CG_FOG11,"FOG11",2928,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG12,CG_FOG12,"FOG12",2929,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG13,CG_FOG13,"FOG13",2930,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG14,CG_FOG14,"FOG14",2931,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FOG15,CG_FOG15,"FOG15",2932,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH0,CG_DEPTH0,"DEPTH0",2933,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH1,CG_DEPTH1,"DEPTH1",2934,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH2,CG_DEPTH2,"DEPTH2",2935,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH3,CG_DEPTH3,"DEPTH3",2936,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH4,CG_DEPTH4,"DEPTH4",2937,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH5,CG_DEPTH5,"DEPTH5",2938,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH6,CG_DEPTH6,"DEPTH6",2939,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH7,CG_DEPTH7,"DEPTH7",2940,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH8,CG_DEPTH8,"DEPTH8",2941,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH9,CG_DEPTH9,"DEPTH9",2942,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH10,CG_DEPTH10,"DEPTH10",2943,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH11,CG_DEPTH11,"DEPTH11",2944,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH12,CG_DEPTH12,"DEPTH12",2945,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH13,CG_DEPTH13,"DEPTH13",2946,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH14,CG_DEPTH14,"DEPTH14",2947,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(DEPTH15,CG_DEPTH15,"DEPTH15",2948,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE0,CG_SAMPLE0,"SAMPLE0",2949,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE1,CG_SAMPLE1,"SAMPLE1",2950,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE2,CG_SAMPLE2,"SAMPLE2",2951,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE3,CG_SAMPLE3,"SAMPLE3",2952,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE4,CG_SAMPLE4,"SAMPLE4",2953,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE5,CG_SAMPLE5,"SAMPLE5",2954,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE6,CG_SAMPLE6,"SAMPLE6",2955,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE7,CG_SAMPLE7,"SAMPLE7",2956,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE8,CG_SAMPLE8,"SAMPLE8",2957,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE9,CG_SAMPLE9,"SAMPLE9",2958,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE10,CG_SAMPLE10,"SAMPLE10",2959,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE11,CG_SAMPLE11,"SAMPLE11",2960,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE12,CG_SAMPLE12,"SAMPLE12",2961,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE13,CG_SAMPLE13,"SAMPLE13",2962,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE14,CG_SAMPLE14,"SAMPLE14",2963,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SAMPLE15,CG_SAMPLE15,"SAMPLE15",2964,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight0,CG_BLENDWEIGHT0,"BLENDWEIGHT0",3028,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight1,CG_BLENDWEIGHT1,"BLENDWEIGHT1",3029,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight2,CG_BLENDWEIGHT2,"BLENDWEIGHT2",3030,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight3,CG_BLENDWEIGHT3,"BLENDWEIGHT3",3031,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight4,CG_BLENDWEIGHT4,"BLENDWEIGHT4",3032,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight5,CG_BLENDWEIGHT5,"BLENDWEIGHT5",3033,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight6,CG_BLENDWEIGHT6,"BLENDWEIGHT6",3034,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight7,CG_BLENDWEIGHT7,"BLENDWEIGHT7",3035,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight8,CG_BLENDWEIGHT8,"BLENDWEIGHT8",3036,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight9,CG_BLENDWEIGHT9,"BLENDWEIGHT9",3037,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight10,CG_BLENDWEIGHT10,"BLENDWEIGHT10",3038,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight11,CG_BLENDWEIGHT11,"BLENDWEIGHT11",3039,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight12,CG_BLENDWEIGHT12,"BLENDWEIGHT12",3040,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight13,CG_BLENDWEIGHT13,"BLENDWEIGHT13",3041,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight14,CG_BLENDWEIGHT14,"BLENDWEIGHT14",3042,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(BlendWeight15,CG_BLENDWEIGHT15,"BLENDWEIGHT15",3043,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal0,CG_NORMAL0,"NORMAL0",3092,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal1,CG_NORMAL1,"NORMAL1",3093,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal2,CG_NORMAL2,"NORMAL2",3094,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal3,CG_NORMAL3,"NORMAL3",3095,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal4,CG_NORMAL4,"NORMAL4",3096,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal5,CG_NORMAL5,"NORMAL5",3097,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal6,CG_NORMAL6,"NORMAL6",3098,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal7,CG_NORMAL7,"NORMAL7",3099,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal8,CG_NORMAL8,"NORMAL8",3100,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal9,CG_NORMAL9,"NORMAL9",3101,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal10,CG_NORMAL10,"NORMAL10",3102,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal11,CG_NORMAL11,"NORMAL11",3103,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal12,CG_NORMAL12,"NORMAL12",3104,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal13,CG_NORMAL13,"NORMAL13",3105,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal14,CG_NORMAL14,"NORMAL14",3106,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Normal15,CG_NORMAL15,"NORMAL15",3107,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(FogCoord,CG_FOGCOORD,"FOGCOORD",3156,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord0,CG_TEXCOORD0,"TEXCOORD0",3220,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord1,CG_TEXCOORD1,"TEXCOORD1",3221,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord2,CG_TEXCOORD2,"TEXCOORD2",3222,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord3,CG_TEXCOORD3,"TEXCOORD3",3223,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord4,CG_TEXCOORD4,"TEXCOORD4",3224,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord5,CG_TEXCOORD5,"TEXCOORD5",3225,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord6,CG_TEXCOORD6,"TEXCOORD6",3226,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord7,CG_TEXCOORD7,"TEXCOORD7",3227,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord8,CG_TEXCOORD8,"TEXCOORD8",3228,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord9,CG_TEXCOORD9,"TEXCOORD9",3229,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord10,CG_TEXCOORD10,"TEXCOORD10",3230,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord11,CG_TEXCOORD11,"TEXCOORD11",3231,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord12,CG_TEXCOORD12,"TEXCOORD12",3232,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord13,CG_TEXCOORD13,"TEXCOORD13",3233,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord14,CG_TEXCOORD14,"TEXCOORD14",3234,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TexCoord15,CG_TEXCOORD15,"TEXCOORD15",3235,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(CombinerConst0,CG_COMBINER_CONST0,"COMBINER_CONST0",3284,0,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(CombinerConst1,CG_COMBINER_CONST1,"COMBINER_CONST1",3285,0,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(CombinerStageConst0,CG_COMBINER_STAGE_CONST0,"COMBINER_STAGE_CONST0",3286,1,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(CombinerStageConst1,CG_COMBINER_STAGE_CONST1,"COMBINER_STAGE_CONST1",3287,1,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(OffsetTextureMatrix,CG_OFFSET_TEXTURE_MATRIX,"OFFSET_TEXTURE_MATRIX",3288,0,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(OffsetTextureScale,CG_OFFSET_TEXTURE_SCALE,"OFFSET_TEXTURE_SCALE",3289,0,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(OffsetTextureBias,CG_OFFSET_TEXTURE_BIAS,"OFFSET_TEXTURE_BIAS",3290,0,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(ConstEye,CG_CONST_EYE,"CONST_EYE",3291,0,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(Coverage, CG_COVERAGE, "COVERAGE", 3292, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(TessFactor,CG_TESSFACTOR,"TESSFACTOR",3255,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(GLSLUniform,CG_GLSL_UNIFORM,"glsl_uniform",3300,1,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(GLSLAttrib,CG_GLSL_ATTRIB,"glsl_attrib",3301,1,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Env,CG_ENV,"ENV",3302,1,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(HLSLUniform,CG_HLSL_UNIFORM,"hlsl_uniform",3559,1,CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(HLSLAttrib,CG_HLSL_VARYING,"hlsl_attrib",3560,1,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SamplerResource,CG_SAMPLER_RES, "SAMPLER_RES", 3561, 1, CGI_UNIFORM_PARAM)
CG_BINDLOCATION_MACRO(LastColor0, CG_LASTCOL0, "LASTCOL0", 4400, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor1, CG_LASTCOL1, "LASTCOL1", 4401, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor2, CG_LASTCOL2, "LASTCOL2", 4402, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor3, CG_LASTCOL3, "LASTCOL3", 4403, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor4, CG_LASTCOL4, "LASTCOL4", 4404, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor5, CG_LASTCOL5, "LASTCOL5", 4405, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor6, CG_LASTCOL6, "LASTCOL6", 4406, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(LastColor7, CG_LASTCOL7, "LASTCOL7", 4407, 0, CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Face,CG_FACE,"FACE",4410,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(PrimitiveId,CG_PRIMITIVEID,"PRIMITIVEID",4411,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(InstanceId,CG_INSTANCEID,"INSTANCEID",4412,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SampleId,CG_SAMPLEID,"SAMPLEID",4413,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(VertexId,CG_VERTEXID,"VERTEXID",4414,0,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(Layer,CG_LAYER,"LAYER",4415,1,CG_VARYING_PARAM)
CG_BINDLOCATION_MACRO(SampleMask,CG_SAMPLEMASK,"SAMPLEMASK",4416,0,CG_VARYING_PARAM)
#undef CG_BINDLOCATION_MACRO

View File

@ -0,0 +1,196 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* The following macro invocations define the supported CG basic data types.
*
* The macros have the form :
*
* CG_DATATYPE_MACRO(name, compiler_name, enum_name, base_name, nrows, ncols, pc_name)
*
* name : The name of the data type.
* compiler_name : The name of the data type within the compiler syntax.
* enum_name : The C enumerant.
* base_name : The C enumerant of the base type.
* nrows : Number of rows for matrix types. Should be 0 other-wise.
* ncols : Number of columns for scalar, vector, and matrix types.
* pc_name : The C enumerant of the parameter class.
*
*/
/*
* ADD NEW DATA TYPES TO THE END OF THIS MACRO LIST!
*
*/
CG_DATATYPE_MACRO(Half,half,CG_HALF,CG_HALF,0,1,CG_PARAMETERCLASS_SCALAR)
CG_DATATYPE_MACRO(Half2,half2,CG_HALF2,CG_HALF,0,2,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Half3,half3,CG_HALF3,CG_HALF,0,3,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Half4,half4,CG_HALF4,CG_HALF,0,4,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Half1x1,half1x1,CG_HALF1x1,CG_HALF,1,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half1x2,half1x2,CG_HALF1x2,CG_HALF,1,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half1x3,half1x3,CG_HALF1x3,CG_HALF,1,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half1x4,half1x4,CG_HALF1x4,CG_HALF,1,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half2x1,half2x1,CG_HALF2x1,CG_HALF,2,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half2x2,half2x2,CG_HALF2x2,CG_HALF,2,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half2x3,half2x3,CG_HALF2x3,CG_HALF,2,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half2x4,half2x4,CG_HALF2x4,CG_HALF,2,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half3x1,half3x1,CG_HALF3x1,CG_HALF,3,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half3x2,half3x2,CG_HALF3x2,CG_HALF,3,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half3x3,half3x3,CG_HALF3x3,CG_HALF,3,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half3x4,half3x4,CG_HALF3x4,CG_HALF,3,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half4x1,half4x1,CG_HALF4x1,CG_HALF,4,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half4x2,half4x2,CG_HALF4x2,CG_HALF,4,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half4x3,half4x3,CG_HALF4x3,CG_HALF,4,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half4x4,half4x4,CG_HALF4x4,CG_HALF,4,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float,float,CG_FLOAT,CG_FLOAT,0,1,CG_PARAMETERCLASS_SCALAR)
CG_DATATYPE_MACRO(Float2,float2,CG_FLOAT2,CG_FLOAT,0,2,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Float3,float3,CG_FLOAT3,CG_FLOAT,0,3,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Float4,float4,CG_FLOAT4,CG_FLOAT,0,4,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Float1x1,float1x1,CG_FLOAT1x1,CG_FLOAT,1,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float1x2,float1x2,CG_FLOAT1x2,CG_FLOAT,1,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float1x3,float1x3,CG_FLOAT1x3,CG_FLOAT,1,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float1x4,float1x4,CG_FLOAT1x4,CG_FLOAT,1,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float2x1,float2x1,CG_FLOAT2x1,CG_FLOAT,2,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float2x2,float2x2,CG_FLOAT2x2,CG_FLOAT,2,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float2x3,float2x3,CG_FLOAT2x3,CG_FLOAT,2,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float2x4,float2x4,CG_FLOAT2x4,CG_FLOAT,2,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float3x1,float3x1,CG_FLOAT3x1,CG_FLOAT,3,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float3x2,float3x2,CG_FLOAT3x2,CG_FLOAT,3,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float3x3,float3x3,CG_FLOAT3x3,CG_FLOAT,3,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float3x4,float3x4,CG_FLOAT3x4,CG_FLOAT,3,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float4x1,float4x1,CG_FLOAT4x1,CG_FLOAT,4,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float4x2,float4x2,CG_FLOAT4x2,CG_FLOAT,4,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float4x3,float4x3,CG_FLOAT4x3,CG_FLOAT,4,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Float4x4,float4x4,CG_FLOAT4x4,CG_FLOAT,4,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Sampler1D,sampler1D,CG_SAMPLER1D,CG_SAMPLER1D,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(Sampler2D,sampler2D,CG_SAMPLER2D,CG_SAMPLER2D,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(Sampler3D,sampler3D,CG_SAMPLER3D,CG_SAMPLER3D,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(SamplerRECT,samplerRECT,CG_SAMPLERRECT,CG_SAMPLERRECT,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(SamplerCUBE,samplerCUBE,CG_SAMPLERCUBE,CG_SAMPLERCUBE,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(Fixed,fixed,CG_FIXED,CG_FIXED,0,1,CG_PARAMETERCLASS_SCALAR)
CG_DATATYPE_MACRO(Fixed2,fixed2,CG_FIXED2,CG_FIXED,0,2,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Fixed3,fixed3,CG_FIXED3,CG_FIXED,0,3,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Fixed4,fixed4,CG_FIXED4,CG_FIXED,0,4,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Fixed1x1,fixed1x1,CG_FIXED1x1,CG_FIXED,1,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed1x2,fixed1x2,CG_FIXED1x2,CG_FIXED,1,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed1x3,fixed1x3,CG_FIXED1x3,CG_FIXED,1,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed1x4,fixed1x4,CG_FIXED1x4,CG_FIXED,1,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed2x1,fixed2x1,CG_FIXED2x1,CG_FIXED,2,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed2x2,fixed2x2,CG_FIXED2x2,CG_FIXED,2,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed2x3,fixed2x3,CG_FIXED2x3,CG_FIXED,2,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed2x4,fixed2x4,CG_FIXED2x4,CG_FIXED,2,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed3x1,fixed3x1,CG_FIXED3x1,CG_FIXED,3,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed3x2,fixed3x2,CG_FIXED3x2,CG_FIXED,3,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed3x3,fixed3x3,CG_FIXED3x3,CG_FIXED,3,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed3x4,fixed3x4,CG_FIXED3x4,CG_FIXED,3,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed4x1,fixed4x1,CG_FIXED4x1,CG_FIXED,4,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed4x2,fixed4x2,CG_FIXED4x2,CG_FIXED,4,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed4x3,fixed4x3,CG_FIXED4x3,CG_FIXED,4,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Fixed4x4,fixed4x4,CG_FIXED4x4,CG_FIXED,4,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Half1,half1,CG_HALF1,CG_HALF,0,1,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Float1,float1,CG_FLOAT1,CG_FLOAT,0,1,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Fixed1,fixed1,CG_FIXED1,CG_FIXED,0,1,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Int,int,CG_INT,CG_INT,0,1,CG_PARAMETERCLASS_SCALAR)
CG_DATATYPE_MACRO(Int1,int1,CG_INT1,CG_INT,0,1,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Int2,int2,CG_INT2,CG_INT,0,2,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Int3,int3,CG_INT3,CG_INT,0,3,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Int4,int4,CG_INT4,CG_INT,0,4,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Int1x1,int1x1,CG_INT1x1,CG_INT,1,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int1x2,int1x2,CG_INT1x2,CG_INT,1,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int1x3,int1x3,CG_INT1x3,CG_INT,1,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int1x4,int1x4,CG_INT1x4,CG_INT,1,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int2x1,int2x1,CG_INT2x1,CG_INT,2,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int2x2,int2x2,CG_INT2x2,CG_INT,2,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int2x3,int2x3,CG_INT2x3,CG_INT,2,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int2x4,int2x4,CG_INT2x4,CG_INT,2,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int3x1,int3x1,CG_INT3x1,CG_INT,3,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int3x2,int3x2,CG_INT3x2,CG_INT,3,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int3x3,int3x3,CG_INT3x3,CG_INT,3,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int3x4,int3x4,CG_INT3x4,CG_INT,3,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int4x1,int4x1,CG_INT4x1,CG_INT,4,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int4x2,int4x2,CG_INT4x2,CG_INT,4,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int4x3,int4x3,CG_INT4x3,CG_INT,4,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Int4x4,int4x4,CG_INT4x4,CG_INT,4,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool,bool,CG_BOOL,CG_BOOL,0,1,CG_PARAMETERCLASS_SCALAR)
CG_DATATYPE_MACRO(Bool1,bool1,CG_BOOL1,CG_BOOL,0,1,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Bool2,bool2,CG_BOOL2,CG_BOOL,0,2,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Bool3,bool3,CG_BOOL3,CG_BOOL,0,3,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Bool4,bool4,CG_BOOL4,CG_BOOL,0,4,CG_PARAMETERCLASS_VECTOR)
CG_DATATYPE_MACRO(Bool1x1,bool1x1,CG_BOOL1x1,CG_BOOL,1,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool1x2,bool1x2,CG_BOOL1x2,CG_BOOL,1,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool1x3,bool1x3,CG_BOOL1x3,CG_BOOL,1,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool1x4,bool1x4,CG_BOOL1x4,CG_BOOL,1,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool2x1,bool2x1,CG_BOOL2x1,CG_BOOL,2,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool2x2,bool2x2,CG_BOOL2x2,CG_BOOL,2,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool2x3,bool2x3,CG_BOOL2x3,CG_BOOL,2,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool2x4,bool2x4,CG_BOOL2x4,CG_BOOL,2,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool3x1,bool3x1,CG_BOOL3x1,CG_BOOL,3,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool3x2,bool3x2,CG_BOOL3x2,CG_BOOL,3,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool3x3,bool3x3,CG_BOOL3x3,CG_BOOL,3,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool3x4,bool3x4,CG_BOOL3x4,CG_BOOL,3,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool4x1,bool4x1,CG_BOOL4x1,CG_BOOL,4,1,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool4x2,bool4x2,CG_BOOL4x2,CG_BOOL,4,2,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool4x3,bool4x3,CG_BOOL4x3,CG_BOOL,4,3,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(Bool4x4,bool4x4,CG_BOOL4x4,CG_BOOL,4,4,CG_PARAMETERCLASS_MATRIX)
CG_DATATYPE_MACRO(String,string,CG_STRING,CG_STRING,0,1,CG_PARAMETERCLASS_OBJECT)
CG_DATATYPE_MACRO(Program,program,CG_PROGRAM_TYPE,CG_PROGRAM_TYPE,0,0,CG_PARAMETERCLASS_OBJECT)
CG_DATATYPE_MACRO(Texture,texture,CG_TEXTURE,CG_TEXTURE,0,0,CG_PARAMETERCLASS_OBJECT)
CG_DATATYPE_MACRO(Sampler1DARRAY,sampler1DARRAY,CG_SAMPLER1DARRAY,CG_SAMPLER1DARRAY,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(Sampler2DARRAY,sampler2DARRAY,CG_SAMPLER2DARRAY,CG_SAMPLER2DARRAY,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(SamplerCUBEARRAY,samplerCUBEARRAY,CG_SAMPLERCUBEARRAY,CG_SAMPLERCUBEARRAY,0,0,CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(VertexShader, vertexshader, CG_VERTEXSHADER_TYPE, CG_VERTEXSHADER_TYPE, 0, 0, CG_PARAMETERCLASS_OBJECT)
CG_DATATYPE_MACRO(PixelShader, pixelshader, CG_PIXELSHADER_TYPE, CG_PIXELSHADER_TYPE, 0, 0, CG_PARAMETERCLASS_OBJECT)
CG_DATATYPE_MACRO(Sampler, sampler, CG_SAMPLER, CG_SAMPLER, 0, 0, CG_PARAMETERCLASS_SAMPLER)
CG_DATATYPE_MACRO(SamplerBUF,samplerBUF,CG_SAMPLERBUF,CG_SAMPLERBUF,0,0,CG_PARAMETERCLASS_SAMPLER)
#undef CG_DATATYPE_MACRO

View File

@ -0,0 +1,128 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* The following macro invocations define the supported CG basic data types.
*
* The macros have the form :
*
* CG_ENUM_MACRO(enum_name, enum_val)
*
* enum_name : The C enumerant name.
* enum_val : The enumerant value.
*
*/
CG_ENUM_MACRO(CG_UNKNOWN, 4096)
CG_ENUM_MACRO(CG_IN, 4097)
CG_ENUM_MACRO(CG_OUT, 4098)
CG_ENUM_MACRO(CG_INOUT, 4099)
CG_ENUM_MACRO(CG_MIXED, 4100)
CG_ENUM_MACRO(CG_VARYING, 4101)
CG_ENUM_MACRO(CG_UNIFORM, 4102)
CG_ENUM_MACRO(CG_CONSTANT, 4103)
CG_ENUM_MACRO(CG_PROGRAM_SOURCE, 4104)
CG_ENUM_MACRO(CG_PROGRAM_ENTRY, 4105)
CG_ENUM_MACRO(CG_COMPILED_PROGRAM, 4106)
CG_ENUM_MACRO(CG_PROGRAM_PROFILE, 4107)
CG_ENUM_MACRO(CG_GLOBAL, 4108)
CG_ENUM_MACRO(CG_PROGRAM, 4109)
CG_ENUM_MACRO(CG_DEFAULT, 4110)
CG_ENUM_MACRO(CG_ERROR, 4111)
CG_ENUM_MACRO(CG_SOURCE, 4112)
CG_ENUM_MACRO(CG_OBJECT, 4113)
CG_ENUM_MACRO(CG_COMPILE_MANUAL, 4114)
CG_ENUM_MACRO(CG_COMPILE_IMMEDIATE, 4115)
CG_ENUM_MACRO(CG_COMPILE_LAZY, 4116)
CG_ENUM_MACRO(CG_CURRENT, 4117)
CG_ENUM_MACRO(CG_LITERAL, 4118)
CG_ENUM_MACRO(CG_VERSION, 4119)
CG_ENUM_MACRO(CG_ROW_MAJOR, 4120)
CG_ENUM_MACRO(CG_COLUMN_MAJOR, 4121)
CG_ENUM_MACRO(CG_FRAGMENT, 4122)
CG_ENUM_MACRO(CG_VERTEX, 4123)
CG_ENUM_MACRO(CG_POINT, 4124)
CG_ENUM_MACRO(CG_LINE, 4125)
CG_ENUM_MACRO(CG_LINE_ADJ, 4126)
CG_ENUM_MACRO(CG_TRIANGLE, 4127)
CG_ENUM_MACRO(CG_TRIANGLE_ADJ, 4128)
CG_ENUM_MACRO(CG_POINT_OUT, 4129)
CG_ENUM_MACRO(CG_LINE_OUT, 4130)
CG_ENUM_MACRO(CG_TRIANGLE_OUT, 4131)
CG_ENUM_MACRO(CG_IMMEDIATE_PARAMETER_SETTING, 4132)
CG_ENUM_MACRO(CG_DEFERRED_PARAMETER_SETTING, 4133)
CG_ENUM_MACRO(CG_NO_LOCKS_POLICY, 4134)
CG_ENUM_MACRO(CG_THREAD_SAFE_POLICY, 4135)
CG_ENUM_MACRO(CG_FORCE_UPPER_CASE_POLICY, 4136)
CG_ENUM_MACRO(CG_UNCHANGED_CASE_POLICY, 4137)
CG_ENUM_MACRO(CG_IS_OPENGL_PROFILE, 4138)
CG_ENUM_MACRO(CG_IS_DIRECT3D_PROFILE, 4139)
CG_ENUM_MACRO(CG_IS_DIRECT3D_8_PROFILE, 4140)
CG_ENUM_MACRO(CG_IS_DIRECT3D_9_PROFILE, 4141)
CG_ENUM_MACRO(CG_IS_DIRECT3D_10_PROFILE, 4142)
CG_ENUM_MACRO(CG_IS_VERTEX_PROFILE, 4143)
CG_ENUM_MACRO(CG_IS_FRAGMENT_PROFILE, 4144)
CG_ENUM_MACRO(CG_IS_GEOMETRY_PROFILE, 4145)
CG_ENUM_MACRO(CG_IS_TRANSLATION_PROFILE, 4146)
CG_ENUM_MACRO(CG_IS_HLSL_PROFILE, 4147)
CG_ENUM_MACRO(CG_IS_GLSL_PROFILE, 4148)
/*
if you add any enums here, you must also change
the last enum value in the definition of cgiEnumStringMap
(currently found in common/cg_enum.cpp)
*/
#undef CG_ENUM_MACRO

View File

@ -0,0 +1,325 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* The following macro invocations define error codes returned by various cg
* API functions.
*
* The macros have the form :
*
* CG_ERROR_MACRO(code, enum_name, message)
*
* code : The integer error code associated with the error.
* enum_name : The name of enumerant of the error code in the API.
* message : A description string associated with the error.
*
*/
CG_ERROR_MACRO(0,
CG_NO_ERROR,
"No error has occurred.")
CG_ERROR_MACRO(1,
CG_COMPILER_ERROR,
"The compile returned an error.")
CG_ERROR_MACRO(2,
CG_INVALID_PARAMETER_ERROR,
"The parameter used is invalid.")
CG_ERROR_MACRO(3,
CG_INVALID_PROFILE_ERROR,
"The profile is not supported.")
CG_ERROR_MACRO(4,
CG_PROGRAM_LOAD_ERROR,
"The program could not load.")
CG_ERROR_MACRO(5,
CG_PROGRAM_BIND_ERROR,
"The program could not bind.")
CG_ERROR_MACRO(6,
CG_PROGRAM_NOT_LOADED_ERROR,
"The program must be loaded before this operation may be used.")
CG_ERROR_MACRO(7,
CG_UNSUPPORTED_GL_EXTENSION_ERROR,
"An unsupported GL extension was required to perform this operation.")
CG_ERROR_MACRO(8,
CG_INVALID_VALUE_TYPE_ERROR,
"An unknown value type was assigned to a parameter.")
CG_ERROR_MACRO(9,
CG_NOT_MATRIX_PARAM_ERROR,
"The parameter is not of matrix type.")
CG_ERROR_MACRO(10,
CG_INVALID_ENUMERANT_ERROR,
"The enumerant parameter has an invalid value.")
CG_ERROR_MACRO(11,
CG_NOT_4x4_MATRIX_ERROR,
"The parameter must be a 4x4 matrix type.")
CG_ERROR_MACRO(12,
CG_FILE_READ_ERROR,
"The file could not be read.")
CG_ERROR_MACRO(13,
CG_FILE_WRITE_ERROR,
"The file could not be written.")
CG_ERROR_MACRO(14,
CG_NVPARSE_ERROR,
"nvparse could not successfully parse the output from the Cg "
"compiler backend.")
CG_ERROR_MACRO(15,
CG_MEMORY_ALLOC_ERROR,
"Memory allocation failed.")
CG_ERROR_MACRO(16,
CG_INVALID_CONTEXT_HANDLE_ERROR,
"Invalid context handle.")
CG_ERROR_MACRO(17,
CG_INVALID_PROGRAM_HANDLE_ERROR,
"Invalid program handle.")
CG_ERROR_MACRO(18,
CG_INVALID_PARAM_HANDLE_ERROR,
"Invalid parameter handle.")
CG_ERROR_MACRO(19,
CG_UNKNOWN_PROFILE_ERROR,
"The specified profile is unknown.")
CG_ERROR_MACRO(20,
CG_VAR_ARG_ERROR,
"The variable arguments were specified incorrectly.")
CG_ERROR_MACRO(21,
CG_INVALID_DIMENSION_ERROR,
"The dimension value is invalid.")
CG_ERROR_MACRO(22,
CG_ARRAY_PARAM_ERROR,
"The parameter must be an array.")
CG_ERROR_MACRO(23,
CG_OUT_OF_ARRAY_BOUNDS_ERROR,
"Index into the array is out of bounds.")
CG_ERROR_MACRO(24,
CG_CONFLICTING_TYPES_ERROR,
"A type being added to the context conflicts with an "
"existing type.")
CG_ERROR_MACRO(25,
CG_CONFLICTING_PARAMETER_TYPES_ERROR,
"The parameters being bound have conflicting types.")
CG_ERROR_MACRO(26,
CG_PARAMETER_IS_NOT_SHARED_ERROR,
"The parameter must be global.")
CG_ERROR_MACRO(27,
CG_INVALID_PARAMETER_VARIABILITY_ERROR,
"The parameter could not be changed to the given variability.")
CG_ERROR_MACRO(28,
CG_CANNOT_DESTROY_PARAMETER_ERROR,
"Cannot destroy the parameter. It is bound to other parameters "
"or is not a root parameter.")
CG_ERROR_MACRO(29,
CG_NOT_ROOT_PARAMETER_ERROR,
"The parameter is not a root parameter.")
CG_ERROR_MACRO(30,
CG_PARAMETERS_DO_NOT_MATCH_ERROR,
"The two parameters being bound do not match.")
CG_ERROR_MACRO(31,
CG_IS_NOT_PROGRAM_PARAMETER_ERROR,
"The parameter is not a program parameter.")
CG_ERROR_MACRO(32,
CG_INVALID_PARAMETER_TYPE_ERROR,
"The type of the parameter is invalid.")
CG_ERROR_MACRO(33,
CG_PARAMETER_IS_NOT_RESIZABLE_ARRAY_ERROR,
"The parameter must be a resizable array.")
CG_ERROR_MACRO(34,
CG_INVALID_SIZE_ERROR,
"The size value is invalid.")
CG_ERROR_MACRO(35,
CG_BIND_CREATES_CYCLE_ERROR,
"Cannot bind the given parameters. Binding will form a cycle.")
CG_ERROR_MACRO(36,
CG_ARRAY_TYPES_DO_NOT_MATCH_ERROR,
"Cannot bind the given parameters. Array types do not match.")
CG_ERROR_MACRO(37,
CG_ARRAY_DIMENSIONS_DO_NOT_MATCH_ERROR,
"Cannot bind the given parameters. "
"Array dimensions do not match.")
CG_ERROR_MACRO(38,
CG_ARRAY_HAS_WRONG_DIMENSION_ERROR,
"The array has the wrong dimension.")
CG_ERROR_MACRO(39,
CG_TYPE_IS_NOT_DEFINED_IN_PROGRAM_ERROR,
"Connecting the parameters failed because The type of the "
"source parameter is not defined within the given program "
"or does not match the type with the same name in the program.")
CG_ERROR_MACRO(40,
CG_INVALID_EFFECT_HANDLE_ERROR,
"Invalid effect handle.")
CG_ERROR_MACRO(41,
CG_INVALID_STATE_HANDLE_ERROR,
"Invalid state handle.")
CG_ERROR_MACRO(42,
CG_INVALID_STATE_ASSIGNMENT_HANDLE_ERROR,
"Invalid stateassignment handle.")
CG_ERROR_MACRO(43,
CG_INVALID_PASS_HANDLE_ERROR,
"Invalid pass handle.")
CG_ERROR_MACRO(44,
CG_INVALID_ANNOTATION_HANDLE_ERROR,
"Invalid annotation handle.")
CG_ERROR_MACRO(45,
CG_INVALID_TECHNIQUE_HANDLE_ERROR,
"Invalid technique handle.")
/* Do not use this! Use CG_INVALID_PARAM_HANDLE_ERROR instead. */
CG_ERROR_MACRO(46,
CG_INVALID_PARAMETER_HANDLE_ERROR,
"Invalid parameter handle.")
CG_ERROR_MACRO(47,
CG_STATE_ASSIGNMENT_TYPE_MISMATCH_ERROR,
"Operation is not valid for this type of stateassignment.")
CG_ERROR_MACRO(48,
CG_INVALID_FUNCTION_HANDLE_ERROR,
"Invalid function handle.")
CG_ERROR_MACRO(49,
CG_INVALID_TECHNIQUE_ERROR,
"Technique did not pass validation.")
CG_ERROR_MACRO(50,
CG_INVALID_POINTER_ERROR,
"The supplied pointer is NULL.")
CG_ERROR_MACRO(51,
CG_NOT_ENOUGH_DATA_ERROR,
"Not enough data was provided.")
CG_ERROR_MACRO(52,
CG_NON_NUMERIC_PARAMETER_ERROR,
"The parameter is not of a numeric type.")
CG_ERROR_MACRO(53,
CG_ARRAY_SIZE_MISMATCH_ERROR,
"The specified array sizes are not compatible with the given array.")
CG_ERROR_MACRO(54,
CG_CANNOT_SET_NON_UNIFORM_PARAMETER_ERROR,
"Cannot set the value of a non-uniform parameter.")
CG_ERROR_MACRO(55,
CG_DUPLICATE_NAME_ERROR,
"This name is already in use.")
CG_ERROR_MACRO(56,
CG_INVALID_OBJ_HANDLE_ERROR,
"Invalid object handle.")
CG_ERROR_MACRO(57,
CG_INVALID_BUFFER_HANDLE_ERROR,
"Invalid buffer handle.")
CG_ERROR_MACRO(58,
CG_BUFFER_INDEX_OUT_OF_RANGE_ERROR,
"Buffer index is out of bounds.")
CG_ERROR_MACRO(59,
CG_BUFFER_ALREADY_MAPPED_ERROR,
"The buffer is already mapped.")
CG_ERROR_MACRO(60,
CG_BUFFER_UPDATE_NOT_ALLOWED_ERROR,
"The buffer cannot be updated.")
CG_ERROR_MACRO(61,
CG_GLSLG_UNCOMBINED_LOAD_ERROR,
"The GLSL geometry program can not load without being combined with a vertex program.")
#undef CG_ERROR_MACRO

View File

@ -0,0 +1,105 @@
/*
*
* Copyright (c) 2002-2009, NVIDIA Corporation.
*
*
*
* NVIDIA Corporation("NVIDIA") supplies this software to you in consideration
* of your agreement to the following terms, and your use, installation,
* modification or redistribution of this NVIDIA software constitutes
* acceptance of these terms. If you do not agree with these terms, please do
* not use, install, modify or redistribute this NVIDIA software.
*
*
*
* In consideration of your agreement to abide by the following terms, and
* subject to these terms, NVIDIA grants you a personal, non-exclusive license,
* under NVIDIA's copyrights in this original NVIDIA software (the "NVIDIA
* Software"), to use, reproduce, modify and redistribute the NVIDIA
* Software, with or without modifications, in source and/or binary forms;
* provided that if you redistribute the NVIDIA Software, you must retain the
* copyright notice of NVIDIA, this notice and the following text and
* disclaimers in all such redistributions of the NVIDIA Software. Neither the
* name, trademarks, service marks nor logos of NVIDIA Corporation may be used
* to endorse or promote products derived from the NVIDIA Software without
* specific prior written permission from NVIDIA. Except as expressly stated
* in this notice, no other rights or licenses express or implied, are granted
* by NVIDIA herein, including but not limited to any patent rights that may be
* infringed by your derivative works or by other works in which the NVIDIA
* Software may be incorporated. No hardware is licensed hereunder.
*
*
*
* THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
* WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR ITS USE AND OPERATION
* EITHER ALONE OR IN COMBINATION WITH OTHER PRODUCTS.
*
*
*
* IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL,
* EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, LOST
* PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY OUT OF THE USE,
* REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE NVIDIA SOFTWARE,
* HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING
* NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF NVIDIA HAS BEEN ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/*
* The following macro invocations define the supported CG profiles.
*
* The macros have the form :
*
* CG_PROFILE_MACRO(name, compiler_id, compiler_id_caps, compiler_opt, int_id, vertex_profile)
*
* name : The name of the profile. Used consistently with the API.
* compiler_id : The identifier string for the profile used by the compiler.
* compiler_id_caps : compiler_id in caps.
* compiler_opt : The command-line switch used to force compilation into
* the profile.
* int_id : Integer enumerant associated with this bind location.
* vertex_profile : Non-zero if this is a vertex profile, otherwise it
* is considered to be a fragment profile.
*
*
*/
#define CG_IN_PROFILES_INCLUDE
/* Used for profile enumeration aliases */
#ifndef CG_PROFILE_ALIAS
#define CG_PROFILE_ALIAS(name, compiler_id, compiler_id_caps, compiler_opt, int_id, vertex_profile) /*nothing*/
#endif
#include <Cg/cgGL_profiles.h>
CG_PROFILE_MACRO(DX9Vertex11,vs_1_1,VS_1_1,"vs_1_1",6153,1)
CG_PROFILE_MACRO(DX9Vertex20,vs_2_0,VS_2_0,"vs_2_0",6154,1)
CG_PROFILE_MACRO(DX9Vertex2x,vs_2_x,VS_2_X,"vs_2_x",6155,1)
CG_PROFILE_MACRO(DX9Vertex2sw,vs_2_sw,VS_2_SW,"vs_2_sw",6156,1)
CG_PROFILE_MACRO(DX9Vertex30,vs_3_0,VS_3_0,"vs_3_0",6157,1)
CG_PROFILE_MACRO(DX9VertexHLSL,hlslv, HLSLV,"hlslv",6158,1)
CG_PROFILE_MACRO(DX9Pixel11,ps_1_1,PS_1_1,"ps_1_1",6159,0)
CG_PROFILE_MACRO(DX9Pixel12,ps_1_2,PS_1_2,"ps_1_2",6160,0)
CG_PROFILE_MACRO(DX9Pixel13,ps_1_3,PS_1_3,"ps_1_3",6161,0)
CG_PROFILE_MACRO(DX9Pixel20,ps_2_0,PS_2_0,"ps_2_0",6162,0)
CG_PROFILE_MACRO(DX9Pixel2x,ps_2_x,PS_2_X,"ps_2_x",6163,0)
CG_PROFILE_MACRO(DX9Pixel2sw,ps_2_sw,PS_2_SW,"ps_2_sw",6164,0)
CG_PROFILE_MACRO(DX9Pixel30,ps_3_0,PS_3_0,"ps_3_0",6165,0)
CG_PROFILE_MACRO(DX9PixelHLSL,hlslf,HLSLF,"hlslf",6166,0)
CG_PROFILE_MACRO(DX10Vertex40,vs_4_0,VS_4_0,"vs_4_0",6167,1)
CG_PROFILE_MACRO(DX10Pixel40,ps_4_0,PS_4_0,"ps_4_0",6168,0)
CG_PROFILE_MACRO(DX10Geometry40,gs_4_0,GS_4_0,"gs_4_0",6169,0)
CG_PROFILE_MACRO(Generic, generic, GENERIC, "generic", 7002,0)
#undef CG_PROFILE_MACRO
#undef CG_PROFILE_ALIAS
#undef CG_IN_PROFILES_INCLUDE

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,797 @@
#ifndef __glut_h__
#define __glut_h__
/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998, 2000, 2006. */
/* This program is freely distributable without licensing fees and is
provided without guarantee or warrantee expressed or implied. This
program is -not- in the public domain. */
#if defined(_WIN32) || defined(__CYGWIN__)
/* GLUT 3.7 now tries to avoid including <windows.h>
to avoid name space pollution, but Win32's <GL/gl.h>
needs APIENTRY and WINGDIAPI defined properly. */
# if 0
/* This would put tons of macros and crap in our clean name space. */
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# else
/* XXX This is from Win32's <windef.h> */
# ifndef APIENTRY
# define GLUT_APIENTRY_DEFINED
/* Cygwin and MingW32 are two free GNU-based Open Source compilation
environments for Win32. Note that __CYGWIN32__ is deprecated
in favor of simply __CYGWIN__. */
# if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__CYGWIN__)
# if defined(__CYGWIN__)
# define APIENTRY __stdcall
# else
# ifdef i386
# define APIENTRY __attribute__((stdcall))
# else
# define APIENTRY
# endif
# endif
# else
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
# define APIENTRY __stdcall
# else
# define APIENTRY
# endif
# endif
# endif
/* XXX This is from Win32's <winnt.h> */
# ifndef CALLBACK
# if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__CYGWIN__)
# ifndef __stdcall
# define __stdcall __attribute__((stdcall))
# endif
# define CALLBACK __stdcall
# else
# if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
# define CALLBACK __stdcall
# else
# define CALLBACK
# endif
# endif
# endif
/* XXX This is from Win32's <wingdi.h> and <winnt.h> */
# ifndef WINGDIAPI
# define GLUT_WINGDIAPI_DEFINED
# if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__CYGWIN__)
# define WINGDIAPI
# else
# define WINGDIAPI __declspec(dllimport)
# endif
# endif
# if defined(__MINGW32__) || defined(__CYGWIN32__) || defined(__CYGWIN__)
/* Rely on Cygwin32/MingW32 <stddef.h> to set wchar_t. */
/* XXX Warning. The Cygwin32/MingW32 definition for wchar_t
is an "int" instead of the "short" used by Windows. */
# include <stddef.h>
# else
/* XXX This is from Win32's <ctype.h> */
# ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
# define _WCHAR_T_DEFINED
# endif
# endif
# endif
/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
in your compile preprocessor options (Microsoft Visual C only). */
# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA) && defined(_MSC_VER)
# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
# pragma comment (lib, "user32.lib") /* link with Windows User lib */
# pragma comment (lib, "gdi32.lib") /* link with Windows GDI lib */
/* To enable automatic SGI OpenGL for Windows library usage for GLUT,
define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */
# ifdef GLUT_USE_SGI_OPENGL
# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */
# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */
# if defined(GLUT_STATIC_LIB)
# pragma comment (lib, "glutstatic.lib") /* link with static Win32 GLUT lib */
# else
# pragma comment (lib, "glut.lib") /* link with Win32 GLUT lib */
# endif
# else
# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
# if defined(GLUT_STATIC_LIB)
# pragma comment (lib, "glutstatic.lib") /* link with static Win32 GLUT lib */
# else
# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
# endif
# endif
# endif
/* To disable supression of annoying warnings about floats being promoted
to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor
options. */
# if defined(_MSC_VER) && !defined(GLUT_NO_WARNING_DISABLE)
# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */
# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
# endif
/* Win32 has an annoying issue where there are multiple C run-time
libraries (CRTs). If the executable is linked with a different CRT
from the GLUT DLL, the GLUT DLL will not share the same CRT static
data seen by the executable. In particular, atexit callbacks registered
in the executable will not be called if GLUT calls its (different)
exit routine). GLUT is typically built with the
"/MD" option (the CRT with multithreading DLL support), but the Visual
C++ linker default is "/ML" (the single threaded CRT).
One workaround to this issue is requiring users to always link with
the same CRT as GLUT is compiled with. That requires users supply a
non-standard option. GLUT 3.7 has its own built-in workaround where
the executable's "exit" function pointer is covertly passed to GLUT.
GLUT then calls the executable's exit function pointer to ensure that
any "atexit" calls registered by the application are called if GLUT
needs to exit.
Note that the __glut*WithExit routines should NEVER be called directly.
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
/* XXX This is from Win32's <process.h> */
# if !defined(_MSC_VER) && !defined(__cdecl)
/* Define __cdecl for non-Microsoft compilers. */
# define __cdecl
# define GLUT_DEFINED___CDECL
# endif
# ifndef _CRTIMP
# ifdef _NTSDK
/* Definition compatible with NT SDK */
# define _CRTIMP
# else
/* Current definition */
# ifdef _DLL
# define _CRTIMP __declspec(dllimport)
# else
# define _CRTIMP
# endif
# endif
# define GLUT_DEFINED__CRTIMP
# endif
/* GLUT API entry point declarations for Win32. */
# ifdef GLUT_BUILDING_LIB
/* MSDN article 835326 says "When you build a DLL by using the 64-bit
version of the Microsoft Visual C++ Compiler and Linker, you may
receive Linker error number LNK4197 if a function has been declared
for export more than one time." GLUT builds with glut.def that
declares GLUT's EXPORTS list so do not use __declspec(dllexport)
to keep 64-bit compiler happy. */
# define GLUTAPI /*__declspec(dllexport)*/
# else
# ifdef _DLL
# define GLUTAPI __declspec(dllimport)
# else
# define GLUTAPI extern
# endif
# endif
/* GLUT callback calling convention for Win32. */
# define GLUTCALLBACK __cdecl
# if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
# define GLUTAPIENTRY __stdcall
# else
# define GLUTAPIENTRY
# endif
#endif /* _WIN32 */
#include <GL/gl.h>
#include <GL/glu.h>
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) || defined(__CYGWIN__)
# ifndef GLUT_BUILDING_LIB
# if __BORLANDC__
# if defined(_BUILDRTLDLL)
void __cdecl __export exit(int __status);
# else
void __cdecl exit(int __status);
# endif
# else
# if _MSC_VER >= 1200
extern _CRTIMP __declspec(noreturn) void __cdecl exit(int);
# else
extern _CRTIMP void __cdecl exit(int);
# endif
# endif
# endif
#else
/* non-Win32 case. */
/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
# define APIENTRY
# define GLUT_APIENTRY_DEFINED
# define CALLBACK
/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
# define GLUTAPI extern
# define GLUTAPIENTRY
# define GLUTCALLBACK
/* Prototype exit for the non-Win32 case (see above). */
# ifdef __GNUC__
extern void exit(int __status) __attribute__((__noreturn__));
# else
extern void exit(int);
# endif
#endif
/**
GLUT API revision history:
GLUT_API_VERSION is updated to reflect incompatible GLUT
API changes (interface changes, semantic changes, deletions,
or additions).
GLUT_API_VERSION=1 First public release of GLUT. 11/29/94
GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling,
extension. Supports new input devices like tablet, dial and button
box, and Spaceball. Easy to query OpenGL extensions.
GLUT_API_VERSION=3 glutMenuStatus added.
GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer,
glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic
video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc,
glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat,
glutJoystickFunc, glutForceJoystickFunc, glutStrokeWidthf,
glutStrokeLengthf (NOT FINALIZED!).
**/
#ifndef GLUT_API_VERSION /* allow this to be overriden */
#define GLUT_API_VERSION 3
#endif
/**
GLUT implementation revision history:
GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT
API revisions and implementation revisions (ie, bug fixes).
GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of
GLUT Xlib-based implementation. 11/29/94
GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of
GLUT Xlib-based implementation providing GLUT version 2
interfaces.
GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95
GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95
GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95
GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96
GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner
and video resize. 1/3/97
GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines.
GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release.
GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling.
GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support.
GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface.
GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa <GL/glut.h>
GLUT_XLIB_IMPLEMENTATION=16 mjk's early GLUT 3.8
GLUT_XLIB_IMPLEMENTATION=17 mjk's GLUT 3.8 with glutStrokeWidthf and glutStrokeLengthf
**/
#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */
#define GLUT_XLIB_IMPLEMENTATION 17
#endif
/* Display mode bit masks. */
#define GLUT_RGB 0
#define GLUT_RGBA GLUT_RGB
#define GLUT_INDEX 1
#define GLUT_SINGLE 0
#define GLUT_DOUBLE 2
#define GLUT_ACCUM 4
#define GLUT_ALPHA 8
#define GLUT_DEPTH 16
#define GLUT_STENCIL 32
#if (GLUT_API_VERSION >= 2)
#define GLUT_MULTISAMPLE 128
#define GLUT_STEREO 256
#endif
#if (GLUT_API_VERSION >= 3)
#define GLUT_LUMINANCE 512
#endif
/* Mouse buttons. */
#define GLUT_LEFT_BUTTON 0
#define GLUT_MIDDLE_BUTTON 1
#define GLUT_RIGHT_BUTTON 2
/* Mouse button state. */
#define GLUT_DOWN 0
#define GLUT_UP 1
#if (GLUT_API_VERSION >= 2)
/* function keys */
#define GLUT_KEY_F1 1
#define GLUT_KEY_F2 2
#define GLUT_KEY_F3 3
#define GLUT_KEY_F4 4
#define GLUT_KEY_F5 5
#define GLUT_KEY_F6 6
#define GLUT_KEY_F7 7
#define GLUT_KEY_F8 8
#define GLUT_KEY_F9 9
#define GLUT_KEY_F10 10
#define GLUT_KEY_F11 11
#define GLUT_KEY_F12 12
/* directional keys */
#define GLUT_KEY_LEFT 100
#define GLUT_KEY_UP 101
#define GLUT_KEY_RIGHT 102
#define GLUT_KEY_DOWN 103
#define GLUT_KEY_PAGE_UP 104
#define GLUT_KEY_PAGE_DOWN 105
#define GLUT_KEY_HOME 106
#define GLUT_KEY_END 107
#define GLUT_KEY_INSERT 108
#endif
/* Entry/exit state. */
#define GLUT_LEFT 0
#define GLUT_ENTERED 1
/* Menu usage state. */
#define GLUT_MENU_NOT_IN_USE 0
#define GLUT_MENU_IN_USE 1
/* Visibility state. */
#define GLUT_NOT_VISIBLE 0
#define GLUT_VISIBLE 1
/* Window status state. */
#define GLUT_HIDDEN 0
#define GLUT_FULLY_RETAINED 1
#define GLUT_PARTIALLY_RETAINED 2
#define GLUT_FULLY_COVERED 3
/* Color index component selection values. */
#define GLUT_RED 0
#define GLUT_GREEN 1
#define GLUT_BLUE 2
#ifdef _WIN32
/* Stroke font constants (use these in GLUT program). */
#define GLUT_STROKE_ROMAN ((void*)0)
#define GLUT_STROKE_MONO_ROMAN ((void*)1)
/* Bitmap font constants (use these in GLUT program). */
#define GLUT_BITMAP_9_BY_15 ((void*)2)
#define GLUT_BITMAP_8_BY_13 ((void*)3)
#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
#if (GLUT_API_VERSION >= 3)
#define GLUT_BITMAP_HELVETICA_10 ((void*)6)
#define GLUT_BITMAP_HELVETICA_12 ((void*)7)
#define GLUT_BITMAP_HELVETICA_18 ((void*)8)
#endif
#else
/* Stroke font opaque addresses (use constants instead in source code). */
GLUTAPI void *glutStrokeRoman;
GLUTAPI void *glutStrokeMonoRoman;
/* Stroke font constants (use these in GLUT program). */
#define GLUT_STROKE_ROMAN (&glutStrokeRoman)
#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman)
/* Bitmap font opaque addresses (use constants instead in source code). */
GLUTAPI void *glutBitmap9By15;
GLUTAPI void *glutBitmap8By13;
GLUTAPI void *glutBitmapTimesRoman10;
GLUTAPI void *glutBitmapTimesRoman24;
GLUTAPI void *glutBitmapHelvetica10;
GLUTAPI void *glutBitmapHelvetica12;
GLUTAPI void *glutBitmapHelvetica18;
/* Bitmap font constants (use these in GLUT program). */
#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15)
#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13)
#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10)
#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24)
#if (GLUT_API_VERSION >= 3)
#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10)
#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12)
#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18)
#endif
#endif
/* glutGet parameters. */
#define GLUT_WINDOW_X ((GLenum) 100)
#define GLUT_WINDOW_Y ((GLenum) 101)
#define GLUT_WINDOW_WIDTH ((GLenum) 102)
#define GLUT_WINDOW_HEIGHT ((GLenum) 103)
#define GLUT_WINDOW_BUFFER_SIZE ((GLenum) 104)
#define GLUT_WINDOW_STENCIL_SIZE ((GLenum) 105)
#define GLUT_WINDOW_DEPTH_SIZE ((GLenum) 106)
#define GLUT_WINDOW_RED_SIZE ((GLenum) 107)
#define GLUT_WINDOW_GREEN_SIZE ((GLenum) 108)
#define GLUT_WINDOW_BLUE_SIZE ((GLenum) 109)
#define GLUT_WINDOW_ALPHA_SIZE ((GLenum) 110)
#define GLUT_WINDOW_ACCUM_RED_SIZE ((GLenum) 111)
#define GLUT_WINDOW_ACCUM_GREEN_SIZE ((GLenum) 112)
#define GLUT_WINDOW_ACCUM_BLUE_SIZE ((GLenum) 113)
#define GLUT_WINDOW_ACCUM_ALPHA_SIZE ((GLenum) 114)
#define GLUT_WINDOW_DOUBLEBUFFER ((GLenum) 115)
#define GLUT_WINDOW_RGBA ((GLenum) 116)
#define GLUT_WINDOW_PARENT ((GLenum) 117)
#define GLUT_WINDOW_NUM_CHILDREN ((GLenum) 118)
#define GLUT_WINDOW_COLORMAP_SIZE ((GLenum) 119)
#if (GLUT_API_VERSION >= 2)
#define GLUT_WINDOW_NUM_SAMPLES ((GLenum) 120)
#define GLUT_WINDOW_STEREO ((GLenum) 121)
#endif
#if (GLUT_API_VERSION >= 3)
#define GLUT_WINDOW_CURSOR ((GLenum) 122)
#endif
#define GLUT_SCREEN_WIDTH ((GLenum) 200)
#define GLUT_SCREEN_HEIGHT ((GLenum) 201)
#define GLUT_SCREEN_WIDTH_MM ((GLenum) 202)
#define GLUT_SCREEN_HEIGHT_MM ((GLenum) 203)
#define GLUT_MENU_NUM_ITEMS ((GLenum) 300)
#define GLUT_DISPLAY_MODE_POSSIBLE ((GLenum) 400)
#define GLUT_INIT_WINDOW_X ((GLenum) 500)
#define GLUT_INIT_WINDOW_Y ((GLenum) 501)
#define GLUT_INIT_WINDOW_WIDTH ((GLenum) 502)
#define GLUT_INIT_WINDOW_HEIGHT ((GLenum) 503)
#define GLUT_INIT_DISPLAY_MODE ((GLenum) 504)
#if (GLUT_API_VERSION >= 2)
#define GLUT_ELAPSED_TIME ((GLenum) 700)
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
#define GLUT_WINDOW_FORMAT_ID ((GLenum) 123)
#endif
#if (GLUT_API_VERSION >= 2)
/* glutDeviceGet parameters. */
#define GLUT_HAS_KEYBOARD ((GLenum) 600)
#define GLUT_HAS_MOUSE ((GLenum) 601)
#define GLUT_HAS_SPACEBALL ((GLenum) 602)
#define GLUT_HAS_DIAL_AND_BUTTON_BOX ((GLenum) 603)
#define GLUT_HAS_TABLET ((GLenum) 604)
#define GLUT_NUM_MOUSE_BUTTONS ((GLenum) 605)
#define GLUT_NUM_SPACEBALL_BUTTONS ((GLenum) 606)
#define GLUT_NUM_BUTTON_BOX_BUTTONS ((GLenum) 607)
#define GLUT_NUM_DIALS ((GLenum) 608)
#define GLUT_NUM_TABLET_BUTTONS ((GLenum) 609)
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
#define GLUT_DEVICE_IGNORE_KEY_REPEAT ((GLenum) 610)
#define GLUT_DEVICE_KEY_REPEAT ((GLenum) 611)
#define GLUT_HAS_JOYSTICK ((GLenum) 612)
#define GLUT_OWNS_JOYSTICK ((GLenum) 613)
#define GLUT_JOYSTICK_BUTTONS ((GLenum) 614)
#define GLUT_JOYSTICK_AXES ((GLenum) 615)
#define GLUT_JOYSTICK_POLL_RATE ((GLenum) 616)
#endif
#if (GLUT_API_VERSION >= 3)
/* glutLayerGet parameters. */
#define GLUT_OVERLAY_POSSIBLE ((GLenum) 800)
#define GLUT_LAYER_IN_USE ((GLenum) 801)
#define GLUT_HAS_OVERLAY ((GLenum) 802)
#define GLUT_TRANSPARENT_INDEX ((GLenum) 803)
#define GLUT_NORMAL_DAMAGED ((GLenum) 804)
#define GLUT_OVERLAY_DAMAGED ((GLenum) 805)
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
/* glutVideoResizeGet parameters. */
#define GLUT_VIDEO_RESIZE_POSSIBLE ((GLenum) 900)
#define GLUT_VIDEO_RESIZE_IN_USE ((GLenum) 901)
#define GLUT_VIDEO_RESIZE_X_DELTA ((GLenum) 902)
#define GLUT_VIDEO_RESIZE_Y_DELTA ((GLenum) 903)
#define GLUT_VIDEO_RESIZE_WIDTH_DELTA ((GLenum) 904)
#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA ((GLenum) 905)
#define GLUT_VIDEO_RESIZE_X ((GLenum) 906)
#define GLUT_VIDEO_RESIZE_Y ((GLenum) 907)
#define GLUT_VIDEO_RESIZE_WIDTH ((GLenum) 908)
#define GLUT_VIDEO_RESIZE_HEIGHT ((GLenum) 909)
#endif
/* glutUseLayer parameters. */
#define GLUT_NORMAL ((GLenum) 0)
#define GLUT_OVERLAY ((GLenum) 1)
/* glutGetModifiers return mask. */
#define GLUT_ACTIVE_SHIFT 1
#define GLUT_ACTIVE_CTRL 2
#define GLUT_ACTIVE_ALT 4
/* glutSetCursor parameters. */
/* Basic arrows. */
#define GLUT_CURSOR_RIGHT_ARROW 0
#define GLUT_CURSOR_LEFT_ARROW 1
/* Symbolic cursor shapes. */
#define GLUT_CURSOR_INFO 2
#define GLUT_CURSOR_DESTROY 3
#define GLUT_CURSOR_HELP 4
#define GLUT_CURSOR_CYCLE 5
#define GLUT_CURSOR_SPRAY 6
#define GLUT_CURSOR_WAIT 7
#define GLUT_CURSOR_TEXT 8
#define GLUT_CURSOR_CROSSHAIR 9
/* Directional cursors. */
#define GLUT_CURSOR_UP_DOWN 10
#define GLUT_CURSOR_LEFT_RIGHT 11
/* Sizing cursors. */
#define GLUT_CURSOR_TOP_SIDE 12
#define GLUT_CURSOR_BOTTOM_SIDE 13
#define GLUT_CURSOR_LEFT_SIDE 14
#define GLUT_CURSOR_RIGHT_SIDE 15
#define GLUT_CURSOR_TOP_LEFT_CORNER 16
#define GLUT_CURSOR_TOP_RIGHT_CORNER 17
#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18
#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
/* Inherit from parent window. */
#define GLUT_CURSOR_INHERIT 100
/* Blank cursor. */
#define GLUT_CURSOR_NONE 101
/* Fullscreen crosshair (if available). */
#define GLUT_CURSOR_FULL_CROSSHAIR 102
#endif
/* GLUT initialization sub-API. */
GLUTAPI void GLUTAPIENTRY glutInit(int *argcp, char **argv);
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
GLUTAPI void GLUTAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
#ifndef GLUT_BUILDING_LIB
static void GLUTAPIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
#define glutInit glutInit_ATEXIT_HACK
#endif
#endif
GLUTAPI void GLUTAPIENTRY glutInitDisplayMode(unsigned int mode);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI void GLUTAPIENTRY glutInitDisplayString(const char *string);
#endif
GLUTAPI void GLUTAPIENTRY glutInitWindowPosition(int x, int y);
GLUTAPI void GLUTAPIENTRY glutInitWindowSize(int width, int height);
GLUTAPI void GLUTAPIENTRY glutMainLoop(void);
/* GLUT window sub-API. */
GLUTAPI int GLUTAPIENTRY glutCreateWindow(const char *title);
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
GLUTAPI int GLUTAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
#ifndef GLUT_BUILDING_LIB
static int GLUTAPIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
#define glutCreateWindow glutCreateWindow_ATEXIT_HACK
#endif
#endif
GLUTAPI int GLUTAPIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
GLUTAPI void GLUTAPIENTRY glutDestroyWindow(int win);
GLUTAPI void GLUTAPIENTRY glutPostRedisplay(void);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
GLUTAPI void GLUTAPIENTRY glutPostWindowRedisplay(int win);
#endif
GLUTAPI void GLUTAPIENTRY glutSwapBuffers(void);
GLUTAPI int GLUTAPIENTRY glutGetWindow(void);
GLUTAPI void GLUTAPIENTRY glutSetWindow(int win);
GLUTAPI void GLUTAPIENTRY glutSetWindowTitle(const char *title);
GLUTAPI void GLUTAPIENTRY glutSetIconTitle(const char *title);
GLUTAPI void GLUTAPIENTRY glutPositionWindow(int x, int y);
GLUTAPI void GLUTAPIENTRY glutReshapeWindow(int width, int height);
GLUTAPI void GLUTAPIENTRY glutPopWindow(void);
GLUTAPI void GLUTAPIENTRY glutPushWindow(void);
GLUTAPI void GLUTAPIENTRY glutIconifyWindow(void);
GLUTAPI void GLUTAPIENTRY glutShowWindow(void);
GLUTAPI void GLUTAPIENTRY glutHideWindow(void);
#if (GLUT_API_VERSION >= 3)
GLUTAPI void GLUTAPIENTRY glutFullScreen(void);
GLUTAPI void GLUTAPIENTRY glutSetCursor(int cursor);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI void GLUTAPIENTRY glutWarpPointer(int x, int y);
#endif
/* GLUT overlay sub-API. */
GLUTAPI void GLUTAPIENTRY glutEstablishOverlay(void);
GLUTAPI void GLUTAPIENTRY glutRemoveOverlay(void);
GLUTAPI void GLUTAPIENTRY glutUseLayer(GLenum layer);
GLUTAPI void GLUTAPIENTRY glutPostOverlayRedisplay(void);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
GLUTAPI void GLUTAPIENTRY glutPostWindowOverlayRedisplay(int win);
#endif
GLUTAPI void GLUTAPIENTRY glutShowOverlay(void);
GLUTAPI void GLUTAPIENTRY glutHideOverlay(void);
#endif
/* GLUT menu sub-API. */
GLUTAPI int GLUTAPIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
GLUTAPI int GLUTAPIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
#ifndef GLUT_BUILDING_LIB
static int GLUTAPIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
#define glutCreateMenu glutCreateMenu_ATEXIT_HACK
#endif
#endif
GLUTAPI void GLUTAPIENTRY glutDestroyMenu(int menu);
GLUTAPI int GLUTAPIENTRY glutGetMenu(void);
GLUTAPI void GLUTAPIENTRY glutSetMenu(int menu);
GLUTAPI void GLUTAPIENTRY glutAddMenuEntry(const char *label, int value);
GLUTAPI void GLUTAPIENTRY glutAddSubMenu(const char *label, int submenu);
GLUTAPI void GLUTAPIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
GLUTAPI void GLUTAPIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
GLUTAPI void GLUTAPIENTRY glutRemoveMenuItem(int item);
GLUTAPI void GLUTAPIENTRY glutAttachMenu(int button);
GLUTAPI void GLUTAPIENTRY glutDetachMenu(int button);
/* GLUT window callback sub-API. */
GLUTAPI void GLUTAPIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void));
GLUTAPI void GLUTAPIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height));
GLUTAPI void GLUTAPIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
GLUTAPI void GLUTAPIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
GLUTAPI void GLUTAPIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
GLUTAPI void GLUTAPIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state));
GLUTAPI void GLUTAPIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state));
GLUTAPI void GLUTAPIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void));
GLUTAPI void GLUTAPIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value);
GLUTAPI void GLUTAPIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state));
#if (GLUT_API_VERSION >= 2)
GLUTAPI void GLUTAPIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
GLUTAPI void GLUTAPIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
GLUTAPI void GLUTAPIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state));
GLUTAPI void GLUTAPIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state));
GLUTAPI void GLUTAPIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value));
GLUTAPI void GLUTAPIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
GLUTAPI void GLUTAPIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
#if (GLUT_API_VERSION >= 3)
GLUTAPI void GLUTAPIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y));
GLUTAPI void GLUTAPIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void));
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI void GLUTAPIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state));
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
GLUTAPI void GLUTAPIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
GLUTAPI void GLUTAPIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);
#endif
#endif
#endif
/* GLUT color index sub-API. */
GLUTAPI void GLUTAPIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue);
GLUTAPI GLfloat GLUTAPIENTRY glutGetColor(int ndx, int component);
GLUTAPI void GLUTAPIENTRY glutCopyColormap(int win);
/* GLUT state retrieval sub-API. */
GLUTAPI int GLUTAPIENTRY glutGet(GLenum type);
GLUTAPI int GLUTAPIENTRY glutDeviceGet(GLenum type);
#if (GLUT_API_VERSION >= 2)
/* GLUT extension support sub-API */
GLUTAPI int GLUTAPIENTRY glutExtensionSupported(const char *name);
#endif
#if (GLUT_API_VERSION >= 3)
GLUTAPI int GLUTAPIENTRY glutGetModifiers(void);
GLUTAPI int GLUTAPIENTRY glutLayerGet(GLenum type);
#endif
/* GLUT font sub-API */
GLUTAPI void GLUTAPIENTRY glutBitmapCharacter(void *font, int character);
GLUTAPI int GLUTAPIENTRY glutBitmapWidth(void *font, int character);
GLUTAPI void GLUTAPIENTRY glutStrokeCharacter(void *font, int character);
GLUTAPI int GLUTAPIENTRY glutStrokeWidth(void *font, int character);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
GLUTAPI int GLUTAPIENTRY glutBitmapLength(void *font, const unsigned char *string);
GLUTAPI int GLUTAPIENTRY glutStrokeLength(void *font, const unsigned char *string);
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 17)
GLUTAPI float GLUTAPIENTRY glutStrokeWidthf(void *font, int character);
GLUTAPI float GLUTAPIENTRY glutStrokeLengthf(void *font, const unsigned char *string);
#endif
/* GLUT pre-built models sub-API */
GLUTAPI void GLUTAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
GLUTAPI void GLUTAPIENTRY glutWireCube(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutSolidCube(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
GLUTAPI void GLUTAPIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
GLUTAPI void GLUTAPIENTRY glutWireDodecahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidDodecahedron(void);
GLUTAPI void GLUTAPIENTRY glutWireTeapot(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutSolidTeapot(GLdouble size);
GLUTAPI void GLUTAPIENTRY glutWireOctahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidOctahedron(void);
GLUTAPI void GLUTAPIENTRY glutWireTetrahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidTetrahedron(void);
GLUTAPI void GLUTAPIENTRY glutWireIcosahedron(void);
GLUTAPI void GLUTAPIENTRY glutSolidIcosahedron(void);
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
/* GLUT video resize sub-API. */
GLUTAPI int GLUTAPIENTRY glutVideoResizeGet(GLenum param);
GLUTAPI void GLUTAPIENTRY glutSetupVideoResizing(void);
GLUTAPI void GLUTAPIENTRY glutStopVideoResizing(void);
GLUTAPI void GLUTAPIENTRY glutVideoResize(int x, int y, int width, int height);
GLUTAPI void GLUTAPIENTRY glutVideoPan(int x, int y, int width, int height);
/* GLUT debugging sub-API. */
GLUTAPI void GLUTAPIENTRY glutReportErrors(void);
#endif
#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
/* GLUT device control sub-API. */
/* glutSetKeyRepeat modes. */
#define GLUT_KEY_REPEAT_OFF 0
#define GLUT_KEY_REPEAT_ON 1
#define GLUT_KEY_REPEAT_DEFAULT 2
/* Joystick button masks. */
#define GLUT_JOYSTICK_BUTTON_A 1
#define GLUT_JOYSTICK_BUTTON_B 2
#define GLUT_JOYSTICK_BUTTON_C 4
#define GLUT_JOYSTICK_BUTTON_D 8
GLUTAPI void GLUTAPIENTRY glutIgnoreKeyRepeat(int ignore);
GLUTAPI void GLUTAPIENTRY glutSetKeyRepeat(int repeatMode);
GLUTAPI void GLUTAPIENTRY glutForceJoystickFunc(void);
/* GLUT game mode sub-API. */
/* glutGameModeGet. */
#define GLUT_GAME_MODE_ACTIVE ((GLenum) 0)
#define GLUT_GAME_MODE_POSSIBLE ((GLenum) 1)
#define GLUT_GAME_MODE_WIDTH ((GLenum) 2)
#define GLUT_GAME_MODE_HEIGHT ((GLenum) 3)
#define GLUT_GAME_MODE_PIXEL_DEPTH ((GLenum) 4)
#define GLUT_GAME_MODE_REFRESH_RATE ((GLenum) 5)
#define GLUT_GAME_MODE_DISPLAY_CHANGED ((GLenum) 6)
GLUTAPI void GLUTAPIENTRY glutGameModeString(const char *string);
GLUTAPI int GLUTAPIENTRY glutEnterGameMode(void);
GLUTAPI void GLUTAPIENTRY glutLeaveGameMode(void);
GLUTAPI int GLUTAPIENTRY glutGameModeGet(GLenum mode);
#endif
#ifdef __cplusplus
}
#endif
#ifdef GLUT_APIENTRY_DEFINED
# undef GLUT_APIENTRY_DEFINED
# if defined(__CYGWIN__)
/* Leave APIENTRY defined when __CYGWIN__ is defined since OpenGL.org's
offical glext.h logic does not define APIENTY when __CYGWIN__
is defined. */
# else
# undef APIENTRY
# endif
#endif
#ifdef GLUT_WINGDIAPI_DEFINED
# undef GLUT_WINGDIAPI_DEFINED
# undef WINGDIAPI
#endif
#ifdef GLUT_DEFINED___CDECL
# undef GLUT_DEFINED___CDECL
# undef __cdecl
#endif
#ifdef GLUT_DEFINED__CRTIMP
# undef GLUT_DEFINED__CRTIMP
# undef _CRTIMP
#endif
#endif /* __glut_h__ */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,145 @@
/*
* This file was taken from RakNet 4.082 without any modifications.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*/
#ifndef __DDS_HEADER_H__
#define __DDS_HEADER_H__
// little-endian, of course
#define DDS_MAGIC 0x20534444
// DDS_header.dwFlags
#define DDSD_CAPS 0x00000001
#define DDSD_HEIGHT 0x00000002
#define DDSD_WIDTH 0x00000004
#define DDSD_PITCH 0x00000008
#define DDSD_PIXELFORMAT 0x00001000
#define DDSD_MIPMAPCOUNT 0x00020000
#define DDSD_LINEARSIZE 0x00080000
#define DDSD_DEPTH 0x00800000
// DDS_header.sPixelFormat.dwFlags
#define DDPF_ALPHAPIXELS 0x00000001
#define DDPF_FOURCC 0x00000004
#define DDPF_INDEXED 0x00000020
#define DDPF_RGB 0x00000040
// DDS_header.sCaps.dwCaps1
#define DDSCAPS_COMPLEX 0x00000008
#define DDSCAPS_TEXTURE 0x00001000
#define DDSCAPS_MIPMAP 0x00400000
// DDS_header.sCaps.dwCaps2
#define DDSCAPS2_CUBEMAP 0x00000200
#define DDSCAPS2_CUBEMAP_POSITIVEX 0x00000400
#define DDSCAPS2_CUBEMAP_NEGATIVEX 0x00000800
#define DDSCAPS2_CUBEMAP_POSITIVEY 0x00001000
#define DDSCAPS2_CUBEMAP_NEGATIVEY 0x00002000
#define DDSCAPS2_CUBEMAP_POSITIVEZ 0x00004000
#define DDSCAPS2_CUBEMAP_NEGATIVEZ 0x00008000
#define DDSCAPS2_VOLUME 0x00200000
#define D3DFMT_DXT1 '1TXD' // DXT1 compression texture format
#define D3DFMT_DXT2 '2TXD' // DXT2 compression texture format
#define D3DFMT_DXT3 '3TXD' // DXT3 compression texture format
#define D3DFMT_DXT4 '4TXD' // DXT4 compression texture format
#define D3DFMT_DXT5 '5TXD' // DXT5 compression texture format
#define PF_IS_DXT1(pf) \
((pf.dwFlags & DDPF_FOURCC) && \
(pf.dwFourCC == D3DFMT_DXT1))
#define PF_IS_DXT3(pf) \
((pf.dwFlags & DDPF_FOURCC) && \
(pf.dwFourCC == D3DFMT_DXT3))
#define PF_IS_DXT5(pf) \
((pf.dwFlags & DDPF_FOURCC) && \
(pf.dwFourCC == D3DFMT_DXT5))
#define PF_IS_BGRA8(pf) \
((pf.dwFlags & DDPF_RGB) && \
(pf.dwFlags & DDPF_ALPHAPIXELS) && \
(pf.dwRGBBitCount == 32) && \
(pf.dwRBitMask == 0xff0000) && \
(pf.dwGBitMask == 0xff00) && \
(pf.dwBBitMask == 0xff) && \
(pf.dwAlphaBitMask == 0xff000000U))
#define PF_IS_BGR8(pf) \
((pf.dwFlags & DDPF_ALPHAPIXELS) && \
!(pf.dwFlags & DDPF_ALPHAPIXELS) && \
(pf.dwRGBBitCount == 24) && \
(pf.dwRBitMask == 0xff0000) && \
(pf.dwGBitMask == 0xff00) && \
(pf.dwBBitMask == 0xff))
#define PF_IS_BGR5A1(pf) \
((pf.dwFlags & DDPF_RGB) && \
(pf.dwFlags & DDPF_ALPHAPIXELS) && \
(pf.dwRGBBitCount == 16) && \
(pf.dwRBitMask == 0x00007c00) && \
(pf.dwGBitMask == 0x000003e0) && \
(pf.dwBBitMask == 0x0000001f) && \
(pf.dwAlphaBitMask == 0x00008000))
#define PF_IS_BGR565(pf) \
((pf.dwFlags & DDPF_RGB) && \
!(pf.dwFlags & DDPF_ALPHAPIXELS) && \
(pf.dwRGBBitCount == 16) && \
(pf.dwRBitMask == 0x0000f800) && \
(pf.dwGBitMask == 0x000007e0) && \
(pf.dwBBitMask == 0x0000001f))
#define PF_IS_INDEX8(pf) \
((pf.dwFlags & DDPF_INDEXED) && \
(pf.dwRGBBitCount == 8))
union DDS_header
{
struct
{
unsigned int dwMagic;
unsigned int dwSize;
unsigned int dwFlags;
unsigned int dwHeight;
unsigned int dwWidth;
unsigned int dwPitchOrLinearSize;
unsigned int dwDepth;
unsigned int dwMipMapCount;
unsigned int dwReserved1[ 11 ];
// DDPIXELFORMAT
struct
{
unsigned int dwSize;
unsigned int dwFlags;
unsigned int dwFourCC;
unsigned int dwRGBBitCount;
unsigned int dwRBitMask;
unsigned int dwGBitMask;
unsigned int dwBBitMask;
unsigned int dwAlphaBitMask;
} sPixelFormat;
// DDCAPS2
struct
{
unsigned int dwCaps1;
unsigned int dwCaps2;
unsigned int dwDDSX;
unsigned int dwReserved;
} sCaps;
unsigned int dwReserved2;
};
char data[ 128 ];
};
#endif // mydds_h

View File

@ -0,0 +1,813 @@
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Portions of this file have been written by using the "Compress YCOCgDXT" sample as a reference.
// Please refer to http://developer.download.nvidia.com/SDK/10/opengl/samples.html#compress_YCoCgDXT for more information.
/* ------------------------------------------------------------------------------------------------------------------------------------ */
/*
* This file was taken from RakNet 4.082.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*
* Modified work: Copyright (c) 2020, SLikeSoft UG (haftungsbeschr<68>nkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Includes
#include <windows.h>
#include <assert.h>
#include "DXTCompressor.h"
#include "FrameBufferRenderBuffer.hpp"
#include "ShaderSource.h"
#include "OpenGLWindow.hpp"
#include <map>
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Enable performance timing
// #define DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Link with these libraries
#pragma comment(lib, "glutstatic")
#pragma comment(lib, "glew32")
#pragma comment(lib, "cg")
#pragma comment(lib, "cgGL")
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Defines
#define DXTCOMPRESSOR_WINDOW_WIDTH 640
#define DXTCOMPRESSOR_WINDOW_HEIGHT 480
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Static class data
int DXTCompressor::m_initRefCount = 0;
CGcontext DXTCompressor::m_cgContext;
CGprofile DXTCompressor::m_cgVProfile;
CGprofile DXTCompressor::m_cgFProfile;
CGprogram DXTCompressor::m_compressVProg;
CGprogram DXTCompressor::m_compressDXT1RGBAFProg;
CGprogram DXTCompressor::m_compressDXT5RGBAFProg;
CGprogram DXTCompressor::m_compressDXT1BGRAFProg;
CGprogram DXTCompressor::m_compressDXT5BGRAFProg;
int DXTCompressor::m_numIterations = 0;
int DXTCompressor::m_currentImageWidth = 0;
int DXTCompressor::m_currentImageHeight = 0;
float DXTCompressor::m_lastCompressionTime = 0;
float DXTCompressor::m_accumulatedTime = 0;
float DXTCompressor::m_timeRunningCompressionShader = 0;
float DXTCompressor::m_timeCopyingPixelDataToCPU = 0;
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Hash table to store framebuffer objects
struct FramebufferObjectKeyCompare
{
bool operator()(int s1, int s2) const
{
return s1 < s2;
}
};
typedef int FramebufferObjectKey;
typedef class map< FramebufferObjectKey, FramebufferObject*, FramebufferObjectKeyCompare > FramebufferObjectHashtable;
// The hashtable
FramebufferObjectHashtable s_frameBuffersHash;
// Hashkey generation
FramebufferObjectKey GetHashKey( CompressionType compressionType, int width, int height )
{
return (int(compressionType) + width + (width*height));
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
// Typedef ticks
typedef __int64 Ticks;
inline Ticks GetTicks()
{
Ticks ticks;
QueryPerformanceCounter( (LARGE_INTEGER*) &ticks);
return ticks;
}
inline float TicksToMilliseconds( Ticks ticks )
{
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
return float(float(ticks) * 1000.0f / float(freq.QuadPart));
}
const int TIMER_STACK_SIZE = 256;
static int g_currentStackId = 0;
static Ticks g_startTrack[ TIMER_STACK_SIZE ];
static Ticks g_endTrack[ TIMER_STACK_SIZE ];
// Used for tracking time
inline void StartTracking()
{
g_startTrack[ g_currentStackId++ ] = GetTicks();
}
inline void EndTracking()
{
g_endTrack[ --g_currentStackId ] = GetTicks();
}
inline float GetDeltaTimeInSeconds()
{
Ticks delta = g_endTrack[ g_currentStackId ] - g_startTrack[ g_currentStackId ];
return TicksToMilliseconds( delta ) / 1000.0f;
}
inline float GetDeltaTimeInMilliseconds()
{
Ticks delta = g_endTrack[ g_currentStackId ] - g_startTrack[ g_currentStackId ];
return TicksToMilliseconds( delta );
}
#endif // #ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
/* ------------------------------------------------------------------------------------------------------------------------------------ */
DXTCompressor::DXTCompressor()
{
m_imageWidth = 0;
m_imageHeight = 0;
m_compressionType = DXT1;
m_pCompressFbo = 0;
m_compressFboTex = 0;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::cgErrorCallback()
{
CGerror lastError = cgGetError();
if( lastError )
{
printf( "%s\n", cgGetErrorString( lastError ) );
printf( "%s\n", cgGetLastListing( m_cgContext ) );
assert( false );
}
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
bool DXTCompressor::Initialize()
{
if( m_initRefCount == 0 )
{
if( !InitOpenGL() )
return false;
if( !InitCG() )
return false;
}
m_initRefCount++;
return true;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::Shutdown()
{
if( m_initRefCount > 0 )
m_initRefCount--;
if( m_initRefCount == 0 )
{
// Deallocate buffers
DeallocateBuffers();
// Shutdown cg stuff
cgGLDisableProfile(m_cgVProfile);
cgGLDisableProfile(m_cgFProfile);
cgGLUnloadProgram( m_compressVProg );
cgGLUnloadProgram( m_compressDXT1RGBAFProg );
cgGLUnloadProgram( m_compressDXT5RGBAFProg );
cgGLUnloadProgram( m_compressDXT1BGRAFProg );
cgGLUnloadProgram( m_compressDXT5BGRAFProg );
cgDestroyContext(m_cgContext);
// Kill the OpenGL window
KillGLWindow();
}
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
bool DXTCompressor::InitOpenGL()
{
bool bFullscreen = false;
#if 1
// Compute desktop window width and height
HWND desktopHwnd = GetDesktopWindow();
RECT windowRect;
GetWindowRect( desktopHwnd, &windowRect );
int windowWidth = windowRect.right - windowRect.left;
int windowHeight = windowRect.bottom - windowRect.top;
bFullscreen = true;
#else
int windowWidth = 640;
int windowHeight = 480;
#endif
// Create the window; this is needed in order to invoke OpenGL commands
BOOL windowCreateSuccess = CreateGLWindow( "Testing", windowWidth, windowHeight, 32, bFullscreen, true );
if( !windowCreateSuccess )
return false;
// Int GLEW
glewInit();
// Make sure these extensions are supported
if (!glewIsSupported(
"GL_VERSION_2_0 "
"GL_ARB_vertex_program "
"GL_ARB_fragment_program "
"GL_NV_gpu_program4 "
"GL_ARB_pixel_buffer_object "
"GL_EXT_framebuffer_object "
"GL_ARB_texture_compression "
"GL_EXT_texture_compression_s3tc "
"GL_EXT_texture_integer "
))
{
printf("Unable to load required OpenGL extension!\n");
return false;
}
// Enable depth testing
glEnable(GL_DEPTH_TEST);
glClearColor(0.2, 0.2, 0.2, 1.0);
// Report any errors to the console screen
glutReportErrors();
// Success
return true;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
bool DXTCompressor::InitCG()
{
// Create Cg Context
m_cgContext = cgCreateContext();
cgSetErrorCallback( cgErrorCallback );
// Load Cg programs
m_cgVProfile = cgGLGetLatestProfile( CG_GL_VERTEX );
m_cgFProfile = cgGLGetLatestProfile( CG_GL_FRAGMENT );
// Shader compile options...
const char *args[] =
{
"-unroll", "all",
0,
};
m_compressVProg = cgCreateProgram( m_cgContext, CG_SOURCE, pDXTCompressorShaderSource, m_cgVProfile, "compress_vp", args );
cgGLLoadProgram( m_compressVProg );
m_compressDXT1RGBAFProg = cgCreateProgram( m_cgContext, CG_SOURCE, pDXTCompressorShaderSource, m_cgFProfile, "compress_DXT1_RGBA_fp", args );
cgGLLoadProgram( m_compressDXT1RGBAFProg );
m_compressDXT1BGRAFProg = cgCreateProgram( m_cgContext, CG_SOURCE, pDXTCompressorShaderSource, m_cgFProfile, "compress_DXT1_BGRA_fp", args );
cgGLLoadProgram( m_compressDXT1BGRAFProg );
m_compressDXT5RGBAFProg = cgCreateProgram( m_cgContext, CG_SOURCE, pDXTCompressorShaderSource, m_cgFProfile, "compress_YCoCgDXT5_RGBA_fp", args );
cgGLLoadProgram( m_compressDXT5RGBAFProg );
m_compressDXT5BGRAFProg = cgCreateProgram( m_cgContext, CG_SOURCE, pDXTCompressorShaderSource, m_cgFProfile, "compress_YCoCgDXT5_BGRA_fp", args );
cgGLLoadProgram( m_compressDXT5BGRAFProg );
return true;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
bool DXTCompressor::IsInitialized()
{
return (m_initRefCount != 0);
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
static GLuint CreateTexture( GLenum target, GLint internalformat, GLenum format, GLenum type, int w, int h )
{
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(target, tex);
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexImage2D(target, 0, internalformat, w, h, 0, format, type, 0);
return tex;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
FramebufferObject* DXTCompressor::RequestFBO( CompressionType compressionType, int width, int height )
{
// Get hash key
FramebufferObjectKey hashKey = GetHashKey( compressionType, width, height );
// See if we have it in the hash
if( s_frameBuffersHash.find( hashKey ) != s_frameBuffersHash.end() )
{
return s_frameBuffersHash[ hashKey ];
}
// Create the texture
GLuint newTextureID = 0;
FramebufferObject* pNewFrameBufferObject = new FramebufferObject();
if( compressionType == DXT1 )
{
newTextureID = CreateTexture(GL_TEXTURE_2D, GL_LUMINANCE_ALPHA32UI_EXT, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_INT, width/4, height/4);
}
else if( compressionType == DXT5_YCOCG )
{
newTextureID = CreateTexture(GL_TEXTURE_2D, GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_INT, width/4, height/4);
}
// Attach texture to framebuffer object
pNewFrameBufferObject->Bind();
pNewFrameBufferObject->AttachTexture(GL_TEXTURE_2D, newTextureID, GL_COLOR_ATTACHMENT0_EXT);
pNewFrameBufferObject->IsValid();
FramebufferObject::Disable();
// Add to hash
s_frameBuffersHash[ hashKey ] = pNewFrameBufferObject;
// Return
return pNewFrameBufferObject;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::DeallocateBuffers()
{
FramebufferObjectHashtable::iterator iter = s_frameBuffersHash.begin();
while( iter != s_frameBuffersHash.end() )
{
// Delete object
FramebufferObject* pFrameBufferObject = iter->second;
GLuint textureID = pFrameBufferObject->GetAttachedTextureID();
glDeleteTextures(1, &textureID);
delete pFrameBufferObject;
// Bump
++iter;
}
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
static inline void SetParameter( CGprogram prog, char *name, float x, float y=0.0, float z=0.0, float w=0.0 )
{
CGparameter param = cgGetNamedParameter( prog, name );
if( param )
{
cgGLSetParameter4f( param, x, y, z, w );
}
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::SetShaderConstants()
{
SetParameter( m_compressDXT1RGBAFProg, "imageSize", m_imageWidth, m_imageHeight );
SetParameter( m_compressDXT5RGBAFProg, "imageSize", m_imageWidth, m_imageHeight );
SetParameter( m_compressDXT1BGRAFProg, "imageSize", m_imageWidth, m_imageHeight );
SetParameter( m_compressDXT5BGRAFProg, "imageSize", m_imageWidth, m_imageHeight );
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
static inline void DrawQuad()
{
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex2f(1.0, -1.0);
glTexCoord2f(1.0, 1.0); glVertex2f(1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, 1.0);
glEnd();
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::CompressInternal(bool sourceFormatIsBGRA)
{
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
StartTracking();
#endif
glViewport(0, 0, m_imageWidth/4, m_imageHeight/4);
glDisable(GL_DEPTH_TEST);
cgGLBindProgram(m_compressVProg);
cgGLEnableProfile(m_cgVProfile);
if( m_compressionType == DXT5_YCOCG )
{
if (sourceFormatIsBGRA==false)
cgGLBindProgram(m_compressDXT5RGBAFProg);
else
cgGLBindProgram(m_compressDXT5BGRAFProg);
}
else if( m_compressionType == DXT1 )
{
if (sourceFormatIsBGRA==false)
cgGLBindProgram(m_compressDXT1RGBAFProg);
else
cgGLBindProgram(m_compressDXT1BGRAFProg);
}
else
{
assert(false );
}
cgGLEnableProfile(m_cgFProfile);
glBindTexture(GL_TEXTURE_2D, m_imageTexId);
SetShaderConstants();
DrawQuad();
cgGLDisableProfile(m_cgVProfile);
cgGLDisableProfile(m_cgFProfile);
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
glFinish();
EndTracking();
m_timeRunningCompressionShader += GetDeltaTimeInMilliseconds();
#endif
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
int DXTCompressor::GetBufferSize( CompressionType compressionType, int inputWidth, int inputHeight )
{
if( compressionType == DXT5_YCOCG )
{
int size = (inputWidth/4)*(inputHeight/4)*8;
return sizeof(GLushort)*size;
}
else
{
int size = (inputWidth/4)*(inputHeight/4)*4;
return sizeof(GLushort)*size;
}
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::DoCompression( void* ppOutputData, bool sourceFormatIsBGRA )
{
if( m_compressionType == DXT5_YCOCG )
{
// Render to integer fbo
m_pCompressFbo->Bind();
CompressInternal(sourceFormatIsBGRA);
// Readback data to host
int size = (m_imageWidth/4)*(m_imageHeight/4)*8;
GLushort *data = (GLushort *) ppOutputData;
// Copy pixel data
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
StartTracking();
#endif
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, m_imageWidth/4, m_imageHeight/4, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, data);
FramebufferObject::Disable();
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
EndTracking();
m_timeCopyingPixelDataToCPU += GetDeltaTimeInMilliseconds();
#endif
}
else if( m_compressionType == DXT1 )
{
// Render to integer fbo
m_pCompressFbo->Bind();
CompressInternal(sourceFormatIsBGRA);
// Readback data to host
int size = (m_imageWidth/4)*(m_imageHeight/4)*4;
GLushort *data = (GLushort *) ppOutputData;
// Copy pixel data
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
StartTracking();
#endif
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
glReadPixels(0, 0, m_imageWidth/4, m_imageHeight/4, GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_UNSIGNED_INT, data);
FramebufferObject::Disable();
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
EndTracking();
m_timeCopyingPixelDataToCPU += GetDeltaTimeInMilliseconds();
#endif
}
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
bool DXTCompressor::CompressImageData( CompressionType compressionType, const void *inputRGBA, int inputWidth, int inputHeight, void *outputData, bool bDisplayResults, bool sourceFormatIsBGRA )
{
// Make sure we're initialized
if( !IsInitialized() )
{
printf( "You need to initialize DXTCompressor before calling compress!\n " );
return false;
}
// Make sure the source width and height are divisible by 4
// This is a requirement by the DXT compression algorithm
if( !( (inputWidth%4)==0 && (inputHeight%4)==0 ) )
{
printf( "Error! Input image width and height must be multiple of 4, as required by DXT compression rules. You have passed in an image of %dx%d", inputWidth, inputHeight );
return false;
}
// Accumulate width and heights
m_numIterations++;
m_currentImageWidth = inputWidth;
m_currentImageHeight = inputHeight;
// Instantiate the compressor
DXTCompressor compressor;
compressor.m_imageWidth = inputWidth;
compressor.m_imageHeight = inputHeight;
compressor.m_compressionType = compressionType;
// Make a copy of the source data and flip the Y. OpenGL rendering has Y going down
/*
char* pFlippedData = new char[ inputWidth*inputHeight*4 ];
{
const int rowSize = inputWidth*4;
char* pRunnerDest = pFlippedData + (rowSize*(inputHeight-1));
const char* pRunnerSrc = (const char*)inputRGBA;
for( int row = inputHeight-1; row >=0; row-- )
{
memcpy( pRunnerDest, pRunnerSrc, rowSize );
pRunnerSrc += rowSize;
pRunnerDest -= rowSize;
}
}
*/
// Generate a texture and bind it to the input source data
glGenTextures(1, &compressor.m_imageTexId);
glBindTexture(GL_TEXTURE_2D, compressor.m_imageTexId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, inputWidth, inputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)pFlippedData );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, inputWidth, inputHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)inputRGBA );
// Request FBO
compressor.m_pCompressFbo = RequestFBO( compressionType, inputWidth, inputHeight );
compressor.m_compressFboTex = compressor.m_pCompressFbo->GetAttachedTextureID();
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
// Start the clock
StartTracking();
#endif
// Do the compression
compressor.DoCompression( outputData, sourceFormatIsBGRA );
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
// Stop the clock
EndTracking();
m_lastCompressionTime = GetDeltaTimeInMilliseconds();
m_accumulatedTime += m_lastCompressionTime;
printf( "Compression time: %f ms\n", m_lastCompressionTime );
#endif
// Display texture? Only DXT1 supported here.
if( bDisplayResults && compressionType == DXT1 )
{
// Create empty dxt1 compressed texture
GLuint tempDisplayTexture;
int dxt1Size = (inputWidth/4)*(inputHeight/4)*8;
GLubyte * tempPadData = new GLubyte [dxt1Size];
memset(tempPadData, 0, dxt1Size);
glGenTextures(1, &tempDisplayTexture);
glBindTexture(GL_TEXTURE_2D, tempDisplayTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, inputWidth, inputHeight, 0, dxt1Size, tempPadData);
delete [] tempPadData;
// Re-upload the texture to VRAM for display
int size = (inputWidth/4)*(inputHeight/4);
glBindTexture(GL_TEXTURE_2D, tempDisplayTexture);
glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, inputWidth, inputHeight, 0, size*8, outputData);
// Display the texture
DisplayTexture( tempDisplayTexture, inputWidth, inputHeight );
// Get rid of the texture
glDeleteTextures(1, &tempDisplayTexture);
}
// Clean up
// delete [] pFlippedData;
// pFlippedData = nullptr;
glDeleteTextures( 1, &compressor.m_imageTexId );
// Done
return true;
}
#include <stdlib.h>
#include "DDSHeader.h"
/* ------------------------------------------------------------------------------------------------------------------------------------ */
int DXTCompressor::GetDDSHeaderSize(void)
{
return sizeof(DDS_header);
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::WriteDDSHeader( CompressionType compressionType, int width, int height, int compresedDataLength, void *outputData )
{
DDS_header* pHdr = (DDS_header*)outputData;
memset( pHdr, 0, sizeof(DDS_header) );
pHdr->dwMagic = DDS_MAGIC;
pHdr->dwSize = 124;
pHdr->dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;
pHdr->dwWidth = width;
pHdr->dwHeight = height;
pHdr->sCaps.dwCaps1 = DDSCAPS_TEXTURE | DDSD_CAPS;
pHdr->sPixelFormat.dwSize = 32;
pHdr->sPixelFormat.dwFlags = DDPF_FOURCC;
if( compressionType == DXT1 )
pHdr->sPixelFormat.dwFourCC = D3DFMT_DXT1;
else if( compressionType == DXT5_YCOCG )
pHdr->sPixelFormat.dwFourCC = D3DFMT_DXT5;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::WriteDDSMemoryFile( CompressionType compressionType, int width, int height, const void* pCompressedData, int compresedDataLength, void **outputData, int *outputLength )
{
// Allocate the header + data
int totalSize = sizeof(DDS_header) + compresedDataLength;
void* pMemFile = new char[ totalSize ];
// Write the header
WriteDDSHeader(compressionType, width, height, compresedDataLength, pMemFile );
// Write the data
void* pData = ((char*)pMemFile + sizeof(DDS_header));
memcpy( pData, pCompressedData, compresedDataLength );
// Return data to user
*outputData = pMemFile;
*outputLength = totalSize;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
void DXTCompressor::PrintPerformanceLog()
{
#ifdef DXTCOMPRESSOR_ENABLE_PERFORMANCE_TIMING
// Compute
float mPixelsPerSec = (m_currentImageWidth*m_currentImageHeight*m_numIterations) / (m_accumulatedTime*1e6/1000.0f);
printf( "For %dx%d image, compression took %f ms, Average of %f mPixelsPerSec (mPixels/sec)\n", m_currentImageWidth, m_currentImageHeight, m_accumulatedTime/m_numIterations, mPixelsPerSec );
printf( "%f ms was spent in running compression shader, %f ms was spent copying pixel data to main memory for the cpu\n", m_timeRunningCompressionShader/m_numIterations, m_timeCopyingPixelDataToCPU/m_numIterations );
// Reset stats
m_currentImageWidth = 0;
m_currentImageHeight = 0;
m_numIterations = 0;
m_accumulatedTime = 0;
m_timeCopyingPixelDataToCPU = 0;
m_timeRunningCompressionShader = 0;
#endif
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
static void glutPrint(float x, float y, const char *s, void *font)
{
int i, len;
glRasterPos2f(x, y);
len = (int) strlen(s);
for (i = 0; i < len; i++) {
glutBitmapCharacter(font, s[i]);
}
}
static bool DrawTexture( GLuint textureID )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0,0,windowWidth,windowHeight);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, textureID);
glEnable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);
glColor3f(1.0, 1.0, 1.0);
DrawQuad();
glDisable(GL_TEXTURE_2D);
glLoadIdentity();
glutPrint(-0.95, -0.95, "DXT1 compressed (push ESC to close)", GLUT_BITMAP_9_BY_15);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
return true;
}
void ClientResize(HWND hWnd, int nWidth, int nHeight)
{
RECT rcClient, rcWindow;
POINT ptDiff;
GetClientRect(hWnd, &rcClient);
GetWindowRect(hWnd, &rcWindow);
ptDiff.x = (rcWindow.right - rcWindow.left) - rcClient.right;
ptDiff.y = (rcWindow.bottom - rcWindow.top) - rcClient.bottom;
MoveWindow(hWnd,rcWindow.left, rcWindow.top, nWidth + ptDiff.x, nHeight + ptDiff.y, TRUE);
}
void DXTCompressor::DisplayTexture( GLuint textureID, int texW, int texH )
{
// Show the window
ShowWindow(hWnd,SW_SHOW);
// Resize the window to match the size of the texture
ClientResize( hWnd, texW, texH );
// Windows message pump
MSG msg;
BOOL done=FALSE;
while(!done)
{
if (PeekMessage(&msg, nullptr,0,0,PM_REMOVE))
{
if (msg.message==WM_QUIT)
{
done=TRUE;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
if ((active && !DrawTexture( textureID )) || keys[VK_ESCAPE])
{
keys[VK_ESCAPE] = FALSE;
done=TRUE;
}
else
{
SwapBuffers(hDC);
}
}
}
// Hide the window
ShowWindow(hWnd,SW_HIDE);
}

View File

@ -0,0 +1,98 @@
/*
* This file was taken from RakNet 4.082 without any modifications.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*/
#ifndef __DXT_COMPRESSOR_H__
#define __DXT_COMPRESSOR_H__
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Includes
#include <GL/glew.h>
#include <GL/glut.h>
#include <Cg/cg.h>
#include <Cg/cgGL.h>
/* ------------------------------------------------------------------------------------------------------------------------------------ */
// Forward decls.
class FramebufferObject;
class Renderbuffer;
/* ------------------------------------------------------------------------------------------------------------------------------------ */
enum CompressionType
{
DXT1,
DXT5_YCOCG,
};
/* ------------------------------------------------------------------------------------------------------------------------------------ */
class DXTCompressor
{
public:
DXTCompressor();
public:
// These need to be called before using the compressor, and shutdown after using the compressor
static bool Initialize();
static void Shutdown();
// Compresses input data into the desired compressed format.
// The input data is assumed to be 32-bit RGBA (1 byte per channel).
// outputData should be allocated to at least GetBufferSize()
// This will return true if the compression is successful.
static bool CompressImageData( CompressionType compressionType, const void *inputRGBA, int inputWidth, int inputHeight, void *outputData, bool bDisplayResults, bool sourceFormatIsBGRA );
static int GetBufferSize(CompressionType compressionType, int inputWidth, int inputHeight );
// Saves the compressed data into a Microsoft DDS file.
static int GetDDSHeaderSize(void);
static void WriteDDSHeader( CompressionType compressionType, int width, int height, int compresedDataLength, void *outputData );
static void WriteDDSMemoryFile( CompressionType compressionType, int width, int height, const void* pCompressedData, int compresedDataLength, void **outputData, int *outputLength );
// Prints out the accumulated performance of the compressor
static void PrintPerformanceLog();
private:
void SetShaderConstants();
void CompressInternal( bool sourceFormatIsBGRA);
void DoCompression( void* ppOutputData, bool sourceFormatIsBGRA );
static bool InitOpenGL();
static bool InitCG();
static void cgErrorCallback();
static bool IsInitialized();
static void DisplayTexture( GLuint textureID, int texW, int texH );
static FramebufferObject* RequestFBO( CompressionType compressionType, int width, int height );
static void DeallocateBuffers();
private:
// Image related data
int m_imageWidth;
int m_imageHeight;
CompressionType m_compressionType;
GLuint m_imageTexId;
FramebufferObject* m_pCompressFbo;
GLuint m_compressFboTex;
// CG related data
static int m_initRefCount;
static CGcontext m_cgContext;
static CGprofile m_cgVProfile, m_cgFProfile;
static CGprogram m_compressVProg, m_compressDXT1RGBAFProg, m_compressDXT5RGBAFProg, m_compressDXT1BGRAFProg, m_compressDXT5BGRAFProg;
// Used to collect stats
static int m_numIterations;
static int m_currentImageWidth, m_currentImageHeight;
static float m_lastCompressionTime;
static float m_accumulatedTime;
static float m_timeRunningCompressionShader;
static float m_timeCopyingPixelDataToCPU;
};
#endif // __DXT_COMPRESSOR_H__

View File

@ -0,0 +1,639 @@
/*
Copyright (c) 2005,
Aaron Lefohn (lefohn@cs.ucdavis.edu)
Adam Moerschell (atmoerschell@ucdavis.edu)
All rights reserved.
This software is licensed under the BSD open-source license. See
http://www.opensource.org/licenses/bsd-license.php for more detail.
*************************************************************
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 name of the University of Californa, Davis nor the names of
the 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 OWNER 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.
*/
#ifndef __FRAMEBUFFERRENDERBUFFER_HPP__
#define __FRAMEBUFFERRENDERBUFFER_HPP__
#include <GL/glew.h>
#include <iostream>
/*!
FramebufferObject Class. This class encapsulates the FramebufferObject
(FBO) OpenGL spec. See the official spec at:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt
for details.
A framebuffer object (FBO) is conceptually a structure containing pointers
to GPU memory. The memory pointed to is either an OpenGL texture or an
OpenGL RenderBuffer. FBOs can be used to render to one or more textures,
share depth buffers between multiple sets of color buffers/textures and
are a complete replacement for pbuffers.
Performance Notes:
1) It is more efficient (but not required) to call Bind()
on an FBO before making multiple method calls. For example:
FramebufferObject fbo;
fbo.Bind();
fbo.AttachTexture(GL_TEXTURE_2D, texId0, GL_COLOR_ATTACHMENT0_EXT);
fbo.AttachTexture(GL_TEXTURE_2D, texId1, GL_COLOR_ATTACHMENT1_EXT);
fbo.IsValid();
To provide a complete encapsulation, the following usage
pattern works correctly but is less efficient:
FramebufferObject fbo;
// NOTE : No Bind() call
fbo.AttachTexture(GL_TEXTURE_2D, texId0, GL_COLOR_ATTACHMENT0_EXT);
fbo.AttachTexture(GL_TEXTURE_2D, texId1, GL_COLOR_ATTACHMENT1_EXT);
fbo.IsValid();
The first usage pattern binds the FBO only once, whereas
the second usage binds/unbinds the FBO for each method call.
2) Use FramebufferObject::Disable() sparingly. We have intentionally
left out an "Unbind()" method because it is largely unnecessary
and encourages rendundant Bind/Unbind coding. Binding an FBO is
usually much faster than enabling/disabling a pbuffer, but is
still a costly operation. When switching between multiple FBOs
and a visible OpenGL framebuffer, the following usage pattern
is recommended:
FramebufferObject fbo1, fbo2;
fbo1.Bind();
... Render ...
// NOTE : No Unbind/Disable here...
fbo2.Bind();
... Render ...
// Disable FBO rendering and return to visible window
// OpenGL framebuffer.
FramebufferObject::Disable();
*/
class FramebufferObject
{
public:
/// Ctor/Dtor
FramebufferObject();
virtual ~FramebufferObject();
/// Bind this FBO as current render target
void Bind();
/// Bind a texture to the "attachment" point of this FBO
virtual void AttachTexture( GLenum texTarget,
GLuint texId,
GLenum attachment = GL_COLOR_ATTACHMENT0_EXT,
int mipLevel = 0,
int zSlice = 0 );
/// Bind an array of textures to multiple "attachment" points of this FBO
/// - By default, the first 'numTextures' attachments are used,
/// starting with GL_COLOR_ATTACHMENT0_EXT
virtual void AttachTextures( int numTextures,
GLenum texTarget[],
GLuint texId[],
GLenum attachment[] = NULL,
int mipLevel[] = NULL,
int zSlice[] = NULL );
/// Bind a render buffer to the "attachment" point of this FBO
virtual void AttachRenderBuffer( GLuint buffId,
GLenum attachment = GL_COLOR_ATTACHMENT0_EXT );
/// Bind an array of render buffers to corresponding "attachment" points
/// of this FBO.
/// - By default, the first 'numBuffers' attachments are used,
/// starting with GL_COLOR_ATTACHMENT0_EXT
virtual void AttachRenderBuffers( int numBuffers, GLuint buffId[],
GLenum attachment[] = NULL );
/// Free any resource bound to the "attachment" point of this FBO
void Unattach( GLenum attachment );
/// Free any resources bound to any attachment points of this FBO
void UnattachAll();
/// Is this FBO currently a valid render target?
/// - Sends output to std::cerr by default but can
/// be a user-defined C++ stream
///
/// NOTE : This function works correctly in debug build
/// mode but always returns "true" if NDEBUG is
/// is defined (optimized builds)
#ifndef NDEBUG
bool IsValid( std::ostream& ostr = std::cerr );
#else
bool IsValid( std::ostream& ostr = std::cerr ) {
return true;
}
#endif
/// BEGIN : Accessors
/// Is attached type GL_RENDERBUFFER_EXT or GL_TEXTURE?
GLenum GetAttachedType( GLenum attachment );
/// What is the Id of Renderbuffer/texture currently
/// attached to "attachement?"
GLuint GetAttachedId( GLenum attachment );
/// Which mipmap level is currently attached to "attachement?"
GLint GetAttachedMipLevel( GLenum attachment );
/// Which cube face is currently attached to "attachment?"
GLint GetAttachedCubeFace( GLenum attachment );
/// Which z-slice is currently attached to "attachment?"
GLint GetAttachedZSlice( GLenum attachment );
/// END : Accessors
GLuint GetAttachedTextureID() const { return m_attachedTexture; }
/// BEGIN : Static methods global to all FBOs
/// Return number of color attachments permitted
static int GetMaxColorAttachments();
/// Disable all FBO rendering and return to traditional,
/// windowing-system controlled framebuffer
/// NOTE:
/// This is NOT an "unbind" for this specific FBO, but rather
/// disables all FBO rendering. This call is intentionally "static"
/// and named "Disable" instead of "Unbind" for this reason. The
/// motivation for this strange semantic is performance. Providing
/// "Unbind" would likely lead to a large number of unnecessary
/// FBO enablings/disabling.
static void Disable();
/// END : Static methods global to all FBOs
protected:
void _GuardedBind();
void _GuardedUnbind();
void _FramebufferTextureND( GLenum attachment, GLenum texTarget,
GLuint texId, int mipLevel, int zSlice );
static GLuint _GenerateFboId();
private:
GLuint m_fboId;
GLint m_savedFboId;
GLuint m_attachedTexture;
};
#include <iostream>
using namespace std;
FramebufferObject::FramebufferObject()
: m_fboId(_GenerateFboId()),
m_savedFboId(0)
{
// Bind this FBO so that it actually gets created now
_GuardedBind();
_GuardedUnbind();
}
FramebufferObject::~FramebufferObject()
{
glDeleteFramebuffersEXT(1, &m_fboId);
}
void FramebufferObject::Bind()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId);
}
void FramebufferObject::Disable()
{
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void
FramebufferObject::AttachTexture( GLenum texTarget, GLuint texId,
GLenum attachment, int mipLevel, int zSlice )
{
_GuardedBind();
/*
#ifndef NDEBUG
if( GetAttachedId(attachment) != texId ) {
#endif
*/
_FramebufferTextureND( attachment, texTarget,
texId, mipLevel, zSlice );
m_attachedTexture = texId;
/*
#ifndef NDEBUG
}
else {
cerr << "FramebufferObject::AttachTexture PERFORMANCE WARNING:\n"
<< "\tRedundant bind of texture (id = " << texId << ").\n"
<< "\tHINT : Compile with -DNDEBUG to remove this warning.\n";
}
#endif
*/
_GuardedUnbind();
}
void
FramebufferObject::AttachTextures( int numTextures, GLenum texTarget[], GLuint texId[],
GLenum attachment[], int mipLevel[], int zSlice[] )
{
for(int i = 0; i < numTextures; ++i) {
AttachTexture( texTarget[i], texId[i],
attachment ? attachment[i] : (GL_COLOR_ATTACHMENT0_EXT + i),
mipLevel ? mipLevel[i] : 0,
zSlice ? zSlice[i] : 0 );
}
}
void
FramebufferObject::AttachRenderBuffer( GLuint buffId, GLenum attachment )
{
_GuardedBind();
#ifndef NDEBUG
if( GetAttachedId(attachment) != buffId ) {
#endif
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_RENDERBUFFER_EXT, buffId);
#ifndef NDEBUG
}
else {
cerr << "FramebufferObject::AttachRenderBuffer PERFORMANCE WARNING:\n"
<< "\tRedundant bind of Renderbuffer (id = " << buffId << ")\n"
<< "\tHINT : Compile with -DNDEBUG to remove this warning.\n";
}
#endif
_GuardedUnbind();
}
void
FramebufferObject::AttachRenderBuffers( int numBuffers, GLuint buffId[], GLenum attachment[] )
{
for(int i = 0; i < numBuffers; ++i) {
AttachRenderBuffer( buffId[i],
attachment ? attachment[i] : (GL_COLOR_ATTACHMENT0_EXT + i) );
}
}
void
FramebufferObject::Unattach( GLenum attachment )
{
_GuardedBind();
GLenum type = GetAttachedType(attachment);
switch(type) {
case GL_NONE:
break;
case GL_RENDERBUFFER_EXT:
AttachRenderBuffer( 0, attachment );
break;
case GL_TEXTURE:
AttachTexture( GL_TEXTURE_2D, 0, attachment );
break;
default:
cerr << "FramebufferObject::unbind_attachment ERROR: Unknown attached resource type\n";
}
_GuardedUnbind();
}
void
FramebufferObject::UnattachAll()
{
int numAttachments = GetMaxColorAttachments();
for(int i = 0; i < numAttachments; ++i) {
Unattach( GL_COLOR_ATTACHMENT0_EXT + i );
}
}
GLint FramebufferObject::GetMaxColorAttachments()
{
GLint maxAttach = 0;
glGetIntegerv( GL_MAX_COLOR_ATTACHMENTS_EXT, &maxAttach );
return maxAttach;
}
GLuint FramebufferObject::_GenerateFboId()
{
GLuint id = 0;
glGenFramebuffersEXT(1, &id);
return id;
}
void FramebufferObject::_GuardedBind()
{
// Only binds if m_fboId is different than the currently bound FBO
glGetIntegerv( GL_FRAMEBUFFER_BINDING_EXT, &m_savedFboId );
if (m_fboId != (GLuint)m_savedFboId) {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId);
}
}
void FramebufferObject::_GuardedUnbind()
{
// Returns FBO binding to the previously enabled FBO
if (m_fboId != (GLuint)m_savedFboId) {
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, (GLuint)m_savedFboId);
}
}
void
FramebufferObject::_FramebufferTextureND( GLenum attachment, GLenum texTarget,
GLuint texId, int mipLevel,
int zSlice )
{
if (texTarget == GL_TEXTURE_1D) {
glFramebufferTexture1DEXT( GL_FRAMEBUFFER_EXT, attachment,
GL_TEXTURE_1D, texId, mipLevel );
}
else if (texTarget == GL_TEXTURE_3D) {
glFramebufferTexture3DEXT( GL_FRAMEBUFFER_EXT, attachment,
GL_TEXTURE_3D, texId, mipLevel, zSlice );
}
else {
// Default is GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_ARB, or cube faces
glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, attachment,
texTarget, texId, mipLevel );
}
}
#ifndef NDEBUG
bool FramebufferObject::IsValid( ostream& ostr )
{
_GuardedBind();
bool isOK = false;
GLenum status;
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
switch(status) {
case GL_FRAMEBUFFER_COMPLETE_EXT: // Everything's OK
isOK = true;
break;
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\n";
isOK = false;
break;
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\n";
isOK = false;
break;
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\n";
isOK = false;
break;
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\n";
isOK = false;
break;
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\n";
isOK = false;
break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\n";
isOK = false;
break;
case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "GL_FRAMEBUFFER_UNSUPPORTED_EXT\n";
isOK = false;
break;
default:
ostr << "glift::CheckFramebufferStatus() ERROR:\n\t"
<< "Unknown ERROR\n";
isOK = false;
}
_GuardedUnbind();
return isOK;
}
#endif // NDEBUG
/// Accessors
GLenum FramebufferObject::GetAttachedType( GLenum attachment )
{
// Returns GL_RENDERBUFFER_EXT or GL_TEXTURE
_GuardedBind();
GLint type = 0;
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT,
&type);
_GuardedUnbind();
return GLenum(type);
}
GLuint FramebufferObject::GetAttachedId( GLenum attachment )
{
_GuardedBind();
GLint id = 0;
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT,
&id);
_GuardedUnbind();
return GLuint(id);
}
GLint FramebufferObject::GetAttachedMipLevel( GLenum attachment )
{
_GuardedBind();
GLint level = 0;
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT,
&level);
_GuardedUnbind();
return level;
}
GLint FramebufferObject::GetAttachedCubeFace( GLenum attachment )
{
_GuardedBind();
GLint level = 0;
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT,
&level);
_GuardedUnbind();
return level;
}
GLint FramebufferObject::GetAttachedZSlice( GLenum attachment )
{
_GuardedBind();
GLint slice = 0;
glGetFramebufferAttachmentParameterivEXT(GL_FRAMEBUFFER_EXT, attachment,
GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT,
&slice);
_GuardedUnbind();
return slice;
}
/*!
Renderbuffer Class. This class encapsulates the Renderbuffer OpenGL
object described in the FramebufferObject (FBO) OpenGL spec.
See the official spec at:
http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt
for complete details.
A "Renderbuffer" is a chunk of GPU memory used by FramebufferObjects to
represent "traditional" framebuffer memory (depth, stencil, and color buffers).
By "traditional," we mean that the memory cannot be bound as a texture.
With respect to GPU shaders, Renderbuffer memory is "write-only." Framebuffer
operations such as alpha blending, depth test, alpha test, stencil test, etc.
read from this memory in post-fragement-shader (ROP) operations.
The most common use of Renderbuffers is to create depth and stencil buffers.
Note that as of 7/1/05, NVIDIA drivers to do not support stencil Renderbuffers.
Usage Notes:
1) "internalFormat" can be any of the following:
Valid OpenGL internal formats beginning with:
RGB, RGBA, DEPTH_COMPONENT
or a stencil buffer format (not currently supported
in NVIDIA drivers as of 7/1/05).
STENCIL_INDEX1_EXT
STENCIL_INDEX4_EXT
STENCIL_INDEX8_EXT
STENCIL_INDEX16_EXT
*/
class Renderbuffer
{
public:
/// Ctors/Dtors
Renderbuffer();
Renderbuffer(GLenum internalFormat, int width, int height);
~Renderbuffer();
void Bind();
void Unbind();
void Set(GLenum internalFormat, int width, int height);
GLuint GetId() const;
static GLint GetMaxSize();
private:
GLuint m_bufId;
static GLuint _CreateBufferId();
};
#include <iostream>
using namespace std;
Renderbuffer::Renderbuffer()
: m_bufId(_CreateBufferId())
{}
Renderbuffer::Renderbuffer(GLenum internalFormat, int width, int height)
: m_bufId(_CreateBufferId())
{
Set(internalFormat, width, height);
}
Renderbuffer::~Renderbuffer()
{
glDeleteRenderbuffersEXT(1, &m_bufId);
}
void Renderbuffer::Bind()
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_bufId);
}
void Renderbuffer::Unbind()
{
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
}
void Renderbuffer::Set(GLenum internalFormat, int width, int height)
{
int maxSize = Renderbuffer::GetMaxSize();
if (width > maxSize || height > maxSize ) {
cerr << "Renderbuffer::Renderbuffer() ERROR:\n\t"
<< "Size too big (" << width << ", " << height << ")\n";
return;
}
// Guarded bind
GLint savedId = 0;
glGetIntegerv( GL_RENDERBUFFER_BINDING_EXT, &savedId );
if (savedId != (GLint)m_bufId) {
Bind();
}
// Allocate memory for renderBuffer
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalFormat, width, height );
// Guarded unbind
if (savedId != (GLint)m_bufId) {
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, savedId);
}
}
GLuint Renderbuffer::GetId() const
{
return m_bufId;
}
GLint Renderbuffer::GetMaxSize()
{
GLint maxAttach = 0;
glGetIntegerv( GL_MAX_RENDERBUFFER_SIZE_EXT, &maxAttach );
return maxAttach;
}
GLuint Renderbuffer::_CreateBufferId()
{
GLuint id = 0;
glGenRenderbuffersEXT(1, &id);
return id;
}
#endif // __FRAMEBUFFERRENDERBUFFER_HPP__

View File

@ -0,0 +1,358 @@
/*
* This Code Was Created By Jeff Molofee 2000
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing This Code, Making It More Flexible!
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/
/*
* This file was taken from RakNet 4.082.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*
* Modified work: Copyright (c) 2015-2020, SLikeSoft UG (haftungsbeschr<68>nkt)
*
* This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
* license found in the license.txt file in the root directory of this source tree.
*/
#include <windows.h> // Header File For Windows
#include <tchar.h> // Header File For Unicode conversion support
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
HDC hDC= nullptr; // Private GDI Device Context
HGLRC hRC= nullptr; // Permanent Rendering Context
HWND hWnd= nullptr; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
int windowWidth = 0, windowHeight = 0;
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
static void MessageBoxPrivate( HWND hWnd, const char* pMessage, const char* pTitle, int flags )
{
printf( "%s: %s\n", pTitle, pMessage );
}
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
return TRUE; // Everything Went OK
}
GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
{
if (fullscreen) // Are We In Fullscreen Mode?
{
ChangeDisplaySettings(nullptr,0); // If So Switch Back To The Desktop
ShowCursor(TRUE); // Show Mouse Pointer
}
if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(nullptr, nullptr)) // Are We Able To Release The DC And RC Contexts?
{
MessageBoxPrivate(nullptr,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBoxPrivate(nullptr,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC= nullptr; // Set RC To nullptr
}
if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC
{
MessageBoxPrivate(nullptr,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC= nullptr; // Set DC To nullptr
}
if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
{
MessageBoxPrivate(nullptr,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd= nullptr; // Set hWnd To nullptr
}
if (!UnregisterClass(_T("OpenGL"),hInstance)) // Are We Able To Unregister Class
{
MessageBoxPrivate(nullptr,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hInstance= nullptr; // Set hInstance To nullptr
}
}
/* This Code Creates Our OpenGL Window. Parameters Are: *
* title - Title To Appear At The Top Of The Window *
* width - Width Of The GL Window Or Fullscreen Mode *
* height - Height Of The GL Window Or Fullscreen Mode *
* bits - Number Of Bits To Use For Color (8/16/24/32) *
* fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag, bool hideWindow=true)
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
WNDCLASS wc; // Windows Class Structure
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
WindowRect.left=(long)0; // Set Left Value To 0
WindowRect.right=(long)width; // Set Right Value To Requested Width
WindowRect.top=(long)0; // Set Top Value To 0
WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
fullscreen=fullscreenflag; // Set The Global Fullscreen Flag
hInstance = GetModuleHandle(nullptr); // Grab An Instance For Our Window
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra = 0; // No Extra Window Data
wc.hInstance = hInstance; // Set The Instance
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO); // Load The Default Icon
wc.hCursor = LoadCursor(nullptr, IDC_ARROW); // Load The Arrow Pointer
wc.hbrBackground = nullptr; // No Background Required For GL
wc.lpszMenuName = nullptr; // We Don't Want A Menu
wc.lpszClassName = _T("OpenGL"); // Set The Class Name
if (!RegisterClass(&wc)) // Attempt To Register The Window Class
{
MessageBoxPrivate(nullptr,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (fullscreen) // Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
/*
// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBoxPrivate(nullptr,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBoxPrivate(nullptr,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE; // Return FALSE
}
*/
fullscreen=FALSE;
}
}
if (fullscreen) // Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
dwStyle=WS_POPUP; // Windows Style
ShowCursor(FALSE); // Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style
}
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
// Create The Window
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
_T("OpenGL"), // Class Name
_T("DXTCompress"), // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top, // Calculate Window Height
nullptr, // No Parent Window
nullptr, // No Menu
hInstance, // Instance
nullptr))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
static_cast<BYTE>(bits), // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context?
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if( hideWindow )
ShowWindow(hWnd,SW_HIDE); // Show The Window
else
ShowWindow(hWnd,SW_SHOW); // Show The Window
SetForegroundWindow(hWnd); // Slightly Higher Priority
SetFocus(hWnd); // Sets Keyboard Focus To The Window
ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
if (!InitGL()) // Initialize Our Newly Created GL Window
{
KillGLWindow(); // Reset The Display
MessageBoxPrivate(nullptr,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
return TRUE; // Success
}
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
switch (uMsg) // Check For Windows Messages
{
case WM_ACTIVATE: // Watch For Window Activate Message
{
if (!HIWORD(wParam)) // Check Minimization State
{
active=TRUE; // Program Is Active
}
else
{
active=FALSE; // Program Is No Longer Active
}
return 0; // Return To The Message Loop
}
case WM_SYSCOMMAND: // Intercept System Commands
{
switch (wParam) // Check System Calls
{
case SC_SCREENSAVE: // Screensaver Trying To Start?
case SC_MONITORPOWER: // Monitor Trying To Enter Powersave?
return 0; // Prevent From Happening
}
break; // Exit
}
case WM_CLOSE: // Did We Receive A Close Message?
{
PostQuitMessage(0); // Send A Quit Message
return 0; // Jump Back
}
case WM_KEYDOWN: // Is A Key Being Held Down?
{
keys[wParam] = TRUE; // If So, Mark It As TRUE
return 0; // Jump Back
}
case WM_KEYUP: // Has A Key Been Released?
{
keys[wParam] = FALSE; // If So, Mark It As FALSE
return 0; // Jump Back
}
case WM_SIZE: // Resize The OpenGL Window
{
windowWidth = LOWORD(lParam);
windowHeight = HIWORD(lParam);
ReSizeGLScene(windowWidth, windowHeight); // LoWord=Width, HiWord=Height
return 0; // Jump Back
}
}
// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}

View File

@ -0,0 +1,571 @@
/*
Real-time DXT1 & YCoCg DXT5 compression (Cg 2.0)
Copyright (c) NVIDIA Corporation.
Written by: Ignacio Castano <icastano@nvidia.com>
Thanks to JMP van Waveren, Simon Green, Eric Werness, Simon Brown
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
const char* pDXTCompressorShaderSource =
" \n"
"// vertex program \n"
"void compress_vp(float4 pos : POSITION, \n"
" float2 texcoord : TEXCOORD0, \n"
" out float4 hpos : POSITION, \n"
" out float2 o_texcoord : TEXCOORD0 \n"
" ) \n"
"{ \n"
" o_texcoord = texcoord; \n"
" hpos = pos; \n"
"} \n"
" \n"
"typedef unsigned int uint; \n"
"typedef unsigned int2 uint2; \n"
"typedef unsigned int3 uint3; \n"
"typedef unsigned int4 uint4; \n"
" \n"
"const float offset = 128.0 / 255.0; \n"
" \n"
"// Use dot product to minimize RMS instead absolute distance like in the CPU compressor. \n"
"float colorDistance(float3 c0, float3 c1) \n"
"{ \n"
" return dot(c0-c1, c0-c1); \n"
"} \n"
"float colorDistance(float2 c0, float2 c1) \n"
"{ \n"
" return dot(c0-c1, c0-c1); \n"
"} \n"
" \n"
" \n"
"void ExtractColorBlockRGB(out float3 col[16], sampler2D image, float2 texcoord, float2 imageSize) \n"
"{ \n"
" // use TXF instruction (integer coordinates with offset) \n"
" // note offsets must be constant \n"
" //int4 base = int4(wpos*4-2, 0, 0); \n"
" int4 base = int4(texcoord * imageSize - 1.5, 0, 0); \n"
" col[0] = tex2Dfetch(image, base, int2(0, 0)).rgb; \n"
" col[1] = tex2Dfetch(image, base, int2(1, 0)).rgb; \n"
" col[2] = tex2Dfetch(image, base, int2(2, 0)).rgb; \n"
" col[3] = tex2Dfetch(image, base, int2(3, 0)).rgb; \n"
" col[4] = tex2Dfetch(image, base, int2(0, 1)).rgb; \n"
" col[5] = tex2Dfetch(image, base, int2(1, 1)).rgb; \n"
" col[6] = tex2Dfetch(image, base, int2(2, 1)).rgb; \n"
" col[7] = tex2Dfetch(image, base, int2(3, 1)).rgb; \n"
" col[8] = tex2Dfetch(image, base, int2(0, 2)).rgb; \n"
" col[9] = tex2Dfetch(image, base, int2(1, 2)).rgb; \n"
" col[10] = tex2Dfetch(image, base, int2(2, 2)).rgb; \n"
" col[11] = tex2Dfetch(image, base, int2(3, 2)).rgb; \n"
" col[12] = tex2Dfetch(image, base, int2(0, 3)).rgb; \n"
" col[13] = tex2Dfetch(image, base, int2(1, 3)).rgb; \n"
" col[14] = tex2Dfetch(image, base, int2(2, 3)).rgb; \n"
" col[15] = tex2Dfetch(image, base, int2(3, 3)).rgb; \n"
"} \n"
" \n"
"void ExtractColorBlockBGR(out float3 col[16], sampler2D image, float2 texcoord, float2 imageSize) \n"
"{ \n"
" // use TXF instruction (integer coordinates with offset) \n"
" // note offsets must be constant \n"
" //int4 base = int4(wpos*4-2, 0, 0); \n"
" int4 base = int4(texcoord * imageSize - 1.5, 0, 0); \n"
" col[0] = tex2Dfetch(image, base, int2(0, 0)).bgr; \n"
" col[1] = tex2Dfetch(image, base, int2(1, 0)).bgr; \n"
" col[2] = tex2Dfetch(image, base, int2(2, 0)).bgr; \n"
" col[3] = tex2Dfetch(image, base, int2(3, 0)).bgr; \n"
" col[4] = tex2Dfetch(image, base, int2(0, 1)).bgr; \n"
" col[5] = tex2Dfetch(image, base, int2(1, 1)).bgr; \n"
" col[6] = tex2Dfetch(image, base, int2(2, 1)).bgr; \n"
" col[7] = tex2Dfetch(image, base, int2(3, 1)).bgr; \n"
" col[8] = tex2Dfetch(image, base, int2(0, 2)).bgr; \n"
" col[9] = tex2Dfetch(image, base, int2(1, 2)).bgr; \n"
" col[10] = tex2Dfetch(image, base, int2(2, 2)).bgr; \n"
" col[11] = tex2Dfetch(image, base, int2(3, 2)).bgr; \n"
" col[12] = tex2Dfetch(image, base, int2(0, 3)).bgr; \n"
" col[13] = tex2Dfetch(image, base, int2(1, 3)).bgr; \n"
" col[14] = tex2Dfetch(image, base, int2(2, 3)).bgr; \n"
" col[15] = tex2Dfetch(image, base, int2(3, 3)).bgr; \n"
"} \n"
" \n"
"float3 toYCoCg(float3 c) \n"
"{ \n"
" float Y = (c.r + 2 * c.g + c.b) * 0.25; \n"
" float Co = ( ( 2 * c.r - 2 * c.b ) * 0.25 + offset ); \n"
" float Cg = ( ( -c.r + 2 * c.g - c.b) * 0.25 + offset ); \n"
" \n"
" return float3(Y, Co, Cg); \n"
"} \n"
" \n"
"void ExtractColorBlockYCoCg_RGB(out float3 col[16], sampler2D image, float2 texcoord, float2 imageSize) \n"
"{ \n"
" // use TXF instruction (integer coordinates with offset) \n"
" // note offsets must be constant \n"
" //int4 base = int4(wpos*4-2, 0, 0); \n"
" int4 base = int4(texcoord * imageSize - 1.5, 0, 0); \n"
" col[0] = toYCoCg(tex2Dfetch(image, base, int2(0, 0)).rgb); \n"
" col[1] = toYCoCg(tex2Dfetch(image, base, int2(1, 0)).rgb); \n"
" col[2] = toYCoCg(tex2Dfetch(image, base, int2(2, 0)).rgb); \n"
" col[3] = toYCoCg(tex2Dfetch(image, base, int2(3, 0)).rgb); \n"
" col[4] = toYCoCg(tex2Dfetch(image, base, int2(0, 1)).rgb); \n"
" col[5] = toYCoCg(tex2Dfetch(image, base, int2(1, 1)).rgb); \n"
" col[6] = toYCoCg(tex2Dfetch(image, base, int2(2, 1)).rgb); \n"
" col[7] = toYCoCg(tex2Dfetch(image, base, int2(3, 1)).rgb); \n"
" col[8] = toYCoCg(tex2Dfetch(image, base, int2(0, 2)).rgb); \n"
" col[9] = toYCoCg(tex2Dfetch(image, base, int2(1, 2)).rgb); \n"
" col[10] = toYCoCg(tex2Dfetch(image, base, int2(2, 2)).rgb); \n"
" col[11] = toYCoCg(tex2Dfetch(image, base, int2(3, 2)).rgb); \n"
" col[12] = toYCoCg(tex2Dfetch(image, base, int2(0, 3)).rgb); \n"
" col[13] = toYCoCg(tex2Dfetch(image, base, int2(1, 3)).rgb); \n"
" col[14] = toYCoCg(tex2Dfetch(image, base, int2(2, 3)).rgb); \n"
" col[15] = toYCoCg(tex2Dfetch(image, base, int2(3, 3)).rgb); \n"
"} \n"
" \n"
"void ExtractColorBlockYCoCg_BGR(out float3 col[16], sampler2D image, float2 texcoord, float2 imageSize) \n"
"{ \n"
" // use TXF instruction (integer coordinates with offset) \n"
" // note offsets must be constant \n"
" //int4 base = int4(wpos*4-2, 0, 0); \n"
" int4 base = int4(texcoord * imageSize - 1.5, 0, 0); \n"
" col[0] = toYCoCg(tex2Dfetch(image, base, int2(0, 0)).bgr); \n"
" col[1] = toYCoCg(tex2Dfetch(image, base, int2(1, 0)).bgr); \n"
" col[2] = toYCoCg(tex2Dfetch(image, base, int2(2, 0)).bgr); \n"
" col[3] = toYCoCg(tex2Dfetch(image, base, int2(3, 0)).bgr); \n"
" col[4] = toYCoCg(tex2Dfetch(image, base, int2(0, 1)).bgr); \n"
" col[5] = toYCoCg(tex2Dfetch(image, base, int2(1, 1)).bgr); \n"
" col[6] = toYCoCg(tex2Dfetch(image, base, int2(2, 1)).bgr); \n"
" col[7] = toYCoCg(tex2Dfetch(image, base, int2(3, 1)).bgr); \n"
" col[8] = toYCoCg(tex2Dfetch(image, base, int2(0, 2)).bgr); \n"
" col[9] = toYCoCg(tex2Dfetch(image, base, int2(1, 2)).bgr); \n"
" col[10] = toYCoCg(tex2Dfetch(image, base, int2(2, 2)).bgr); \n"
" col[11] = toYCoCg(tex2Dfetch(image, base, int2(3, 2)).bgr); \n"
" col[12] = toYCoCg(tex2Dfetch(image, base, int2(0, 3)).bgr); \n"
" col[13] = toYCoCg(tex2Dfetch(image, base, int2(1, 3)).bgr); \n"
" col[14] = toYCoCg(tex2Dfetch(image, base, int2(2, 3)).bgr); \n"
" col[15] = toYCoCg(tex2Dfetch(image, base, int2(3, 3)).bgr); \n"
"} \n"
" \n"
"// find minimum and maximum colors based on bounding box in color space \n"
"void FindMinMaxColorsBox(float3 block[16], out float3 mincol, out float3 maxcol) \n"
"{ \n"
" mincol = block[0]; \n"
" maxcol = block[0]; \n"
" \n"
" for (int i = 1; i < 16; i++) { \n"
" mincol = min(mincol, block[i]); \n"
" maxcol = max(maxcol, block[i]); \n"
" } \n"
"} \n"
" \n"
"void InsetBBox(in out float3 mincol, in out float3 maxcol) \n"
"{ \n"
" float3 inset = (maxcol - mincol) / 16.0 - (8.0 / 255.0) / 16; \n"
" mincol = saturate(mincol + inset); \n"
" maxcol = saturate(maxcol - inset); \n"
"} \n"
"void InsetYBBox(in out float mincol, in out float maxcol) \n"
"{ \n"
" float inset = (maxcol - mincol) / 32.0 - (16.0 / 255.0) / 32.0; \n"
" mincol = saturate(mincol + inset); \n"
" maxcol = saturate(maxcol - inset); \n"
"} \n"
"void InsetCoCgBBox(in out float2 mincol, in out float2 maxcol) \n"
"{ \n"
" float2 inset = (maxcol - mincol) / 16.0 - (8.0 / 255.0) / 16; \n"
" mincol = saturate(mincol + inset); \n"
" maxcol = saturate(maxcol - inset); \n"
"} \n"
" \n"
"void SelectDiagonal(float3 block[16], in out float3 mincol, in out float3 maxcol) \n"
"{ \n"
" float3 center = (mincol + maxcol) * 0.5; \n"
" \n"
" float2 cov = 0; \n"
" for (int i = 0; i < 16; i++) \n"
" { \n"
" float3 t = block[i] - center; \n"
" cov.x += t.x * t.z; \n"
" cov.y += t.y * t.z; \n"
" } \n"
" \n"
" if (cov.x < 0) { \n"
" float temp = maxcol.x; \n"
" maxcol.x = mincol.x; \n"
" mincol.x = temp; \n"
" } \n"
" if (cov.y < 0) { \n"
" float temp = maxcol.y; \n"
" maxcol.y = mincol.y; \n"
" mincol.y = temp; \n"
" } \n"
"} \n"
" \n"
"float3 RoundAndExpand(float3 v, out uint w) \n"
"{ \n"
" int3 c = round(v * float3(31, 63, 31)); \n"
" w = (c.r << 11) | (c.g << 5) | c.b; \n"
" \n"
" c.rb = (c.rb << 3) | (c.rb >> 2); \n"
" c.g = (c.g << 2) | (c.g >> 4); \n"
" \n"
" return (float3)c * (1.0 / 255.0); \n"
"} \n"
" \n"
"uint EmitEndPointsDXT1(in out float3 mincol, in out float3 maxcol) \n"
"{ \n"
" uint2 output; \n"
" maxcol = RoundAndExpand(maxcol, output.x); \n"
" mincol = RoundAndExpand(mincol, output.y); \n"
" \n"
" // We have to do this in case we select an alternate diagonal. \n"
" if (output.x < output.y) \n"
" { \n"
" float3 tmp = mincol; \n"
" mincol = maxcol; \n"
" maxcol = tmp; \n"
" return output.y | (output.x << 16); \n"
" } \n"
" \n"
" return output.x | (output.y << 16); \n"
"} \n"
" \n"
"uint EmitIndicesDXT1(float3 block[16], float3 mincol, float3 maxcol) \n"
"{ \n"
" const float RGB_RANGE = 3; \n"
" \n"
" float3 dir = (maxcol - mincol); \n"
" float3 origin = maxcol + dir / (2.0 * RGB_RANGE); \n"
" dir /= dot(dir, dir); \n"
" \n"
" // Compute indices \n"
" uint indices = 0; \n"
" for (int i = 0; i < 16; i++) \n"
" { \n"
" uint index = saturate(dot(origin - block[i], dir)) * RGB_RANGE; \n"
" indices |= index << (i * 2); \n"
" } \n"
" \n"
" uint i0 = (indices & 0x55555555); \n"
" uint i1 = (indices & 0xAAAAAAAA) >> 1; \n"
" indices = ((i0 ^ i1) << 1) | i1; \n"
" \n"
" // Output indices \n"
" return indices; \n"
"} \n"
" \n"
"int ScaleYCoCg(float2 minColor, float2 maxColor) \n"
"{ \n"
" float2 m0 = abs(minColor - offset); \n"
" float2 m1 = abs(maxColor - offset); \n"
" \n"
" float m = max(max(m0.x, m0.y), max(m1.x, m1.y)); \n"
" \n"
" const float s0 = 64.0 / 255.0; \n"
" const float s1 = 32.0 / 255.0; \n"
" \n"
" int scale = 1; \n"
" if (m < s0) scale = 2; \n"
" if (m < s1) scale = 4; \n"
" \n"
" return scale; \n"
"} \n"
" \n"
"void SelectYCoCgDiagonal(const float3 block[16], in out float2 minColor, in out float2 maxColor) \n"
"{ \n"
" float2 mid = (maxColor + minColor) * 0.5; \n"
" \n"
" float cov = 0; \n"
" for (int i = 0; i < 16; i++) \n"
" { \n"
" float2 t = block[i].yz - mid; \n"
" cov += t.x * t.y; \n"
" } \n"
" if (cov < 0) { \n"
" float tmp = maxColor.y; \n"
" maxColor.y = minColor.y; \n"
" minColor.y = tmp; \n"
" } \n"
"} \n"
" \n"
" \n"
"uint EmitEndPointsYCoCgDXT5(in out float2 mincol, in out float2 maxcol, int scale) \n"
"{ \n"
" maxcol = (maxcol - offset) * scale + offset; \n"
" mincol = (mincol - offset) * scale + offset; \n"
" \n"
" InsetCoCgBBox(mincol, maxcol); \n"
" \n"
" maxcol = round(maxcol * float2(31, 63)); \n"
" mincol = round(mincol * float2(31, 63)); \n"
" \n"
" int2 imaxcol = maxcol; \n"
" int2 imincol = mincol; \n"
" \n"
" uint2 output; \n"
" output.x = (imaxcol.r << 11) | (imaxcol.g << 5) | (scale - 1); \n"
" output.y = (imincol.r << 11) | (imincol.g << 5) | (scale - 1); \n"
" \n"
" imaxcol.r = (imaxcol.r << 3) | (imaxcol.r >> 2); \n"
" imaxcol.g = (imaxcol.g << 2) | (imaxcol.g >> 4); \n"
" imincol.r = (imincol.r << 3) | (imincol.r >> 2); \n"
" imincol.g = (imincol.g << 2) | (imincol.g >> 4); \n"
" \n"
" maxcol = (float2)imaxcol * (1.0 / 255.0); \n"
" mincol = (float2)imincol * (1.0 / 255.0); \n"
" \n"
" // Undo rescale. \n"
" maxcol = (maxcol - offset) / scale + offset; \n"
" mincol = (mincol - offset) / scale + offset; \n"
" \n"
" return output.x | (output.y << 16); \n"
"} \n"
" \n"
"uint EmitIndicesYCoCgDXT5(float3 block[16], float2 mincol, float2 maxcol) \n"
"{ \n"
" const float COCG_RANGE = 3; \n"
" \n"
" float2 dir = (maxcol - mincol); \n"
" float2 origin = maxcol + dir / (2.0 * COCG_RANGE); \n"
" dir /= dot(dir, dir); \n"
" \n"
" // Compute indices \n"
" uint indices = 0; \n"
" for (int i = 0; i < 16; i++) \n"
" { \n"
" uint index = saturate(dot(origin - block[i].yz, dir)) * COCG_RANGE; \n"
" indices |= index << (i * 2); \n"
" } \n"
" \n"
" uint i0 = (indices & 0x55555555); \n"
" uint i1 = (indices & 0xAAAAAAAA) >> 1; \n"
" indices = ((i0 ^ i1) << 1) | i1; \n"
" \n"
" // Output indices \n"
" return indices; \n"
"} \n"
" \n"
"uint EmitAlphaEndPointsYCoCgDXT5(float mincol, float maxcol) \n"
"{ \n"
" uint c0 = round(mincol * 255); \n"
" uint c1 = round(maxcol * 255); \n"
" \n"
" return (c0 << 8) | c1; \n"
"} \n"
" \n"
"// Optimized index selection. \n"
"uint2 EmitAlphaIndicesYCoCgDXT5(float3 block[16], float minAlpha, float maxAlpha) \n"
"{ \n"
" const int ALPHA_RANGE = 7; \n"
" \n"
" float bias = maxAlpha + (maxAlpha - minAlpha) / (2.0 * ALPHA_RANGE); \n"
" float scale = 1.0f / (maxAlpha - minAlpha); \n"
" \n"
" uint2 indices = 0; \n"
" \n"
" for (int i = 0; i < 6; i++) \n"
" { \n"
" uint index = saturate((bias - block[i].x) * scale) * ALPHA_RANGE; \n"
" indices.x |= index << (3 * i); \n"
" } \n"
" \n"
" for (int i = 6; i < 16; i++) \n"
" { \n"
" uint index = saturate((bias - block[i].x) * scale) * ALPHA_RANGE; \n"
" indices.y |= index << (3 * i - 18); \n"
" } \n"
" \n"
" uint2 i0 = (indices >> 0) & 0x09249249; \n"
" uint2 i1 = (indices >> 1) & 0x09249249; \n"
" uint2 i2 = (indices >> 2) & 0x09249249; \n"
" \n"
" i2 ^= i0 & i1; \n"
" i1 ^= i0; \n"
" i0 ^= (i1 | i2); \n"
" \n"
" indices.x = (i2.x << 2) | (i1.x << 1) | i0.x; \n"
" indices.y = (((i2.y << 2) | (i1.y << 1) | i0.y) << 2) | (indices.x >> 16); \n"
" indices.x <<= 16; \n"
" \n"
" return indices; \n"
"} \n"
" \n"
"// compress a 4x4 block to DXT1 format \n"
"// integer version, renders to 2 x int32 buffer \n"
"uint4 compress_DXT1_RGBA_fp(float2 texcoord : TEXCOORD0, \n"
" uniform sampler2D image, \n"
" uniform float2 imageSize = { 512.0, 512.0 } \n"
" ) : COLOR \n"
"{ \n"
" // read block \n"
" float3 block[16]; \n"
" ExtractColorBlockRGB(block, image, texcoord, imageSize); \n"
" \n"
" // find min and max colors \n"
" float3 mincol, maxcol; \n"
" FindMinMaxColorsBox(block, mincol, maxcol); \n"
" \n"
" SelectDiagonal(block, mincol, maxcol); \n"
" \n"
" InsetBBox(mincol, maxcol); \n"
" \n"
" uint4 output; \n"
" output.x = EmitEndPointsDXT1(mincol, maxcol); \n"
" output.w = EmitIndicesDXT1(block, mincol, maxcol); \n"
" \n"
" return output; \n"
"} \n"
" \n"
"uint4 compress_DXT1_BGRA_fp(float2 texcoord : TEXCOORD0, \n"
" uniform sampler2D image, \n"
" uniform float2 imageSize = { 512.0, 512.0 } \n"
" ) : COLOR \n"
"{ \n"
" // read block \n"
" float3 block[16]; \n"
" ExtractColorBlockBGR(block, image, texcoord, imageSize); \n"
" \n"
" // find min and max colors \n"
" float3 mincol, maxcol; \n"
" FindMinMaxColorsBox(block, mincol, maxcol); \n"
" \n"
" SelectDiagonal(block, mincol, maxcol); \n"
" \n"
" InsetBBox(mincol, maxcol); \n"
" \n"
" uint4 output; \n"
" output.x = EmitEndPointsDXT1(mincol, maxcol); \n"
" output.w = EmitIndicesDXT1(block, mincol, maxcol); \n"
" \n"
" return output; \n"
"} \n"
" \n"
" \n"
"// compress a 4x4 block to YCoCg DXT5 format \n"
"// integer version, renders to 4 x int32 buffer \n"
"uint4 compress_YCoCgDXT5_RGBA_fp(float2 texcoord : TEXCOORD0, \n"
" uniform sampler2D image, \n"
" uniform float2 imageSize = { 512.0, 512.0 } \n"
" ) : COLOR \n"
"{ \n"
" //imageSize = tex2Dsize(image, texcoord); \n"
" \n"
" // read block \n"
" float3 block[16]; \n"
" ExtractColorBlockYCoCg_RGB(block, image, texcoord, imageSize); \n"
" \n"
" // find min and max colors \n"
" float3 mincol, maxcol; \n"
" FindMinMaxColorsBox(block, mincol, maxcol); \n"
" \n"
" SelectYCoCgDiagonal(block, mincol.yz, maxcol.yz); \n"
" \n"
" int scale = ScaleYCoCg(mincol.yz, maxcol.yz); \n"
" \n"
" // Output CoCg in DXT1 block. \n"
" uint4 output; \n"
" output.z = EmitEndPointsYCoCgDXT5(mincol.yz, maxcol.yz, scale); \n"
" output.w = EmitIndicesYCoCgDXT5(block, mincol.yz, maxcol.yz); \n"
" \n"
" InsetYBBox(mincol.x, maxcol.x); \n"
" \n"
" // Output Y in DXT5 alpha block. \n"
" output.x = EmitAlphaEndPointsYCoCgDXT5(mincol.x, maxcol.x); \n"
" \n"
" uint2 indices = EmitAlphaIndicesYCoCgDXT5(block, mincol.x, maxcol.x); \n"
" output.x |= indices.x; \n"
" output.y = indices.y; \n"
" \n"
" return output; \n"
"} \n"
" \n"
"uint4 compress_YCoCgDXT5_BGRA_fp(float2 texcoord : TEXCOORD0, \n"
" uniform sampler2D image, \n"
" uniform float2 imageSize = { 512.0, 512.0 } \n"
" ) : COLOR \n"
"{ \n"
" //imageSize = tex2Dsize(image, texcoord); \n"
" \n"
" // read block \n"
" float3 block[16]; \n"
" ExtractColorBlockYCoCg_BGR(block, image, texcoord, imageSize); \n"
" \n"
" // find min and max colors \n"
" float3 mincol, maxcol; \n"
" FindMinMaxColorsBox(block, mincol, maxcol); \n"
" \n"
" SelectYCoCgDiagonal(block, mincol.yz, maxcol.yz); \n"
" \n"
" int scale = ScaleYCoCg(mincol.yz, maxcol.yz); \n"
" \n"
" // Output CoCg in DXT1 block. \n"
" uint4 output; \n"
" output.z = EmitEndPointsYCoCgDXT5(mincol.yz, maxcol.yz, scale); \n"
" output.w = EmitIndicesYCoCgDXT5(block, mincol.yz, maxcol.yz); \n"
" \n"
" InsetYBBox(mincol.x, maxcol.x); \n"
" \n"
" // Output Y in DXT5 alpha block. \n"
" output.x = EmitAlphaEndPointsYCoCgDXT5(mincol.x, maxcol.x); \n"
" \n"
" uint2 indices = EmitAlphaIndicesYCoCgDXT5(block, mincol.x, maxcol.x); \n"
" output.x |= indices.x; \n"
" output.y = indices.y; \n"
" \n"
" return output; \n"
"} \n"
" \n"
"uniform bool reconstructColor = false; \n"
"uniform bool displayError = false; \n"
"uniform float errorScale = 4.0f; \n"
" \n"
"uniform sampler2D image : TEXUNIT0; \n"
"uniform sampler2D originalImage : TEXUNIT1; \n"
" \n"
"float4 display_fp(float2 texcoord : TEXCOORD0) : COLOR \n"
"{ \n"
" float4 rgba = tex2D(image, texcoord); \n"
" \n"
" if (reconstructColor) \n"
" { \n"
" float Y = rgba.a; \n"
" float scale = 1.0 / ((255.0 / 8.0) * rgba.b + 1); \n"
" float Co = (rgba.r - offset) * scale; \n"
" float Cg = (rgba.g - offset) * scale; \n"
" \n"
" float R = Y + Co - Cg; \n"
" float G = Y + Cg; \n"
" float B = Y - Co - Cg; \n"
" \n"
" rgba = float4(R, G, B, 1); \n"
" } \n"
" \n"
" if (displayError) \n"
" { \n"
" float3 originalColor = tex2D(originalImage, texcoord).rgb; \n"
" float3 diff = abs(rgba.rgb - originalColor) * errorScale; \n"
" return float4(diff, 1); \n"
" } \n"
" else \n"
" { \n"
" return rgba; \n"
" } \n"
"} \n"
" \n";

View File

@ -0,0 +1,194 @@
/*
* This file was taken from RakNet 4.082 without any modifications.
* Please see licenses/RakNet license.txt for the underlying license and related copyright.
*/
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include "DXTCompressor.h"
/* ------------------------------------------------------------------------------------------------------------------------------------ */
bool LoadTGAFromFile( const char* pFilename, void **image, int* width, int* height )
{
typedef struct
{
char identsize;
char colourmaptype;
char imagetype;
unsigned short colourmapstart;
unsigned short colourmaplength;
char colourmapbits;
unsigned short xstart;
unsigned short ystart;
unsigned short width;
unsigned short height;
char bits;
char descriptor;
} TGA_HEADER;
// Open the file
FILE* pic;
if((pic=fopen( pFilename, "rb"))==NULL )
{
return false;
}
// Zero out the header
TGA_HEADER TGAheader;
memset(&TGAheader,0,sizeof(TGA_HEADER));
// Read the header
fread(&TGAheader.identsize,sizeof(char),1,pic);
fread(&TGAheader.colourmaptype,sizeof(char),1,pic);
fread(&TGAheader.imagetype,sizeof(char),1,pic);
fread(&TGAheader.colourmapstart,sizeof(unsigned short),1,pic);
fread(&TGAheader.colourmaplength,sizeof(unsigned short),1,pic);
fread(&TGAheader.colourmapbits,sizeof(char),1,pic);
fread(&TGAheader.xstart,sizeof(unsigned short),1,pic);
fread(&TGAheader.ystart,sizeof(unsigned short),1,pic);
fread(&TGAheader.width,sizeof(unsigned short),1,pic);
fread(&TGAheader.height,sizeof(unsigned short),1,pic);
fread(&TGAheader.bits,sizeof(char),1,pic);
fread(&TGAheader.descriptor,sizeof(char),1,pic);
*width = TGAheader.width;
*height = TGAheader.height;
int DataSize = TGAheader.width*TGAheader.height*4;
// Read the pixels
*image = new char[DataSize];
if ((TGAheader.descriptor>>5) & 1)
{
// Right side up
fread(*image, sizeof(char),DataSize, pic);
}
else
{
//Upside down
for (int row=TGAheader.height-1; row >=0; row--)
{
fread(((char*) (*image))+row*TGAheader.width*TGAheader.bits/8, TGAheader.bits/8, TGAheader.width, pic);
}
}
// Close the file
fclose(pic);
// TGA is stored on disk BGRA
// Endian swap bits so that the image is actually in RGBA format
if( TGAheader.bits == 32 )
{
unsigned char* pRunner = (unsigned char*)*image;
for( int i = 0; i < DataSize; i+=4 )
{
char color[4] =
{
pRunner[ 0 ],
pRunner[ 1 ],
pRunner[ 2 ],
pRunner[ 3 ],
};
pRunner[ 0 ] = color[ 2 ];
pRunner[ 1 ] = color[ 1 ];
pRunner[ 2 ] = color[ 0 ];
pRunner[ 3 ] = color[ 3 ];
pRunner += 4;
}
}
return true;
}
/* ------------------------------------------------------------------------------------------------------------------------------------ */
int main( int argc, const char* argv[] )
{
// Initialize the compressor
DXTCompressor::Initialize();
// Load sample .tga
void* pSourceData;
int w, h;
//bool bFileLoaded = LoadTGAFromFile( "1600x1200.tga", &pSourceData, &w, &h );
bool bFileLoaded = LoadTGAFromFile( "320x200.tga", &pSourceData, &w, &h );
if( bFileLoaded )
{
// Test performance
// const int numIterations = 100;
// for( int i = 0; i < numIterations; i++ )
// {
// // Compress the data
// void* pOutputData;
// int outputLength;
// bool bCompressSuccess = DXTCompressor::CompressRGBAImageData( DXT1, pSourceData, w, h, &pOutputData, &outputLength, false );
//
// // Clean up
// delete [] pOutputData;
// pOutputData = NULL;
// }
// Print total stats
// printf( "\n\n****Total stats on %d iterations****\n", numIterations );
// DXTCompressor::PrintPerformanceLog();
// Now test saving to DDS memory file
{
// Compress the data
// void* pCompressedOutput;
// int compressedOutputLength;
// bool bCompressSuccess = DXTCompressor::CompressRGBAImageData( DXT1, pSourceData, w, h, &pCompressedOutput, &compressedOutputLength, false );
char *outputData;
int bufferSize = DXTCompressor::GetBufferSize(DXT1,
w,
h);
int ddsHeaderSize = DXTCompressor::GetDDSHeaderSize();
outputData = (char*) malloc(bufferSize + ddsHeaderSize );
bool bCompressSuccess = DXTCompressor::CompressRGBAImageData(
DXT1,
pSourceData,
w,
h,
outputData+ddsHeaderSize, false );
if( bCompressSuccess )
{
// Save DDS file
// void* pOutputDDSFile;
// int outputDDSFileLength;
// DXTCompressor::WriteDDSMemoryFile( DXT1, w, h, pCompressedOutput, compressedOutputLength, &pOutputDDSFile, &outputDDSFileLength );
// Clean up
// delete [] pCompressedOutput;
// pCompressedOutput = NULL;
// delete [] pOutputDDSFile;
// pOutputDDSFile = NULL;
DXTCompressor::WriteDDSHeader(DXT1,
w,
h,
bufferSize,
outputData);
FILE *fp = fopen("DXTCompressorTGAtoDDS.dds", "wb");
fwrite(outputData,1,bufferSize + ddsHeaderSize,fp);
fclose(fp);
free(outputData);
}
}
}
// Shutdown the compressor
DXTCompressor::Shutdown();
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.