Glitch64: Add raw code to project

This commit is contained in:
zilmar 2013-04-10 17:08:48 +10:00
parent b999946d15
commit 4d45d46270
38 changed files with 18785 additions and 0 deletions

View File

@ -0,0 +1,89 @@
#define grAADrawTriangle _grAADrawTriangle
#define grAlphaBlendFunction _grAlphaBlendFunction
#define grAlphaCombine _grAlphaCombine
#define grAlphaControlsITRGBLighting _grAlphaControlsITRGBLighting
#define grAlphaTestFunction _grAlphaTestFunction
#define grAlphaTestReferenceValue _grAlphaTestReferenceValue
#define grBufferClear _grBufferClear
#define grBufferSwap _grBufferSwap
#define grChromakeyMode _grChromakeyMode
#define grChromakeyValue _grChromakeyValue
#define grClipWindow _grClipWindow
#define grColorCombine _grColorCombine
#define grColorMask _grColorMask
#define grConstantColorValue _grConstantColorValue
#define grCoordinateSpace _grCoordinateSpace
#define grCullMode _grCullMode
#define grDepthBiasLevel _grDepthBiasLevel
#define grDepthBufferFunction _grDepthBufferFunction
#define grDepthBufferMode _grDepthBufferMode
#define grDepthMask _grDepthMask
#define grDepthRange _grDepthRange
#define grDisable _grDisable
#define grDisableAllEffects _grDisableAllEffects
#define grDitherMode _grDitherMode
#define grDrawLine _grDrawLine
#define grDrawPoint _grDrawPoint
#define grDrawTriangle _grDrawTriangle
#define grDrawVertexArray _grDrawVertexArray
#define grDrawVertexArrayContiguous _grDrawVertexArrayContiguous
#define grEnable _grEnable
#define grErrorSetCallback _grErrorSetCallback
#define grFinish _grFinish
#define grFlush _grFlush
#define grFogColorValue _grFogColorValue
#define grFogMode _grFogMode
#define grFogTable _grFogTable
#define grGet _grGet
#define grGetProcAddress _grGetProcAddress
#define grGetString _grGetString
#define grGlideGetState _grGlideGetState
#define grGlideGetVertexLayout _grGlideGetVertexLayout
#define grGlideInit _grGlideInit
#define grGlideSetState _grGlideSetState
#define grGlideSetVertexLayout _grGlideSetVertexLayout
#define grGlideShutdown _grGlideShutdown
#define grLfbConstantAlpha _grLfbConstantAlpha
#define grLfbConstantDepth _grLfbConstantDepth
#define grLfbLock _grLfbLock
#define grLfbReadRegion _grLfbReadRegion
#define grLfbUnlock _grLfbUnlock
#define grLfbWriteColorFormat _grLfbWriteColorFormat
#define grLfbWriteColorSwizzle _grLfbWriteColorSwizzle
#define grLfbWriteRegion _grLfbWriteRegion
#define grLoadGammaTable _grLoadGammaTable
#define grQueryResolutions _grQueryResolutions
#define grRenderBuffer _grRenderBuffer
#define grReset _grReset
#define grSelectContext _grSelectContext
#define grSplash _grSplash
#define grSstOrigin _grSstOrigin
#define grSstSelect _grSstSelect
#define grSstWinClose _grSstWinClose
#define grSstWinOpen _grSstWinOpen
#define grStippleMode _grStippleMode
#define grStipplePattern _grStipplePattern
#define grTexCalcMemRequired _grTexCalcMemRequired
#define grTexClampMode _grTexClampMode
#define grTexCombine _grTexCombine
#define grTexDetailControl _grTexDetailControl
#define grTexDownloadMipMap _grTexDownloadMipMap
#define grTexDownloadMipMapLevel _grTexDownloadMipMapLevel
#define grTexDownloadMipMapLevelPartial _grTexDownloadMipMapLevelPartial
#define grTexDownloadTable _grTexDownloadTable
#define grTexDownloadTablePartial _grTexDownloadTablePartial
#define grTexFilterMode _grTexFilterMode
#define grTexLodBiasValue _grTexLodBiasValue
#define grTexMaxAddress _grTexMaxAddress
#define grTexMinAddress _grTexMinAddress
#define grTexMipMapMode _grTexMipMapMode
#define grTexMultibase _grTexMultibase
#define grTexMultibaseAddress _grTexMultibaseAddress
#define grTexNCCTable _grTexNCCTable
#define grTexSource _grTexSource
#define grTexTextureMemRequired _grTexTextureMemRequired
#define grVertexLayout _grVertexLayout
#define grViewport _grViewport
#define guFogGenerateLinear _guFogGenerateLinear
#define guFogTableIndexToW _guFogTableIndexToW
#define guGammaCorrectionRGB _guGammaCorrectionRGB

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="Glitch64" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin\Glitch64" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Debug\" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-DBUILD_DLL" />
<Add directory="..\inc" />
</Compiler>
<Linker>
<Add library="user32" />
<Add directory="..\lib" />
</Linker>
</Target>
<Target title="Release">
<Option output="bin\Glitch64" prefix_auto="1" extension_auto="1" />
<Option object_output="obj\Release\" />
<Option type="3" />
<Option compiler="gcc" />
<Option createDefFile="1" />
<Option createStaticLib="1" />
<Compiler>
<Add option="-O2" />
<Add option="-Wall" />
<Add option="-DBUILD_DLL" />
<Add option="-DGLIDE3X_EXPORTS" />
</Compiler>
<Linker>
<Add option="-s" />
<Add library="user32" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-DWIN32" />
<Add option="-DWINDOWS" />
<Add option="-D_USRDLL" />
<Add option="-DGLIDEXPORT" />
<Add directory="..\inc" />
</Compiler>
<Linker>
<Add option="-lopengl32" />
<Add option="-lglu32" />
<Add option="-lgdi32" />
<Add option="-ldxguid" />
<Add option="-lole32" />
<Add option="-loleaut32" />
<Add directory="..\lib" />
</Linker>
<Unit filename="..\3dfx-mangling.h" />
<Unit filename="..\combiner.cpp" />
<Unit filename="..\geometry.cpp" />
<Unit filename="..\main.cpp" />
<Unit filename="..\main.h" />
<Unit filename="..\textures.cpp" />
<Unit filename="..\vram.cpp" />
<Extensions>
<code_completion />
<envvars />
<debugger />
</Extensions>
</Project>
</CodeBlocks_project_file>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -0,0 +1,10 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

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 @@
Manifest resource last updated at 6:38:20.94 on Fri 05/04/2013

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,256 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="Glitch64"
ProjectGUID="{462C2608-182F-452C-944F-AF201E19300B}"
RootNamespace="glide3x"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Debug/glide3x.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\inc"
PreprocessorDefinitions="_DEBUG;_CRT_SECURE_NO_WARNINGS;WIN32;WINDOWS;_USRDLL;GLIDE3X_EXPORTS;__MSC__"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\Debug/glide3x.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="odbc32.lib odbccp32.lib opengl32.lib glu32.lib"
OutputFile="$(OutDir)\glide3x.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\Debug/glide3x.pdb"
ImportLibrary=".\Debug/glide3x.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/glide3x.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="NDEBUG"
MkTypLibCompatible="true"
SuppressStartupBanner="true"
TargetEnvironment="1"
TypeLibraryName=".\Release/glide3x.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
AdditionalIncludeDirectories="..\inc"
PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS; WIN32;WINDOWS;_USRDLL;GLIDE3X_EXPORTS;__MSC__"
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\Release/glide3x.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1036"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="opengl32.lib glu32.lib"
OutputFile="$(OutDir)\glide3x.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\lib"
ProgramDatabaseFile=".\Release/glide3x.pdb"
ImportLibrary=".\Release/glide3x.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Release/glide3x.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Headers"
Filter="*.h"
>
<File
RelativePath="..\3dfx-mangling.h"
>
</File>
<File
RelativePath="..\main.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
Filter="*.cpp"
>
<File
RelativePath="..\combiner.cpp"
>
</File>
<File
RelativePath="..\geometry.cpp"
>
</File>
<File
RelativePath="..\main.cpp"
>
</File>
<File
RelativePath="..\textures.cpp"
>
</File>
<File
RelativePath="..\vram.cpp"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,134 @@
# This MUST be processed by GNU make
#
# Glitch64 Makefile
# Version: 1.0
#
# this is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# this is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GNU Make; see the file COPYING. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# Available options:
#
# Environment variables:
# DEBUG=1 enable debugging checks and messages
# default = no
#
# Environment variables:
#
# Targets:
# all: build dynamic module
# clean: remove object files
# realclean: remove all generated files
#
#
# Requirements:
#
# Compiler:
# GCC 4.2
#
# Libraries:
# SDL 1.2 (http://www.libsdl.org)
#
.PHONY: all clean realclean
OS=$(shell uname)
ifeq ($(findstring MINGW,$(OS)),MINGW)
OS := WINDOWS
endif
ifeq ($(findstring CYGWIN,$(OS)),CYGWIN)
OS=WINDOWS
endif
ifeq ($(findstring WINNT,$(OS)),WINNT)
OS=WINDOWS
endif
ifeq ($(OS),Darwin)
OS=MACOSX
endif
ifeq ($(OS), WINDOWS)
DLLNAME = glide3x.dll
else
ifeq ($(OS), MACOSX)
DLLNAME = glide3x.dylib
else
DLLNAME = glide3x.so
endif
endif
EXT_INC = ./inc
EXT_LIB = ./lib
CC = g++
STRIP = strip
CFLAGS = -DBUILDING_DLL=1 -fexceptions
ifeq ($(OS), Linux)
LDFLAGS = -shared -lstdc++
CFLAGS += -D__unix__
endif
ifeq ($(OS), MACOSX)
LDFLAGS = -dynamiclib -lstdc++
CFLAGS += -D__unix__ -Dmacintosh
endif
ifeq ($(OS), WINDOWS)
LDFLAGS = -shared -mwindows
CFLAGS += -D__WIN32__ -DWIN32 -D_WIN32
endif
CFLAGS += -ffast-math -funroll-loops
CFLAGS += -I. -I$(EXT_INC) `sdl-config --cflags`
ifdef DEBUG
CFLAGS += -g -DDEBUG
endif
LD = g++
LDFLAGS2 = --out-implib=libglide3x.a
LDLIBS = -L"." -L"lib" `sdl-config --libs`
ifeq ($(OS), MACOSX)
LDLIBS += -framework OpenGL -framework GLUT
endif
RM = rm
SOURCES = \
combiner.cpp \
geometry.cpp \
main.cpp \
textures.cpp \
vram.cpp
OBJECTS = $(SOURCES:.cpp=.o)
.cpp.o:
$(CC) -o $@ $(CFLAGS) -c $<
all: $(DLLNAME)
$(DLLNAME): $(OBJECTS)
$(LD) -o $@ $(LDFLAGS) $^ $(LDLIBS) --out-implib=libglide3x.a
ifeq ($(OS), Linux)
$(STRIP) $@
endif
clean:
-$(RM) *.o
realclean: clean
-$(RM) $(DLLNAME)
-include depend

2750
Source/Glitch64/combiner.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,720 @@
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#endif // _WIN32
#include "glide.h"
#include "main.h"
#define Z_MAX (65536.0f)
static int xy_off;
static int xy_en;
static int z_en;
static int z_off;
static int q_off;
static int q_en;
static int pargb_off;
static int pargb_en;
static int st0_off;
static int st0_en;
static int st1_off;
static int st1_en;
static int fog_ext_off;
static int fog_ext_en;
int w_buffer_mode;
int inverted_culling;
int culling_mode;
inline float ZCALC(const float & z, const float & q) {
float res = z_en ? ((z) / Z_MAX) / (q) : 1.0f;
return res;
}
#define zclamp (1.0f-1.0f/zscale)
static inline void zclamp_glVertex4f(float a, float b, float c, float d)
{
if (c<zclamp) c = zclamp;
glVertex4f(a,b,c,d);
}
#define glVertex4f(a,b,c,d) zclamp_glVertex4f(a,b,c,d)
static inline float ytex(int tmu, float y) {
if (invtex[tmu])
return invtex[tmu] - y;
else
return y;
}
void init_geometry()
{
xy_en = q_en = pargb_en = st0_en = st1_en = z_en = 0;
w_buffer_mode = 0;
inverted_culling = 0;
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
}
FX_ENTRY void FX_CALL
grCoordinateSpace( GrCoordinateSpaceMode_t mode )
{
LOG("grCoordinateSpace(%d)\r\n", mode);
switch(mode)
{
case GR_WINDOW_COORDS:
break;
default:
display_warning("unknwown coordinate space : %x", mode);
}
}
FX_ENTRY void FX_CALL
grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
{
LOG("grVertexLayout(%d,%d,%d)\r\n", param, offset, mode);
switch(param)
{
case GR_PARAM_XY:
xy_en = mode;
xy_off = offset;
break;
case GR_PARAM_Z:
z_en = mode;
z_off = offset;
break;
case GR_PARAM_Q:
q_en = mode;
q_off = offset;
break;
case GR_PARAM_FOG_EXT:
fog_ext_en = mode;
fog_ext_off = offset;
break;
case GR_PARAM_PARGB:
pargb_en = mode;
pargb_off = offset;
break;
case GR_PARAM_ST0:
st0_en = mode;
st0_off = offset;
break;
case GR_PARAM_ST1:
st1_en = mode;
st1_off = offset;
break;
default:
display_warning("unknown grVertexLayout parameter : %x", param);
}
}
FX_ENTRY void FX_CALL
grCullMode( GrCullMode_t mode )
{
LOG("grCullMode(%d)\r\n", mode);
static int oldmode = -1, oldinv = -1;
culling_mode = mode;
if (inverted_culling == oldinv && oldmode == mode)
return;
oldmode = mode;
oldinv = inverted_culling;
switch(mode)
{
case GR_CULL_DISABLE:
glDisable(GL_CULL_FACE);
break;
case GR_CULL_NEGATIVE:
if (!inverted_culling)
glCullFace(GL_FRONT);
else
glCullFace(GL_BACK);
glEnable(GL_CULL_FACE);
break;
case GR_CULL_POSITIVE:
if (!inverted_culling)
glCullFace(GL_BACK);
else
glCullFace(GL_FRONT);
glEnable(GL_CULL_FACE);
break;
default:
display_warning("unknown cull mode : %x", mode);
}
}
// Depth buffer
FX_ENTRY void FX_CALL
grDepthBufferMode( GrDepthBufferMode_t mode )
{
LOG("grDepthBufferMode(%d)\r\n", mode);
switch(mode)
{
case GR_DEPTHBUFFER_DISABLE:
glDisable(GL_DEPTH_TEST);
w_buffer_mode = 0;
return;
case GR_DEPTHBUFFER_WBUFFER:
case GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS:
glEnable(GL_DEPTH_TEST);
w_buffer_mode = 1;
break;
case GR_DEPTHBUFFER_ZBUFFER:
case GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS:
glEnable(GL_DEPTH_TEST);
w_buffer_mode = 0;
break;
default:
display_warning("unknown depth buffer mode : %x", mode);
}
}
FX_ENTRY void FX_CALL
grDepthBufferFunction( GrCmpFnc_t function )
{
LOG("grDepthBufferFunction(%d)\r\n", function);
switch(function)
{
case GR_CMP_GEQUAL:
if (w_buffer_mode)
glDepthFunc(GL_LEQUAL);
else
glDepthFunc(GL_GEQUAL);
break;
case GR_CMP_LEQUAL:
if (w_buffer_mode)
glDepthFunc(GL_GEQUAL);
else
glDepthFunc(GL_LEQUAL);
break;
case GR_CMP_LESS:
if (w_buffer_mode)
glDepthFunc(GL_GREATER);
else
glDepthFunc(GL_LESS);
break;
case GR_CMP_ALWAYS:
glDepthFunc(GL_ALWAYS);
break;
case GR_CMP_EQUAL:
glDepthFunc(GL_EQUAL);
break;
case GR_CMP_GREATER:
if (w_buffer_mode)
glDepthFunc(GL_LESS);
else
glDepthFunc(GL_GREATER);
break;
case GR_CMP_NEVER:
glDepthFunc(GL_NEVER);
break;
case GR_CMP_NOTEQUAL:
glDepthFunc(GL_NOTEQUAL);
break;
default:
display_warning("unknown depth buffer function : %x", function);
}
}
FX_ENTRY void FX_CALL
grDepthMask( FxBool mask )
{
LOG("grDepthMask(%d)\r\n", mask);
glDepthMask(mask);
}
float biasFactor = 0;
void FindBestDepthBias()
{
float f, bestz = 0.25f;
int x;
if (biasFactor) return;
biasFactor = 64.0f; // default value
glPushAttrib(GL_ALL_ATTRIB_BITS);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_ALWAYS);
glEnable(GL_POLYGON_OFFSET_FILL);
glDrawBuffer(GL_BACK);
glReadBuffer(GL_BACK);
glDisable(GL_BLEND);
glDisable(GL_ALPHA_TEST);
glColor4ub(255,255,255,255);
glDepthMask(GL_TRUE);
for (x=0, f=1.0f; f<=65536.0f; x+=4, f*=2.0f) {
float z;
glPolygonOffset(0, f);
glBegin(GL_TRIANGLE_STRIP);
glVertex3f(float(x+4 - widtho)/(width/2), float(0 - heighto)/(height/2), 0.5);
glVertex3f(float(x - widtho)/(width/2), float(0 - heighto)/(height/2), 0.5);
glVertex3f(float(x+4 - widtho)/(width/2), float(4 - heighto)/(height/2), 0.5);
glVertex3f(float(x - widtho)/(width/2), float(4 - heighto)/(height/2), 0.5);
glEnd();
glReadPixels(x+2, 2+viewport_offset, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
z -= 0.75f + 8e-6f;
if (z<0.0f) z = -z;
if (z > 0.01f) continue;
if (z < bestz) {
bestz = z;
biasFactor = f;
}
//printf("f %g z %g\n", f, z);
}
//printf(" --> bias factor %g\n", biasFactor);
glPopAttrib();
}
FX_ENTRY void FX_CALL
grDepthBiasLevel( FxI32 level )
{
LOG("grDepthBiasLevel(%d)\r\n", level);
if (level)
{
if(w_buffer_mode)
glPolygonOffset(1.0f, -(float)level*zscale/255.0f);
else
glPolygonOffset(0, (float)level*biasFactor);
glEnable(GL_POLYGON_OFFSET_FILL);
}
else
{
glPolygonOffset(0,0);
glDisable(GL_POLYGON_OFFSET_FILL);
}
}
// draw
FX_ENTRY void FX_CALL
grDrawTriangle( const void *a, const void *b, const void *c )
{
float *a_x = (float*)a + xy_off/sizeof(float);
float *a_y = (float*)a + xy_off/sizeof(float) + 1;
float *a_z = (float*)a + z_off/sizeof(float);
float *a_q = (float*)a + q_off/sizeof(float);
unsigned char *a_pargb = (unsigned char*)a + pargb_off;
float *a_s0 = (float*)a + st0_off/sizeof(float);
float *a_t0 = (float*)a + st0_off/sizeof(float) + 1;
float *a_s1 = (float*)a + st1_off/sizeof(float);
float *a_t1 = (float*)a + st1_off/sizeof(float) + 1;
float *a_fog = (float*)a + fog_ext_off/sizeof(float);
float *b_x = (float*)b + xy_off/sizeof(float);
float *b_y = (float*)b + xy_off/sizeof(float) + 1;
float *b_z = (float*)b + z_off/sizeof(float);
float *b_q = (float*)b + q_off/sizeof(float);
unsigned char *b_pargb = (unsigned char*)b + pargb_off;
float *b_s0 = (float*)b + st0_off/sizeof(float);
float *b_t0 = (float*)b + st0_off/sizeof(float) + 1;
float *b_s1 = (float*)b + st1_off/sizeof(float);
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1;
float *b_fog = (float*)b + fog_ext_off/sizeof(float);
float *c_x = (float*)c + xy_off/sizeof(float);
float *c_y = (float*)c + xy_off/sizeof(float) + 1;
float *c_z = (float*)c + z_off/sizeof(float);
float *c_q = (float*)c + q_off/sizeof(float);
unsigned char *c_pargb = (unsigned char*)c + pargb_off;
float *c_s0 = (float*)c + st0_off/sizeof(float);
float *c_t0 = (float*)c + st0_off/sizeof(float) + 1;
float *c_s1 = (float*)c + st1_off/sizeof(float);
float *c_t1 = (float*)c + st1_off/sizeof(float) + 1;
float *c_fog = (float*)c + fog_ext_off/sizeof(float);
LOG("grDrawTriangle()\r\n");
// ugly ? i know but nvidia drivers are losing the viewport otherwise
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
glBegin(GL_TRIANGLES);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *a_s0 / *a_q / (float)tex1_width,
ytex(0, *a_t0 / *a_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *a_s1 / *a_q / (float)tex0_width,
ytex(1, *a_t1 / *a_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*a_s0 / *a_q / (float)tex0_width,
ytex(0, *a_t0 / *a_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(a_pargb[2]/255.0f, a_pargb[1]/255.0f, a_pargb[0]/255.0f, a_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*a_x - (float)widtho) / (float)(width/2) / *a_q,
-(*a_y - (float)heighto) / (float)(height/2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *b_s0 / *b_q / (float)tex1_width,
ytex(0, *b_t0 / *b_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *b_s1 / *b_q / (float)tex0_width,
ytex(1, *b_t1 / *b_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*b_s0 / *b_q / (float)tex0_width,
ytex(0, *b_t0 / *b_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(b_pargb[2]/255.0f, b_pargb[1]/255.0f, b_pargb[0]/255.0f, b_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*b_x - (float)widtho) / (float)(width/2) / *b_q,
-(*b_y - (float)heighto) / (float)(height/2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *c_s0 / *c_q / (float)tex1_width,
ytex(0, *c_t0 / *c_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *c_s1 / *c_q / (float)tex0_width,
ytex(1, *c_t1 / *c_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*c_s0 / *c_q / (float)tex0_width,
ytex(0, *c_t0 / *c_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(c_pargb[2]/255.0f, c_pargb[1]/255.0f, c_pargb[0]/255.0f, c_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *c_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *c_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*c_x - (float)widtho) / (float)(width/2) / *c_q,
-(*c_y - (float)heighto) / (float)(height/2) / *c_q, ZCALC(*c_z ,*c_q), 1.0f / *c_q);
glEnd();
}
FX_ENTRY void FX_CALL
grDrawPoint( const void *pt )
{
float *x = (float*)pt + xy_off/sizeof(float);
float *y = (float*)pt + xy_off/sizeof(float) + 1;
float *z = (float*)pt + z_off/sizeof(float);
float *q = (float*)pt + q_off/sizeof(float);
unsigned char *pargb = (unsigned char*)pt + pargb_off;
float *s0 = (float*)pt + st0_off/sizeof(float);
float *t0 = (float*)pt + st0_off/sizeof(float) + 1;
float *s1 = (float*)pt + st1_off/sizeof(float);
float *t1 = (float*)pt + st1_off/sizeof(float) + 1;
float *fog = (float*)pt + fog_ext_off/sizeof(float);
LOG("grDrawPoint()\r\n");
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
glBegin(GL_POINTS);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
ytex(0, *t0 / *q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
ytex(1, *t1 / *q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*s0 / *q / (float)tex0_width,
ytex(0, *t0 / *q / (float)tex0_height));
}
if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z ,*q), 1.0f / *q);
glEnd();
}
FX_ENTRY void FX_CALL
grDrawLine( const void *a, const void *b )
{
float *a_x = (float*)a + xy_off/sizeof(float);
float *a_y = (float*)a + xy_off/sizeof(float) + 1;
float *a_z = (float*)a + z_off/sizeof(float);
float *a_q = (float*)a + q_off/sizeof(float);
unsigned char *a_pargb = (unsigned char*)a + pargb_off;
float *a_s0 = (float*)a + st0_off/sizeof(float);
float *a_t0 = (float*)a + st0_off/sizeof(float) + 1;
float *a_s1 = (float*)a + st1_off/sizeof(float);
float *a_t1 = (float*)a + st1_off/sizeof(float) + 1;
float *a_fog = (float*)a + fog_ext_off/sizeof(float);
float *b_x = (float*)b + xy_off/sizeof(float);
float *b_y = (float*)b + xy_off/sizeof(float) + 1;
float *b_z = (float*)b + z_off/sizeof(float);
float *b_q = (float*)b + q_off/sizeof(float);
unsigned char *b_pargb = (unsigned char*)b + pargb_off;
float *b_s0 = (float*)b + st0_off/sizeof(float);
float *b_t0 = (float*)b + st0_off/sizeof(float) + 1;
float *b_s1 = (float*)b + st1_off/sizeof(float);
float *b_t1 = (float*)b + st1_off/sizeof(float) + 1;
float *b_fog = (float*)b + fog_ext_off/sizeof(float);
LOG("grDrawLine()\r\n");
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
glBegin(GL_LINES);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *a_s0 / *a_q / (float)tex1_width, ytex(0, *a_t0 / *a_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *a_s1 / *a_q / (float)tex0_width, ytex(1, *a_t1 / *a_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*a_s0 / *a_q / (float)tex0_width, ytex(0, *a_t0 / *a_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(a_pargb[2]/255.0f, a_pargb[1]/255.0f, a_pargb[0]/255.0f, a_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *a_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *a_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*a_x - (float)widtho) / (float)(width/2) / *a_q,
-(*a_y - (float)heighto) / (float)(height/2) / *a_q, ZCALC(*a_z, *a_q), 1.0f / *a_q);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *b_s0 / *b_q / (float)tex1_width,
ytex(0, *b_t0 / *b_q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *b_s1 / *b_q / (float)tex0_width,
ytex(1, *b_t1 / *b_q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*b_s0 / *b_q / (float)tex0_width,
ytex(0, *b_t0 / *b_q / (float)tex0_height));
}
if (pargb_en)
glColor4f(b_pargb[2]/255.0f, b_pargb[1]/255.0f, b_pargb[0]/255.0f, b_pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *b_q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *b_fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*b_x - (float)widtho) / (float)(width/2) / *b_q,
-(*b_y - (float)heighto) / (float)(height/2) / *b_q, ZCALC(*b_z, *b_q), 1.0f / *b_q);
glEnd();
}
FX_ENTRY void FX_CALL
grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers2)
{
unsigned int i;
float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog;
unsigned char *pargb;
void **pointers = (void**)pointers2;
LOG("grDrawVertexArray(%d,%d)\r\n", mode, Count);
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
switch(mode)
{
case GR_TRIANGLE_FAN:
glBegin(GL_TRIANGLE_FAN);
break;
default:
display_warning("grDrawVertexArray : unknown mode : %x", mode);
}
for (i=0; i<Count; i++)
{
x = (float*)pointers[i] + xy_off/sizeof(float);
y = (float*)pointers[i] + xy_off/sizeof(float) + 1;
z = (float*)pointers[i] + z_off/sizeof(float);
q = (float*)pointers[i] + q_off/sizeof(float);
pargb = (unsigned char*)pointers[i] + pargb_off;
s0 = (float*)pointers[i] + st0_off/sizeof(float);
t0 = (float*)pointers[i] + st0_off/sizeof(float) + 1;
s1 = (float*)pointers[i] + st1_off/sizeof(float);
t1 = (float*)pointers[i] + st1_off/sizeof(float) + 1;
fog = (float*)pointers[i] + fog_ext_off/sizeof(float);
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
ytex(0, *t0 / *q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
ytex(1, *t1 / *q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*s0 / *q / (float)tex0_width,
ytex(0, *t0 / *q / (float)tex0_height));
}
if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z, *q), 1.0f / *q);
}
glEnd();
}
FX_ENTRY void FX_CALL
grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 stride)
{
unsigned int i;
float *x, *y, *q, *s0, *t0, *s1, *t1, *z, *fog;
unsigned char *pargb;
LOG("grDrawVertexArrayContiguous(%d,%d,%d)\r\n", mode, Count, stride);
if(nvidia_viewport_hack && !render_to_texture)
{
glViewport(0, viewport_offset, viewport_width, viewport_height);
nvidia_viewport_hack = 0;
}
reloadTexture();
if(need_to_compile) compile_shader();
switch(mode)
{
case GR_TRIANGLE_STRIP:
glBegin(GL_TRIANGLE_STRIP);
break;
case GR_TRIANGLE_FAN:
glBegin(GL_TRIANGLE_FAN);
break;
default:
display_warning("grDrawVertexArrayContiguous : unknown mode : %x", mode);
}
for (i=0; i<Count; i++)
{
x = (float*)((unsigned char*)pointers+stride*i) + xy_off/sizeof(float);
y = (float*)((unsigned char*)pointers+stride*i) + xy_off/sizeof(float) + 1;
z = (float*)((unsigned char*)pointers+stride*i) + z_off/sizeof(float);
q = (float*)((unsigned char*)pointers+stride*i) + q_off/sizeof(float);
pargb = (unsigned char*)pointers+stride*i + pargb_off;
s0 = (float*)((unsigned char*)pointers+stride*i) + st0_off/sizeof(float);
t0 = (float*)((unsigned char*)pointers+stride*i) + st0_off/sizeof(float) + 1;
s1 = (float*)((unsigned char*)pointers+stride*i) + st1_off/sizeof(float);
t1 = (float*)((unsigned char*)pointers+stride*i) + st1_off/sizeof(float) + 1;
fog = (float*)((unsigned char*)pointers+stride*i) + fog_ext_off/sizeof(float);
//if(*fog == 0.0f) *fog = 1.0f;
if (nbTextureUnits > 2)
{
if (st0_en)
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, *s0 / *q / (float)tex1_width,
ytex(0, *t0 / *q / (float)tex1_height));
if (st1_en)
glMultiTexCoord2fARB(GL_TEXTURE0_ARB, *s1 / *q / (float)tex0_width,
ytex(1, *t1 / *q / (float)tex0_height));
}
else
{
if (st0_en)
glTexCoord2f(*s0 / *q / (float)tex0_width,
ytex(0, *t0 / *q / (float)tex0_height));
}
if (pargb_en)
glColor4f(pargb[2]/255.0f, pargb[1]/255.0f, pargb[0]/255.0f, pargb[3]/255.0f);
if (fog_enabled && fog_coord_support)
{
if(!fog_ext_en || fog_enabled != 2)
glSecondaryColor3f((1.0f / *q) / 255.0f, 0.0f, 0.0f);
else
glSecondaryColor3f((1.0f / *fog) / 255.0f, 0.0f, 0.0f);
}
glVertex4f((*x - (float)widtho) / (float)(width/2) / *q,
-(*y - (float)heighto) / (float)(height/2) / *q, ZCALC(*z, *q), 1.0f / *q);
}
glEnd();
}

130
Source/Glitch64/inc/3dfx.h Normal file
View File

@ -0,0 +1,130 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
**
** $Revision: 1.3.4.2 $
** $Date: 2003/05/05 06:50:41 $
*/
#ifndef __3DFX_H__
#define __3DFX_H__
/*
** basic data types
*/
typedef unsigned char FxU8;
typedef signed char FxI8;
typedef unsigned short FxU16;
typedef signed short FxI16;
#if defined(__alpha__) || defined (__LP64__)
typedef signed int FxI32;
typedef unsigned int FxU32;
#else
typedef signed long FxI32;
typedef unsigned long FxU32;
#endif
typedef unsigned long AnyPtr;
typedef int FxBool;
typedef float FxFloat;
typedef double FxDouble;
/*
** color types
*/
typedef unsigned long FxColor_t;
typedef struct { float r, g, b, a; } FxColor4;
/*
** fundamental types
*/
#define FXTRUE 1
#define FXFALSE 0
/*
** helper macros
*/
#define FXUNUSED( a ) ((void)(a))
#define FXBIT( i ) ( 1L << (i) )
/*
** export macros
*/
#if defined(__MSC__) || defined(_MSC_VER)
# if defined (MSVC16)
# define FX_ENTRY
# define FX_CALL
# else
# define FX_ENTRY __declspec(dllexport) extern
# define FX_CALL __stdcall
# endif
#elif defined(__WATCOMC__)
# define FX_ENTRY extern
# define FX_CALL __stdcall
#elif defined (__IBMC__) || defined (__IBMCPP__)
/* IBM Visual Age C/C++: */
# define FX_ENTRY extern
# define FX_CALL __stdcall
#elif defined(__DJGPP__)
# define FX_ENTRY extern
# define FX_CALL
#elif defined(__MINGW32__)
# define FX_ENTRY extern
# define FX_CALL __stdcall
#elif defined(__unix__)
# define FX_ENTRY extern
# define FX_CALL
#elif defined(__MWERKS__)
# if macintosh
# define FX_ENTRY extern
# define FX_CALL
# else /* !macintosh */
# error "Unknown MetroWerks target platform"
# endif /* !macintosh */
#else
# warning define FX_ENTRY & FX_CALL for your compiler
# define FX_ENTRY extern
# define FX_CALL
#endif
/*
** x86 compiler specific stuff
*/
#if defined(__BORLANDC_)
# define REALMODE
# define REGW( a, b ) ((a).x.b)
# define REGB( a, b ) ((a).h.b)
# define INT86( a, b, c ) int86(a,b,c)
# define INT86X( a, b, c, d ) int86x(a,b,c,d)
# define RM_SEG( a ) FP_SEG( a )
# define RM_OFF( a ) FP_OFF( a )
#elif defined(__WATCOMC__)
# undef FP_SEG
# undef FP_OFF
# define REGW( a, b ) ((a).w.b)
# define REGB( a, b ) ((a).h.b)
# define INT86( a, b, c ) int386(a,b,c)
# define INT86X( a, b, c, d ) int386x(a,b,c,d)
# define RM_SEG( a ) ( ( ( ( FxU32 ) (a) ) & 0x000F0000 ) >> 4 )
# define RM_OFF( a ) ( ( FxU16 ) (a) )
#endif
#endif /* !__3DFX_H__ */

View File

@ -0,0 +1,187 @@
/*==========================================================================;
*
* Copyright (C) Microsoft Corporation. All Rights Reserved.
*
* File: dxdiag.h
* Content: DirectX Diagnostic Tool include file
*
****************************************************************************/
#ifndef _DXDIAG_H_
#define _DXDIAG_H_
#include <ole2.h> // for DECLARE_INTERFACE_ and HRESULT
// This identifier is passed to IDxDiagProvider::Initialize in order to ensure that an
// application was built against the correct header files. This number is
// incremented whenever a header (or other) change would require applications
// to be rebuilt. If the version doesn't match, IDxDiagProvider::Initialize will fail.
// (The number itself has no meaning.)
#define DXDIAG_DX9_SDK_VERSION 111
#ifdef __cplusplus
extern "C" {
#endif
/****************************************************************************
*
* DxDiag Errors
*
****************************************************************************/
#define DXDIAG_E_INSUFFICIENT_BUFFER ((HRESULT)0x8007007AL) // HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
/****************************************************************************
*
* DxDiag CLSIDs
*
****************************************************************************/
// {A65B8071-3BFE-4213-9A5B-491DA4461CA7}
DEFINE_GUID(CLSID_DxDiagProvider,
0xA65B8071, 0x3BFE, 0x4213, 0x9A, 0x5B, 0x49, 0x1D, 0xA4, 0x46, 0x1C, 0xA7);
/****************************************************************************
*
* DxDiag Interface IIDs
*
****************************************************************************/
// {9C6B4CB0-23F8-49CC-A3ED-45A55000A6D2}
DEFINE_GUID(IID_IDxDiagProvider,
0x9C6B4CB0, 0x23F8, 0x49CC, 0xA3, 0xED, 0x45, 0xA5, 0x50, 0x00, 0xA6, 0xD2);
// {0x7D0F462F-0x4064-0x4862-BC7F-933E5058C10F}
DEFINE_GUID(IID_IDxDiagContainer,
0x7D0F462F, 0x4064, 0x4862, 0xBC, 0x7F, 0x93, 0x3E, 0x50, 0x58, 0xC1, 0x0F);
/****************************************************************************
*
* DxDiag Interface Pointer definitions
*
****************************************************************************/
typedef struct IDxDiagProvider *LPDXDIAGPROVIDER, *PDXDIAGPROVIDER;
typedef struct IDxDiagContainer *LPDXDIAGCONTAINER, *PDXDIAGCONTAINER;
/****************************************************************************
*
* DxDiag Structures
*
****************************************************************************/
typedef struct _DXDIAG_INIT_PARAMS
{
DWORD dwSize; // Size of this structure.
DWORD dwDxDiagHeaderVersion; // Pass in DXDIAG_DX9_SDK_VERSION. This verifies
// the header and dll are correctly matched.
BOOL bAllowWHQLChecks; // If true, allow dxdiag to check if drivers are
// digital signed as logo'd by WHQL which may
// connect via internet to update WHQL certificates.
VOID* pReserved; // Reserved. Must be NULL.
} DXDIAG_INIT_PARAMS;
/****************************************************************************
*
* DxDiag Application Interfaces
*
****************************************************************************/
//
// COM definition for IDxDiagProvider
//
#undef INTERFACE // External COM Implementation
#define INTERFACE IDxDiagProvider
DECLARE_INTERFACE_(IDxDiagProvider,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDxDiagProvider methods ***/
STDMETHOD(Initialize) (THIS_ DXDIAG_INIT_PARAMS* pParams) PURE;
STDMETHOD(GetRootContainer) (THIS_ IDxDiagContainer **ppInstance) PURE;
};
//
// COM definition for IDxDiagContainer
//
#undef INTERFACE // External COM Implementation
#define INTERFACE IDxDiagContainer
DECLARE_INTERFACE_(IDxDiagContainer,IUnknown)
{
/*** IUnknown methods ***/
STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID *ppvObj) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
/*** IDxDiagContainer methods ***/
STDMETHOD(GetNumberOfChildContainers) (THIS_ DWORD *pdwCount) PURE;
STDMETHOD(EnumChildContainerNames) (THIS_ DWORD dwIndex, LPWSTR pwszContainer, DWORD cchContainer) PURE;
STDMETHOD(GetChildContainer) (THIS_ LPCWSTR pwszContainer, IDxDiagContainer **ppInstance) PURE;
STDMETHOD(GetNumberOfProps) (THIS_ DWORD *pdwCount) PURE;
STDMETHOD(EnumPropNames) (THIS_ DWORD dwIndex, LPWSTR pwszPropName, DWORD cchPropName) PURE;
STDMETHOD(GetProp) (THIS_ LPCWSTR pwszPropName, VARIANT *pvarProp) PURE;
};
/****************************************************************************
*
* DxDiag application interface macros
*
****************************************************************************/
#if !defined(__cplusplus) || defined(CINTERFACE)
#define IDxDiagProvider_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDxDiagProvider_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDxDiagProvider_Release(p) (p)->lpVtbl->Release(p)
#define IDxDiagProvider_Initialize(p,a,b) (p)->lpVtbl->Initialize(p,a,b)
#define IDxDiagProvider_GetRootContainer(p,a) (p)->lpVtbl->GetRootContainer(p,a)
#define IDxDiagContainer_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
#define IDxDiagContainer_AddRef(p) (p)->lpVtbl->AddRef(p)
#define IDxDiagContainer_Release(p) (p)->lpVtbl->Release(p)
#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->lpVtbl->GetNumberOfChildContainers(p,a)
#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->lpVtbl->EnumChildContainerNames(p,a,b,c)
#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->lpVtbl->GetChildContainer(p,a,b)
#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->lpVtbl->GetNumberOfProps(p,a)
#define IDxDiagContainer_EnumProps(p,a,b) (p)->lpVtbl->EnumProps(p,a,b,c)
#define IDxDiagContainer_GetProp(p,a,b) (p)->lpVtbl->GetProp(p,a,b)
#else /* C++ */
#define IDxDiagProvider_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b)
#define IDxDiagProvider_AddRef(p) (p)->AddRef(p)
#define IDxDiagProvider_Release(p) (p)->Release(p)
#define IDxDiagProvider_Initialize(p,a,b) (p)->Initialize(p,a,b)
#define IDxDiagProvider_GetRootContainer(p,a) (p)->GetRootContainer(p,a)
#define IDxDiagContainer_QueryInterface(p,a,b) (p)->QueryInterface(p,a,b)
#define IDxDiagContainer_AddRef(p) (p)->AddRef(p)
#define IDxDiagContainer_Release(p) (p)->Release(p)
#define IDxDiagContainer_GetNumberOfChildContainers(p,a) (p)->GetNumberOfChildContainers(p,a)
#define IDxDiagContainer_EnumChildContainerNames(p,a,b,c) (p)->EnumChildContainerNames(p,a,b,c)
#define IDxDiagContainer_GetChildContainer(p,a,b) (p)->GetChildContainer(p,a,b)
#define IDxDiagContainer_GetNumberOfProps(p,a) (p)->GetNumberOfProps(p,a)
#define IDxDiagContainer_EnumProps(p,a,b) (p)->EnumProps(p,a,b,c)
#define IDxDiagContainer_GetProp(p,a,b) (p)->GetProp(p,a,b)
#endif
#ifdef __cplusplus
}
#endif
#endif /* _DXDIAG_H_ */

187
Source/Glitch64/inc/g3ext.h Normal file
View File

@ -0,0 +1,187 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
*/
/*
** H3EXT.H
**
** The following #defines are relevant when using Glide:
**
** One of the following "platform constants" must be defined during
** compilation:
**
** __DOS__ Defined for 32-bit DOS applications
** __WIN32__ Defined for 32-bit Windows applications
** __sparc__ Defined for Sun Solaris/SunOS
** __linux__ Defined for Linux applications
** __FreeBSD__ Defined for FreeBSD applications
** __NetBSD__ Defined for NetBSD applications
** __OpenBSD__ Defined for OpenBSD applications
** __IRIX__ Defined for SGI Irix applications
**
*/
#ifndef __H3EXT_H__
#define __H3EXT_H__
#include <3dfx.h>
#include <glidesys.h>
#include <sst1vid.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
** -----------------------------------------------------------------------
** TYPE DEFINITIONS
** -----------------------------------------------------------------------
*/
/*
** -----------------------------------------------------------------------
** CONSTANTS AND TYPES
** -----------------------------------------------------------------------
*/
/*
* gregk 5/3/99
* Constants defined for SSTH3_ALPHADITHERMODE registry key
*/
#define OPTIMAL 1
#define SHARPER 2
#define SMOOTHER 3
/* tbext */
#define GR_BUFFER_TEXTUREBUFFER_EXT 0x6
#define GR_BUFFER_TEXTUREAUXBUFFER_EXT 0x7
typedef FxU32 GrPixelFormat_t;
#define GR_PIXFMT_I_8 0x0001
#define GR_PIXFMT_AI_88 0x0002
#define GR_PIXFMT_RGB_565 0x0003
#define GR_PIXFMT_ARGB_1555 0x0004
#define GR_PIXFMT_ARGB_8888 0x0005
#define GR_PIXFMT_AA_2_RGB_565 0x0006
#define GR_PIXFMT_AA_2_ARGB_1555 0x0007
#define GR_PIXFMT_AA_2_ARGB_8888 0x0008
#define GR_PIXFMT_AA_4_RGB_565 0x0009
#define GR_PIXFMT_AA_4_ARGB_1555 0x000a
#define GR_PIXFMT_AA_4_ARGB_8888 0x000b
#define GR_PIXFMT_AA_8_RGB_565 0x000c /* 8xaa */
#define GR_PIXFMT_AA_8_ARGB_1555 0x000d
#define GR_PIXFMT_AA_8_ARGB_8888 0x000e
#define GR_LFBWRITEMODE_Z32 0x0008
typedef FxU32 GrAAMode_t;
#define GR_AA_NONE 0x0000
#define GR_AA_4SAMPLES 0x0001
typedef FxU8 GrStencil_t;
typedef FxU32 GrStencilOp_t;
#define GR_STENCILOP_KEEP 0x00 /* keep current value */
#define GR_STENCILOP_ZERO 0x01 /* set to zero */
#define GR_STENCILOP_REPLACE 0x02 /* replace with reference value */
#define GR_STENCILOP_INCR_CLAMP 0x03 /* increment - clamp */
#define GR_STENCILOP_DECR_CLAMP 0x04 /* decrement - clamp */
#define GR_STENCILOP_INVERT 0x05 /* bitwise inversion */
#define GR_STENCILOP_INCR_WRAP 0x06 /* increment - wrap */
#define GR_STENCILOP_DECR_WRAP 0x07 /* decrement - wrap */
#define GR_TEXTURE_UMA_EXT 0x06
#define GR_STENCIL_MODE_EXT 0x07
#define GR_OPENGL_MODE_EXT 0x08
typedef FxU32 GrCCUColor_t;
typedef FxU32 GrACUColor_t;
typedef FxU32 GrTCCUColor_t;
typedef FxU32 GrTACUColor_t;
#define GR_CMBX_ZERO 0x00
#define GR_CMBX_TEXTURE_ALPHA 0x01
#define GR_CMBX_ALOCAL 0x02
#define GR_CMBX_AOTHER 0x03
#define GR_CMBX_B 0x04
#define GR_CMBX_CONSTANT_ALPHA 0x05
#define GR_CMBX_CONSTANT_COLOR 0x06
#define GR_CMBX_DETAIL_FACTOR 0x07
#define GR_CMBX_ITALPHA 0x08
#define GR_CMBX_ITRGB 0x09
#define GR_CMBX_LOCAL_TEXTURE_ALPHA 0x0a
#define GR_CMBX_LOCAL_TEXTURE_RGB 0x0b
#define GR_CMBX_LOD_FRAC 0x0c
#define GR_CMBX_OTHER_TEXTURE_ALPHA 0x0d
#define GR_CMBX_OTHER_TEXTURE_RGB 0x0e
#define GR_CMBX_TEXTURE_RGB 0x0f
#define GR_CMBX_TMU_CALPHA 0x10
#define GR_CMBX_TMU_CCOLOR 0x11
typedef FxU32 GrCombineMode_t;
#define GR_FUNC_MODE_ZERO 0x00
#define GR_FUNC_MODE_X 0x01
#define GR_FUNC_MODE_ONE_MINUS_X 0x02
#define GR_FUNC_MODE_NEGATIVE_X 0x03
#define GR_FUNC_MODE_X_MINUS_HALF 0x04
typedef FxU32 GrAlphaBlendOp_t;
#define GR_BLEND_OP_ADD 0x00
#define GR_BLEND_OP_SUB 0x01
#define GR_BLEND_OP_REVSUB 0x02
#define GR_BLEND_SAME_COLOR_EXT 0x08
#define GR_BLEND_ONE_MINUS_SAME_COLOR_EXT 0x09
/* Napalm extensions to GrTextureFormat_t */
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
#define GR_TEXFMT_ARGB_8888 0x12
#define GR_TEXFMT_YUYV_422 0x13
#define GR_TEXFMT_UYVY_422 0x14
#define GR_TEXFMT_AYUV_444 0x15
#define GR_TEXFMT_ARGB_CMP_DXT1 0x16
#define GR_TEXFMT_ARGB_CMP_DXT2 0x17
#define GR_TEXFMT_ARGB_CMP_DXT3 0x18
#define GR_TEXFMT_ARGB_CMP_DXT4 0x19
#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A
#define GR_TEXTFMT_RGB_888 0xFF
/* Napalm extensions to GrLOD_t */
#define GR_LOD_LOG2_2048 0xb
#define GR_LOD_LOG2_1024 0xa
#define GR_LOD_LOG2_512 0x9
/* Napalm extensions to GrTexBaseRange_t */
#define GR_TEXBASE_2048 0x7
#define GR_TEXBASE_1024 0x6
#define GR_TEXBASE_512 0x5
#define GR_TEXBASE_256_TO_1 0x4
#ifdef __cplusplus
}
#endif
#include <glideutl.h>
#endif /* __H3EXT_H__ */

1473
Source/Glitch64/inc/gl.h Normal file

File diff suppressed because it is too large Load Diff

6498
Source/Glitch64/inc/glext.h Normal file

File diff suppressed because it is too large Load Diff

946
Source/Glitch64/inc/glide.h Normal file
View File

@ -0,0 +1,946 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
*/
/*
** GLIDE.H
**
** The following #defines are relevant when using Glide:
**
** One of the following "platform constants" must be defined during
** compilation:
**
** __DOS__ Defined for 32-bit DOS applications
** __WIN32__ Defined for 32-bit Windows applications
** __sparc__ Defined for Sun Solaris/SunOS
** __linux__ Defined for Linux applications
** __FreeBSD__ Defined for FreeBSD applications
** __NetBSD__ Defined for NetBSD applications
** __OpenBSD__ Defined for OpenBSD applications
** __IRIX__ Defined for SGI Irix applications
**
*/
#ifndef __GLIDE_H__
#define __GLIDE_H__
#include <3dfx.h>
#include <glidesys.h>
#include <sst1vid.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
** -----------------------------------------------------------------------
** TYPE DEFINITIONS
** -----------------------------------------------------------------------
*/
typedef FxU32 GrColor_t;
typedef FxU8 GrAlpha_t;
typedef FxU32 GrMipMapId_t;
typedef FxU32 GrStipplePattern_t;
typedef FxU8 GrFog_t;
typedef FxU32 GrContext_t;
typedef int (FX_CALL *GrProc)();
/*
** -----------------------------------------------------------------------
** CONSTANTS AND TYPES
** -----------------------------------------------------------------------
*/
#define GR_NULL_MIPMAP_HANDLE ((GrMipMapId_t) -1)
#define GR_MIPMAPLEVELMASK_EVEN FXBIT(0)
#define GR_MIPMAPLEVELMASK_ODD FXBIT(1)
#define GR_MIPMAPLEVELMASK_BOTH (GR_MIPMAPLEVELMASK_EVEN | GR_MIPMAPLEVELMASK_ODD )
#define GR_LODBIAS_BILINEAR 0.5
#define GR_LODBIAS_TRILINEAR 0.0
typedef FxI32 GrChipID_t;
#define GR_TMU0 0x0
#define GR_TMU1 0x1
#define GR_TMU2 0x2
#define GR_FBI 0x0
typedef FxI32 GrCombineFunction_t;
#define GR_COMBINE_FUNCTION_ZERO 0x0
#define GR_COMBINE_FUNCTION_NONE GR_COMBINE_FUNCTION_ZERO
#define GR_COMBINE_FUNCTION_LOCAL 0x1
#define GR_COMBINE_FUNCTION_LOCAL_ALPHA 0x2
#define GR_COMBINE_FUNCTION_SCALE_OTHER 0x3
#define GR_COMBINE_FUNCTION_BLEND_OTHER GR_COMBINE_FUNCTION_SCALE_OTHER
#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL 0x4
#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA 0x5
#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL 0x6
#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL 0x7
#define GR_COMBINE_FUNCTION_BLEND GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL
#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x8
#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL 0x9
#define GR_COMBINE_FUNCTION_BLEND_LOCAL GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL
#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x10
typedef FxI32 GrCombineFactor_t;
#define GR_COMBINE_FACTOR_ZERO 0x0
#define GR_COMBINE_FACTOR_NONE GR_COMBINE_FACTOR_ZERO
#define GR_COMBINE_FACTOR_LOCAL 0x1
#define GR_COMBINE_FACTOR_OTHER_ALPHA 0x2
#define GR_COMBINE_FACTOR_LOCAL_ALPHA 0x3
#define GR_COMBINE_FACTOR_TEXTURE_ALPHA 0x4
#define GR_COMBINE_FACTOR_TEXTURE_RGB 0x5
#define GR_COMBINE_FACTOR_DETAIL_FACTOR GR_COMBINE_FACTOR_TEXTURE_ALPHA
#define GR_COMBINE_FACTOR_LOD_FRACTION 0x5
#define GR_COMBINE_FACTOR_ONE 0x8
#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL 0x9
#define GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA 0xa
#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA 0xb
#define GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA 0xc
#define GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA
#define GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION 0xd
typedef FxI32 GrCombineLocal_t;
#define GR_COMBINE_LOCAL_ITERATED 0x0
#define GR_COMBINE_LOCAL_CONSTANT 0x1
#define GR_COMBINE_LOCAL_NONE GR_COMBINE_LOCAL_CONSTANT
#define GR_COMBINE_LOCAL_DEPTH 0x2
typedef FxI32 GrCombineOther_t;
#define GR_COMBINE_OTHER_ITERATED 0x0
#define GR_COMBINE_OTHER_TEXTURE 0x1
#define GR_COMBINE_OTHER_CONSTANT 0x2
#define GR_COMBINE_OTHER_NONE GR_COMBINE_OTHER_CONSTANT
typedef FxI32 GrAlphaSource_t;
#define GR_ALPHASOURCE_CC_ALPHA 0x0
#define GR_ALPHASOURCE_ITERATED_ALPHA 0x1
#define GR_ALPHASOURCE_TEXTURE_ALPHA 0x2
#define GR_ALPHASOURCE_TEXTURE_ALPHA_TIMES_ITERATED_ALPHA 0x3
typedef FxI32 GrColorCombineFnc_t;
#define GR_COLORCOMBINE_ZERO 0x0
#define GR_COLORCOMBINE_CCRGB 0x1
#define GR_COLORCOMBINE_ITRGB 0x2
#define GR_COLORCOMBINE_ITRGB_DELTA0 0x3
#define GR_COLORCOMBINE_DECAL_TEXTURE 0x4
#define GR_COLORCOMBINE_TEXTURE_TIMES_CCRGB 0x5
#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB 0x6
#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_DELTA0 0x7
#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_ADD_ALPHA 0x8
#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA 0x9
#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA_ADD_ITRGB 0xa
#define GR_COLORCOMBINE_TEXTURE_ADD_ITRGB 0xb
#define GR_COLORCOMBINE_TEXTURE_SUB_ITRGB 0xc
#define GR_COLORCOMBINE_CCRGB_BLEND_ITRGB_ON_TEXALPHA 0xd
#define GR_COLORCOMBINE_DIFF_SPEC_A 0xe
#define GR_COLORCOMBINE_DIFF_SPEC_B 0xf
#define GR_COLORCOMBINE_ONE 0x10
typedef FxI32 GrAlphaBlendFnc_t;
#define GR_BLEND_ZERO 0x0
#define GR_BLEND_SRC_ALPHA 0x1
#define GR_BLEND_SRC_COLOR 0x2
#define GR_BLEND_DST_COLOR GR_BLEND_SRC_COLOR
#define GR_BLEND_DST_ALPHA 0x3
#define GR_BLEND_ONE 0x4
#define GR_BLEND_ONE_MINUS_SRC_ALPHA 0x5
#define GR_BLEND_ONE_MINUS_SRC_COLOR 0x6
#define GR_BLEND_ONE_MINUS_DST_COLOR GR_BLEND_ONE_MINUS_SRC_COLOR
#define GR_BLEND_ONE_MINUS_DST_ALPHA 0x7
#define GR_BLEND_RESERVED_8 0x8
#define GR_BLEND_RESERVED_9 0x9
#define GR_BLEND_RESERVED_A 0xa
#define GR_BLEND_RESERVED_B 0xb
#define GR_BLEND_RESERVED_C 0xc
#define GR_BLEND_RESERVED_D 0xd
#define GR_BLEND_RESERVED_E 0xe
#define GR_BLEND_ALPHA_SATURATE 0xf
#define GR_BLEND_PREFOG_COLOR GR_BLEND_ALPHA_SATURATE
typedef FxI32 GrAspectRatio_t;
#define GR_ASPECT_LOG2_8x1 3 /* 8W x 1H */
#define GR_ASPECT_LOG2_4x1 2 /* 4W x 1H */
#define GR_ASPECT_LOG2_2x1 1 /* 2W x 1H */
#define GR_ASPECT_LOG2_1x1 0 /* 1W x 1H */
#define GR_ASPECT_LOG2_1x2 -1 /* 1W x 2H */
#define GR_ASPECT_LOG2_1x4 -2 /* 1W x 4H */
#define GR_ASPECT_LOG2_1x8 -3 /* 1W x 8H */
typedef FxI32 GrBuffer_t;
#define GR_BUFFER_FRONTBUFFER 0x0
#define GR_BUFFER_BACKBUFFER 0x1
#define GR_BUFFER_AUXBUFFER 0x2
#define GR_BUFFER_DEPTHBUFFER 0x3
#define GR_BUFFER_ALPHABUFFER 0x4
#define GR_BUFFER_TRIPLEBUFFER 0x5
typedef FxI32 GrChromakeyMode_t;
#define GR_CHROMAKEY_DISABLE 0x0
#define GR_CHROMAKEY_ENABLE 0x1
typedef FxI32 GrChromaRangeMode_t;
#define GR_CHROMARANGE_RGB_ALL_EXT 0x0
#define GR_CHROMARANGE_DISABLE_EXT 0x00
#define GR_CHROMARANGE_ENABLE_EXT 0x01
typedef FxI32 GrTexChromakeyMode_t;
#define GR_TEXCHROMA_DISABLE_EXT 0x0
#define GR_TEXCHROMA_ENABLE_EXT 0x1
#define GR_TEXCHROMARANGE_RGB_ALL_EXT 0x0
typedef FxI32 GrCmpFnc_t;
#define GR_CMP_NEVER 0x0
#define GR_CMP_LESS 0x1
#define GR_CMP_EQUAL 0x2
#define GR_CMP_LEQUAL 0x3
#define GR_CMP_GREATER 0x4
#define GR_CMP_NOTEQUAL 0x5
#define GR_CMP_GEQUAL 0x6
#define GR_CMP_ALWAYS 0x7
typedef FxI32 GrColorFormat_t;
#define GR_COLORFORMAT_ARGB 0x0
#define GR_COLORFORMAT_ABGR 0x1
#define GR_COLORFORMAT_RGBA 0x2
#define GR_COLORFORMAT_BGRA 0x3
typedef FxI32 GrCullMode_t;
#define GR_CULL_DISABLE 0x0
#define GR_CULL_NEGATIVE 0x1
#define GR_CULL_POSITIVE 0x2
typedef FxI32 GrDepthBufferMode_t;
#define GR_DEPTHBUFFER_DISABLE 0x0
#define GR_DEPTHBUFFER_ZBUFFER 0x1
#define GR_DEPTHBUFFER_WBUFFER 0x2
#define GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS 0x3
#define GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS 0x4
typedef FxI32 GrDitherMode_t;
#define GR_DITHER_DISABLE 0x0
#define GR_DITHER_2x2 0x1
#define GR_DITHER_4x4 0x2
typedef FxI32 GrStippleMode_t;
#define GR_STIPPLE_DISABLE 0x0
#define GR_STIPPLE_PATTERN 0x1
#define GR_STIPPLE_ROTATE 0x2
typedef FxI32 GrFogMode_t;
#define GR_FOG_DISABLE 0x0
#define GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT 0x1
#define GR_FOG_WITH_TABLE_ON_Q 0x2
#define GR_FOG_WITH_TABLE_ON_W GR_FOG_WITH_TABLE_ON_Q
#define GR_FOG_WITH_ITERATED_Z 0x3
#define GR_FOG_WITH_ITERATED_ALPHA_EXT 0x4
#define GR_FOG_MULT2 0x100
#define GR_FOG_ADD2 0x200
typedef FxU32 GrLock_t;
#define GR_LFB_READ_ONLY 0x00
#define GR_LFB_WRITE_ONLY 0x01
#define GR_LFB_IDLE 0x00
#define GR_LFB_NOIDLE 0x10
#define GR_LFB_WRITE_ONLY_EXPLICIT_EXT 0x02 /* explicitly not allow reading from the lfb pointer */
typedef FxI32 GrLfbBypassMode_t;
#define GR_LFBBYPASS_DISABLE 0x0
#define GR_LFBBYPASS_ENABLE 0x1
typedef FxI32 GrLfbWriteMode_t;
#define GR_LFBWRITEMODE_565 0x0 /* RGB:RGB */
#define GR_LFBWRITEMODE_555 0x1 /* RGB:RGB */
#define GR_LFBWRITEMODE_1555 0x2 /* ARGB:ARGB */
#define GR_LFBWRITEMODE_RESERVED1 0x3
#define GR_LFBWRITEMODE_888 0x4 /* RGB */
#define GR_LFBWRITEMODE_8888 0x5 /* ARGB */
#define GR_LFBWRITEMODE_RESERVED2 0x6
#define GR_LFBWRITEMODE_RESERVED3 0x7
#define GR_LFBWRITEMODE_RESERVED4 0x8
#define GR_LFBWRITEMODE_RESERVED5 0x9
#define GR_LFBWRITEMODE_RESERVED6 0xa
#define GR_LFBWRITEMODE_RESERVED7 0xb
#define GR_LFBWRITEMODE_565_DEPTH 0xc /* RGB:DEPTH */
#define GR_LFBWRITEMODE_555_DEPTH 0xd /* RGB:DEPTH */
#define GR_LFBWRITEMODE_1555_DEPTH 0xe /* ARGB:DEPTH */
#define GR_LFBWRITEMODE_ZA16 0xf /* DEPTH:DEPTH */
#define GR_LFBWRITEMODE_ANY 0xFF
typedef FxI32 GrOriginLocation_t;
#define GR_ORIGIN_UPPER_LEFT 0x0
#define GR_ORIGIN_LOWER_LEFT 0x1
#define GR_ORIGIN_ANY 0xFF
typedef struct {
int size;
void *lfbPtr;
FxU32 strideInBytes;
GrLfbWriteMode_t writeMode;
GrOriginLocation_t origin;
} GrLfbInfo_t;
typedef FxI32 GrLOD_t;
#define GR_LOD_LOG2_256 0x8
#define GR_LOD_LOG2_128 0x7
#define GR_LOD_LOG2_64 0x6
#define GR_LOD_LOG2_32 0x5
#define GR_LOD_LOG2_16 0x4
#define GR_LOD_LOG2_8 0x3
#define GR_LOD_LOG2_4 0x2
#define GR_LOD_LOG2_2 0x1
#define GR_LOD_LOG2_1 0x0
typedef FxI32 GrMipMapMode_t;
#define GR_MIPMAP_DISABLE 0x0 /* no mip mapping */
#define GR_MIPMAP_NEAREST 0x1 /* use nearest mipmap */
#define GR_MIPMAP_NEAREST_DITHER 0x2 /* GR_MIPMAP_NEAREST + LOD dith */
typedef FxI32 GrSmoothingMode_t;
#define GR_SMOOTHING_DISABLE 0x0
#define GR_SMOOTHING_ENABLE 0x1
typedef FxI32 GrTextureClampMode_t;
#define GR_TEXTURECLAMP_WRAP 0x0
#define GR_TEXTURECLAMP_CLAMP 0x1
#define GR_TEXTURECLAMP_MIRROR_EXT 0x2
typedef FxI32 GrTextureCombineFnc_t;
#define GR_TEXTURECOMBINE_ZERO 0x0 /* texout = 0 */
#define GR_TEXTURECOMBINE_DECAL 0x1 /* texout = texthis */
#define GR_TEXTURECOMBINE_OTHER 0x2 /* this TMU in passthru mode */
#define GR_TEXTURECOMBINE_ADD 0x3 /* tout = tthis + t(this+1) */
#define GR_TEXTURECOMBINE_MULTIPLY 0x4 /* texout = tthis * t(this+1) */
#define GR_TEXTURECOMBINE_SUBTRACT 0x5 /* Sutract from upstream TMU */
#define GR_TEXTURECOMBINE_DETAIL 0x6 /* detail--detail on tthis */
#define GR_TEXTURECOMBINE_DETAIL_OTHER 0x7 /* detail--detail on tthis+1 */
#define GR_TEXTURECOMBINE_TRILINEAR_ODD 0x8 /* trilinear--odd levels tthis*/
#define GR_TEXTURECOMBINE_TRILINEAR_EVEN 0x9 /*trilinear--even levels tthis*/
#define GR_TEXTURECOMBINE_ONE 0xa /* texout = 0xFFFFFFFF */
typedef FxI32 GrTextureFilterMode_t;
#define GR_TEXTUREFILTER_POINT_SAMPLED 0x0
#define GR_TEXTUREFILTER_BILINEAR 0x1
typedef FxI32 GrTextureFormat_t;
/* KoolSmoky - */
#define GR_TEXFMT_8BIT 0x0
#define GR_TEXFMT_RGB_332 GR_TEXFMT_8BIT
#define GR_TEXFMT_YIQ_422 0x1
#define GR_TEXFMT_ALPHA_8 0x2 /* (0..0xFF) alpha */
#define GR_TEXFMT_INTENSITY_8 0x3 /* (0..0xFF) intensity */
#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
#define GR_TEXFMT_P_8 0x5 /* 8-bit palette */
#define GR_TEXFMT_RSVD0 0x6 /* GR_TEXFMT_P_8_RGBA */
#define GR_TEXFMT_P_8_6666 GR_TEXFMT_RSVD0
#define GR_TEXFMT_P_8_6666_EXT GR_TEXFMT_RSVD0
#define GR_TEXFMT_RSVD1 0x7
#define GR_TEXFMT_16BIT 0x8
#define GR_TEXFMT_ARGB_8332 GR_TEXFMT_16BIT
#define GR_TEXFMT_AYIQ_8422 0x9
#define GR_TEXFMT_RGB_565 0xa
#define GR_TEXFMT_ARGB_1555 0xb
#define GR_TEXFMT_ARGB_4444 0xc
#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
#define GR_TEXFMT_AP_88 0xe /* 8-bit alpha 8-bit palette */
#define GR_TEXFMT_RSVD2 0xf
#define GR_TEXFMT_RSVD4 GR_TEXFMT_RSVD2
typedef FxU32 GrTexTable_t;
#define GR_TEXTABLE_NCC0 0x0
#define GR_TEXTABLE_NCC1 0x1
#define GR_TEXTABLE_PALETTE 0x2
#define GR_TEXTABLE_PALETTE_6666_EXT 0x3
typedef FxU32 GrNCCTable_t;
#define GR_NCCTABLE_NCC0 0x0
#define GR_NCCTABLE_NCC1 0x1
typedef FxU32 GrTexBaseRange_t;
#define GR_TEXBASE_256 0x3
#define GR_TEXBASE_128 0x2
#define GR_TEXBASE_64 0x1
#define GR_TEXBASE_32_TO_1 0x0
typedef FxU32 GrEnableMode_t;
#define GR_MODE_DISABLE 0x0
#define GR_MODE_ENABLE 0x1
#define GR_AA_ORDERED 0x01
#define GR_ALLOW_MIPMAP_DITHER 0x02
#define GR_PASSTHRU 0x03
#define GR_SHAMELESS_PLUG 0x04
#define GR_VIDEO_SMOOTHING 0x05
typedef FxU32 GrCoordinateSpaceMode_t;
#define GR_WINDOW_COORDS 0x00
#define GR_CLIP_COORDS 0x01
/* Types of data in strips */
#define GR_FLOAT 0
#define GR_U8 1
/* Parameters for strips */
#define GR_PARAM_XY 0x01
#define GR_PARAM_Z 0x02
#define GR_PARAM_W 0x03
#define GR_PARAM_Q 0x04
#define GR_PARAM_FOG_EXT 0x05
#define GR_PARAM_A 0x10
#define GR_PARAM_RGB 0x20
#define GR_PARAM_PARGB 0x30
#define GR_PARAM_ST0 0x40
#define GR_PARAM_ST1 GR_PARAM_ST0+1
#define GR_PARAM_ST2 GR_PARAM_ST0+2
#define GR_PARAM_Q0 0x50
#define GR_PARAM_Q1 GR_PARAM_Q0+1
#define GR_PARAM_Q2 GR_PARAM_Q0+2
#define GR_PARAM_DISABLE 0x00
#define GR_PARAM_ENABLE 0x01
/*
** grDrawVertexArray/grDrawVertexArrayContiguous primitive type
*/
#define GR_POINTS 0
#define GR_LINE_STRIP 1
#define GR_LINES 2
#define GR_POLYGON 3
#define GR_TRIANGLE_STRIP 4
#define GR_TRIANGLE_FAN 5
#define GR_TRIANGLES 6
#define GR_TRIANGLE_STRIP_CONTINUE 7
#define GR_TRIANGLE_FAN_CONTINUE 8
/*
** grGet/grReset types
*/
#define GR_BITS_DEPTH 0x01
#define GR_BITS_RGBA 0x02
#define GR_FIFO_FULLNESS 0x03
#define GR_FOG_TABLE_ENTRIES 0x04
#define GR_GAMMA_TABLE_ENTRIES 0x05
#define GR_GLIDE_STATE_SIZE 0x06
#define GR_GLIDE_VERTEXLAYOUT_SIZE 0x07
#define GR_IS_BUSY 0x08
#define GR_LFB_PIXEL_PIPE 0x09
#define GR_MAX_TEXTURE_SIZE 0x0a
#define GR_MAX_TEXTURE_ASPECT_RATIO 0x0b
#define GR_MEMORY_FB 0x0c
#define GR_MEMORY_TMU 0x0d
#define GR_MEMORY_UMA 0x0e
#define GR_NUM_BOARDS 0x0f
#define GR_NON_POWER_OF_TWO_TEXTURES 0x10
#define GR_NUM_FB 0x11
#define GR_NUM_SWAP_HISTORY_BUFFER 0x12
#define GR_NUM_TMU 0x13
#define GR_PENDING_BUFFERSWAPS 0x14
#define GR_REVISION_FB 0x15
#define GR_REVISION_TMU 0x16
#define GR_STATS_LINES 0x17 /* grGet/grReset */
#define GR_STATS_PIXELS_AFUNC_FAIL 0x18
#define GR_STATS_PIXELS_CHROMA_FAIL 0x19
#define GR_STATS_PIXELS_DEPTHFUNC_FAIL 0x1a
#define GR_STATS_PIXELS_IN 0x1b
#define GR_STATS_PIXELS_OUT 0x1c
#define GR_STATS_PIXELS 0x1d /* grReset */
#define GR_STATS_POINTS 0x1e /* grGet/grReset */
#define GR_STATS_TRIANGLES_IN 0x1f
#define GR_STATS_TRIANGLES_OUT 0x20
#define GR_STATS_TRIANGLES 0x21 /* grReset */
#define GR_SWAP_HISTORY 0x22
#define GR_SUPPORTS_PASSTHRU 0x23
#define GR_TEXTURE_ALIGN 0x24
#define GR_VIDEO_POSITION 0x25
#define GR_VIEWPORT 0x26
#define GR_WDEPTH_MIN_MAX 0x27
#define GR_ZDEPTH_MIN_MAX 0x28
#define GR_VERTEX_PARAMETER 0x29
#define GR_BITS_GAMMA 0x2a
#define GR_GET_RESERVED_1 0x1000
/*
** grGetString types
*/
#define GR_EXTENSION 0xa0
#define GR_HARDWARE 0xa1
#define GR_RENDERER 0xa2
#define GR_VENDOR 0xa3
#define GR_VERSION 0xa4
/*
** -----------------------------------------------------------------------
** STRUCTURES
** -----------------------------------------------------------------------
*/
typedef struct {
GrLOD_t smallLodLog2;
GrLOD_t largeLodLog2;
GrAspectRatio_t aspectRatioLog2;
GrTextureFormat_t format;
void *data;
} GrTexInfo;
typedef struct GrSstPerfStats_s {
FxU32 pixelsIn; /* # pixels processed (minus buffer clears) */
FxU32 chromaFail; /* # pixels not drawn due to chroma key */
FxU32 zFuncFail; /* # pixels not drawn due to Z comparison */
FxU32 aFuncFail; /* # pixels not drawn due to alpha comparison */
FxU32 pixelsOut; /* # pixels drawn (including buffer clears) */
} GrSstPerfStats_t;
typedef struct {
GrScreenResolution_t resolution;
GrScreenRefresh_t refresh;
int numColorBuffers;
int numAuxBuffers;
} GrResolution;
typedef GrResolution GlideResolution;
#define GR_QUERY_ANY ((FxU32)(~0))
typedef FxU32 GrLfbSrcFmt_t;
#define GR_LFB_SRC_FMT_565 0x00
#define GR_LFB_SRC_FMT_555 0x01
#define GR_LFB_SRC_FMT_1555 0x02
#define GR_LFB_SRC_FMT_888 0x04
#define GR_LFB_SRC_FMT_8888 0x05
#define GR_LFB_SRC_FMT_565_DEPTH 0x0c
#define GR_LFB_SRC_FMT_555_DEPTH 0x0d
#define GR_LFB_SRC_FMT_1555_DEPTH 0x0e
#define GR_LFB_SRC_FMT_ZA16 0x0f
#define GR_LFB_SRC_FMT_RLE16 0x80
#ifdef H3D
#define GR_HINT_H3DENABLE 4
#undef GR_HINTTYPE_MAX
#define GR_HINTTYPE_MAX 4
#endif
/*
** -----------------------------------------------------------------------
** FUNCTION PROTOTYPES
** -----------------------------------------------------------------------
*/
#ifndef FX_GLIDE_NO_FUNC_PROTO
/*
** rendering functions
*/
FX_ENTRY void FX_CALL
grDrawPoint( const void *pt );
FX_ENTRY void FX_CALL
grDrawLine( const void *v1, const void *v2 );
FX_ENTRY void FX_CALL
grDrawTriangle( const void *a, const void *b, const void *c );
FX_ENTRY void FX_CALL
grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode);
FX_ENTRY void FX_CALL
grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers);
FX_ENTRY void FX_CALL
grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count, void *pointers, FxU32 stride);
/*
** Antialiasing Functions
*/
FX_ENTRY void FX_CALL
grAADrawTriangle(
const void *a, const void *b, const void *c,
FxBool ab_antialias, FxBool bc_antialias, FxBool ca_antialias
);
/*
** buffer management
*/
FX_ENTRY void FX_CALL
grBufferClear( GrColor_t color, GrAlpha_t alpha, FxU32 depth );
FX_ENTRY void FX_CALL
grBufferSwap( FxU32 swap_interval );
FX_ENTRY void FX_CALL
grRenderBuffer( GrBuffer_t buffer );
/*
** error management
*/
typedef void (*GrErrorCallbackFnc_t)( const char *string, FxBool fatal );
FX_ENTRY void FX_CALL
grErrorSetCallback( GrErrorCallbackFnc_t fnc );
/*
** SST routines
*/
FX_ENTRY void FX_CALL
grFinish(void);
FX_ENTRY void FX_CALL
grFlush(void);
FX_ENTRY GrContext_t FX_CALL
grSstWinOpen(
FxU32 hWnd,
GrScreenResolution_t screen_resolution,
GrScreenRefresh_t refresh_rate,
GrColorFormat_t color_format,
GrOriginLocation_t origin_location,
int nColBuffers,
int nAuxBuffers);
FX_ENTRY FxBool FX_CALL
grSstWinClose( GrContext_t context );
FX_ENTRY void FX_CALL
grSetNumPendingBuffers(FxI32 NumPendingBuffers);
FX_ENTRY FxBool FX_CALL
grSelectContext( GrContext_t context );
FX_ENTRY void FX_CALL
grSstOrigin(GrOriginLocation_t origin);
FX_ENTRY void FX_CALL
grSstSelect( int which_sst );
/*
** Glide configuration and special effect maintenance functions
*/
FX_ENTRY void FX_CALL
grAlphaBlendFunction(
GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df,
GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df
);
FX_ENTRY void FX_CALL
grAlphaCombine(
GrCombineFunction_t function, GrCombineFactor_t factor,
GrCombineLocal_t local, GrCombineOther_t other,
FxBool invert
);
FX_ENTRY void FX_CALL
grAlphaControlsITRGBLighting( FxBool enable );
FX_ENTRY void FX_CALL
grAlphaTestFunction( GrCmpFnc_t function );
FX_ENTRY void FX_CALL
grAlphaTestReferenceValue( GrAlpha_t value );
FX_ENTRY void FX_CALL
grChromakeyMode( GrChromakeyMode_t mode );
FX_ENTRY void FX_CALL
grChromakeyValue( GrColor_t value );
FX_ENTRY void FX_CALL
grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy );
FX_ENTRY void FX_CALL
grColorCombine(
GrCombineFunction_t function, GrCombineFactor_t factor,
GrCombineLocal_t local, GrCombineOther_t other,
FxBool invert );
FX_ENTRY void FX_CALL
grColorMask( FxBool rgb, FxBool a );
FX_ENTRY void FX_CALL
grCullMode( GrCullMode_t mode );
FX_ENTRY void FX_CALL
grConstantColorValue( GrColor_t value );
FX_ENTRY void FX_CALL
grDepthBiasLevel( FxI32 level );
FX_ENTRY void FX_CALL
grDepthBufferFunction( GrCmpFnc_t function );
FX_ENTRY void FX_CALL
grDepthBufferMode( GrDepthBufferMode_t mode );
FX_ENTRY void FX_CALL
grDepthMask( FxBool mask );
FX_ENTRY void FX_CALL
grDisableAllEffects( void );
FX_ENTRY void FX_CALL
grDitherMode( GrDitherMode_t mode );
FX_ENTRY void FX_CALL
grFogColorValue( GrColor_t fogcolor );
FX_ENTRY void FX_CALL
grFogMode( GrFogMode_t mode );
FX_ENTRY void FX_CALL
grFogTable( const GrFog_t ft[] );
FX_ENTRY void FX_CALL
grLoadGammaTable( FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
FX_ENTRY void FX_CALL
grSplash(float x, float y, float width, float height, FxU32 frame);
FX_ENTRY FxU32 FX_CALL
grGet( FxU32 pname, FxU32 plength, FxI32 *params );
FX_ENTRY const char * FX_CALL
grGetString( FxU32 pname );
FX_ENTRY FxI32 FX_CALL
grQueryResolutions( const GrResolution *resTemplate, GrResolution *output );
FX_ENTRY FxBool FX_CALL
grReset( FxU32 what );
FX_ENTRY GrProc FX_CALL
grGetProcAddress( char *procName );
FX_ENTRY void FX_CALL
grEnable( GrEnableMode_t mode );
FX_ENTRY void FX_CALL
grDisable( GrEnableMode_t mode );
FX_ENTRY void FX_CALL
grCoordinateSpace( GrCoordinateSpaceMode_t mode );
FX_ENTRY void FX_CALL
grDepthRange( FxFloat n, FxFloat f );
FX_ENTRY void FX_CALL
grStippleMode( GrStippleMode_t mode );
FX_ENTRY void FX_CALL
grStipplePattern( GrStipplePattern_t mode );
FX_ENTRY void FX_CALL
grViewport( FxI32 x, FxI32 y, FxI32 width, FxI32 height );
/*
** texture mapping control functions
*/
FX_ENTRY FxU32 FX_CALL
grTexCalcMemRequired(
GrLOD_t lodmin, GrLOD_t lodmax,
GrAspectRatio_t aspect, GrTextureFormat_t fmt);
FX_ENTRY FxU32 FX_CALL
grTexTextureMemRequired( FxU32 evenOdd,
GrTexInfo *info );
FX_ENTRY FxU32 FX_CALL
grTexMinAddress( GrChipID_t tmu );
FX_ENTRY FxU32 FX_CALL
grTexMaxAddress( GrChipID_t tmu );
FX_ENTRY void FX_CALL
grTexNCCTable( GrNCCTable_t table );
FX_ENTRY void FX_CALL
grTexSource( GrChipID_t tmu,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info );
FX_ENTRY void FX_CALL
grTexClampMode(
GrChipID_t tmu,
GrTextureClampMode_t s_clampmode,
GrTextureClampMode_t t_clampmode
);
FX_ENTRY void FX_CALL
grTexCombine(
GrChipID_t tmu,
GrCombineFunction_t rgb_function,
GrCombineFactor_t rgb_factor,
GrCombineFunction_t alpha_function,
GrCombineFactor_t alpha_factor,
FxBool rgb_invert,
FxBool alpha_invert
);
FX_ENTRY void FX_CALL
grTexDetailControl(
GrChipID_t tmu,
int lod_bias,
FxU8 detail_scale,
float detail_max
);
FX_ENTRY void FX_CALL
grTexFilterMode(
GrChipID_t tmu,
GrTextureFilterMode_t minfilter_mode,
GrTextureFilterMode_t magfilter_mode
);
FX_ENTRY void FX_CALL
grTexLodBiasValue(GrChipID_t tmu, float bias );
FX_ENTRY void FX_CALL
grTexDownloadMipMap( GrChipID_t tmu,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info );
FX_ENTRY void FX_CALL
grTexDownloadMipMapLevel( GrChipID_t tmu,
FxU32 startAddress,
GrLOD_t thisLod,
GrLOD_t largeLod,
GrAspectRatio_t aspectRatio,
GrTextureFormat_t format,
FxU32 evenOdd,
void *data );
FX_ENTRY FxBool FX_CALL
grTexDownloadMipMapLevelPartial( GrChipID_t tmu,
FxU32 startAddress,
GrLOD_t thisLod,
GrLOD_t largeLod,
GrAspectRatio_t aspectRatio,
GrTextureFormat_t format,
FxU32 evenOdd,
void *data,
int start,
int end );
FX_ENTRY void FX_CALL
grTexDownloadTable( GrTexTable_t type,
void *data );
FX_ENTRY void FX_CALL
grTexDownloadTablePartial( GrTexTable_t type,
void *data,
int start,
int end );
FX_ENTRY void FX_CALL
grTexMipMapMode( GrChipID_t tmu,
GrMipMapMode_t mode,
FxBool lodBlend );
FX_ENTRY void FX_CALL
grTexMultibase( GrChipID_t tmu,
FxBool enable );
FX_ENTRY void FX_CALL
grTexMultibaseAddress( GrChipID_t tmu,
GrTexBaseRange_t range,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info );
/*
** linear frame buffer functions
*/
FX_ENTRY FxBool FX_CALL
grLfbLock( GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode,
GrOriginLocation_t origin, FxBool pixelPipeline,
GrLfbInfo_t *info );
FX_ENTRY FxBool FX_CALL
grLfbUnlock( GrLock_t type, GrBuffer_t buffer );
FX_ENTRY void FX_CALL
grLfbConstantAlpha( GrAlpha_t alpha );
FX_ENTRY void FX_CALL
grLfbConstantDepth( FxU32 depth );
FX_ENTRY void FX_CALL
grLfbWriteColorSwizzle(FxBool swizzleBytes, FxBool swapWords);
FX_ENTRY void FX_CALL
grLfbWriteColorFormat(GrColorFormat_t colorFormat);
FX_ENTRY FxBool FX_CALL
grLfbWriteRegion( GrBuffer_t dst_buffer,
FxU32 dst_x, FxU32 dst_y,
GrLfbSrcFmt_t src_format,
FxU32 src_width, FxU32 src_height,
FxBool pixelPipeline,
FxI32 src_stride, void *src_data );
FX_ENTRY FxBool FX_CALL
grLfbReadRegion( GrBuffer_t src_buffer,
FxU32 src_x, FxU32 src_y,
FxU32 src_width, FxU32 src_height,
FxU32 dst_stride, void *dst_data );
/*
** glide management functions
*/
FX_ENTRY void FX_CALL
grGlideInit( void );
FX_ENTRY void FX_CALL
grGlideShutdown( void );
FX_ENTRY void FX_CALL
grGlideGetState( void *state );
FX_ENTRY void FX_CALL
grGlideSetState( const void *state );
FX_ENTRY void FX_CALL
grGlideGetVertexLayout( void *layout );
FX_ENTRY void FX_CALL
grGlideSetVertexLayout( const void *layout );
#endif /* FX_GLIDE_NO_FUNC_PROTO */
#ifdef __cplusplus
}
#endif
#include <glideutl.h>
#endif /* __GLIDE_H__ */

View File

@ -0,0 +1,160 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
**
** $Header: /cvsroot/glide/glide3x/h5/glide3/src/glidesys.h,v 1.3.4.3 2003/07/24 03:51:08 anholt Exp $
** $Log:
** 3 3dfx 1.0.1.0.1.0 10/11/00 Brent Forced check in to enforce
** branching.
** 2 3dfx 1.0.1.0 06/20/00 Joseph Kain Changes to support the
** Napalm Glide open source release. Changes include cleaned up offensive
** comments and new legal headers.
** 1 3dfx 1.0 09/11/99 StarTeam VTS Administrator
** $
**
** 4 11/05/98 11:18a Russp
** Fix GLIDE_NUM_TMU error check (change "&&" to "||")
**
** 3 7/24/98 1:41p Hohn
**
** 2 6/15/98 10:50a Peter
** made csim compile time option
*
* 1 1/16/98 4:29p Atai
* create glide 3 src
*
* 10 12/09/97 12:20p Peter
* mac glide port
*
* 9 11/04/97 4:00p Dow
* Banshee Mods
*
* 8 8/18/97 3:52p Peter
* pre-hw arrival fixes/cleanup
*
* 7 6/02/97 4:09p Peter
* Compile w/ gcc for Dural
*
* 6 5/27/97 1:16p Peter
* Basic cvg, w/o cmd fifo stuff.
*
* 5 5/21/97 6:05a Peter
*/
#ifndef __GLIDESYS_H__
#define __GLIDESYS_H__
/*
n** -----------------------------------------------------------------------
** COMPILER/ENVIRONMENT CONFIGURATION
** -----------------------------------------------------------------------
*/
/* Endianness is stored in bits [30:31] */
#define GLIDE_ENDIAN_SHIFT 30
#define GLIDE_ENDIAN_LITTLE (0x1 << GLIDE_ENDIAN_SHIFT)
#define GLIDE_ENDIAN_BIG (0x2 << GLIDE_ENDIAN_SHIFT)
/* OS is stored in bits [0:6] */
#define GLIDE_OS_SHIFT 0
#define GLIDE_OS_UNIX 0x1
#define GLIDE_OS_DOS32 0x2
#define GLIDE_OS_WIN32 0x4
#define GLIDE_OS_MACOS 0x8
#define GLIDE_OS_OS2 0x10
#define GLIDE_OS_OTHER 0x40 /* For Proprietary Arcade HW */
/* Sim vs. Hardware is stored in bits [7:8] */
#define GLIDE_SST_SHIFT 7
#define GLIDE_SST_SIM (0x1 << GLIDE_SST_SHIFT)
#define GLIDE_SST_HW (0x2 << GLIDE_SST_SHIFT)
/* Hardware Type is stored in bits [9:13] */
#define GLIDE_HW_SHIFT 9
#define GLIDE_HW_SST1 (0x1 << GLIDE_HW_SHIFT)
#define GLIDE_HW_SST96 (0x2 << GLIDE_HW_SHIFT)
#define GLIDE_HW_H3 (0x4 << GLIDE_HW_SHIFT)
#define GLIDE_HW_SST2 (0x8 << GLIDE_HW_SHIFT)
#define GLIDE_HW_CVG (0x10 << GLIDE_HW_SHIFT)
/*
** Make sure we handle all instances of WIN32
*/
#ifndef __WIN32__
# if defined (_WIN32) || defined (WIN32) || defined(__NT__)
# define __WIN32__
# endif
#endif
/* We need two checks on the OS: one for endian, the other for OS */
/* Check for endianness */
#if defined(__IRIX__) || defined(__sparc__) || defined(MACOS)
# define GLIDE_ENDIAN GLIDE_ENDIAN_BIG
#else
# define GLIDE_ENDIAN GLIDE_ENDIAN_LITTLE
#endif
/* Check for OS */
#if defined(__IRIX__) || defined(__sparc__) || defined(__linux__) || \
defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define GLIDE_OS GLIDE_OS_UNIX
#elif defined(__DOS__)
# define GLIDE_OS GLIDE_OS_DOS32
#elif defined(__WIN32__)
# define GLIDE_OS GLIDE_OS_WIN32
#elif defined(macintosh)
# define GLIDE_OS GLIDE_OS_MACOS
#else
#error "Unknown OS"
#endif
/* Check for Simulator vs. Hardware */
#if HAL_CSIM || HWC_CSIM
# define GLIDE_SST GLIDE_SST_SIM
#else
# define GLIDE_SST GLIDE_SST_HW
#endif
/* Check for type of hardware */
#ifdef SST96
# define GLIDE_HW GLIDE_HW_SST96
#elif defined(H3)
# define GLIDE_HW GLIDE_HW_H3
#elif defined(SST2)
# define GLIDE_HW GLIDE_HW_SST2
#elif defined(CVG)
# define GLIDE_HW GLIDE_HW_CVG
#else /* Default to SST1 */
# define GLIDE_HW GLIDE_HW_SST1
#endif
#define GLIDE_PLATFORM (GLIDE_ENDIAN | GLIDE_OS | GLIDE_SST | GLIDE_HW)
/*
** Control the number of TMUs
*/
#ifndef GLIDE_NUM_TMU
# define GLIDE_NUM_TMU 2
#endif
#if ((GLIDE_NUM_TMU < 0) || (GLIDE_NUM_TMU > 3))
# error "GLIDE_NUM_TMU set to an invalid value"
#endif
#endif /* __GLIDESYS_H__ */

View File

@ -0,0 +1,153 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
**
** $Header: /cvsroot/glide/glide3x/h5/glide3/src/glideutl.h,v 1.3.4.2 2003/06/05 08:23:53 koolsmoky Exp $
** $Log:
** 3 3dfx 1.0.1.0.1.0 10/11/00 Brent Forced check in to enforce
** branching.
** 2 3dfx 1.0.1.0 06/20/00 Joseph Kain Changes to support the
** Napalm Glide open source release. Changes include cleaned up offensive
** comments and new legal headers.
** 1 3dfx 1.0 09/11/99 StarTeam VTS Administrator
** $
**
** 4 7/24/98 1:41p Hohn
**
** 3 1/30/98 4:27p Atai
** gufog* prototype
**
** 1 1/29/98 4:00p Atai
*
* 1 1/16/98 4:29p Atai
* create glide 3 src
*
* 11 1/07/98 11:18a Atai
* remove GrMipMapInfo and GrGC.mm_table in glide3
*
* 10 1/06/98 6:47p Atai
* undo grSplash and remove gu routines
*
* 9 1/05/98 6:04p Atai
* move 3df gu related data structure from glide.h to glideutl.h
*
* 8 12/18/97 2:13p Peter
* fogTable cataclysm
*
* 7 12/15/97 5:52p Atai
* disable obsolete glide2 api for glide3
*
* 6 8/14/97 5:32p Pgj
* remove dead code per GMT
*
* 5 6/12/97 5:19p Pgj
* Fix bug 578
*
* 4 3/05/97 9:36p Jdt
* Removed guFbWriteRegion added guEncodeRLE16
*
* 3 1/16/97 3:45p Dow
* Embedded fn protos in ifndef FX_GLIDE_NO_FUNC_PROTO
*/
/* Glide Utility routines */
#ifndef __GLIDEUTL_H__
#define __GLIDEUTL_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
** 3DF texture file structs
*/
typedef struct
{
FxU32 width, height;
int small_lod, large_lod;
GrAspectRatio_t aspect_ratio;
GrTextureFormat_t format;
} Gu3dfHeader;
typedef struct
{
FxU8 yRGB[16];
FxI16 iRGB[4][3];
FxI16 qRGB[4][3];
FxU32 packed_data[12];
} GuNccTable;
typedef struct {
FxU32 data[256];
} GuTexPalette;
typedef union {
GuNccTable nccTable;
GuTexPalette palette;
} GuTexTable;
typedef struct
{
Gu3dfHeader header;
GuTexTable table;
void *data;
FxU32 mem_required; /* memory required for mip map in bytes. */
} Gu3dfInfo;
#ifndef FX_GLIDE_NO_FUNC_PROTO
/*
** Gamma functions
*/
FX_ENTRY void FX_CALL
guGammaCorrectionRGB( FxFloat red, FxFloat green, FxFloat blue );
/*
** fog stuff
*/
FX_ENTRY float FX_CALL
guFogTableIndexToW( int i );
FX_ENTRY void FX_CALL
guFogGenerateExp( GrFog_t *fogtable, float density );
FX_ENTRY void FX_CALL
guFogGenerateExp2( GrFog_t *fogtable, float density );
FX_ENTRY void FX_CALL
guFogGenerateLinear(GrFog_t *fogtable,
float nearZ, float farZ );
/*
** hi-level texture manipulation tools.
*/
FX_ENTRY FxBool FX_CALL
gu3dfGetInfo( const char *filename, Gu3dfInfo *info );
FX_ENTRY FxBool FX_CALL
gu3dfLoad( const char *filename, Gu3dfInfo *data );
#endif /* FX_GLIDE_NO_FUNC_PROTO */
#ifdef __cplusplus
}
#endif
#endif /* __GLIDEUTL_H__ */

View File

@ -0,0 +1,148 @@
/*
** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY
** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT
** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX
** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE
** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com).
** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A
** FULL TEXT OF THE NON-WARRANTY PROVISIONS.
**
** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO
** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN
** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013,
** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR
** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF
** THE UNITED STATES.
**
** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED
**
** $Header: /cvsroot/glide/glide3x/h5/incsrc/sst1vid.h,v 1.3.4.1 2003/04/06 18:23:10 koolsmoky Exp $
** $Log:
** 7 3dfx 1.4.1.0.1.0 10/11/00 Brent Forced check in to enforce
** branching.
** 6 3dfx 1.4.1.0 06/20/00 Joseph Kain Changes to support the
** Napalm Glide open source release. Changes include cleaned up offensive
** comments and new legal headers.
** 5 3dfx 1.4 12/10/99 Leo Galway Removed previous hi-res
** mode information for Glide3. These modes were only necessary for
** Cornerstone (or future hi-res) support in RT4.2 source branch and
** proceeded to break the V3 and V2 builds (from 3dfx view), hence they have
** been removed.
** 4 3dfx 1.3 12/08/99 Leo Galway Added mode information for
** 1600x1280, 1792x1440, 1920x1080, 1920x1200, 2046x1536 (as a result of
** glide being tested with Cornerstone modes). Although not all of these
** modes are currently capable under Glide, their inclusion prevents Glide
** apps from displaying in incorrect modes when these hi-res modes are
** selected. Search for SUSTAINED_ENGINEERING_CHANGE_BEGIN.
** 3 3dfx 1.2 09/17/99 Jeremy Zelsnack
** 2 3dfx 1.1 09/17/99 Jeremy Zelsnack
** 1 3dfx 1.0 09/11/99 StarTeam VTS Administrator
** $
**
** 8 3/04/99 1:19p Atai
** sync new res modes
**
** 10 2/27/99 12:28p Dow
** new resolutions
**
** 6 2/13/99 1:56p Dow
** Added new resolution constants
**
** 5 7/24/98 1:38p Hohn
*
* 4 9/09/97 7:35p Sellers
* Added 400x300 resolution
*
* 3 8/24/97 9:31a Sellers
* moved new video timing to sst1vid.h
* redefined 1600x1280 to be 1600x1200
*
* 2 6/05/97 11:14p Pgj
*
* 5 7/24/96 3:43p Sellers
* added 512x384 @ 60 Hz for arcade monitors
* added 512x256 @ 60 Hz for arcade monitors
*
* 4 7/18/96 10:58a Sellers
* fixed FT and TF clock delay values for lower frequencies with
* .5/.5 combos
*
* 3 6/18/96 6:54p Sellers
* added sst1InitShutdownSli() to fix Glide Splash screen problems with
* SLI
*
* 2 6/13/96 7:45p Sellers
* added "voodoo.ini" support
* added DirectX support
* misc cleanup
*
* 2 6/11/96 1:43p Sellers
* added support for 60, 75, 85, and 120 Hz refresh rates for "most"
* resolutions
*
* 1 5/08/96 5:43p Paik
* Video definitions
*/
#ifndef __SST1VID_H__
#define __SST1VID_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Video defines */
typedef FxI32 GrScreenRefresh_t;
#define GR_REFRESH_60Hz 0x0
#define GR_REFRESH_70Hz 0x1
#define GR_REFRESH_72Hz 0x2
#define GR_REFRESH_75Hz 0x3
#define GR_REFRESH_80Hz 0x4
#define GR_REFRESH_90Hz 0x5
#define GR_REFRESH_100Hz 0x6
#define GR_REFRESH_85Hz 0x7
#define GR_REFRESH_120Hz 0x8
#define GR_REFRESH_NONE 0xff
typedef FxI32 GrScreenResolution_t;
#define GR_RESOLUTION_320x200 0x0
#define GR_RESOLUTION_320x240 0x1
#define GR_RESOLUTION_400x256 0x2
#define GR_RESOLUTION_512x384 0x3
#define GR_RESOLUTION_640x200 0x4
#define GR_RESOLUTION_640x350 0x5
#define GR_RESOLUTION_640x400 0x6
#define GR_RESOLUTION_640x480 0x7
#define GR_RESOLUTION_800x600 0x8
#define GR_RESOLUTION_960x720 0x9
#define GR_RESOLUTION_856x480 0xa
#define GR_RESOLUTION_512x256 0xb
#define GR_RESOLUTION_1024x768 0xC
#define GR_RESOLUTION_1280x1024 0xD
#define GR_RESOLUTION_1600x1200 0xE
#define GR_RESOLUTION_400x300 0xF
#define GR_RESOLUTION_1152x864 0x10
#define GR_RESOLUTION_1280x960 0x11
#define GR_RESOLUTION_1600x1024 0x12
#define GR_RESOLUTION_1792x1344 0x13
#define GR_RESOLUTION_1856x1392 0x14
#define GR_RESOLUTION_1920x1440 0x15
#define GR_RESOLUTION_2048x1536 0x16
#define GR_RESOLUTION_2048x2048 0x17
#define GR_RESOLUTION_NONE 0xff
#ifdef GR_RESOLUTION_MAX
#undef GR_RESOLUTION_MAX
#endif
#ifdef GR_RESOLUTION_MIN
#undef GR_RESOLUTION_MIN
#endif
#define GR_RESOLUTION_MIN GR_RESOLUTION_320x200
#define GR_RESOLUTION_MAX GR_RESOLUTION_2048x2048
#ifdef __cplusplus
}
#endif
#endif /* __SST1VID_H__ */

View File

@ -0,0 +1,648 @@
#ifndef __wglext_h_
#define __wglext_h_
#ifdef __cplusplus
extern "C" {
#endif
/*
** Copyright (c) 2007 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
** "Materials"), to deal in the Materials without restriction, including
** without limitation the rights to use, copy, modify, merge, publish,
** distribute, sublicense, and/or sell copies of the Materials, and to
** permit persons to whom the Materials are 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 Materials.
**
** THE MATERIALS ARE 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
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
*/
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#endif
#ifndef APIENTRY
#define APIENTRY
#endif
#ifndef APIENTRYP
#define APIENTRYP APIENTRY *
#endif
#ifndef GLAPI
#define GLAPI extern
#endif
/*************************************************************/
/* Header file version number */
/* wglext.h last updated 2007/02/09 */
/* Current version at http://www.opengl.org/registry/ */
#define WGL_WGLEXT_VERSION 9
#ifndef WGL_ARB_buffer_region
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002
#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004
#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008
#endif
#ifndef WGL_ARB_multisample
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif
#ifndef WGL_ARB_extensions_string
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#endif
#ifndef WGL_ARB_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043
#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
#endif
#ifndef WGL_ARB_render_texture
#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070
#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071
#define WGL_TEXTURE_FORMAT_ARB 0x2072
#define WGL_TEXTURE_TARGET_ARB 0x2073
#define WGL_MIPMAP_TEXTURE_ARB 0x2074
#define WGL_TEXTURE_RGB_ARB 0x2075
#define WGL_TEXTURE_RGBA_ARB 0x2076
#define WGL_NO_TEXTURE_ARB 0x2077
#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078
#define WGL_TEXTURE_1D_ARB 0x2079
#define WGL_TEXTURE_2D_ARB 0x207A
#define WGL_MIPMAP_LEVEL_ARB 0x207B
#define WGL_CUBE_MAP_FACE_ARB 0x207C
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080
#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081
#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082
#define WGL_FRONT_LEFT_ARB 0x2083
#define WGL_FRONT_RIGHT_ARB 0x2084
#define WGL_BACK_LEFT_ARB 0x2085
#define WGL_BACK_RIGHT_ARB 0x2086
#define WGL_AUX0_ARB 0x2087
#define WGL_AUX1_ARB 0x2088
#define WGL_AUX2_ARB 0x2089
#define WGL_AUX3_ARB 0x208A
#define WGL_AUX4_ARB 0x208B
#define WGL_AUX5_ARB 0x208C
#define WGL_AUX6_ARB 0x208D
#define WGL_AUX7_ARB 0x208E
#define WGL_AUX8_ARB 0x208F
#define WGL_AUX9_ARB 0x2090
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0
#endif
#ifndef WGL_EXT_make_current_read
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000
#define WGL_DRAW_TO_WINDOW_EXT 0x2001
#define WGL_DRAW_TO_BITMAP_EXT 0x2002
#define WGL_ACCELERATION_EXT 0x2003
#define WGL_NEED_PALETTE_EXT 0x2004
#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005
#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006
#define WGL_SWAP_METHOD_EXT 0x2007
#define WGL_NUMBER_OVERLAYS_EXT 0x2008
#define WGL_NUMBER_UNDERLAYS_EXT 0x2009
#define WGL_TRANSPARENT_EXT 0x200A
#define WGL_TRANSPARENT_VALUE_EXT 0x200B
#define WGL_SHARE_DEPTH_EXT 0x200C
#define WGL_SHARE_STENCIL_EXT 0x200D
#define WGL_SHARE_ACCUM_EXT 0x200E
#define WGL_SUPPORT_GDI_EXT 0x200F
#define WGL_SUPPORT_OPENGL_EXT 0x2010
#define WGL_DOUBLE_BUFFER_EXT 0x2011
#define WGL_STEREO_EXT 0x2012
#define WGL_PIXEL_TYPE_EXT 0x2013
#define WGL_COLOR_BITS_EXT 0x2014
#define WGL_RED_BITS_EXT 0x2015
#define WGL_RED_SHIFT_EXT 0x2016
#define WGL_GREEN_BITS_EXT 0x2017
#define WGL_GREEN_SHIFT_EXT 0x2018
#define WGL_BLUE_BITS_EXT 0x2019
#define WGL_BLUE_SHIFT_EXT 0x201A
#define WGL_ALPHA_BITS_EXT 0x201B
#define WGL_ALPHA_SHIFT_EXT 0x201C
#define WGL_ACCUM_BITS_EXT 0x201D
#define WGL_ACCUM_RED_BITS_EXT 0x201E
#define WGL_ACCUM_GREEN_BITS_EXT 0x201F
#define WGL_ACCUM_BLUE_BITS_EXT 0x2020
#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021
#define WGL_DEPTH_BITS_EXT 0x2022
#define WGL_STENCIL_BITS_EXT 0x2023
#define WGL_AUX_BUFFERS_EXT 0x2024
#define WGL_NO_ACCELERATION_EXT 0x2025
#define WGL_GENERIC_ACCELERATION_EXT 0x2026
#define WGL_FULL_ACCELERATION_EXT 0x2027
#define WGL_SWAP_EXCHANGE_EXT 0x2028
#define WGL_SWAP_COPY_EXT 0x2029
#define WGL_SWAP_UNDEFINED_EXT 0x202A
#define WGL_TYPE_RGBA_EXT 0x202B
#define WGL_TYPE_COLORINDEX_EXT 0x202C
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_DRAW_TO_PBUFFER_EXT 0x202D
#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E
#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F
#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030
#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031
#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032
#define WGL_PBUFFER_LARGEST_EXT 0x2033
#define WGL_PBUFFER_WIDTH_EXT 0x2034
#define WGL_PBUFFER_HEIGHT_EXT 0x2035
#endif
#ifndef WGL_EXT_depth_float
#define WGL_DEPTH_FLOAT_EXT 0x2040
#endif
#ifndef WGL_3DFX_multisample
#define WGL_SAMPLE_BUFFERS_3DFX 0x2060
#define WGL_SAMPLES_3DFX 0x2061
#endif
#ifndef WGL_EXT_multisample
#define WGL_SAMPLE_BUFFERS_EXT 0x2041
#define WGL_SAMPLES_EXT 0x2042
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050
#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051
#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052
#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053
#endif
#ifndef WGL_I3D_gamma
#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E
#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F
#endif
#ifndef WGL_I3D_genlock
#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044
#define WGL_GENLOCK_SOURCE_EXTENAL_SYNC_I3D 0x2045
#define WGL_GENLOCK_SOURCE_EXTENAL_FIELD_I3D 0x2046
#define WGL_GENLOCK_SOURCE_EXTENAL_TTL_I3D 0x2047
#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048
#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049
#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A
#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B
#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001
#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002
#endif
#ifndef WGL_I3D_swap_frame_lock
#endif
#ifndef WGL_NV_render_depth_texture
#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4
#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5
#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6
#define WGL_DEPTH_COMPONENT_NV 0x20A7
#endif
#ifndef WGL_NV_render_texture_rectangle
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1
#define WGL_TEXTURE_RECTANGLE_NV 0x20A2
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0
#endif
#ifndef WGL_NV_float_buffer
#define WGL_FLOAT_COMPONENTS_NV 0x20B0
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3
#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4
#define WGL_TEXTURE_FLOAT_R_NV 0x20B5
#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6
#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7
#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8
#endif
#ifndef WGL_3DL_stereo_control
#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055
#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056
#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057
#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9
#endif
/*************************************************************/
#ifndef WGL_ARB_pbuffer
DECLARE_HANDLE(HPBUFFERARB);
#endif
#ifndef WGL_EXT_pbuffer
DECLARE_HANDLE(HPBUFFEREXT);
#endif
#ifndef WGL_ARB_buffer_region
#define WGL_ARB_buffer_region 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HANDLE WINAPI wglCreateBufferRegionARB (HDC, int, UINT);
extern VOID WINAPI wglDeleteBufferRegionARB (HANDLE);
extern BOOL WINAPI wglSaveBufferRegionARB (HANDLE, int, int, int, int);
extern BOOL WINAPI wglRestoreBufferRegionARB (HANDLE, int, int, int, int, int, int);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType);
typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion);
typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height);
typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc);
#endif
#ifndef WGL_ARB_multisample
#define WGL_ARB_multisample 1
#endif
#ifndef WGL_ARB_extensions_string
#define WGL_ARB_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringARB (HDC);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc);
#endif
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivARB (HDC, int, int, UINT, const int *, int *);
extern BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC, int, int, UINT, const int *, FLOAT *);
extern BOOL WINAPI wglChoosePixelFormatARB (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_ARB_make_current_read
#define WGL_ARB_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentARB (HDC, HDC, HGLRC);
extern HDC WINAPI wglGetCurrentReadDCARB (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void);
#endif
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFERARB WINAPI wglCreatePbufferARB (HDC, int, int, int, const int *);
extern HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB);
extern int WINAPI wglReleasePbufferDCARB (HPBUFFERARB, HDC);
extern BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB);
extern BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB, int, int *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_ARB_render_texture
#define WGL_ARB_render_texture 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglBindTexImageARB (HPBUFFERARB, int);
extern BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB, int);
extern BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB, const int *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer);
typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList);
#endif
#ifndef WGL_ARB_pixel_format_float
#define WGL_ARB_pixel_format_float 1
#endif
#ifndef WGL_EXT_display_color_table
#define WGL_EXT_display_color_table 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort);
extern GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *, GLuint);
extern GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort);
extern VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length);
typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id);
typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id);
#endif
#ifndef WGL_EXT_extensions_string
#define WGL_EXT_extensions_string 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern const char * WINAPI wglGetExtensionsStringEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef const char * (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void);
#endif
#ifndef WGL_EXT_make_current_read
#define WGL_EXT_make_current_read 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglMakeContextCurrentEXT (HDC, HDC, HGLRC);
extern HDC WINAPI wglGetCurrentReadDCEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc);
typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void);
#endif
#ifndef WGL_EXT_pbuffer
#define WGL_EXT_pbuffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC, int, int, int, const int *);
extern HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT);
extern int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT, HDC);
extern BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT);
extern BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT, int, int *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer);
typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC);
typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer);
typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue);
#endif
#ifndef WGL_EXT_pixel_format
#define WGL_EXT_pixel_format 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC, int, int, UINT, int *, int *);
extern BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC, int, int, UINT, int *, FLOAT *);
extern BOOL WINAPI wglChoosePixelFormatEXT (HDC, const int *, const FLOAT *, UINT, int *, UINT *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues);
typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues);
typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats);
#endif
#ifndef WGL_EXT_swap_control
#define WGL_EXT_swap_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglSwapIntervalEXT (int);
extern int WINAPI wglGetSwapIntervalEXT (void);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval);
typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void);
#endif
#ifndef WGL_EXT_depth_float
#define WGL_EXT_depth_float 1
#endif
#ifndef WGL_NV_vertex_array_range
#define WGL_NV_vertex_array_range 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern void* WINAPI wglAllocateMemoryNV (GLsizei, GLfloat, GLfloat, GLfloat);
extern void WINAPI wglFreeMemoryNV (void *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef void* (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer);
#endif
#ifndef WGL_3DFX_multisample
#define WGL_3DFX_multisample 1
#endif
#ifndef WGL_EXT_multisample
#define WGL_EXT_multisample 1
#endif
#ifndef WGL_OML_sync_control
#define WGL_OML_sync_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetSyncValuesOML (HDC, INT64 *, INT64 *, INT64 *);
extern BOOL WINAPI wglGetMscRateOML (HDC, INT32 *, INT32 *);
extern INT64 WINAPI wglSwapBuffersMscOML (HDC, INT64, INT64, INT64);
extern INT64 WINAPI wglSwapLayerBuffersMscOML (HDC, int, INT64, INT64, INT64);
extern BOOL WINAPI wglWaitForMscOML (HDC, INT64, INT64, INT64, INT64 *, INT64 *, INT64 *);
extern BOOL WINAPI wglWaitForSbcOML (HDC, INT64, INT64 *, INT64 *, INT64 *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator);
typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder);
typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc);
typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc);
#endif
#ifndef WGL_I3D_digital_video_control
#define WGL_I3D_digital_video_control 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC, int, int *);
extern BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC, int, const int *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
#endif
#ifndef WGL_I3D_gamma
#define WGL_I3D_gamma 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetGammaTableParametersI3D (HDC, int, int *);
extern BOOL WINAPI wglSetGammaTableParametersI3D (HDC, int, const int *);
extern BOOL WINAPI wglGetGammaTableI3D (HDC, int, USHORT *, USHORT *, USHORT *);
extern BOOL WINAPI wglSetGammaTableI3D (HDC, int, const USHORT *, const USHORT *, const USHORT *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue);
typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue);
typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue);
#endif
#ifndef WGL_I3D_genlock
#define WGL_I3D_genlock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableGenlockI3D (HDC);
extern BOOL WINAPI wglDisableGenlockI3D (HDC);
extern BOOL WINAPI wglIsEnabledGenlockI3D (HDC, BOOL *);
extern BOOL WINAPI wglGenlockSourceI3D (HDC, UINT);
extern BOOL WINAPI wglGetGenlockSourceI3D (HDC, UINT *);
extern BOOL WINAPI wglGenlockSourceEdgeI3D (HDC, UINT);
extern BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC, UINT *);
extern BOOL WINAPI wglGenlockSampleRateI3D (HDC, UINT);
extern BOOL WINAPI wglGetGenlockSampleRateI3D (HDC, UINT *);
extern BOOL WINAPI wglGenlockSourceDelayI3D (HDC, UINT);
extern BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC, UINT *);
extern BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC, UINT *, UINT *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC);
typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge);
typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate);
typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay);
typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay);
typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay);
#endif
#ifndef WGL_I3D_image_buffer
#define WGL_I3D_image_buffer 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern LPVOID WINAPI wglCreateImageBufferI3D (HDC, DWORD, UINT);
extern BOOL WINAPI wglDestroyImageBufferI3D (HDC, LPVOID);
extern BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC, const HANDLE *, const LPVOID *, const DWORD *, UINT);
extern BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC, const LPVOID *, UINT);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags);
typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress);
typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count);
typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count);
#endif
#ifndef WGL_I3D_swap_frame_lock
#define WGL_I3D_swap_frame_lock 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglEnableFrameLockI3D (void);
extern BOOL WINAPI wglDisableFrameLockI3D (void);
extern BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *);
extern BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag);
#endif
#ifndef WGL_I3D_swap_frame_usage
#define WGL_I3D_swap_frame_usage 1
#ifdef WGL_WGLEXT_PROTOTYPES
extern BOOL WINAPI wglGetFrameUsageI3D (float *);
extern BOOL WINAPI wglBeginFrameTrackingI3D (void);
extern BOOL WINAPI wglEndFrameTrackingI3D (void);
extern BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *, DWORD *, float *);
#endif /* WGL_WGLEXT_PROTOTYPES */
typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage);
typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void);
typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage);
#endif
#ifndef WGL_ATI_pixel_format_float
#define WGL_ATI_pixel_format_float 1
#endif
#ifndef WGL_NV_float_buffer
#define WGL_NV_float_buffer 1
#endif
#ifndef WGL_EXT_pixel_format_packed_float
#define WGL_EXT_pixel_format_packed_float 1
#endif
#ifndef WGL_EXT_framebuffer_sRGB
#define WGL_EXT_framebuffer_sRGB 1
#endif
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

2950
Source/Glitch64/main.cpp Normal file

File diff suppressed because it is too large Load Diff

277
Source/Glitch64/main.h Normal file
View File

@ -0,0 +1,277 @@
#ifndef MAIN_H
#define MAIN_H
#ifndef _WIN32
//#define VPDEBUG
#endif
#ifdef VPDEBUG
void dump_tex(int id);
void dump_start();
void dump_stop();
extern int dumping;
#endif
#define zscale 1.0f
typedef struct _wrapper_config
{
int res;
int fbo;
int anisofilter;
int vram_size;
} wrapper_config;
extern wrapper_config config;
// VP added this utility function
// returns the bytes per pixel of a given GR texture format
int grTexFormatSize(int fmt);
extern int packed_pixels_support;
extern int ati_sucks;
extern float largest_supported_anisotropy;
extern int default_texture; // the infamous "32*1024*1024" is now configurable
extern int depth_texture;
void set_depth_shader();
void set_bw_shader();
extern float invtex[2];
extern int buffer_cleared; // mark that the buffer has been cleared, used to check if we need to reload the texture buffer content
#ifdef _WIN32
#include <windows.h>
extern "C" {
#include "gl.h"
#include "glext.h"
#include "wglext.h"
}
#else
#include <stdio.h>
//#define printf(...)
#define GL_GLEXT_PROTOTYPES
#include <SDL_opengl.h>
#endif // _WIN32
#include "glide.h"
void display_warning(const unsigned char *text, ...);
void display_warning(const char *text, ...);
void init_geometry();
void init_textures();
void init_combiner();
void free_textures();
void updateCombiner(int i);
void updateCombinera(int i);
void remove_tex(unsigned int idmin, unsigned int idmax);
void add_tex(unsigned int id);
#ifdef _WIN32
extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
extern PFNGLBLENDFUNCSEPARATEEXTPROC glBlendFuncSeparateEXT;
extern PFNGLFOGCOORDFPROC glFogCoordfEXT;
extern PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB;
extern PFNGLSHADERSOURCEARBPROC glShaderSourceARB;
extern PFNGLCOMPILESHADERARBPROC glCompileShaderARB;
extern PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB;
extern PFNGLATTACHOBJECTARBPROC glAttachObjectARB;
extern PFNGLLINKPROGRAMARBPROC glLinkProgramARB;
extern PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB;
extern PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB;
extern PFNGLUNIFORM1IARBPROC glUniform1iARB;
extern PFNGLUNIFORM4IARBPROC glUniform4iARB;
extern PFNGLUNIFORM4FARBPROC glUniform4fARB;
extern PFNGLUNIFORM1FARBPROC glUniform1fARB;
extern PFNGLDELETEOBJECTARBPROC glDeleteObjectARB;
extern PFNGLGETINFOLOGARBPROC glGetInfoLogARB;
extern PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB;
extern PFNGLSECONDARYCOLOR3FPROC glSecondaryColor3f;
#endif
extern int w_buffer_mode;
extern int nbTextureUnits;
extern int width, height, widtho, heighto;
extern int tex0_width, tex0_height, tex1_width, tex1_height;
extern float texture_env_color[4];
extern int fog_enabled;
extern float lambda;
extern int need_lambda[2];
extern float lambda_color[2][4];
extern int inverted_culling;
extern int culling_mode;
extern int render_to_texture;
extern int lfb_color_fmt;
extern int need_to_compile;
extern int blackandwhite0;
extern int blackandwhite1;
extern int TMU_SIZE;
extern int blend_func_separate_support;
extern int fog_coord_support;
//extern int pbuffer_support;
extern int glsl_support;
extern unsigned int pBufferAddress;
extern int viewport_width, viewport_height, viewport_offset, nvidia_viewport_hack;
extern int UMAmode;
void grChromaRangeExt(GrColor_t color0, GrColor_t color1, FxU32 mode);
void grChromaRangeModeExt(GrChromakeyMode_t mode);
void grTexChromaRangeExt(GrChipID_t tmu, GrColor_t color0, GrColor_t color1, GrTexChromakeyMode_t mode);
void grTexChromaModeExt(GrChipID_t tmu, GrChromakeyMode_t mode);
void updateTexture();
void reloadTexture();
void free_combiners();
void compile_shader();
void set_lambda();
void set_copy_shader();
// config functions
//FX_ENTRY void FX_CALL grConfigWrapperExt(HINSTANCE instance, HWND hwnd);
FX_ENTRY void FX_CALL grConfigWrapperExt(FxI32, FxI32, FxBool, FxBool);
FX_ENTRY GrScreenResolution_t FX_CALL grWrapperFullScreenResolutionExt(FxU32*, FxU32*);
FX_ENTRY char ** FX_CALL grQueryResolutionsExt(FxI32*);
FX_ENTRY FxBool FX_CALL grKeyPressedExt(FxU32 key);
FX_ENTRY void FX_CALL grGetGammaTableExt(FxU32, FxU32*, FxU32*, FxU32*);
int getFullScreenWidth();
int getFullScreenHeight();
// ZIGGY framebuffer copy extension
// allow to copy the depth or color buffer from back/front to front/back
#define GR_FBCOPY_MODE_DEPTH 0
#define GR_FBCOPY_MODE_COLOR 1
#define GR_FBCOPY_BUFFER_BACK 0
#define GR_FBCOPY_BUFFER_FRONT 1
FX_ENTRY void FX_CALL grFramebufferCopyExt(int x, int y, int w, int h,
int buffer_from, int buffer_to, int mode);
// COMBINE extension
typedef FxU32 GrCCUColor_t;
typedef FxU32 GrACUColor_t;
typedef FxU32 GrTCCUColor_t;
typedef FxU32 GrTACUColor_t;
typedef FxU32 GrCombineMode_t;
#define GR_FUNC_MODE_ZERO 0x00
#define GR_FUNC_MODE_X 0x01
#define GR_FUNC_MODE_ONE_MINUS_X 0x02
#define GR_FUNC_MODE_NEGATIVE_X 0x03
#define GR_FUNC_MODE_X_MINUS_HALF 0x04
#define GR_CMBX_ZERO 0x00
#define GR_CMBX_TEXTURE_ALPHA 0x01
#define GR_CMBX_ALOCAL 0x02
#define GR_CMBX_AOTHER 0x03
#define GR_CMBX_B 0x04
#define GR_CMBX_CONSTANT_ALPHA 0x05
#define GR_CMBX_CONSTANT_COLOR 0x06
#define GR_CMBX_DETAIL_FACTOR 0x07
#define GR_CMBX_ITALPHA 0x08
#define GR_CMBX_ITRGB 0x09
#define GR_CMBX_LOCAL_TEXTURE_ALPHA 0x0a
#define GR_CMBX_LOCAL_TEXTURE_RGB 0x0b
#define GR_CMBX_LOD_FRAC 0x0c
#define GR_CMBX_OTHER_TEXTURE_ALPHA 0x0d
#define GR_CMBX_OTHER_TEXTURE_RGB 0x0e
#define GR_CMBX_TEXTURE_RGB 0x0f
#define GR_CMBX_TMU_CALPHA 0x10
#define GR_CMBX_TMU_CCOLOR 0x11
FX_ENTRY void FX_CALL
grColorCombineExt(GrCCUColor_t a, GrCombineMode_t a_mode,
GrCCUColor_t b, GrCombineMode_t b_mode,
GrCCUColor_t c, FxBool c_invert,
GrCCUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert);
FX_ENTRY void FX_CALL
grAlphaCombineExt(GrACUColor_t a, GrCombineMode_t a_mode,
GrACUColor_t b, GrCombineMode_t b_mode,
GrACUColor_t c, FxBool c_invert,
GrACUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert);
FX_ENTRY void FX_CALL
grTexColorCombineExt(GrChipID_t tmu,
GrTCCUColor_t a, GrCombineMode_t a_mode,
GrTCCUColor_t b, GrCombineMode_t b_mode,
GrTCCUColor_t c, FxBool c_invert,
GrTCCUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert);
FX_ENTRY void FX_CALL
grTexAlphaCombineExt(GrChipID_t tmu,
GrTACUColor_t a, GrCombineMode_t a_mode,
GrTACUColor_t b, GrCombineMode_t b_mode,
GrTACUColor_t c, FxBool c_invert,
GrTACUColor_t d, FxBool d_invert,
FxU32 shift, FxBool invert);
FX_ENTRY void FX_CALL
grConstantColorValueExt(GrChipID_t tmu,
GrColor_t value);
#define CHECK_FRAMEBUFFER_STATUS() \
{\
GLenum status; \
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); \
/*display_warning("%x\n", status);*/\
switch(status) { \
case GL_FRAMEBUFFER_COMPLETE_EXT: \
/*display_warning("framebuffer complete!\n");*/\
break; \
case GL_FRAMEBUFFER_UNSUPPORTED_EXT: \
display_warning("framebuffer GL_FRAMEBUFFER_UNSUPPORTED_EXT\n");\
/* you gotta choose different formats */ \
/*assert(0);*/ \
break; \
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT: \
display_warning("framebuffer INCOMPLETE_ATTACHMENT\n");\
break; \
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT: \
display_warning("framebuffer FRAMEBUFFER_MISSING_ATTACHMENT\n");\
break; \
case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT: \
display_warning("framebuffer FRAMEBUFFER_DIMENSIONS\n");\
break; \
/*case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: \
display_warning("framebuffer INCOMPLETE_DUPLICATE_ATTACHMENT\n");\
break;*/ \
case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: \
display_warning("framebuffer INCOMPLETE_FORMATS\n");\
break; \
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: \
display_warning("framebuffer INCOMPLETE_DRAW_BUFFER\n");\
break; \
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: \
display_warning("framebuffer INCOMPLETE_READ_BUFFER\n");\
break; \
case GL_FRAMEBUFFER_BINDING_EXT: \
display_warning("framebuffer BINDING_EXT\n");\
break; \
default: \
break; \
/* programming error; will fail on all hardware */ \
/*assert(0);*/ \
}\
}
#ifdef VPDEBUG
#define LOGGING
#endif
#ifdef LOGGING
void OPEN_LOG();
void CLOSE_LOG();
void LOG(const char *text, ...);
#else // LOGGING
#define OPEN_LOG()
#define CLOSE_LOG()
#define LOG
#endif // LOGGING
#endif

View File

@ -0,0 +1,869 @@
#ifdef _WIN32
#include <windows.h>
#else // _WIN32
#include <stdlib.h>
#endif // _WIN32
#include "glide.h"
#include "main.h"
#include <stdio.h>
/* Napalm extensions to GrTextureFormat_t */
#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
#define GR_TEXFMT_ARGB_8888 0x12
#define GR_TEXFMT_YUYV_422 0x13
#define GR_TEXFMT_UYVY_422 0x14
#define GR_TEXFMT_AYUV_444 0x15
#define GR_TEXFMT_ARGB_CMP_DXT1 0x16
#define GR_TEXFMT_ARGB_CMP_DXT2 0x17
#define GR_TEXFMT_ARGB_CMP_DXT3 0x18
#define GR_TEXFMT_ARGB_CMP_DXT4 0x19
#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A
#define GR_TEXTFMT_RGB_888 0xFF
int TMU_SIZE = 8*2048*2048;
static unsigned char* texture = NULL;
int packed_pixels_support = -1;
int ati_sucks = -1;
float largest_supported_anisotropy = 1.0f;
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#endif
int tex0_width, tex0_height, tex1_width, tex1_height;
float lambda;
static int min_filter0, mag_filter0, wrap_s0, wrap_t0;
static int min_filter1, mag_filter1, wrap_s1, wrap_t1;
unsigned char *filter(unsigned char *source, int width, int height, int *width2, int *height2);
typedef struct _texlist
{
unsigned int id;
struct _texlist *next;
} texlist;
static int nbTex = 0;
static texlist *list = NULL;
#ifdef _WIN32
extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
extern PFNGLDELETEFRAMEBUFFERSEXTPROC glDeleteFramebuffersEXT;
extern PFNGLCOMPRESSEDTEXIMAGE2DARBPROC glCompressedTexImage2DARB;
#endif
void remove_tex(unsigned int idmin, unsigned int idmax)
{
unsigned int *t;
int n = 0;
texlist *aux = list;
int sz = nbTex;
if (aux == NULL) return;
t = (unsigned int*)malloc(sz * sizeof(int));
while (aux && aux->id >= idmin && aux->id < idmax)
{
if (n >= sz)
t = (unsigned int *) realloc(t, ++sz*sizeof(int));
t[n++] = aux->id;
aux = aux->next;
free(list);
list = aux;
nbTex--;
}
while (aux != NULL && aux->next != NULL)
{
if (aux->next->id >= idmin && aux->next->id < idmax)
{
texlist *aux2 = aux->next->next;
if (n >= sz)
t = (unsigned int *) realloc(t, ++sz*sizeof(int));
t[n++] = aux->next->id;
free(aux->next);
aux->next = aux2;
nbTex--;
}
aux = aux->next;
}
glDeleteTextures(n, t);
free(t);
//printf("RMVTEX nbtex is now %d (%06x - %06x)\n", nbTex, idmin, idmax);
}
void add_tex(unsigned int id)
{
texlist *aux = list;
texlist *aux2;
//printf("ADDTEX nbtex is now %d (%06x)\n", nbTex, id);
if (list == NULL || id < list->id)
{
nbTex++;
list = (texlist*)malloc(sizeof(texlist));
list->next = aux;
list->id = id;
return;
}
while (aux->next != NULL && aux->next->id < id) aux = aux->next;
// ZIGGY added this test so that add_tex now accept re-adding an existing texture
if (aux->next != NULL && aux->next->id == id) return;
nbTex++;
aux2 = aux->next;
aux->next = (texlist*)malloc(sizeof(texlist));
aux->next->id = id;
aux->next->next = aux2;
}
void init_textures()
{
tex0_width = tex0_height = tex1_width = tex1_height = 2;
// ZIGGY because remove_tex isn't called (Pj64 doesn't like it), it's better
// to leave these so that they'll be reused (otherwise we have a memory leak)
// list = NULL;
// nbTex = 0;
if (!texture) texture = (unsigned char*)malloc(2048*2048*4);
}
void free_textures()
{
#ifndef WIN32
// ZIGGY for some reasons, Pj64 doesn't like remove_tex on exit
remove_tex(0x00000000, 0xFFFFFFFF);
#endif
if (texture != NULL) {
free(texture);
texture = NULL;
}
}
FX_ENTRY FxU32 FX_CALL
grTexMinAddress( GrChipID_t tmu )
{
LOG("grTexMinAddress(%d)\r\n", tmu);
if (UMAmode)
return 0;
else
return tmu*TMU_SIZE;
}
FX_ENTRY FxU32 FX_CALL
grTexMaxAddress( GrChipID_t tmu )
{
LOG("grTexMaxAddress(%d)\r\n", tmu);
if (UMAmode)
return TMU_SIZE*2 - 1;
else
return tmu*TMU_SIZE + TMU_SIZE - 1;
}
FX_ENTRY FxU32 FX_CALL
grTexTextureMemRequired( FxU32 evenOdd,
GrTexInfo *info )
{
int width, height;
LOG("grTextureMemRequired(%d)\r\n", evenOdd);
if (info->largeLodLog2 != info->smallLodLog2) display_warning("grTexTextureMemRequired : loading more than one LOD");
if (info->aspectRatioLog2 < 0)
{
height = 1 << info->largeLodLog2;
width = height >> -info->aspectRatioLog2;
}
else
{
width = 1 << info->largeLodLog2;
height = width >> info->aspectRatioLog2;
}
switch(info->format)
{
case GR_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8: // I8 support - H.Morii
case GR_TEXFMT_ALPHA_INTENSITY_44:
return width*height;
break;
case GR_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_4444:
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_RGB_565:
return (width*height)<<1;
break;
case GR_TEXFMT_ARGB_8888:
return (width*height)<<2;
break;
case GR_TEXFMT_ARGB_CMP_DXT1: // FXT1,DXT1,5 support - H.Morii
return ((((width+0x3)&~0x3)*((height+0x3)&~0x3))>>1);
case GR_TEXFMT_ARGB_CMP_DXT3:
return ((width+0x3)&~0x3)*((height+0x3)&~0x3);
case GR_TEXFMT_ARGB_CMP_DXT5:
return ((width+0x3)&~0x3)*((height+0x3)&~0x3);
case GR_TEXFMT_ARGB_CMP_FXT1:
return ((((width+0x7)&~0x7)*((height+0x3)&~0x3))>>1);
default:
display_warning("grTexTextureMemRequired : unknown texture format: %x", info->format);
}
return 0;
}
FX_ENTRY FxU32 FX_CALL
grTexCalcMemRequired(
GrLOD_t lodmin, GrLOD_t lodmax,
GrAspectRatio_t aspect, GrTextureFormat_t fmt)
{
int width, height;
LOG("grTexCalcMemRequired(%d, %d, %d, %d)\r\n", lodmin, lodmax, aspect, fmt);
if (lodmax != lodmin) display_warning("grTexCalcMemRequired : loading more than one LOD");
if (aspect < 0)
{
height = 1 << lodmax;
width = height >> -aspect;
}
else
{
width = 1 << lodmax;
height = width >> aspect;
}
switch(fmt)
{
case GR_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8: // I8 support - H.Morii
case GR_TEXFMT_ALPHA_INTENSITY_44:
return width*height;
break;
case GR_TEXFMT_ARGB_1555:
case GR_TEXFMT_ARGB_4444:
case GR_TEXFMT_ALPHA_INTENSITY_88:
case GR_TEXFMT_RGB_565:
return (width*height)<<1;
break;
case GR_TEXFMT_ARGB_8888:
return (width*height)<<2;
break;
case GR_TEXFMT_ARGB_CMP_DXT1: // FXT1,DXT1,5 support - H.Morii
return ((((width+0x3)&~0x3)*((height+0x3)&~0x3))>>1);
case GR_TEXFMT_ARGB_CMP_DXT3:
return ((width+0x3)&~0x3)*((height+0x3)&~0x3);
case GR_TEXFMT_ARGB_CMP_DXT5:
return ((width+0x3)&~0x3)*((height+0x3)&~0x3);
case GR_TEXFMT_ARGB_CMP_FXT1:
return ((((width+0x7)&~0x7)*((height+0x3)&~0x3))>>1);
default:
display_warning("grTexTextureMemRequired : unknown texture format: %x", fmt);
}
return 0;
}
int grTexFormatSize(int fmt)
{
int factor = -1;
switch(fmt) {
case GR_TEXFMT_ALPHA_8:
case GR_TEXFMT_INTENSITY_8: // I8 support - H.Morii
factor = 1;
break;
case GR_TEXFMT_ALPHA_INTENSITY_44:
factor = 1;
break;
case GR_TEXFMT_RGB_565:
factor = 2;
break;
case GR_TEXFMT_ARGB_1555:
factor = 2;
break;
case GR_TEXFMT_ALPHA_INTENSITY_88:
factor = 2;
break;
case GR_TEXFMT_ARGB_4444:
factor = 2;
break;
case GR_TEXFMT_ARGB_8888:
factor = 4;
break;
case GR_TEXFMT_ARGB_CMP_DXT1: // FXT1,DXT1,5 support - H.Morii
factor = 8; // HACKALERT: factor holds block bytes
break;
case GR_TEXFMT_ARGB_CMP_DXT3: // FXT1,DXT1,5 support - H.Morii
factor = 16; // HACKALERT: factor holds block bytes
break;
case GR_TEXFMT_ARGB_CMP_DXT5:
factor = 16;
break;
case GR_TEXFMT_ARGB_CMP_FXT1:
factor = 8;
break;
default:
display_warning("grTexFormatSize : unknown texture format: %x", fmt);
}
return factor;
}
int grTexFormat2GLPackedFmt(int fmt, int * gltexfmt, int * glpixfmt, int * glpackfmt)
{
int factor = -1;
switch(fmt) {
case GR_TEXFMT_ALPHA_8:
factor = 1;
*gltexfmt = GL_INTENSITY8;
*glpixfmt = GL_LUMINANCE;
*glpackfmt = GL_UNSIGNED_BYTE;
break;
case GR_TEXFMT_INTENSITY_8: // I8 support - H.Morii
factor = 1;
*gltexfmt = GL_LUMINANCE8;
*glpixfmt = GL_LUMINANCE;
*glpackfmt = GL_UNSIGNED_BYTE;
break;
case GR_TEXFMT_ALPHA_INTENSITY_44:
break;
case GR_TEXFMT_RGB_565:
factor = 2;
*gltexfmt = GL_RGB;
*glpixfmt = GL_RGB;
*glpackfmt = GL_UNSIGNED_SHORT_5_6_5;
break;
case GR_TEXFMT_ARGB_1555:
if (ati_sucks > 0) return -1; // ATI sucks as usual (fixes slowdown on ATI)
factor = 2;
*gltexfmt = GL_RGB5_A1;
*glpixfmt = GL_BGRA;
*glpackfmt = GL_UNSIGNED_SHORT_1_5_5_5_REV;
break;
case GR_TEXFMT_ALPHA_INTENSITY_88:
factor = 2;
*gltexfmt = GL_LUMINANCE8_ALPHA8;
*glpixfmt = GL_LUMINANCE_ALPHA;
*glpackfmt = GL_UNSIGNED_BYTE;
break;
case GR_TEXFMT_ARGB_4444:
factor = 2;
*gltexfmt = GL_RGBA4;
*glpixfmt = GL_BGRA;
*glpackfmt = GL_UNSIGNED_SHORT_4_4_4_4_REV;
break;
case GR_TEXFMT_ARGB_8888:
factor = 4;
*gltexfmt = GL_RGBA8;
*glpixfmt = GL_BGRA;
*glpackfmt = GL_UNSIGNED_INT_8_8_8_8_REV;
break;
case GR_TEXFMT_ARGB_CMP_DXT1: // FXT1,DXT1,5 support - H.Morii
// HACKALERT: 3Dfx Glide uses GR_TEXFMT_ARGB_CMP_DXT1 for both opaque DXT1 and DXT1 with 1bit alpha.
// GlideHQ compiled with GLIDE64_DXTN option enabled, uses opaqe DXT1 only.
factor = 8; // HACKALERT: factor holds block bytes
*gltexfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT; // these variables aren't used
*glpixfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
*glpackfmt = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
break;
case GR_TEXFMT_ARGB_CMP_DXT3:
factor = 16;
*gltexfmt = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
*glpixfmt = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
*glpackfmt = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
break;
case GR_TEXFMT_ARGB_CMP_DXT5:
factor = 16;
*gltexfmt = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
*glpixfmt = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
*glpackfmt = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break;
case GR_TEXFMT_ARGB_CMP_FXT1:
factor = 8;
*gltexfmt = GL_COMPRESSED_RGBA_FXT1_3DFX;
*glpixfmt = GL_COMPRESSED_RGBA_FXT1_3DFX;
*glpackfmt = GL_COMPRESSED_RGBA_FXT1_3DFX; // XXX: what should we do about GL_COMPRESSED_RGB_FXT1_3DFX?
break;
default:
display_warning("grTexFormat2GLPackedFmt : unknown texture format: %x", fmt);
}
return factor;
}
FX_ENTRY void FX_CALL
grTexDownloadMipMap( GrChipID_t tmu,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info )
{
int width, height, i, j;
int factor;
int glformat = 0;
int gltexfmt, glpixfmt, glpackfmt;
LOG("grTexDownloadMipMap(%d,%d,%d)\r\n", tmu, startAddress, evenOdd);
if (info->largeLodLog2 != info->smallLodLog2) display_warning("grTexDownloadMipMap : loading more than one LOD");
if (info->aspectRatioLog2 < 0)
{
height = 1 << info->largeLodLog2;
width = height >> -info->aspectRatioLog2;
}
else
{
width = 1 << info->largeLodLog2;
height = width >> info->aspectRatioLog2;
}
if (!packed_pixels_support)
factor = -1;
else
factor = grTexFormat2GLPackedFmt(info->format, &gltexfmt, &glpixfmt, &glpackfmt);
if (factor < 0) {
// VP fixed the texture conversions to be more accurate, also swapped
// the for i/j loops so that is is less likely to break the memory cache
register int n = 0, m = 0;
switch(info->format)
{
case GR_TEXFMT_ALPHA_8:
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = (unsigned int)((unsigned char*)info->data)[m];
texel |= (texel << 8);
texel |= (texel << 16);
((unsigned int*)texture)[n] = texel;
m++;
n++;
}
}
factor = 1;
glformat = GL_INTENSITY8;
break;
case GR_TEXFMT_INTENSITY_8: // I8 support - H.Morii
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = (unsigned int)((unsigned char*)info->data)[m];
texel |= (0xFF000000 | (texel << 16) | (texel << 8));
((unsigned int*)texture)[n] = texel;
m++;
n++;
}
}
factor = 1;
glformat = GL_LUMINANCE8;
break;
case GR_TEXFMT_ALPHA_INTENSITY_44:
#if 1
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = (unsigned int)((unsigned char*)info->data)[m];
#if 1
/* accurate conversion */
unsigned int texel_hi = (texel & 0x000000F0) << 20;
unsigned int texel_low = texel & 0x0000000F;
texel_low |= (texel_low << 4);
texel_hi |= ((texel_hi << 4) | (texel_low << 16) | (texel_low << 8) | texel_low);
#else
unsigned int texel_hi = (texel & 0x000000F0) << 24;
unsigned int texel_low = (texel & 0x0000000F) << 4;
texel_hi |= ((texel_low << 16) | (texel_low << 8) | texel_low);
#endif
((unsigned int*)texture)[n] = texel_hi;
m++;
n++;
}
}
factor = 1;
glformat = GL_LUMINANCE4_ALPHA4;
#endif
break;
case GR_TEXFMT_RGB_565:
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = (unsigned int)((unsigned short*)info->data)[m];
unsigned int B = texel & 0x0000F800;
unsigned int G = texel & 0x000007E0;
unsigned int R = texel & 0x0000001F;
#if 0
/* accurate conversion */
((unsigned int*)texture)[n] = 0xFF000000 | (R << 19) | ((R >> 2) << 16) | (G << 5) | ((G >> 9) << 8) | (B >> 8) | (B >> 13);
#else
((unsigned int*)texture)[n] = 0xFF000000 | (R << 19) | (G << 5) | (B >> 8);
#endif
m++;
n++;
}
}
factor = 2;
glformat = GL_RGB;
break;
case GR_TEXFMT_ARGB_1555:
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = (unsigned int)((unsigned short*)info->data)[m];
unsigned int A = texel & 0x00008000 ? 0xFF000000 : 0;
unsigned int B = texel & 0x00007C00;
unsigned int G = texel & 0x000003E0;
unsigned int R = texel & 0x0000001F;
#if 0
/* accurate conversion */
((unsigned int*)texture)[n] = A | (R << 19) | ((R >> 2) << 16) | (G << 6) | ((G >> 8) << 8) | (B >> 7) | (B >> 12);
#else
((unsigned int*)texture)[n] = A | (R << 19) | (G << 6) | (B >> 7);
#endif
m++;
n++;
}
}
factor = 2;
glformat = GL_RGB5_A1;
break;
case GR_TEXFMT_ALPHA_INTENSITY_88:
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int AI = (unsigned int)((unsigned short*)info->data)[m];
unsigned int I = (unsigned int)(AI & 0x000000FF);
((unsigned int*)texture)[n] = (AI << 16) | (I << 8) | I;
m++;
n++;
}
}
factor = 2;
glformat = GL_LUMINANCE8_ALPHA8;
break;
case GR_TEXFMT_ARGB_4444:
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = (unsigned int)((unsigned short*)info->data)[m];
unsigned int A = texel & 0x0000F000;
unsigned int B = texel & 0x00000F00;
unsigned int G = texel & 0x000000F0;
unsigned int R = texel & 0x0000000F;
#if 0
/* accurate conversion */
((unsigned int*)texture)[n] = (A << 16) | (A << 12) | (R << 20) | (R << 16) | (G << 8) | (G << 4) | (B >> 4) | (B >> 8);
#else
((unsigned int*)texture)[n] = (A << 16) | (R << 20) | (G << 8) | (B >> 4);
#endif
m++;
n++;
}
}
factor = 2;
glformat = GL_RGBA4;
break;
case GR_TEXFMT_ARGB_8888:
for (i=0; i<height; i++)
{
for (j=0; j<width; j++)
{
unsigned int texel = ((unsigned int*)info->data)[m];
unsigned int A = texel & 0xFF000000;
unsigned int B = texel & 0x00FF0000;
unsigned int G = texel & 0x0000FF00;
unsigned int R = texel & 0x000000FF;
((unsigned int*)texture)[n] = A | (R << 16) | G | (B >> 16);
m++;
n++;
}
}
factor = 4;
glformat = GL_RGBA8;
break;
case GR_TEXFMT_ARGB_CMP_DXT1: // FXT1,DXT1,5 support - H.Morii
factor = 8; // HACKALERT: factor holds block bytes
glformat = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
break;
case GR_TEXFMT_ARGB_CMP_DXT3: // FXT1,DXT1,5 support - H.Morii
factor = 16; // HACKALERT: factor holds block bytes
glformat = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
break;
case GR_TEXFMT_ARGB_CMP_DXT5:
factor = 16;
glformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
break;
case GR_TEXFMT_ARGB_CMP_FXT1:
factor = 8;
glformat = GL_COMPRESSED_RGBA_FXT1_3DFX;
break;
default:
display_warning("grTexDownloadMipMap : unknown texture format: %x", info->format);
factor = 0;
}
}
if (nbTextureUnits <= 2)
glActiveTextureARB(GL_TEXTURE1_ARB);
else
glActiveTextureARB(GL_TEXTURE2_ARB);
switch(info->format)
{
case GR_TEXFMT_ARGB_CMP_DXT1:
case GR_TEXFMT_ARGB_CMP_DXT3:
case GR_TEXFMT_ARGB_CMP_DXT5:
case GR_TEXFMT_ARGB_CMP_FXT1:
remove_tex(startAddress+1, startAddress+1+((width*height*factor)>>4));
break;
default:
remove_tex(startAddress+1, startAddress+1+(width*height*factor));
}
add_tex(startAddress+1);
glBindTexture(GL_TEXTURE_2D, startAddress+1);
if (largest_supported_anisotropy > 1.0f)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);
switch(info->format)
{
case GR_TEXFMT_ARGB_CMP_DXT1:
case GR_TEXFMT_ARGB_CMP_DXT3:
case GR_TEXFMT_ARGB_CMP_DXT5:
case GR_TEXFMT_ARGB_CMP_FXT1:
glCompressedTexImage2DARB(GL_TEXTURE_2D, 0, (glformat ? glformat : gltexfmt), width, height, 0, (width*height*factor)>>4, info->data);
break;
default:
if (glformat) {
glTexImage2D(GL_TEXTURE_2D, 0, glformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
} else
glTexImage2D(GL_TEXTURE_2D, 0, gltexfmt, width, height, 0, glpixfmt, glpackfmt, info->data);
}
glBindTexture(GL_TEXTURE_2D, default_texture);
}
int CheckTextureBufferFormat(GrChipID_t tmu, FxU32 startAddress, GrTexInfo *info );
FX_ENTRY void FX_CALL
grTexSource( GrChipID_t tmu,
FxU32 startAddress,
FxU32 evenOdd,
GrTexInfo *info )
{
LOG("grTexSource(%d,%d,%d)\r\n", tmu, startAddress, evenOdd);
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
{
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
glActiveTextureARB(GL_TEXTURE0_ARB);
if (info->aspectRatioLog2 < 0)
{
tex0_height = 256;
tex0_width = tex0_height >> -info->aspectRatioLog2;
}
else
{
tex0_width = 256;
tex0_height = tex0_width >> info->aspectRatioLog2;
}
glBindTexture(GL_TEXTURE_2D, startAddress+1);
#ifdef VPDEBUG
dump_tex(startAddress+1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t0);
}
else
{
glActiveTextureARB(GL_TEXTURE1_ARB);
if (info->aspectRatioLog2 < 0)
{
tex1_height = 256;
tex1_width = tex1_height >> -info->aspectRatioLog2;
}
else
{
tex1_width = 256;
tex1_height = tex1_width >> info->aspectRatioLog2;
}
glBindTexture(GL_TEXTURE_2D, startAddress+1);
#ifdef VPDEBUG
dump_tex(startAddress+1);
#endif
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t1);
}
if(!CheckTextureBufferFormat(tmu, startAddress+1, info))
{
if(tmu == 0 && blackandwhite1 != 0)
{
blackandwhite1 = 0;
need_to_compile = 1;
}
if(tmu == 1 && blackandwhite0 != 0)
{
blackandwhite0 = 0;
need_to_compile = 1;
}
}
#if 0
extern int auxbuffer;
static int oldbuffer;
FX_ENTRY void FX_CALL grAuxBufferExt( GrBuffer_t buffer );
if (auxbuffer == GR_BUFFER_AUXBUFFER && auxbuffer != oldbuffer)
grAuxBufferExt(auxbuffer);
oldbuffer = auxbuffer;
#endif
}
FX_ENTRY void FX_CALL
grTexDetailControl(
GrChipID_t tmu,
int lod_bias,
FxU8 detail_scale,
float detail_max
)
{
LOG("grTexDetailControl(%d,%d,%d,%d)\r\n", tmu, lod_bias, detail_scale, detail_max);
if (lod_bias != 31 && detail_scale != 7)
{
if (!lod_bias && !detail_scale && !detail_max) return;
else
display_warning("grTexDetailControl : %d, %d, %f", lod_bias, detail_scale, detail_max);
}
lambda = detail_max;
if(lambda > 1.0f)
{
lambda = 1.0f - (255.0f - lambda);
}
if(lambda > 1.0f) display_warning("lambda:%f", lambda);
set_lambda();
}
FX_ENTRY void FX_CALL
grTexLodBiasValue(GrChipID_t tmu, float bias )
{
LOG("grTexLodBiasValue(%d,%f)\r\n", tmu, bias);
}
FX_ENTRY void FX_CALL
grTexFilterMode(
GrChipID_t tmu,
GrTextureFilterMode_t minfilter_mode,
GrTextureFilterMode_t magfilter_mode
)
{
LOG("grTexFilterMode(%d,%d,%d)\r\n", tmu, minfilter_mode, magfilter_mode);
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
{
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
if (minfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) min_filter0 = GL_NEAREST;
else min_filter0 = GL_LINEAR;
if (magfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) mag_filter0 = GL_NEAREST;
else mag_filter0 = GL_LINEAR;
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter0);
}
else
{
if (minfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) min_filter1 = GL_NEAREST;
else min_filter1 = GL_LINEAR;
if (magfilter_mode == GR_TEXTUREFILTER_POINT_SAMPLED) mag_filter1 = GL_NEAREST;
else mag_filter1 = GL_LINEAR;
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mag_filter1);
}
}
FX_ENTRY void FX_CALL
grTexClampMode(
GrChipID_t tmu,
GrTextureClampMode_t s_clampmode,
GrTextureClampMode_t t_clampmode
)
{
LOG("grTexClampMode(%d, %d, %d)\r\n", tmu, s_clampmode, t_clampmode);
if (tmu == GR_TMU1 || nbTextureUnits <= 2)
{
if (tmu == GR_TMU1 && nbTextureUnits <= 2) return;
switch(s_clampmode)
{
case GR_TEXTURECLAMP_WRAP:
wrap_s0 = GL_REPEAT;
break;
case GR_TEXTURECLAMP_CLAMP:
wrap_s0 = GL_CLAMP_TO_EDGE;
break;
case GR_TEXTURECLAMP_MIRROR_EXT:
wrap_s0 = GL_MIRRORED_REPEAT_ARB;
break;
default:
display_warning("grTexClampMode : unknown s_clampmode : %x", s_clampmode);
}
switch(t_clampmode)
{
case GR_TEXTURECLAMP_WRAP:
wrap_t0 = GL_REPEAT;
break;
case GR_TEXTURECLAMP_CLAMP:
wrap_t0 = GL_CLAMP_TO_EDGE;
break;
case GR_TEXTURECLAMP_MIRROR_EXT:
wrap_t0 = GL_MIRRORED_REPEAT_ARB;
break;
default:
display_warning("grTexClampMode : unknown t_clampmode : %x", t_clampmode);
}
glActiveTextureARB(GL_TEXTURE0_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t0);
}
else
{
switch(s_clampmode)
{
case GR_TEXTURECLAMP_WRAP:
wrap_s1 = GL_REPEAT;
break;
case GR_TEXTURECLAMP_CLAMP:
wrap_s1 = GL_CLAMP_TO_EDGE;
break;
case GR_TEXTURECLAMP_MIRROR_EXT:
wrap_s1 = GL_MIRRORED_REPEAT_ARB;
break;
default:
display_warning("grTexClampMode : unknown s_clampmode : %x", s_clampmode);
}
switch(t_clampmode)
{
case GR_TEXTURECLAMP_WRAP:
wrap_t1 = GL_REPEAT;
break;
case GR_TEXTURECLAMP_CLAMP:
wrap_t1 = GL_CLAMP_TO_EDGE;
break;
case GR_TEXTURECLAMP_MIRROR_EXT:
wrap_t1 = GL_MIRRORED_REPEAT_ARB;
break;
default:
display_warning("grTexClampMode : unknown t_clampmode : %x", t_clampmode);
}
glActiveTextureARB(GL_TEXTURE1_ARB);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap_s1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_t1);
}
}

114
Source/Glitch64/vram.cpp Normal file
View File

@ -0,0 +1,114 @@
#include <stdio.h>
#ifdef _WIN32 //Windows, duh!
#include <objbase.h>
#include "dxdiag.h"
#include "main.h"
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "dxguid.lib")
#define SAFE_RELEASE(x) { if (x != NULL) { x->Release(); x = NULL; } }
IDxDiagProvider* Provider;
IDxDiagContainer* RootContainer;
bool ComInitialized;
static void InitCom()
{
try
{
Provider = NULL;
RootContainer = NULL;
// Init COM
ComInitialized = SUCCEEDED(CoInitialize(NULL));
// Create a provider interface
if (FAILED(CoCreateInstance(CLSID_DxDiagProvider, NULL, CLSCTX_INPROC_SERVER, IID_IDxDiagProvider, (void**)&Provider)))
throw "Unable to create provider instance";
// Initialize the provider
DXDIAG_INIT_PARAMS initParams;
ZeroMemory(&initParams, sizeof(DXDIAG_INIT_PARAMS));
initParams.dwSize = sizeof(DXDIAG_INIT_PARAMS);
initParams.dwDxDiagHeaderVersion = DXDIAG_DX9_SDK_VERSION;
if (FAILED(Provider->Initialize(&initParams)))
throw "Unable to initialize provider";
// Get the root container
if (FAILED(Provider->GetRootContainer(&RootContainer)))
throw "Unable to get root container";
}
catch (const char* msg)
{
LOG("\nDxDiag Error: %s", msg);
}
}
static IDxDiagContainer* GetContainer(IDxDiagContainer* parent, const WCHAR* name)
{
IDxDiagContainer* container;
if (SUCCEEDED(parent->GetChildContainer(name, &container)))
return container;
return NULL;
}
static void GetPropertyValue(IDxDiagContainer* container, const WCHAR* name, WCHAR* value, int maxValueLen)
{
VARIANT var;
VariantInit(&var);
if (SUCCEEDED(container->GetProp(name, &var)))
{
// Assuming an integer or bstring value here
// @@ Handle all the VT_* types properly...
if (var.vt != VT_BSTR)
wsprintf((LPSTR)value, "%i", var.iVal);
else
wcsncpy(value, var.bstrVal, maxValueLen - 1);
value[maxValueLen - 1] = 0;
VariantClear(&var);
}
else
{
value[0] = 0;
}
}
static int GetTotalVideoMemory()
{
if (RootContainer != NULL)
{
// Get device container
IDxDiagContainer* container = GetContainer(RootContainer, L"DxDiag_DisplayDevices");
if (container != NULL)
{
// Get device name
container = GetContainer(container, L"0");
if (container != NULL)
{
const int bufferLength = 256;
WCHAR buffer[bufferLength];
GetPropertyValue(container, L"szDisplayMemoryLocalized", buffer, bufferLength);
// Value in MB is first token in string
return _wtoi(buffer);
}
}
}
// No good!
return -1;
}
int getVRAMSize()
{
static int mem;
if (!mem) {
InitCom();
mem = GetTotalVideoMemory();
}
return mem * 1024 * 1024;
}
#endif