├── platform ├── CVS │ ├── Repository │ ├── Root │ ├── Entries.Log │ └── Entries ├── linux │ ├── CVS │ │ ├── Repository │ │ ├── Root │ │ └── Entries │ ├── Makefile.am │ ├── error.cpp │ ├── library.cpp │ ├── openglext.cpp │ ├── clock.cpp │ └── platform.h ├── sdl │ ├── CVS │ │ ├── Repository │ │ ├── Root │ │ └── Entries │ ├── Makefile.am │ ├── openglext.cpp │ └── window.cpp ├── dosemu │ ├── CVS │ │ ├── Repository │ │ ├── Root │ │ └── Entries │ ├── glide2x.ovl │ ├── linux_tombraider_openglide.jpeg │ ├── glide2x.h │ └── built.txt ├── windows │ ├── CVS │ │ ├── Repository │ │ ├── Root │ │ └── Entries │ ├── Makefile.am │ ├── openglext.cpp │ ├── error.cpp │ ├── platform.h │ ├── clock.cpp │ ├── library.cpp │ └── window.cpp ├── Makefile.am ├── clock.h ├── error.h ├── openglext.h └── window.h ├── Glide2x.rc ├── grguTex.cpp ├── autogen.sh ├── bootstrap ├── wrapper_config.h ├── resource.h ├── README.md ├── OpenGLid.ini ├── Glide2x.dsw ├── Glide2x.sln ├── FormatConversion.h ├── OGLTables.h ├── OGLMiscTables.cpp ├── TexDB.h ├── Makefile.am ├── OGLFogTables.cpp ├── sdk2_unix.h.in ├── Glextensions.h ├── PGUTexture.h ├── PGTexture.h ├── configure.ac ├── sdk2_3dfx.h ├── sdk2_sst1vid.h ├── grguBuffer.cpp ├── sdk2_glidesys.h ├── gbanner.cpp ├── grguDepth.cpp ├── sdk2_glideutl.h ├── Glide.cpp ├── TexDB.cpp ├── Glide2x.def ├── GLRender.h ├── grguFog.cpp ├── acinclude.m4 ├── PGUTexture.cpp ├── Glide2x.vcproj ├── grguDraw.cpp ├── grguMisc.cpp ├── grgu3df.cpp ├── grguLfb.cpp ├── GlOgl.h └── LICENSE /platform/CVS/Repository: -------------------------------------------------------------------------------- 1 | openglide/platform 2 | -------------------------------------------------------------------------------- /platform/linux/CVS/Repository: -------------------------------------------------------------------------------- 1 | openglide/platform/linux 2 | -------------------------------------------------------------------------------- /platform/sdl/CVS/Repository: -------------------------------------------------------------------------------- 1 | openglide/platform/sdl 2 | -------------------------------------------------------------------------------- /platform/dosemu/CVS/Repository: -------------------------------------------------------------------------------- 1 | openglide/platform/dosemu 2 | -------------------------------------------------------------------------------- /platform/windows/CVS/Repository: -------------------------------------------------------------------------------- 1 | openglide/platform/windows 2 | -------------------------------------------------------------------------------- /Glide2x.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcbarros/openglide/HEAD/Glide2x.rc -------------------------------------------------------------------------------- /grguTex.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcbarros/openglide/HEAD/grguTex.cpp -------------------------------------------------------------------------------- /platform/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@openglide.cvs.sourceforge.net:/cvsroot/openglide 2 | -------------------------------------------------------------------------------- /platform/sdl/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@openglide.cvs.sourceforge.net:/cvsroot/openglide 2 | -------------------------------------------------------------------------------- /platform/CVS/Entries.Log: -------------------------------------------------------------------------------- 1 | A D/dosemu//// 2 | A D/linux//// 3 | A D/sdl//// 4 | A D/windows//// 5 | -------------------------------------------------------------------------------- /platform/dosemu/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@openglide.cvs.sourceforge.net:/cvsroot/openglide 2 | -------------------------------------------------------------------------------- /platform/linux/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@openglide.cvs.sourceforge.net:/cvsroot/openglide 2 | -------------------------------------------------------------------------------- /platform/windows/CVS/Root: -------------------------------------------------------------------------------- 1 | :pserver:anonymous@openglide.cvs.sourceforge.net:/cvsroot/openglide 2 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | aclocal 3 | autoconf 4 | autoheader 5 | libtoolize 6 | automake --add-missing 7 | -------------------------------------------------------------------------------- /platform/dosemu/glide2x.ovl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcbarros/openglide/HEAD/platform/dosemu/glide2x.ovl -------------------------------------------------------------------------------- /platform/dosemu/linux_tombraider_openglide.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fcbarros/openglide/HEAD/platform/dosemu/linux_tombraider_openglide.jpeg -------------------------------------------------------------------------------- /platform/sdl/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Makefile.am/1.2/Tue Sep 15 11:37:07 2009// 2 | /openglext.cpp/1.4/Sun Feb 15 11:00:59 2009// 3 | /window.cpp/1.12/Sun Mar 28 13:52:29 2010// 4 | D 5 | -------------------------------------------------------------------------------- /platform/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | SUBDIRS=linux sdl windows 4 | 5 | EXTRA_DIST=\ 6 | clock.h \ 7 | error.h \ 8 | openglext.h \ 9 | window.h \ 10 | \ 11 | windows 12 | -------------------------------------------------------------------------------- /platform/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Makefile.am/1.4/Tue Sep 15 11:37:07 2009// 2 | /clock.h/1.2/Tue May 31 12:05:04 2005// 3 | /error.h/1.2/Tue May 31 12:05:04 2005// 4 | /openglext.h/1.4/Tue May 31 12:05:04 2005// 5 | /window.h/1.3/Sun Mar 28 13:52:28 2010// 6 | D 7 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | aclocal 3 | 4 | # MacOSX has glibtoolize 5 | if [ "`uname`" = "Darwin" ]; then 6 | LIBTOOLIZE=glibtoolize 7 | else 8 | LIBTOOLIZE=libtoolize 9 | fi 10 | 11 | $LIBTOOLIZE --force --copy 12 | autoheader --force 13 | automake --add-missing --copy 14 | autoconf --force 15 | -------------------------------------------------------------------------------- /platform/sdl/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LTLIBRARIES = libsdl.la 4 | 5 | libsdl_la_SOURCES = \ 6 | openglext.cpp \ 7 | window.cpp \ 8 | \ 9 | platform/clock.h \ 10 | platform/error.h \ 11 | platform/openglext.h \ 12 | platform/window.h \ 13 | platform/linux/platform.h \ 14 | platform/windows/platform.h 15 | -------------------------------------------------------------------------------- /platform/linux/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Makefile.am/1.1/Thu Jun 2 19:00:52 2005// 2 | /clock.cpp/1.5/Sun Mar 28 13:52:28 2010// 3 | /error.cpp/1.4/Tue Sep 15 11:37:07 2009// 4 | /library.cpp/1.4/Tue Sep 15 11:37:07 2009// 5 | /openglext.cpp/1.9/Tue Sep 15 11:37:07 2009// 6 | /platform.h/1.6/Tue Sep 15 11:37:07 2009// 7 | /window.cpp/1.24/Sun Mar 28 13:52:29 2010// 8 | D 9 | -------------------------------------------------------------------------------- /platform/windows/CVS/Entries: -------------------------------------------------------------------------------- 1 | /Makefile.am/1.1/Mon Oct 19 23:02:19 2009// 2 | /clock.cpp/1.4/Tue Sep 15 11:37:07 2009// 3 | /error.cpp/1.3/Tue Sep 15 11:37:07 2009// 4 | /library.cpp/1.3/Tue Sep 15 11:37:07 2009// 5 | /openglext.cpp/1.7/Tue Sep 15 11:37:07 2009// 6 | /platform.h/1.6/Tue Sep 15 11:37:07 2009// 7 | /window.cpp/1.8/Sun Mar 28 13:52:29 2010// 8 | D 9 | -------------------------------------------------------------------------------- /platform/linux/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LTLIBRARIES = libplatform.la 4 | 5 | libplatform_la_SOURCES = \ 6 | clock.cpp \ 7 | error.cpp \ 8 | openglext.cpp \ 9 | library.cpp \ 10 | window.cpp \ 11 | \ 12 | platform/clock.h \ 13 | platform/error.h \ 14 | platform/openglext.h \ 15 | platform/window.h \ 16 | platform/linux/platform.h 17 | -------------------------------------------------------------------------------- /platform/windows/Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | noinst_LTLIBRARIES = libwindows.la 4 | 5 | libwindows_la_SOURCES = \ 6 | clock.cpp \ 7 | error.cpp \ 8 | openglext.cpp \ 9 | library.cpp \ 10 | window.cpp \ 11 | \ 12 | platform/clock.h \ 13 | platform/error.h \ 14 | platform/openglext.h \ 15 | platform/window.h \ 16 | platform/windows/platform.h 17 | -------------------------------------------------------------------------------- /platform/dosemu/CVS/Entries: -------------------------------------------------------------------------------- 1 | /built.txt/1.1/Mon Jan 26 21:50:23 2009// 2 | /dosemu-1.4.0-openglide.patch/1.6/Mon Jun 8 20:08:43 2009// 3 | /glide2x.c/1.14/Sun Feb 15 01:27:49 2009// 4 | /glide2x.h/1.4/Sun Feb 15 01:00:21 2009// 5 | /glide2x.ovl/1.2/Sun Feb 15 01:27:49 2009/-kb/ 6 | /linux_tombraider_openglide.jpeg/1.1/Mon Jan 26 22:45:51 2009// 7 | /thunks.i/1.8/Sun Jun 7 21:32:03 2009// 8 | D 9 | -------------------------------------------------------------------------------- /wrapper_config.h: -------------------------------------------------------------------------------- 1 | #ifndef WRAPPER_CONFIG_H 2 | #define WRAPPER_CONFIG_H 3 | 4 | #include "sdk2_3dfx.h" 5 | 6 | #define WRAPPER_FLAG_WINDOWED (0x1) 7 | #define WRAPPER_FLAG_MIPMAPS (0x2) 8 | #define WRAPPER_FLAG_PALETTED_TEXTURE_CACHE (0x4) 9 | #define WRAPPER_FLAG_MANAGED_TEXTURES (0x8) 10 | 11 | FX_ENTRY void FX_CALL setConfig(FxU32 flags); 12 | 13 | #endif /* WRAPPER_CONFIG_H */ 14 | -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Developer Studio generated include file. 3 | // Used by Glide2x.rc 4 | // 5 | 6 | // Next default values for new objects 7 | // 8 | #ifdef APSTUDIO_INVOKED 9 | #ifndef APSTUDIO_READONLY_SYMBOLS 10 | #define _APS_NEXT_RESOURCE_VALUE 101 11 | #define _APS_NEXT_COMMAND_VALUE 40001 12 | #define _APS_NEXT_CONTROL_VALUE 1000 13 | #define _APS_NEXT_SYMED_VALUE 101 14 | #endif 15 | #endif 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OpenGLide 2 | OpenGLide is a Glide wrapper. Glide is an old graphics library for 3DFX boards to run games. OpenGlide wraps it and run the games in OpenGL. 3 | It is mainly for old DOS games and it is used on projects like: https://www.glidos.net/ 4 | 5 | # Important 6 | 7 | This is the last CVS version on SourceForge.net. 8 | 9 | The project was previous moved to Github at: 10 | 11 | https://github.com/voyageur/openglide 12 | 13 | Please use the above repository to download/get sources. 14 | 15 | -------------------------------------------------------------------------------- /OpenGLid.ini: -------------------------------------------------------------------------------- 1 | Configuration File for OpenGLide 2 | 3 | Info: 4 | Priority goes from 0(HIGH) to 5(IDLE) 5 | Texture Memory goes from 2 to 32 6 | Frame Buffer Memory goes from 2 to 16 7 | All other fields are boolean with 1(TRUE) and 0(FALSE) 8 | 9 | Version=0.09rc9 10 | 11 | [Options] 12 | WrapperPriority=2 13 | CreateWindow=0 14 | InitFullScreen=0 15 | EnableMipMaps=0 16 | IgnorePaletteChange=0 17 | Wrap565to5551=1 18 | EnablePrecisionFix=1 19 | EnableMultiTextureEXT=1 20 | EnablePaletteEXT=1 21 | EnableVertexArrayEXT=0 22 | TextureMemorySize=16 23 | FrameBufferMemorySize=8 24 | NoSplash=1 25 | -------------------------------------------------------------------------------- /Glide2x.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "Glide2x"=.\Glide2x.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /platform/clock.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Platform specific clock functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __CLOCK_H__ 14 | #define __CLOCK_H__ 15 | 16 | float ClockFrequency( void ); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /platform/error.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Platform specific functions for reporting errors 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __ERROR_H__ 14 | #define __ERROR_H__ 15 | 16 | void ReportWarning(const char *); 17 | void ReportError(const char *); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /platform/openglext.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Platform specific functions for handling OpenGL extensions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __OPENGLEXT_H__ 14 | #define __OPENGLEXT_H__ 15 | 16 | #include "platform.h" 17 | 18 | ExtFn OGLGetProcAddress(const char *x); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /platform/sdl/openglext.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* SDL specific functions for handling OpenGL extensions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #ifdef C_USE_SDL 17 | 18 | #include "SDL.h" 19 | 20 | #include "platform/openglext.h" 21 | 22 | ExtFn OGLGetProcAddress(const char *x) 23 | { 24 | return (ExtFn)SDL_GL_GetProcAddress(x); 25 | } 26 | 27 | #endif // C_USE_SDL 28 | -------------------------------------------------------------------------------- /platform/linux/error.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Linux specific functions for reporting errors 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifndef WIN32 13 | 14 | #include 15 | #include "platform/error.h" 16 | 17 | void ReportWarning(const char *message) 18 | { 19 | printf("Warning: %s\n", message); 20 | } 21 | 22 | void ReportError(const char *message) 23 | { 24 | printf("Error: %s\n", message); 25 | } 26 | 27 | #endif // WIN32 28 | -------------------------------------------------------------------------------- /platform/windows/openglext.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Windows specific functions for handling OpenGL extensions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #if !defined C_USE_SDL && defined WIN32 17 | 18 | #include 19 | 20 | #include "platform/openglext.h" 21 | 22 | ExtFn OGLGetProcAddress(const char *x) 23 | { 24 | return wglGetProcAddress(x); 25 | } 26 | 27 | #endif // !C_USE_SDL && WIN32 28 | -------------------------------------------------------------------------------- /platform/windows/error.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Windows specific functions for reporting errors 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef WIN32 13 | 14 | #include 15 | #include "platform/error.h" 16 | 17 | void ReportWarning(const char *message) 18 | { 19 | MessageBox( NULL, message, "Warning", MB_OK ); 20 | } 21 | 22 | void ReportError(const char *message) 23 | { 24 | MessageBox( NULL, message, "Error", MB_OK ); 25 | } 26 | 27 | #endif // WIN32 28 | -------------------------------------------------------------------------------- /platform/windows/platform.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Windows specific includes and macros 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef WIN32 13 | 14 | #ifndef __PLATFORM_H__ 15 | #define __PLATFORM_H__ 16 | 17 | #include 18 | #include 19 | 20 | #define FASTCALL __fastcall 21 | #define OG_memcpy MMXCopyMemory 22 | 23 | #define VARARGDECL(t) t _cdecl 24 | typedef int (__stdcall *ExtFn)(); 25 | 26 | #ifdef _MSC_VER 27 | typedef __int64 FxI64; 28 | typedef unsigned __int64 FxU64; 29 | typedef int FxI; 30 | typedef unsigned int FxU; 31 | #endif 32 | 33 | #endif 34 | 35 | #endif // WIN32 36 | -------------------------------------------------------------------------------- /platform/linux/library.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Linux specific functions for library initialisation 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifndef WIN32 13 | 14 | #include 15 | #include "GlOgl.h" 16 | 17 | class InitLibrary 18 | { 19 | public: 20 | InitLibrary( ) 21 | { 22 | if ( !ClearAndGenerateLogFile( ) ) 23 | { 24 | exit( 0 ); 25 | } 26 | InitMainVariables( ); 27 | } 28 | ~InitLibrary( ) 29 | { 30 | grGlideShutdown( ); 31 | CloseLogFile( ); 32 | } 33 | }; 34 | 35 | static InitLibrary initLibrary; 36 | 37 | #endif // WIN32 38 | -------------------------------------------------------------------------------- /platform/linux/openglext.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Linux specific functions for handling OpenGL extensions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #if !defined C_USE_SDL && !defined WIN32 17 | #define GLX_GLXEXT_PROTOTYPES 18 | 19 | #include 20 | 21 | #include "platform/openglext.h" 22 | 23 | ExtFn OGLGetProcAddress(const char *x) 24 | { 25 | #ifdef GLX_ARB_get_proc_address 26 | return glXGetProcAddressARB((const GLubyte *) x); 27 | #else 28 | return glXGetProcAddress((const GLubyte *) x); 29 | #endif 30 | } 31 | 32 | #endif // !C_USE_SDL && !WIN32 33 | -------------------------------------------------------------------------------- /platform/linux/clock.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Linux specific clock functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifndef WIN32 13 | 14 | #include 15 | #include 16 | #include "platform/clock.h" 17 | 18 | float ClockFrequency( void ) 19 | { 20 | char str[35]; 21 | float freq = 0.0; 22 | FILE *f = fopen ("/proc/cpuinfo", "r"); 23 | // Be nice and don't crash 24 | if ( f == NULL ) return freq; 25 | while (fgets (str, sizeof (str), f)) 26 | { 27 | if (!strncmp ("cpu MHz", str, 7)) 28 | { 29 | sscanf (strchr(str, ':')+1, "%f", &freq); 30 | break; 31 | } 32 | } 33 | fclose (f); 34 | return freq * 1000000.0; 35 | } 36 | 37 | #endif // WIN32 38 | -------------------------------------------------------------------------------- /Glide2x.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 7.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Glide2x", "Glide2x.vcproj", "{A9DE043C-CA98-44A4-80BE-D93BACDFB186}" 3 | EndProject 4 | Global 5 | GlobalSection(SourceCodeControl) = preSolution 6 | SccNumberOfProjects = 1 7 | SccProjectUniqueName0 = Glide2x.vcproj 8 | SccProjectName0 = \u0022$/Glide2x\u0022,\u0020BAAAAAAA 9 | SccLocalPath0 = . 10 | SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe 11 | EndGlobalSection 12 | GlobalSection(SolutionConfiguration) = preSolution 13 | ConfigName.0 = Debug 14 | ConfigName.1 = Release 15 | EndGlobalSection 16 | GlobalSection(ProjectDependencies) = postSolution 17 | EndGlobalSection 18 | GlobalSection(ProjectConfiguration) = postSolution 19 | {A9DE043C-CA98-44A4-80BE-D93BACDFB186}.Debug.ActiveCfg = Debug|Win32 20 | {A9DE043C-CA98-44A4-80BE-D93BACDFB186}.Debug.Build.0 = Debug|Win32 21 | {A9DE043C-CA98-44A4-80BE-D93BACDFB186}.Release.ActiveCfg = Release|Win32 22 | {A9DE043C-CA98-44A4-80BE-D93BACDFB186}.Release.Build.0 = Release|Win32 23 | EndGlobalSection 24 | GlobalSection(ExtensibilityGlobals) = postSolution 25 | EndGlobalSection 26 | GlobalSection(ExtensibilityAddIns) = postSolution 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /FormatConversion.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TEXTURE_CONVERSION_H__ 3 | #define __TEXTURE_CONVERSION_H__ 4 | 5 | #include "GlOgl.h" 6 | 7 | void Convert565to8888( FxU16 *Buffer1, FxU32 *Buffer2, FxU32 Pixels ); 8 | void Convert565Kto8888( FxU16 *Buffer1, FxU16 key, FxU32 *Buffer2, FxU32 Pixels ); 9 | void Convert565to5551( FxU32 *Buffer1, FxU32 *Buffer2, int Pixels ); 10 | void Convert5551to565( FxU32 *Buffer1, FxU32 *Buffer2, int Pixels ); 11 | void Convert8888to565( FxU32 *Src, FxU16 *Dst, FxU32 Pixels ); 12 | void Convert4444to4444special( FxU32 *Buffer1, FxU32 *Buffer2, int Pixels ); 13 | void Convert1555to5551( FxU32 *Buffer1, FxU32 *Buffer2, int Pixels ); 14 | void ConvertA8toAP88( FxU8 *Buffer1, FxU16 *Buffer2, FxU32 Pixels ); 15 | void ConvertAI44toAP88( FxU8 *Buffer1, FxU16 *Buffer2, FxU32 Pixels ); 16 | void Convert8332to8888( FxU16 *Buffer1, FxU32 *Buffer2, FxU32 Pixels ); 17 | void ConvertP8to8888( FxU8 *Buffer1, FxU32 *Buffer2, FxU32 Pixels, FxU32 *palette ); 18 | void ConvertAP88to8888( FxU16 *Buffer1, FxU32 *Buffer2, FxU32 Pixels, FxU32 *palette ); 19 | void ConvertYIQto8888( FxU8 *in, FxU32 *out, FxU32 Pixels, GuNccTable *ncc ); 20 | void ConvertAYIQto8888( FxU16 *in, FxU32 *out, FxU32 Pixels, GuNccTable *ncc ); 21 | void SplitAP88( FxU16 *ap88, FxU8 *index, FxU8 *alpha, FxU32 pixels ); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /OGLTables.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __OGL_TABLES_H__ 3 | #define __OGL_TABLES_H__ 4 | 5 | #include "GlOgl.h" 6 | #include "GLRender.h" 7 | 8 | typedef struct 9 | { 10 | float h; 11 | float w; 12 | } OGLAspect; 13 | 14 | typedef struct 15 | { 16 | int width; 17 | int height; 18 | int numPixels; 19 | } OGLTexInfo; 20 | 21 | typedef struct 22 | { 23 | bool local; 24 | bool other; 25 | ALPHAFACTORFUNCPROC func; 26 | } OGLAlphaTable; 27 | 28 | typedef struct 29 | { 30 | bool local; 31 | bool other; 32 | bool alocal; 33 | bool aother; 34 | COLORFACTORFUNCPROC factorfunc; 35 | COLORFUNCTIONPROC func; 36 | } OGLColorTable; 37 | 38 | // OGLTextureTables.cpp 39 | extern OGLAspect texAspects[ 7 ]; 40 | extern OGLTexInfo texInfo[ 7 ][ 9 ]; 41 | extern FxU32 nSquareLod[ 2 ][ 7 ][ 9 ]; 42 | extern FxU32 nSquareTexLod[ 2 ][ 7 ][ 9 ][ 9 ]; 43 | 44 | // OGLColorAlphaTables.cpp 45 | extern OGLAlphaTable alphaCombineTable[ 14 ][ 17 ]; 46 | extern OGLColorTable colorCombineTable[ 14 ][ 17 ]; 47 | 48 | // OGLFogTables.cpp 49 | extern FxU32 intStartEnd[ GR_FOG_TABLE_SIZE + 1 ]; 50 | extern FxU32 intEndMinusStart[ GR_FOG_TABLE_SIZE ]; 51 | extern float tableIndexToW[ GR_FOG_TABLE_SIZE ]; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /platform/window.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Platform specific functions for handling display window 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #ifndef __WINDOW_H__ 17 | #define __WINDOW_H__ 18 | 19 | #include "sdk2_3dfx.h" 20 | 21 | // Include proper OpenGL headers 22 | #ifdef C_USE_SDL 23 | #include "SDL_opengl.h" 24 | #elif defined(__MACOSX__) 25 | #include /* Header File For The OpenGL Library */ 26 | #include /* Header File For The GLU Library */ 27 | #else 28 | #include 29 | #include 30 | #endif 31 | 32 | bool InitialiseOpenGLWindow(FxU wnd, int x, int y, int width, int height); 33 | void FinaliseOpenGLWindow( void); 34 | 35 | void SetGamma(float value); 36 | void RestoreGamma(); 37 | 38 | bool SetScreenMode(int &xsize, int &ysize); 39 | void ResetScreenMode(); 40 | 41 | void SwapBuffers(); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /OGLMiscTables.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OGLTables.h" 3 | 4 | /* Move to grguSstGlide, since only use there. 5 | * These are unsafe as all users have to 6 | * take care not to buffer overrun. Is better 7 | * to have a safe accessing function e.g 8 | * (InterpretScreenResolution, etc). 9 | OGLWindow windowDimensions[ 16 ] = 10 | { 11 | { 320, 200 }, // GR_RESOLUTION_320x200 12 | { 320, 240 }, // GR_RESOLUTION_320x240 13 | { 400, 256 }, // GR_RESOLUTION_400x256 14 | { 512, 384 }, // GR_RESOLUTION_512x384 15 | { 640, 200 }, // GR_RESOLUTION_640x200 16 | { 640, 350 }, // GR_RESOLUTION_640x350 17 | { 640, 400 }, // GR_RESOLUTION_640x400 18 | { 640, 480 }, // GR_RESOLUTION_640x480 19 | { 800, 600 }, // GR_RESOLUTION_800x600 20 | { 960, 720 }, // GR_RESOLUTION_960x720 21 | { 856, 480 }, // GR_RESOLUTION_856x480: 22 | { 512, 256 }, // GR_RESOLUTION_512x256: 23 | { 1024, 768 }, // GR_RESOLUTION_1024x768: 24 | { 1280, 1024 }, // GR_RESOLUTION_1280x1024: 25 | { 1600, 1200 }, // GR_RESOLUTION_1600x1200: 26 | { 400, 300 } // GR_RESOLUTION_400x300: 27 | }; 28 | 29 | int windowRefresh[ 9 ] = 30 | { 31 | 60, // GR_REFRESH_60Hz 32 | 70, // GR_REFRESH_70Hz 33 | 72, // GR_REFRESH_72Hz 34 | 75, // GR_REFRESH_75Hz 35 | 80, // GR_REFRESH_80Hz 36 | 90, // GR_REFRESH_90Hz 37 | 100, // GR_REFRESH_100Hz 38 | 85, // GR_REFRESH_85Hz 39 | 120 // GR_REFRESH_120Hz 40 | }; 41 | */ 42 | -------------------------------------------------------------------------------- /platform/linux/platform.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Linux Specific includes and macros 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifndef WIN32 13 | 14 | #ifndef __PLATFORM_H__ 15 | #define __PLATFORM_H__ 16 | 17 | #include 18 | #define __STDC_LIMIT_MACROS 19 | #include // Ansi C99 header 20 | #include 21 | #include 22 | #define _strtime(s) {time_t t = time(0); strftime(s, 99, "%H:%M:%S", localtime (&t));} 23 | #define _strdate(s) {time_t t = time(0); strftime(s, 99, "%d %b %Y", localtime (&t));} 24 | #define ZeroMemory(d,l) memset(d,0,l) 25 | #define CopyMemory(d,s,l) memcpy(d,s,l) 26 | #define max(x,y) ((x) < (y) ? (y) : (x)) 27 | 28 | #if HAVE_MMX 29 | # if SIZEOF_INT_P == 4 30 | # define FASTCALL __attribute__((__fastcall__)) 31 | # else 32 | # define FASTCALL 33 | # endif 34 | #define OG_memcpy MMXCopyMemory 35 | #else 36 | #define FASTCALL 37 | #define OG_memcpy memcpy 38 | #endif 39 | 40 | #define VARARGDECL(t) extern "C" t 41 | typedef void (*ExtFn)(); 42 | 43 | #endif 44 | 45 | #endif // WIN32 46 | -------------------------------------------------------------------------------- /TexDB.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* TexDB Class Definition 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __TEXDB_H__ 14 | #define __TEXDB_H__ 15 | 16 | #include "sdk2_glide.h" 17 | 18 | class TexDB 19 | { 20 | public: 21 | void Clear( void ); 22 | 23 | struct Record 24 | { 25 | FxU32 startAddress; 26 | FxU32 endAddress; 27 | GrTexInfo info; 28 | FxU32 hash; 29 | GLuint texNum; 30 | GLuint tex2Num; 31 | Record *next; 32 | 33 | Record( bool two_tex ); 34 | ~Record( void ); 35 | bool Match( FxU32 stt, GrTexInfo *inf, FxU32 h ); 36 | }; 37 | 38 | void Add( FxU32 startAddress, FxU32 endAddress, GrTexInfo *info, FxU32 hash, GLuint *pTexNum, GLuint *pTex2Num ); 39 | void WipeRange( FxU32 startAddress, FxU32 endAddress, FxU32 hash ); 40 | GrTexInfo * Find( FxU32 startAddress, GrTexInfo *info, FxU32 hash, 41 | GLuint *pTexNum, GLuint *pTex2Num, bool *pal_change ); 42 | TexDB( unsigned int MemorySize ); 43 | virtual ~TexDB( void ); 44 | 45 | private: 46 | unsigned int numberOfTexSections; 47 | Record ** m_first; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | 3 | #bin_PROGRAMS = test 4 | #test_SOURCES = test12.c tlib.c linutil.c 5 | #test_LDADD = ./libglide2x.la 6 | #test_LDADD = -L/usr/lib -lglide2x -lm 7 | 8 | SUBDIRS=platform 9 | EXTRA_DIST=splash.dat banner.dat 10 | 11 | lib_LTLIBRARIES = libglide2x.la 12 | 13 | libglide2xincludedir = $(includedir)/openglide 14 | libglide2xinclude_HEADERS = \ 15 | sdk2_glide.h \ 16 | sdk2_3dfx.h \ 17 | sdk2_glidesys.h \ 18 | sdk2_glideutl.h \ 19 | sdk2_sst1vid.h \ 20 | sdk2_unix.h 21 | 22 | libglide2x_la_SOURCES = \ 23 | grguDepth.cpp \ 24 | grguMisc.cpp \ 25 | grgu3df.cpp \ 26 | grguDraw.cpp \ 27 | grguSstGlide.cpp \ 28 | grguFog.cpp \ 29 | grguTex.cpp \ 30 | grguLfb.cpp \ 31 | GLRender.cpp \ 32 | OGLFogTables.cpp \ 33 | OGLTextureTables.cpp \ 34 | OGLColorAlphaTables.cpp \ 35 | TexDB.cpp \ 36 | PGUTexture.cpp \ 37 | Glide.cpp \ 38 | GLExtensions.cpp \ 39 | PGTexture.cpp \ 40 | FormatConversion.cpp \ 41 | grguBuffer.cpp \ 42 | grguColorAlpha.cpp \ 43 | GLutil.cpp \ 44 | gsplash.cpp \ 45 | \ 46 | FormatConversion.h \ 47 | glext.h \ 48 | Glextensions.h \ 49 | GlOgl.h \ 50 | GLRender.h \ 51 | OGLTables.h \ 52 | PGTexture.h \ 53 | PGUTexture.h \ 54 | TexDB.h 55 | 56 | # We substitute the libtool-specific library version in configure.in. 57 | libglide2x_la_LDFLAGS = -no-undefined -version-info $(LIBVERSION) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(DLLFLAGS) 58 | 59 | INCLUDES= 60 | 61 | libglide2x_la_LIBADD = ./platform/linux/libplatform.la ./platform/sdl/libsdl.la ./platform/windows/libwindows.la 62 | 63 | install-data-hook: 64 | ln -sf $(libglide2xincludedir)/sdk2_glide.h $(includedir)/glide.h 65 | -------------------------------------------------------------------------------- /platform/windows/clock.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Windows specific clock functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef WIN32 13 | 14 | #include 15 | #include "GlOgl.h" 16 | 17 | #include "platform/clock.h" 18 | 19 | #pragma optimize( "", off ) 20 | float ClockFrequency( void ) 21 | { 22 | FxI64 i64_perf_start, 23 | i64_perf_freq, 24 | i64_perf_end, 25 | i64_clock_start, 26 | i64_clock_end; 27 | double d_loop_period, 28 | d_clock_freq; 29 | 30 | QueryPerformanceFrequency( (LARGE_INTEGER*)&i64_perf_freq ); 31 | 32 | QueryPerformanceCounter( (LARGE_INTEGER*)&i64_perf_start ); 33 | i64_perf_end = 0; 34 | 35 | RDTSC( i64_clock_start ); 36 | while( i64_perf_end < ( i64_perf_start + 350000 ) ) 37 | { 38 | QueryPerformanceCounter( (LARGE_INTEGER*)&i64_perf_end ); 39 | } 40 | RDTSC( i64_clock_end ); 41 | 42 | i64_clock_end -= i64_clock_start; 43 | 44 | d_loop_period = ((double)i64_perf_freq) / 350000.0; 45 | d_clock_freq = ((double)( i64_clock_end & 0xffffffff )) * d_loop_period; 46 | 47 | return (float)d_clock_freq; 48 | } 49 | #pragma optimize( "", on ) 50 | 51 | #endif // WIN32 52 | -------------------------------------------------------------------------------- /OGLFogTables.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "OGLTables.h" 3 | 4 | FxU32 intStartEnd[ GR_FOG_TABLE_SIZE + 1 ] = 5 | { 6 | 1, 1, 1, 1, 2, 2, 2, 3, 4, 4, 5, 6, 8, 9, 11, 13, 16, 19, 22, 26, 32, 38, 45, 53, 7 | 64, 76, 90, 107, 128, 152, 181, 215, 256, 304, 362, 430, 512, 608, 724, 861, 8 | 1024, 1217, 1448, 1722, 2048, 2435, 2896, 3444, 4096, 4870, 5792, 6888, 8192, 9 | 9741, 11585, 13777, 16384, 19483, 23170, 27554, 32768, 38967, 46340, 55108, 65536 10 | }; 11 | 12 | FxU32 intEndMinusStart[ GR_FOG_TABLE_SIZE ] = 13 | { 14 | 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 2, 1, 2, 2, 3, 3, 3, 4, 6, 6, 7, 8, 11, 12, 14, 15 | 17, 21, 24, 29, 34, 41, 48, 58, 68, 82, 96, 116, 137, 163, 193, 231, 274, 326, 16 | 387, 461, 548, 652, 774, 922, 1096, 1304, 1549, 1844, 2192, 2607, 3099, 3687, 17 | 4384, 5214, 6199, 7373, 8768, 10428 18 | }; 19 | 20 | float tableIndexToW[ GR_FOG_TABLE_SIZE ] = 21 | { 22 | 1.000000f, 1.142857f, 1.333333f, 1.600000f, 23 | 2.000000f, 2.285714f, 2.666667f, 3.200000f, 24 | 4.000000f, 4.571429f, 5.333333f, 6.400000f, 25 | 8.000000f, 9.142858f, 10.666667f, 12.800000f, 26 | 16.000000f, 18.285715f, 21.333334f, 25.600000f, 27 | 32.000000f, 36.571430f, 42.666668f, 51.200001f, 28 | 64.000000f, 73.142860f, 85.333336f, 102.400002f, 29 | 128.000000f, 146.285721f, 170.666672f, 204.800003f, 30 | 256.000000f, 292.571442f, 341.333344f, 409.600006f, 31 | 512.000000f, 585.142883f, 682.666687f, 819.200012f, 32 | 1024.000000f, 1170.285767f, 1365.333374f, 1638.400024f, 33 | 2048.000000f, 2340.571533f, 2730.666748f, 3276.800049f, 34 | 4096.000000f, 4681.143066f, 5461.333496f, 6553.600098f, 35 | 8192.000000f, 9362.286133f, 10922.666992f, 13107.200195f, 36 | 16384.000000f, 18724.572266f, 21845.333984f, 26214.400391f, 37 | 32768.000000f, 37449.144531f, 43690.667969f, 52428.800781f 38 | }; 39 | 40 | -------------------------------------------------------------------------------- /sdk2_unix.h.in: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* OpenGLide is OpenSource under LGPL license 6 | //* Originaly made by Fabio Barros 7 | //* Modified by Paul for Glidos (http://www.glidos.net) 8 | //* Linux version by Simon White 9 | //************************************************************** 10 | #ifndef __SDK2_UNIX_H__ 11 | #define __SDK2_UNIX_H__ 12 | 13 | /* Define the sizeof of types in bytes */ 14 | #define FXSIZEOF_UNSIGNED_CHAR @SIZEOF_UNSIGNED_CHAR@ 15 | #define FXSIZEOF_UNSIGNED_SHORT @SIZEOF_UNSIGNED_SHORT@ 16 | #define FXSIZEOF_UNSIGNED_INT @SIZEOF_UNSIGNED_INT@ 17 | #define FXSIZEOF_UNSIGNED_LONG @SIZEOF_UNSIGNED_LONG@ 18 | #define FXSIZEOF_UNSIGNED_LONG_LONG @SIZEOF_UNSIGNED_LONG_LONG@ 19 | #define FXSIZEOF_INT_P @SIZEOF_INT_P@ 20 | 21 | /* 22 | ** basic data types 23 | */ 24 | #if FXSIZEOF_UNSIGNED_CHAR != 1 25 | # error "sizeof (unsigned char) != 1" 26 | #else 27 | typedef unsigned char FxU8; 28 | typedef signed char FxI8; 29 | #endif 30 | 31 | #if FXSIZEOF_UNSIGNED_SHORT != 2 32 | # error "sizeof (unsigned short) != 2" 33 | #else 34 | typedef unsigned short FxU16; 35 | typedef signed short FxI16; 36 | #endif 37 | 38 | #if FXSIZEOF_UNSIGNED_INT == 4 39 | typedef unsigned int FxU32; 40 | typedef signed int FxI32; 41 | #elif FXSIZEOF_UNSIGNED_LONG == 4 42 | typedef unsigned long FxU32; 43 | typedef signed long FxI32; 44 | #else 45 | # error "can't find sizeof(type) of 4 bytes!" 46 | #endif 47 | 48 | #if FXSIZEOF_UNSIGNED_LONG == 8 49 | typedef unsigned long FxU64; 50 | typedef signed long FxI64; 51 | #elif FXSIZEOF_UNSIGNED_LONG_LONG == 8 52 | typedef unsigned long long FxU64; 53 | typedef signed long long FxI64; 54 | #else 55 | # error "can't find data type of 8 bytes" 56 | #endif 57 | 58 | #if FXSIZEOF_INT_P == 4 59 | typedef FxU32 FxU; 60 | typedef FxI32 FxI; 61 | #else 62 | typedef FxU64 FxU; 63 | typedef FxI64 FxI; 64 | #endif 65 | 66 | typedef FxI32 FxBool; 67 | typedef float FxFloat; 68 | typedef double FxDouble; 69 | 70 | #endif // __SDK2_UNIX_H__ 71 | -------------------------------------------------------------------------------- /Glextensions.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* OpenGL Extensions Header 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __GLEXTENSIONS__ 14 | #define __GLEXTENSIONS__ 15 | 16 | #include "glext.h" 17 | 18 | void ValidateUserConfig(); 19 | 20 | // Extensions Functions Declarations 21 | // This cannot have the same name as the prototype functions 22 | // in glext.h, else compiler compiains about object being 23 | // redeclared as different type of symbol (func->variable). 24 | extern PFNGLCLIENTACTIVETEXTUREARBPROC p_glClientActiveTexture; 25 | extern PFNGLMULTITEXCOORD4FARBPROC p_glMultiTexCoord4fARB; 26 | extern PFNGLMULTITEXCOORD4FVARBPROC p_glMultiTexCoord4fvARB; 27 | extern PFNGLACTIVETEXTUREARBPROC p_glActiveTextureARB; 28 | extern PFNGLSECONDARYCOLOR3UBVEXTPROC p_glSecondaryColor3ubvEXT; 29 | extern PFNGLSECONDARYCOLOR3UBEXTPROC p_glSecondaryColor3ubEXT; 30 | extern PFNGLSECONDARYCOLORPOINTEREXTPROC p_glSecondaryColorPointerEXT; 31 | extern PFNGLFOGCOORDFEXTPROC p_glFogCoordfEXT; 32 | extern PFNGLFOGCOORDPOINTEREXTPROC p_glFogCoordPointerEXT; 33 | extern PFNGLSECONDARYCOLOR3FVEXTPROC p_glSecondaryColor3fvEXT; 34 | extern PFNGLSECONDARYCOLOR3FEXTPROC p_glSecondaryColor3fEXT; 35 | 36 | extern PFNGLCOLORTABLEEXTPROC p_glColorTableEXT; 37 | extern PFNGLCOLORSUBTABLEEXTPROC p_glColorSubTableEXT; 38 | extern PFNGLGETCOLORTABLEEXTPROC p_glGetColorTableEXT; 39 | extern PFNGLGETCOLORTABLEPARAMETERIVEXTPROC p_glGetColorTableParameterivEXT; 40 | extern PFNGLGETCOLORTABLEPARAMETERFVEXTPROC p_glGetColorTableParameterfvEXT; 41 | 42 | extern PFNGLBLENDFUNCSEPARATEEXTPROC p_glBlendFuncSeparateEXT; 43 | 44 | 45 | void APIENTRY DummyV( const void *a ); 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /platform/windows/library.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Windows specific functions for library initialisation 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef WIN32 13 | 14 | #include 15 | #include "GlOgl.h" 16 | 17 | BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvreserved ) 18 | { 19 | int Priority; 20 | 21 | switch ( dwReason ) 22 | { 23 | case DLL_THREAD_ATTACH: 24 | break; 25 | 26 | case DLL_PROCESS_ATTACH: 27 | if ( !ClearAndGenerateLogFile( ) ) 28 | { 29 | return false; 30 | } 31 | InitMainVariables( ); 32 | 33 | if ( SetPriorityClass( GetCurrentProcess( ), NORMAL_PRIORITY_CLASS ) == 0 ) 34 | { 35 | Error( "Could not set Class Priority.\n" ); 36 | } 37 | else 38 | { 39 | GlideMsg( OGL_LOG_SEPARATE ); 40 | GlideMsg( "Wrapper Class Priority of %d\n", NORMAL_PRIORITY_CLASS ); 41 | } 42 | 43 | switch ( UserConfig.Priority ) 44 | { 45 | case 0: Priority = THREAD_PRIORITY_HIGHEST; break; 46 | case 1: Priority = THREAD_PRIORITY_ABOVE_NORMAL; break; 47 | case 2: Priority = THREAD_PRIORITY_NORMAL; break; 48 | case 3: Priority = THREAD_PRIORITY_BELOW_NORMAL; break; 49 | case 4: Priority = THREAD_PRIORITY_LOWEST; break; 50 | case 5: Priority = THREAD_PRIORITY_IDLE; break; 51 | default: Priority = THREAD_PRIORITY_NORMAL; break; 52 | } 53 | if ( SetThreadPriority( GetCurrentThread(), Priority ) == 0 ) 54 | { 55 | Error( "Could not set Thread Priority.\n" ); 56 | } 57 | else 58 | { 59 | GlideMsg( "Wrapper Priority of %d\n", UserConfig.Priority ); 60 | GlideMsg( OGL_LOG_SEPARATE ); 61 | } 62 | break; 63 | 64 | case DLL_THREAD_DETACH: 65 | break; 66 | 67 | case DLL_PROCESS_DETACH: 68 | grGlideShutdown( ); 69 | CloseLogFile( ); 70 | break; 71 | } 72 | return TRUE; 73 | } 74 | 75 | #endif // WIN32 76 | -------------------------------------------------------------------------------- /PGUTexture.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* PGUTexture Class Definition 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __PGUTEXTURE_H__ 14 | #define __PGUTEXTURE_H__ 15 | 16 | #include "sdk2_glide.h" 17 | 18 | class PGUTexture 19 | { 20 | public: 21 | FxU32 MemQueryAvail( GrChipID_t tmu ); 22 | GrMipMapId_t GetCurrentMipMap( GrChipID_t tmu ); 23 | FxBool ChangeAttributes( GrMipMapId_t mmid, int width, int height, 24 | GrTextureFormat_t fmt, GrMipMapMode_t mm_mode, 25 | GrLOD_t smallest_lod, GrLOD_t largest_lod, 26 | GrAspectRatio_t aspect, GrTextureClampMode_t s_clamp_mode, 27 | GrTextureClampMode_t t_clamp_mode, 28 | GrTextureFilterMode_t minFilterMode, 29 | GrTextureFilterMode_t magFilterMode ); 30 | GrMipMapInfo * GetMipMapInfo( GrMipMapId_t mmid ); 31 | void Source( GrMipMapId_t id ); 32 | void MemReset( void ); 33 | void DownloadMipMapLevel( GrMipMapId_t mmid, GrLOD_t lod, const void **src ); 34 | void DownloadMipMap( GrMipMapId_t mmid, const void *src, const GuNccTable *table ); 35 | GrMipMapId_t AllocateMemory( GrChipID_t tmu, FxU8 odd_even_mask, int width, int height, 36 | GrTextureFormat_t fmt, GrMipMapMode_t mm_mode, 37 | GrLOD_t smallest_lod, GrLOD_t largest_lod, 38 | GrAspectRatio_t aspect, GrTextureClampMode_t s_clamp_mode, 39 | GrTextureClampMode_t t_clamp_mode, 40 | GrTextureFilterMode_t minfilter_mode, 41 | GrTextureFilterMode_t magfilter_mode, 42 | float lod_bias, FxBool trilinear ); 43 | 44 | PGUTexture( void ); 45 | virtual ~PGUTexture( void ); 46 | 47 | 48 | private: 49 | 50 | enum { MAX_MM = 1024 }; 51 | 52 | GrMipMapInfo mm_info[ MAX_MM ]; 53 | FxU32 mm_start[ MAX_MM ]; 54 | FxU32 m_free_mem; 55 | GrMipMapId_t m_free_id; 56 | GrMipMapId_t m_current_id; 57 | }; 58 | 59 | extern PGUTexture UTextures; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /platform/dosemu/glide2x.h: -------------------------------------------------------------------------------- 1 | #ifndef _glide2x_h_ 2 | #define _glide2x_h_ 3 | 4 | #define CMD_GRGLIDEINIT (0) 5 | #define CMD_GRSSTQUERYHARDWARE (1) 6 | #define CMD_GRSSTSELECT (2) 7 | #define CMD_GRSSTWINOPEN (3) 8 | #define CMD_GRDEPTHBUFFERMODE (4) 9 | #define CMD_GRDEPTHBUFFERFUNCTION (5) 10 | #define CMD_GRDEPTHMASK (6) 11 | #define CMD_GRTEXCOMBINEFUNCTION (7) 12 | #define CMD_GRCONSTANTCOLORVALUE (8) 13 | #define CMD_GUALPHASOURCE (9) 14 | #define CMD_GRCHROMAKEYMODE (10) 15 | #define CMD_GRCHROMAKEYVALUE (11) 16 | #define CMD_GRGAMMACORRECTIONVALUE (12) 17 | #define CMD_GRTEXDOWNLOADTABLE (13) 18 | #define CMD_GUTEXMEMRESET (14) 19 | #define CMD_GU3DFGETINFO (15) 20 | #define CMD_GU3DFLOAD (16) 21 | #define CMD_GUTEXALLOCATEMEMORY (17) 22 | #define CMD_GUTEXDOWNLOADMIPMAP (18) 23 | #define CMD_GRBUFFERCLEAR (19) 24 | #define CMD_GUCOLORCOMBINEFUNCTION (20) 25 | #define CMD_GUTEXSOURCE (21) 26 | #define CMD_GRDRAWPOLYGONVERTEXLIST (22) 27 | #define CMD_GRBUFFERSWAP (23) 28 | #define CMD_GRTEXFILTERMODE (24) 29 | #define CMD_GRSSTWINCLOSE (25) 30 | #define CMD_GRDEPTHBIASLEVEL (26) 31 | #define CMD_GRCOLORCOMBINE (27) 32 | #define CMD_GRALPHABLENDFUNCTION (28) 33 | #define CMD_GRDRAWLINE (29) 34 | #define CMD_GRCONSTANTCOLORVALUE4 (30) 35 | #define CMD_GRGLIDESHUTDOWN (31) 36 | #define CMD_GRAADRAWLINE (32) 37 | #define CMD_GRRENDERBUFFER (33) 38 | #define CMD_GRTEXDOWNLOADMIPMAP (34) 39 | #define CMD_GRTEXSOURCE (35) 40 | #define CMD_GRDRAWTRIANGLE (36) 41 | #define CMD_GRDISABLEALLEFFECTS (36) 42 | #define CMD_GRTEXMIPMAPMODE (37) 43 | #define CMD_GRTEXLODBIASVALUE (38) 44 | #define CMD_GRTEXCLAMPMODE (39) 45 | #define CMD_GRALPHACOMBINE (40) 46 | #define CMD_GRFOGMODE (41) 47 | #define CMD_GRALPHATESTFUNCTION (42) 48 | #define CMD_GRCLIPWINDOW (43) 49 | #define CMD_GRCULLMODE (44) 50 | #define CMD_GRFOGCOLORVALUE (45) 51 | #define CMD_GRFOGTABLE (46) 52 | #define CMD_GRCOLORMASK (47) 53 | #define CMD_GRLFBLOCK (48) 54 | #define CMD_GRTEXDETAILCONTROL (49) 55 | #define CMD_GRHINTS (50) 56 | #define CMD_GUDRAWTRIANGLEWITHCLIP (51) 57 | #define CMD_GUFOGGENERATEEXP (52) 58 | #define CMD_GRTEXCOMBINE (53) 59 | #define CMD_GRBUFFERNUMPENDING (54) 60 | #define CMD_GRGLIDEGETSTATE (55) 61 | #define CMD_GRGLIDEGETVERSION (56) 62 | #define CMD_GRGLIDESHAMELESSPLUG (57) 63 | #define CMD_GRLFBUNLOCK (58) 64 | #define CMD_GRSSTSTATUS (59) 65 | #define CMD_GRTEXCALCMEMREQUIRED (60) 66 | #define CMD_GUTEXCOMBINEFUNCTION (61) 67 | #define CMD_GRTEXDOWNLOADMIPMAPLEVEL (62) 68 | #define CMD_GRTEXMAXADDRESS (63) 69 | #define CMD_GRTEXMINADDRESS (64) 70 | #define CMD_GUTEXMEMQUERYAVAIL (65) 71 | #define CMD_GRTEXTEXTUREMEMREQUIRED (66) 72 | #define CMD_GRSPLASH (67) 73 | #define CMD_MAX (68) 74 | 75 | #endif /* _glide2x_h_ */ 76 | -------------------------------------------------------------------------------- /platform/dosemu/built.txt: -------------------------------------------------------------------------------- 1 | Building the code for dosemu. 2 | 3 | This original code was designed for compiling with djgpp. 4 | Whilst being able to create an executable for DOS that 5 | could communicate through to the openglide code, I was 6 | unsuccessfull in creating a dll for DOS games written 7 | in DOS4GW. 8 | 9 | Investigation into this reveals that the dll for those 10 | games requires a compiler that can compile OS/2 libraries 11 | and so far only open Watcom seems to do this. 12 | 13 | The assembly was re-worked to allow use in Watcom. DJGPP 14 | allowed use of inline assembly with local labels, a 15 | feature I was using to push return addresses onto the 16 | stack. So far Watcom does not support this, preventing 17 | the use of direct calls to each of the glide functions. 18 | 19 | Instead for Watcom I opted for an indirect call that 20 | passed an index number of the function to be called 21 | in the openglide library. 22 | 23 | Watcom build files: 24 | 25 | make.bat 26 | 27 | del glide2x.obj 28 | wcl386 -c -bt=dos -3r -s glide2x.c 29 | wlink @glide2x.lnk 30 | 31 | glide2x.lnk 32 | 33 | formatt os2 le dll 34 | name glide2x.dll 35 | file glide2x.obj 36 | option map 37 | option nodefault 38 | option description 'Glide Router' 39 | 40 | The thunks.i file is included into both the Linux and DOS builds. 41 | The macros are defined in the file that includes thinks.i and 42 | is different in either case. The macros contain code for 43 | marshalling and un-marshalling all the parameters to/from the 44 | DOS environment. 45 | 46 | At the time of writing tombraider successfully starts up in 47 | DOSEMU making calls into the Linux openglide library. Openglide 48 | support is added via a plugin to DOSEMU using an extension to 49 | the vxd framework. Currently the emulation does crash, the 50 | problem being opening of the X display for glide. The call 51 | results in: 52 | 53 | THUNK_GRGLIDEINIT-done 54 | THUNK_GRSSTQUERYHARDWARE-done 55 | THUNK_GRSSTSELECT-done 56 | THUNK_GRSSTWINOPEN-done 57 | ERROR: Fault in dosemu code, in_dpmi=1 58 | ERROR: cpu exception in dosemu code outside of DPMI client! 59 | trapno: 0x0e errorcode: 0x00000006 cr2: 0x8500cf10 60 | eip: 0x00000007 esp: 0xbfcbd330 eflags: 0x00010206 61 | cs: 0x0073 ds: 0x007b es: 0x007b ss: 0x007b 62 | Page fault: write instruction to linear address: 0x8500cf10 63 | CPU was in user mode 64 | Exception was caused by non-available page 65 | ERROR: Fault handler re-entered! signal=11 _trapno=0xE 66 | ERROR: cpu exception in dosemu code outside of DPMI client! 67 | trapno: 0x0e errorcode: 0x00000005 cr2: 0xfffffffd 68 | eip: 0x08087827 esp: 0xbfcccfe0 eflags: 0x00010283 69 | cs: 0x0073 ds: 0x007b es: 0x007b ss: 0x007b 70 | Page fault: read instruction to linear address: 0xfffffffd 71 | CPU was in user mode 72 | Exception was caused by insufficient privilege 73 | 74 | The cause of this problem is unknown and currently under 75 | investigation. 76 | -------------------------------------------------------------------------------- /PGTexture.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* PGTexture Class Definition 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __PGTEXTURE_H__ 14 | #define __PGTEXTURE_H__ 15 | 16 | #include "sdk2_glide.h" 17 | #include "TexDB.h" 18 | 19 | class PGTexture 20 | { 21 | struct TexValues 22 | { 23 | GrLOD_t lod; 24 | FxU32 width; 25 | FxU32 height; 26 | FxU32 nPixels; 27 | }; 28 | 29 | public: 30 | void NCCTable( GrNCCTable_t tab ); 31 | 32 | static FxU32 LodOffset( FxU32 evenOdd, GrTexInfo *info ); 33 | static FxU32 MipMapMemRequired( GrLOD_t lod, GrAspectRatio_t aspectRatio, 34 | GrTextureFormat_t format ); 35 | void ChromakeyMode( GrChromakeyMode_t mode ); 36 | void ChromakeyValue( GrColor_t value ); 37 | void GetAspect( float *hAspect, float *wAspect ); 38 | void Clear( void ); 39 | static FxU32 TextureMemRequired( FxU32 evenOdd, GrTexInfo *info ); 40 | bool MakeReady( void ); 41 | void DownloadTable( GrTexTable_t type, FxU32 *data, int first, int count ); 42 | void Source( FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info ); 43 | void DownloadMipMap( FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info ); 44 | FxU32 GetMemorySize( void ); 45 | 46 | PGTexture( int mem_size ); 47 | virtual ~PGTexture(); 48 | 49 | #ifdef OGL_DEBUG 50 | int Num_565_Tex; 51 | int Num_1555_Tex; 52 | int Num_4444_Tex; 53 | int Num_332_Tex; 54 | int Num_8332_Tex; 55 | int Num_Alpha_Tex; 56 | int Num_AlphaIntensity88_Tex; 57 | int Num_AlphaIntensity44_Tex; 58 | int Num_AlphaPalette_Tex; 59 | int Num_Palette_Tex; 60 | int Num_Intensity_Tex; 61 | int Num_YIQ_Tex; 62 | int Num_AYIQ_Tex; 63 | int Num_Other_Tex; 64 | #endif 65 | 66 | private: 67 | void ApplyKeyToPalette( void ); 68 | void GetTexValues( TexValues *tval ); 69 | 70 | FxU32 m_tex_memory_size; 71 | bool m_palette_dirty; 72 | FxU32 m_palette_hash; 73 | TexDB * m_db; 74 | GrChromakeyMode_t m_chromakey_mode; 75 | FxU32 m_chromakey_value_8888; 76 | FxU16 m_chromakey_value_565; 77 | float m_wAspect; 78 | float m_hAspect; 79 | 80 | FxU32 m_tex_temp[ 256 * 256 ]; 81 | bool m_valid; 82 | FxU8 * m_memory; 83 | FxU32 m_startAddress; 84 | FxU32 m_evenOdd; 85 | GrTexInfo m_info; 86 | FxU32 m_palette[ 256 ]; 87 | GrNCCTable_t m_ncc_select; 88 | GuNccTable m_ncc[2]; 89 | }; 90 | 91 | extern PGTexture *Textures; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl Setup library CURRENT, REVISION and AGE 2 | m4_define([LIBCUR],0) 3 | m4_define([LIBREV],0) 4 | m4_define([LIBAGE],0) 5 | 6 | dnl Process this file with autoconf to produce a configure script. 7 | AC_INIT(libglide2x,2.LIBCUR.LIBREV) 8 | AM_CONFIG_HEADER(config.h) 9 | AC_CONFIG_SRCDIR(Makefile.am) 10 | 11 | dnl libtool-style version-info number 12 | LIBVERSION=LIBCUR:LIBREV:LIBAGE 13 | AC_SUBST(LIBVERSION) 14 | AC_SUBST(DLLFLAGS) 15 | 16 | AC_CANONICAL_HOST 17 | AC_CANONICAL_TARGET 18 | AM_INIT_AUTOMAKE(no-define) 19 | 20 | dnl Checks for programs. 21 | AC_PROG_CXX 22 | 23 | dnl Initialize libtool. 24 | AC_LIBTOOL_WIN32_DLL 25 | AC_PROG_LIBTOOL 26 | 27 | dnl Checks for header files. 28 | AC_HEADER_STDC 29 | 30 | dnl Checks for data type sizes 31 | AC_CHECK_SIZEOF(unsigned char) 32 | AC_CHECK_SIZEOF(unsigned short) 33 | AC_CHECK_SIZEOF(unsigned int) 34 | AC_CHECK_SIZEOF(unsigned long) 35 | AC_CHECK_SIZEOF(unsigned long long) 36 | AC_CHECK_SIZEOF(int *) 37 | 38 | AC_SUBST(SIZEOF_UNSIGNED_CHAR,$ac_cv_sizeof_unsigned_char) 39 | AC_SUBST(SIZEOF_UNSIGNED_SHORT,$ac_cv_sizeof_unsigned_short) 40 | AC_SUBST(SIZEOF_UNSIGNED_INT,$ac_cv_sizeof_unsigned_int) 41 | AC_SUBST(SIZEOF_UNSIGNED_LONG,$ac_cv_sizeof_unsigned_long) 42 | AC_SUBST(SIZEOF_UNSIGNED_LONG_LONG,$ac_cv_sizeof_unsigned_long_long) 43 | AC_SUBST(SIZEOF_INT_P,$ac_cv_sizeof_int_p) 44 | 45 | dnl Check for the X11 library 46 | AC_PATH_XTRA 47 | 48 | AH_TEMPLATE(C_USE_SDL,[Define to use SDL library]) 49 | AC_ARG_ENABLE(sdl,AC_HELP_STRING([--disable-sdl],[Disable SDL support]),,disable_sdl=no) 50 | 51 | dnl Check for SDL 52 | if test x$disable_sdl = xno ; then 53 | SDL_VERSION=1.2.0 54 | AM_PATH_SDL($SDL_VERSION, 55 | have_sdl_lib=yes, 56 | AC_MSG_WARN([SDL version $SDL_VERSION not found!]) 57 | ) 58 | fi 59 | 60 | if test x$have_sdl_lib = xyes ; then 61 | AC_DEFINE(C_USE_SDL) 62 | # Don't need SDLmain since we're a library 63 | LIBS="$LIBS ${SDL_LIBS/-lSDLmain/}" 64 | CPPFLAGS="$CPPFLAGS $SDL_CFLAGS" 65 | fi 66 | 67 | dnl The target cpu checks 68 | AH_TEMPLATE(HAVE_MMX,[Define if you have mmx support]) 69 | AC_MSG_CHECKING(for target cpu type) 70 | case "$target_cpu" in 71 | x86_64 | amd64) 72 | AC_DEFINE(HAVE_MMX,1) 73 | AC_MSG_RESULT(x86-64 bit compatible) 74 | ;; 75 | i?86) 76 | AC_DEFINE(HAVE_MMX,1) 77 | AC_MSG_RESULT(x86 compatible) 78 | CXXFLAGS="$CXXFLAGS -mmmx" 79 | #CXXFLAGS="-march=$target_cpu -fomit-frame-pointer $CXXFLAGS" 80 | ;; 81 | *) 82 | AC_MSG_RESULT(unknown) 83 | ;; 84 | esac 85 | 86 | dnl OS flag define test 87 | osflag="" 88 | case "$host" in 89 | *cygwin* | *mingw32*) 90 | CXXFLAGS="$CXXFLAGS -DWIN32 -I\$(top_srcdir)/platform/windows" 91 | LIBS="$LIBS -luser32 -lgdi32 -lopengl32 -lglu32" 92 | DLLFLAGS="-avoid-version -Wc,-def -Wc,Glide2x.def" 93 | ;; 94 | *darwin*) 95 | osflag="__linux__" 96 | CXXFLAGS="$CXXFLAGS -D__unix__ -D$osflag -I\$(top_srcdir)/platform/linux" 97 | LIBS="$LIBS -Wl,-framework,OpenGL" 98 | ;; 99 | *freebsd*) 100 | ;; 101 | *hpux*) 102 | ;; 103 | *irix*) 104 | ;; 105 | *linux*) 106 | osflag="__linux__" 107 | CXXFLAGS="$CXXFLAGS -D__unix__ -D$osflag -I\$(top_srcdir)/platform/linux $X_CFLAGS" 108 | LIBS="$LIBS -lGL -lGLU" 109 | if test x$have_sdl_lib != xyes ; then 110 | X_EXTRA_LIBS="$X_EXTRA_LIBS -lXxf86vm" 111 | fi 112 | ;; 113 | *netbsd*) 114 | ;; 115 | *qnx*) 116 | ;; 117 | *solaris*) 118 | ;; 119 | *sunos*) 120 | ;; 121 | *) 122 | ;; 123 | esac 124 | 125 | AC_OUTPUT( 126 | Makefile \ 127 | sdk2_unix.h \ 128 | platform/Makefile \ 129 | platform/linux/Makefile \ 130 | platform/sdl/Makefile \ 131 | platform/windows/Makefile \ 132 | ) 133 | -------------------------------------------------------------------------------- /sdk2_3dfx.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 1995, 3Dfx Interactive, Inc. 3 | ** All Rights Reserved. 4 | ** 5 | ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of 3Dfx Interactive, Inc.; 6 | ** the contents of this file may not be disclosed to third parties, copied or 7 | ** duplicated in any form, in whole or in part, without the prior written 8 | ** permission of 3Dfx Interactive, Inc. 9 | ** 10 | ** RESTRICTED RIGHTS LEGEND: 11 | ** Use, duplication or disclosure by the Government is subject to restrictions 12 | ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data 13 | ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or 14 | ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 15 | ** rights reserved under the Copyright Laws of the United States. 16 | ** 17 | ** $Revision: 1.4 $ 18 | ** $Date: 2009/09/15 11:37:06 $ 19 | */ 20 | #ifndef __3DFX_H__ 21 | #define __3DFX_H__ 22 | 23 | #if defined(__unix__) || (__MINGW32__) 24 | #include "sdk2_unix.h" 25 | #else 26 | /* 27 | ** basic data types 28 | */ 29 | typedef unsigned char FxU8; 30 | typedef signed char FxI8; 31 | typedef unsigned short FxU16; 32 | typedef signed short FxI16; 33 | typedef signed int FxI32; 34 | typedef unsigned int FxU32; 35 | typedef int FxBool; 36 | typedef float FxFloat; 37 | typedef double FxDouble; 38 | typedef FxU32 FxU; 39 | typedef FxI32 FxI; 40 | #endif 41 | 42 | /* 43 | ** color types 44 | */ 45 | typedef unsigned long FxColor_t; 46 | typedef struct { float r, g, b, a; } FxColor4; 47 | 48 | /* 49 | ** fundamental types 50 | */ 51 | #define FXTRUE 1 52 | #define FXFALSE 0 53 | 54 | /* 55 | ** helper macros 56 | */ 57 | #define FXUNUSED( a ) ((void)(a)) 58 | #define FXBIT( i ) ( 1L << (i) ) 59 | 60 | /* 61 | ** export macros 62 | */ 63 | 64 | #if defined(CPPDLL) 65 | #define DLLEXPORT extern "C" __declspec(dllexport) 66 | # define FX_ENTRY DLLEXPORT 67 | # define FX_CALL __stdcall 68 | #elif defined(__MSC__) 69 | # if defined (MSVC16) 70 | # define FX_ENTRY 71 | # define FX_CALL 72 | # else 73 | # define FX_ENTRY extern 74 | # define FX_CALL __stdcall 75 | # endif 76 | #elif defined(__MINGW32__) 77 | # define FX_ENTRY extern "C" 78 | # define FX_CALL __stdcall 79 | #elif defined(__WATCOMC__) 80 | # define FX_ENTRY extern 81 | # define FX_CALL __stdcall 82 | #elif defined (__IBMC__) || defined (__IBMCPP__) 83 | /* IBM Visual Age C/C++: */ 84 | # define FX_ENTRY extern 85 | # define FX_CALL __stdcall 86 | #elif defined(__DJGPP__) 87 | # define FX_ENTRY extern 88 | # define FX_CALL 89 | #elif defined(__unix__) 90 | # define FX_ENTRY extern 91 | # define FX_CALL 92 | #elif defined(__MWERKS__) 93 | # if macintosh 94 | # define FX_ENTRY extern 95 | # define FX_CALL 96 | # else /* !macintosh */ 97 | # error "Unknown MetroWerks target platform" 98 | # endif /* !macintosh */ 99 | #else 100 | # warning define FX_ENTRY & FX_CALL for your compiler 101 | # define FX_ENTRY extern 102 | # define FX_CALL 103 | #endif 104 | 105 | /* 106 | ** x86 compiler specific stuff 107 | */ 108 | #if defined(__BORLANDC_) 109 | # define REALMODE 110 | 111 | # define REGW( a, b ) ((a).x.b) 112 | # define REGB( a, b ) ((a).h.b) 113 | # define INT86( a, b, c ) int86(a,b,c) 114 | # define INT86X( a, b, c, d ) int86x(a,b,c,d) 115 | 116 | # define RM_SEG( a ) FP_SEG( a ) 117 | # define RM_OFF( a ) FP_OFF( a ) 118 | #elif defined(__WATCOMC__) 119 | # undef FP_SEG 120 | # undef FP_OFF 121 | 122 | # define REGW( a, b ) ((a).w.b) 123 | # define REGB( a, b ) ((a).h.b) 124 | # define INT86( a, b, c ) int386(a,b,c) 125 | # define INT86X( a, b, c, d ) int386x(a,b,c,d) 126 | 127 | # define RM_SEG( a ) ( ( ( ( FxU32 ) (a) ) & 0x000F0000 ) >> 4 ) 128 | # define RM_OFF( a ) ( ( FxU16 ) (a) ) 129 | #endif 130 | 131 | #endif /* !__3DFX_H__ */ 132 | -------------------------------------------------------------------------------- /sdk2_sst1vid.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 1995, 3Dfx Interactive, Inc. 3 | ** All Rights Reserved. 4 | ** 5 | ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of 3Dfx Interactive, Inc.; 6 | ** the contents of this file may not be disclosed to third parties, copied or 7 | ** duplicated in any form, in whole or in part, without the prior written 8 | ** permission of 3Dfx Interactive, Inc. 9 | ** 10 | ** RESTRICTED RIGHTS LEGEND: 11 | ** Use, duplication or disclosure by the Government is subject to restrictions 12 | ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data 13 | ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or 14 | ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 15 | ** rights reserved under the Copyright Laws of the United States. 16 | ** 17 | ** $Header: /cvsroot/openglide/openglide/sdk2_sst1vid.h,v 1.1 2002/12/05 13:50:21 fbarros Exp $ 18 | ** $Log: sdk2_sst1vid.h,v $ 19 | ** Revision 1.1 2002/12/05 13:50:21 fbarros 20 | ** 3dfx sdk 2 header file 21 | ** 22 | ** Revision 1.1.1.1 2001/06/25 18:00:49 paul 23 | ** v006 from sourceforge 24 | ** 25 | ** Revision 1.1.1.1 2001/02/01 16:24:51 fbarros 26 | ** Version 0.06 27 | ** 28 | ** CVs: ---------------------------------------------------------------------- 29 | ** 30 | * 31 | * 4 9/09/97 7:35p Sellers 32 | * Added 400x300 resolution 33 | * 34 | * 3 8/24/97 9:31a Sellers 35 | * moved new video timing to sst1vid.h 36 | * redefined 1600x1280 to be 1600x1200 37 | * 38 | * 2 6/05/97 11:14p Pgj 39 | * 40 | * 5 7/24/96 3:43p Sellers 41 | * added 512x384 @ 60 Hz for arcade monitors 42 | * added 512x256 @ 60 Hz for arcade monitors 43 | * 44 | * 4 7/18/96 10:58a Sellers 45 | * fixed FT and TF clock delay values for lower frequencies with 46 | * .5/.5 combos 47 | * 48 | * 3 6/18/96 6:54p Sellers 49 | * added sst1InitShutdownSli() to fix Glide Splash screen problems with 50 | * SLI 51 | * 52 | * 2 6/13/96 7:45p Sellers 53 | * added "voodoo.ini" support 54 | * added DirectX support 55 | * misc cleanup 56 | * 57 | * 2 6/11/96 1:43p Sellers 58 | * added support for 60, 75, 85, and 120 Hz refresh rates for "most" 59 | * resolutions 60 | * 61 | * 1 5/08/96 5:43p Paik 62 | * Video definitions 63 | */ 64 | #ifndef __SST1VID_H__ 65 | #define __SST1VID_H__ 66 | 67 | #ifdef __cplusplus 68 | extern "C" { 69 | #endif 70 | 71 | /* Video defines */ 72 | 73 | typedef FxI32 GrScreenRefresh_t; 74 | #define GR_REFRESH_60Hz 0x0 75 | #define GR_REFRESH_70Hz 0x1 76 | #define GR_REFRESH_72Hz 0x2 77 | #define GR_REFRESH_75Hz 0x3 78 | #define GR_REFRESH_80Hz 0x4 79 | #define GR_REFRESH_90Hz 0x5 80 | #define GR_REFRESH_100Hz 0x6 81 | #define GR_REFRESH_85Hz 0x7 82 | #define GR_REFRESH_120Hz 0x8 83 | #define GR_REFRESH_NONE 0xff 84 | 85 | typedef FxI32 GrScreenResolution_t; 86 | #define GR_RESOLUTION_320x200 0x0 87 | #define GR_RESOLUTION_320x240 0x1 88 | #define GR_RESOLUTION_400x256 0x2 89 | #define GR_RESOLUTION_512x384 0x3 90 | #define GR_RESOLUTION_640x200 0x4 91 | #define GR_RESOLUTION_640x350 0x5 92 | #define GR_RESOLUTION_640x400 0x6 93 | #define GR_RESOLUTION_640x480 0x7 94 | #define GR_RESOLUTION_800x600 0x8 95 | #define GR_RESOLUTION_960x720 0x9 96 | #define GR_RESOLUTION_856x480 0xa 97 | #define GR_RESOLUTION_512x256 0xb 98 | #define GR_RESOLUTION_1024x768 0xC 99 | #define GR_RESOLUTION_1280x1024 0xD 100 | #define GR_RESOLUTION_1600x1200 0xE 101 | #define GR_RESOLUTION_400x300 0xF 102 | #define GR_RESOLUTION_NONE 0xff 103 | 104 | #ifdef GR_RESOLUTION_MAX 105 | #undef GR_RESOLUTION_MAX 106 | #endif 107 | #ifdef GR_RESOLUTION_MIN 108 | #undef GR_RESOLUTION_MIN 109 | #endif 110 | #define GR_RESOLUTION_MIN GR_RESOLUTION_320x200 111 | #define GR_RESOLUTION_MAX GR_RESOLUTION_1600x1200 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif /* __SST1VID_H__ */ 118 | -------------------------------------------------------------------------------- /platform/sdl/window.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* SDL specific functions for handling display window 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #ifdef C_USE_SDL 17 | 18 | #include 19 | #include 20 | 21 | #include "SDL.h" 22 | #include "SDL_opengl.h" 23 | 24 | #include "GlOgl.h" 25 | 26 | #include "platform/window.h" 27 | 28 | static struct 29 | { 30 | Uint16 red[ 256 ]; 31 | Uint16 green[ 256 ]; 32 | Uint16 blue[ 256 ]; 33 | } old_ramp; 34 | 35 | static bool ramp_stored = false; 36 | static bool wasInit = false; 37 | 38 | bool InitialiseOpenGLWindow(FxU wnd, int x, int y, int width, int height) 39 | { 40 | bool FullScreen = UserConfig.InitFullScreen; 41 | wasInit = SDL_WasInit(SDL_INIT_VIDEO)!=0; 42 | if(!wasInit) 43 | { 44 | bool err = false; 45 | char *oldWindowId = 0; 46 | char windowId[40]; 47 | 48 | if (wnd) 49 | { // Set SDL window ID 50 | sprintf (windowId, "SDL_WINDOWID=%ld", (long)wnd); 51 | oldWindowId = getenv("SDL_WINDOWID"); 52 | if (oldWindowId) 53 | oldWindowId = strdup(oldWindowId); 54 | putenv(windowId); 55 | } 56 | 57 | if (SDL_Init(SDL_INIT_VIDEO)) 58 | { 59 | GlideMsg("Can't init SDL %s",SDL_GetError()); 60 | err = true; 61 | } 62 | 63 | if (wnd) 64 | { // Restore old value 65 | if (!oldWindowId) 66 | putenv("SDL_WINDOWID"); 67 | else 68 | { 69 | sprintf (windowId, "SDL_WINDOWID=%s", oldWindowId); 70 | putenv(windowId); 71 | free (oldWindowId); 72 | } 73 | } 74 | 75 | if (err) 76 | return false; 77 | } else { 78 | SDL_Surface* tmpSurface = SDL_GetVideoSurface(); 79 | if (tmpSurface) 80 | { 81 | // Preserve window/fullscreen mode in SDL apps and override config file entry 82 | (tmpSurface->flags&SDL_FULLSCREEN) ? (FullScreen = true) : (FullScreen = false); 83 | } 84 | } 85 | 86 | SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); 87 | SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); 88 | 89 | if((SDL_SetVideoMode(width, height, 32, FullScreen ? SDL_OPENGL|SDL_FULLSCREEN : SDL_OPENGL)) == 0) 90 | { 91 | GlideMsg("Video mode set failed: %s\n", SDL_GetError()); 92 | return false; 93 | } 94 | 95 | SDL_GL_GetAttribute(SDL_GL_DEPTH_SIZE, &height); 96 | if ( height > 16 ) { 97 | UserConfig.PrecisionFix = false; 98 | } 99 | 100 | if(SDL_GetGammaRamp(old_ramp.red, old_ramp.green, old_ramp.blue) != -1) 101 | ramp_stored = true; 102 | 103 | return true; 104 | } 105 | 106 | void FinaliseOpenGLWindow( void) 107 | { 108 | if ( ramp_stored ) 109 | SDL_SetGammaRamp(old_ramp.red, old_ramp.green, old_ramp.blue); 110 | if (!wasInit) 111 | SDL_Quit(); 112 | } 113 | 114 | void SetGamma(float value) 115 | { 116 | struct 117 | { 118 | Uint16 red[256]; 119 | Uint16 green[256]; 120 | Uint16 blue[256]; 121 | } ramp; 122 | int i; 123 | 124 | for ( i = 0; i < 256; i++ ) 125 | { 126 | Uint16 v = (Uint16)( 0xffff * pow( i / 255.0, 1.0 / value ) ); 127 | 128 | ramp.red[ i ] = ramp.green[ i ] = ramp.blue[ i ] = ( v & 0xff00 ); 129 | } 130 | 131 | SDL_SetGammaRamp(ramp.red, ramp.green, ramp.blue); 132 | } 133 | 134 | void RestoreGamma() 135 | { 136 | } 137 | 138 | bool SetScreenMode(int &xsize, int &ysize) 139 | { 140 | return true; 141 | } 142 | 143 | void ResetScreenMode() 144 | { 145 | } 146 | 147 | void SwapBuffers() 148 | { 149 | SDL_GL_SwapBuffers(); 150 | } 151 | 152 | #endif // C_USE_SDL 153 | -------------------------------------------------------------------------------- /grguBuffer.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Buffer functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include 14 | 15 | #include "GlOgl.h" 16 | #include "GLRender.h" 17 | 18 | #include "platform/window.h" 19 | 20 | // extern functions 21 | void ConvertColorF( GrColor_t GlideColor, float &R, float &G, float &B, float &A ); 22 | 23 | 24 | //************************************************* 25 | //* Clear all the Buffers 26 | //************************************************* 27 | FX_ENTRY void FX_CALL 28 | grBufferClear( GrColor_t color, GrAlpha_t alpha, FxU16 depth ) 29 | { 30 | #if defined( OGL_PARTDONE ) || defined( OGL_COMBINE ) 31 | GlideMsg( "grBufferClear( %d, %d, %d )\n", color, alpha, depth ); 32 | #endif 33 | 34 | static GrColor_t old_color = 0; 35 | static float BR = 0.0f, 36 | BG = 0.0f, 37 | BB = 0.0f, 38 | BA = 0.0f; 39 | static unsigned int Bits; 40 | 41 | Bits = 0; 42 | 43 | RenderDrawTriangles( ); 44 | 45 | if ( OpenGL.ColorMask ) 46 | { 47 | Bits = GL_COLOR_BUFFER_BIT; 48 | if ( color != old_color ) 49 | { 50 | old_color = color; 51 | ConvertColorF( color, BR, BG, BB, BA ); 52 | } 53 | glClearColor( BR, BG, BB, BA ); 54 | } 55 | 56 | if ( Glide.State.DepthBufferWritting ) 57 | { 58 | glClearDepth( depth * D1OVER65535 ); 59 | Bits |= GL_DEPTH_BUFFER_BIT; 60 | } 61 | 62 | if ( ! OpenGL.Clipping ) 63 | { 64 | glClear( Bits ); 65 | } 66 | else 67 | { 68 | glEnable( GL_SCISSOR_TEST ); 69 | glClear( Bits ); 70 | glDisable( GL_SCISSOR_TEST ); 71 | } 72 | 73 | #ifdef OPENGL_DEBUG 74 | GLErro( "grBufferClear" ); 75 | #endif 76 | } 77 | 78 | //************************************************* 79 | //* Swaps Front and Back Buffers 80 | //************************************************* 81 | FX_ENTRY void FX_CALL 82 | grBufferSwap( int swap_interval ) 83 | { 84 | #if defined( OGL_PARTDONE ) || defined( OGL_COMBINE ) 85 | GlideMsg( "grBufferSwap( %d )\n", swap_interval ); 86 | #endif 87 | 88 | RenderDrawTriangles( ); 89 | glFlush( ); 90 | 91 | #ifdef OGL_DEBUG 92 | static float Temp = 1.0f; 93 | 94 | if ( OGLRender.FrameTriangles > OGLRender.MaxTriangles ) 95 | { 96 | OGLRender.MaxTriangles = OGLRender.FrameTriangles; 97 | } 98 | OGLRender.FrameTriangles = 0; 99 | #endif 100 | 101 | SwapBuffers( ); 102 | 103 | #ifdef OGL_DEBUG 104 | RDTSC( FinalTick ); 105 | Temp = (float)(FinalTick - InitialTick); 106 | FpsAux += Temp; 107 | Frame++; 108 | RDTSC( InitialTick ); 109 | #endif 110 | 111 | #ifdef OPENGL_DEBUG 112 | GLErro( "grBufferSwap" ); 113 | #endif 114 | } 115 | 116 | //************************************************* 117 | //* Return the number of queued buffer swap requests 118 | //* Always 0, never pending 119 | //************************************************* 120 | FX_ENTRY int FX_CALL 121 | grBufferNumPending( void ) 122 | { 123 | #ifdef OGL_DONE 124 | GlideMsg( "grBufferNumPending( ) = 0\n" ); 125 | #endif 126 | 127 | return 0; 128 | } 129 | 130 | //************************************************* 131 | //* Defines the Buffer to Render 132 | //************************************************* 133 | FX_ENTRY void FX_CALL 134 | grRenderBuffer( GrBuffer_t dwBuffer ) 135 | { 136 | #ifdef OGL_DONE 137 | GlideMsg( "grRenderBuffer( %d )\n", dwBuffer ); 138 | #endif 139 | 140 | RenderDrawTriangles( ); 141 | 142 | Glide.State.RenderBuffer = dwBuffer; 143 | 144 | // Valid parameters are only FRONT and BACK ( 0x0 and 0x1 ) 145 | OpenGL.RenderBuffer = GL_FRONT + dwBuffer; 146 | 147 | glDrawBuffer( OpenGL.RenderBuffer ); 148 | 149 | #ifdef OPENGL_DEBUG 150 | GLErro( "grRenderBuffer" ); 151 | #endif 152 | } 153 | -------------------------------------------------------------------------------- /sdk2_glidesys.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 1995, 3Dfx Interactive, Inc. 3 | ** All Rights Reserved. 4 | ** 5 | ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of 3Dfx Interactive, Inc.; 6 | ** the contents of this file may not be disclosed to third parties, copied or 7 | ** duplicated in any form, in whole or in part, without the prior written 8 | ** permission of 3Dfx Interactive, Inc. 9 | ** 10 | ** RESTRICTED RIGHTS LEGEND: 11 | ** Use, duplication or disclosure by the Government is subject to restrictions 12 | n** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data 13 | ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or 14 | ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 15 | ** rights reserved under the Copyright Laws of the United States. 16 | ** 17 | ** $Header: /cvsroot/openglide/openglide/sdk2_glidesys.h,v 1.1 2002/12/05 13:50:21 fbarros Exp $ 18 | ** $Log: sdk2_glidesys.h,v $ 19 | ** Revision 1.1 2002/12/05 13:50:21 fbarros 20 | ** 3dfx sdk 2 header file 21 | ** 22 | ** Revision 1.1.1.1 2001/06/25 18:00:50 paul 23 | ** v006 from sourceforge 24 | ** 25 | ** Revision 1.1.1.1 2001/02/01 16:24:51 fbarros 26 | ** Version 0.06 27 | ** 28 | ** CVs: ---------------------------------------------------------------------- 29 | ** 30 | */ 31 | #ifndef __GLIDESYS_H__ 32 | #define __GLIDESYS_H__ 33 | 34 | /* 35 | n** ----------------------------------------------------------------------- 36 | ** COMPILER/ENVIRONMENT CONFIGURATION 37 | ** ----------------------------------------------------------------------- 38 | */ 39 | 40 | /* Endianness is stored in bits [30:31] */ 41 | #define GLIDE_ENDIAN_SHIFT 30 42 | #define GLIDE_ENDIAN_LITTLE (0x1 << GLIDE_ENDIAN_SHIFT) 43 | #define GLIDE_ENDIAN_BIG (0x2 << GLIDE_ENDIAN_SHIFT) 44 | 45 | /* OS is stored in bits [0:6] */ 46 | #define GLIDE_OS_SHIFT 0 47 | #define GLIDE_OS_UNIX 0x1 48 | #define GLIDE_OS_DOS32 0x2 49 | #define GLIDE_OS_WIN32 0x4 50 | #define GLIDE_OS_SYSTEM7 0x8 51 | #define GLIDE_OS_OS2 0x10 52 | #define GLIDE_OS_OTHER 0x20 /* For Proprietary Arcade HW */ 53 | 54 | /* Sim vs. Hardware is stored in bits [7:8] */ 55 | #define GLIDE_SST_SHIFT 7 56 | #define GLIDE_SST_SIM (0x1 << GLIDE_SST_SHIFT) 57 | #define GLIDE_SST_HW (0x2 << GLIDE_SST_SHIFT ) 58 | 59 | /* Hardware Type is stored in bits [9:12] */ 60 | #define GLIDE_HW_SHIFT 9 61 | #define GLIDE_HW_SST1 (0x1 << GLIDE_HW_SHIFT) 62 | #define GLIDE_HW_SST96 (0x2 << GLIDE_HW_SHIFT) 63 | #define GLIDE_HW_SSTH3 (0x4 << GLIDE_HW_SHIFT) 64 | #define GLIDE_HW_SST2 (0x8 << GLIDE_HW_SHIFT) 65 | 66 | /* 67 | ** Make sure we handle all instances of WIN32 68 | */ 69 | #ifndef __WIN32__ 70 | # if defined ( _WIN32 ) || defined (WIN32) || defined(__NT__) 71 | # define __WIN32__ 72 | # endif 73 | #endif 74 | 75 | /* We need two checks on the OS: one for endian, the other for OS */ 76 | /* Check for endianness */ 77 | #if defined(__IRIX__) || defined(__sparc__) || defined(MACOS) 78 | # define GLIDE_ENDIAN GLIDE_ENDIAN_BIG 79 | #else 80 | # define GLIDE_ENDIAN GLIDE_ENDIAN_LITTLE 81 | #endif 82 | 83 | /* Check for OS */ 84 | #if defined(__IRIX__) || defined(__sparc__) || defined(__linux__) 85 | # define GLIDE_OS GLIDE_OS_UNIX 86 | #elif defined(__DOS__) 87 | # define GLIDE_OS GLIDE_OS_DOS32 88 | #elif defined(__WIN32__) 89 | # define GLIDE_OS GLIDE_OS_WIN32 90 | #endif 91 | 92 | /* Check for Simulator vs. Hardware */ 93 | #ifdef GLIDE_SIMULATOR 94 | # define GLIDE_SST GLIDE_SST_SIM 95 | #else 96 | # define GLIDE_SST GLIDE_SST_HW 97 | #endif 98 | 99 | /* Check for type of hardware */ 100 | #ifdef SST96 101 | # define GLIDE_HW GLIDE_HW_SST96 102 | #elif defined(SSTH3) 103 | # define GLIDE_HW GLIDE_HW_SSTH3 104 | #elif defined(SST2) 105 | # define GLIDE_HW GLIDE_HW_SST2 106 | #else /* Default to SST1 */ 107 | # define GLIDE_HW GLIDE_HW_SST1 108 | #endif 109 | 110 | 111 | #define GLIDE_PLATFORM (GLIDE_ENDIAN | GLIDE_OS | GLIDE_SST | GLIDE_HW) 112 | 113 | /* 114 | ** Control the number of TMUs 115 | */ 116 | #ifndef GLIDE_NUM_TMU 117 | # define GLIDE_NUM_TMU 2 118 | #endif 119 | 120 | 121 | #if ( ( GLIDE_NUM_TMU < 0 ) && ( GLIDE_NUM_TMU > 3 ) ) 122 | # error "GLIDE_NUM_TMU set to an invalid value" 123 | #endif 124 | 125 | #endif /* __GLIDESYS_H__ */ 126 | -------------------------------------------------------------------------------- /gbanner.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ** THIS SOFTWARE IS SUBJECT TO COPYRIGHT PROTECTION AND IS OFFERED ONLY 3 | ** PURSUANT TO THE 3DFX GLIDE GENERAL PUBLIC LICENSE. THERE IS NO RIGHT 4 | ** TO USE THE GLIDE TRADEMARK WITHOUT PRIOR WRITTEN PERMISSION OF 3DFX 5 | ** INTERACTIVE, INC. A COPY OF THIS LICENSE MAY BE OBTAINED FROM THE 6 | ** DISTRIBUTOR OR BY CONTACTING 3DFX INTERACTIVE INC(info@3dfx.com). 7 | ** THIS PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER 8 | ** EXPRESSED OR IMPLIED. SEE THE 3DFX GLIDE GENERAL PUBLIC LICENSE FOR A 9 | ** FULL TEXT OF THE NON-WARRANTY PROVISIONS. 10 | ** 11 | ** USE, DUPLICATION OR DISCLOSURE BY THE GOVERNMENT IS SUBJECT TO 12 | ** RESTRICTIONS AS SET FORTH IN SUBDIVISION (C)(1)(II) OF THE RIGHTS IN 13 | ** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013, 14 | ** AND/OR IN SIMILAR OR SUCCESSOR CLAUSES IN THE FAR, DOD OR NASA FAR 15 | ** SUPPLEMENT. UNPUBLISHED RIGHTS RESERVED UNDER THE COPYRIGHT LAWS OF 16 | ** THE UNITED STATES. 17 | ** 18 | ** COPYRIGHT 3DFX INTERACTIVE, INC. 1999, ALL RIGHTS RESERVED 19 | ** 20 | ** $Header: /cvsroot/openglide/openglide/gbanner.cpp,v 1.1 2009/02/15 21:54:46 s_a_white Exp $ 21 | ** $Log: gbanner.cpp,v $ 22 | ** Revision 1.1 2009/02/15 21:54:46 s_a_white 23 | ** Add banner support (shameless plug) and user configuration options for 24 | ** this and the splash screen 25 | ** 26 | ** Revision 1.2 2005/07/20 20:45:56 jens-olaf 27 | ** Commented out unwanted code instead of using #define statements 28 | ** 29 | ** Revision 1.1 2005/07/09 21:28:54 jens-olaf 30 | ** Added splash screen and shameless plug 31 | ** 32 | ** Revision 1.1.1.1 1999/12/07 21:48:52 joseph 33 | ** Initial checkin into SourceForge. 34 | ** 35 | * 36 | * 9 5/02/97 2:08p Pgj 37 | * screen_width/height now FxU32 38 | * 39 | * 8 3/16/97 2:24a Jdt 40 | * Fixed bug. Didn't initialize info. 41 | * 42 | * 7 3/12/97 11:51p Jdt 43 | * Watcom warning. 44 | * 45 | * 6 3/12/97 4:20p Jdt 46 | * Fixed for VG96 and optimized SST-1 47 | * 48 | * 5 2/26/97 11:55a Jdt 49 | * Updated banner for new lfb api 50 | * 51 | * 4 12/23/96 1:37p Dow 52 | * chagnes for multiplatform glide 53 | ** 54 | */ 55 | 56 | #include 57 | #include 58 | #include 59 | #include "GlOgl.h" 60 | 61 | // OpenGLide specific 62 | 63 | #include "banner.dat" 64 | 65 | /* display the translucent 3Dfx powerfield logo */ 66 | void 67 | grShamelessPlug( void ) 68 | { 69 | // #ifdef GLIDE_PLUG 70 | GrState state; 71 | GrLfbInfo_t info; 72 | 73 | grGlideGetState( &state ); 74 | grDisableAllEffects(); 75 | 76 | grAlphaCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, 77 | GR_COMBINE_FACTOR_ONE, 78 | GR_COMBINE_LOCAL_CONSTANT, 79 | GR_COMBINE_OTHER_TEXTURE, FXFALSE ); 80 | grColorCombine( GR_COMBINE_FUNCTION_SCALE_OTHER, 81 | GR_COMBINE_FACTOR_ONE, 82 | GR_COMBINE_LOCAL_NONE, 83 | GR_COMBINE_OTHER_TEXTURE, 84 | FXFALSE ); 85 | grAlphaBlendFunction( GR_BLEND_SRC_ALPHA, 86 | GR_BLEND_ONE_MINUS_SRC_ALPHA, 87 | GR_BLEND_ZERO, GR_BLEND_ZERO ); 88 | grClipWindow( 0, 0, 89 | Glide.WindowWidth - 1, 90 | Glide.WindowHeight - 1); 91 | grDepthMask(FXFALSE); 92 | grDepthBufferFunction(GR_CMP_ALWAYS); 93 | grDepthBufferMode( GR_DEPTHBUFFER_DISABLE ); 94 | 95 | grChromakeyValue( 0x0000 ); 96 | grChromakeyMode( GR_CHROMAKEY_ENABLE ); 97 | grLfbConstantAlpha( (FxU8) 90); 98 | grLfbWriteColorFormat(GR_COLORFORMAT_ARGB); 99 | 100 | /* Attempt to lock with pixpipe enabled */ 101 | info.size = sizeof( info ); 102 | if ( grLfbLock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER, 103 | GR_LFBWRITEMODE_565,GR_ORIGIN_UPPER_LEFT, 104 | FXTRUE, &info ) ) { 105 | FxU32 *dstData; 106 | FxU32 dstJump; 107 | FxU32 *srcData; 108 | FxI32 srcJump; 109 | FxU32 srcScanlineLength; 110 | FxU32 scrWidth = Glide.WindowWidth; 111 | FxU32 scrHeight = Glide.WindowHeight; 112 | 113 | FxU32 scanline; 114 | 115 | /* Draw Banner in lower right of screen */ 116 | if ( scrWidth < (FxU32)banner_width ) return; 117 | if ( scrHeight < (FxU32)banner_height ) return; 118 | 119 | dstData = static_cast(info.lfbPtr); 120 | dstData = (FxU32*)( ((char*)dstData) + 121 | (info.strideInBytes*((scrHeight-1)-banner_height)) + 122 | ((scrWidth-banner_width)<<1) ); 123 | dstJump = ((info.strideInBytes >> 1) - banner_width)>>1; 124 | srcData = (FxU32*)&banner_data[banner_width*(banner_height-1)]; 125 | srcScanlineLength = banner_width>>1; 126 | srcJump = (-banner_width); 127 | 128 | for( scanline = 0; scanline < (FxU32)banner_height; scanline++ ) { 129 | FxU32 *end = srcData + srcScanlineLength; 130 | while( srcData < end ) *dstData++ = *srcData++; 131 | dstData += dstJump; 132 | srcData += srcJump; 133 | } 134 | 135 | grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_BACKBUFFER ); 136 | } 137 | grGlideSetState( &state ); 138 | } /* grShamelessPlug */ 139 | -------------------------------------------------------------------------------- /grguDepth.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Depth (Z/W-Buffer) Functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include "GlOgl.h" 14 | #include "GLRender.h" 15 | 16 | //************************************************* 17 | //* Changes Depth Buffer Mode 18 | //************************************************* 19 | FX_ENTRY void FX_CALL 20 | grDepthBufferMode( GrDepthBufferMode_t mode ) 21 | { 22 | #ifdef OGL_DONE 23 | GlideMsg( "grDepthBufferMode( %d )\n", mode ); 24 | #endif 25 | 26 | RenderDrawTriangles( ); 27 | 28 | Glide.State.DepthBufferMode = mode; 29 | 30 | /* 31 | * In AddTriangle etc. Use of z or w for 32 | * depth buffering is determined by the 33 | * value of OpenGL.DepthBufferType. So 34 | * I set it here. 35 | */ 36 | switch ( mode ) 37 | { 38 | case GR_DEPTHBUFFER_DISABLE: 39 | OpenGL.DepthBufferType = 0; 40 | glDisable( GL_DEPTH_TEST ); 41 | return; 42 | 43 | case GR_DEPTHBUFFER_ZBUFFER: 44 | case GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS: 45 | OpenGL.DepthBufferType = 1; 46 | OpenGL.ZNear = ZBUFFERNEAR; 47 | OpenGL.ZFar = ZBUFFERFAR; 48 | break; 49 | 50 | case GR_DEPTHBUFFER_WBUFFER: 51 | case GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS: 52 | OpenGL.DepthBufferType = 0; 53 | OpenGL.ZNear = WBUFFERNEAR; 54 | OpenGL.ZFar = WBUFFERFAR; 55 | break; 56 | } 57 | 58 | glEnable( GL_DEPTH_TEST ); 59 | 60 | glMatrixMode( GL_PROJECTION ); 61 | glLoadIdentity( ); 62 | 63 | if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT ) 64 | { 65 | glOrtho( Glide.State.ClipMinX, Glide.State.ClipMaxX, 66 | Glide.State.ClipMinY, Glide.State.ClipMaxY, 67 | OpenGL.ZNear, OpenGL.ZFar ); 68 | glViewport( Glide.State.ClipMinX, Glide.State.ClipMinY, 69 | Glide.State.ClipMaxX - Glide.State.ClipMinX, 70 | Glide.State.ClipMaxY - Glide.State.ClipMinY ); 71 | } 72 | else 73 | { 74 | glOrtho( Glide.State.ClipMinX, Glide.State.ClipMaxX, 75 | Glide.State.ClipMaxY, Glide.State.ClipMinY, 76 | OpenGL.ZNear, OpenGL.ZFar ); 77 | glViewport( Glide.State.ClipMinX, OpenGL.WindowHeight - Glide.State.ClipMaxY, 78 | Glide.State.ClipMaxX - Glide.State.ClipMinX, 79 | Glide.State.ClipMaxY - Glide.State.ClipMinY ); 80 | } 81 | 82 | glMatrixMode( GL_MODELVIEW ); 83 | 84 | #ifdef OPENGL_DEBUG 85 | GLErro( "grDepthBufferMode" ); 86 | #endif 87 | } 88 | 89 | //************************************************* 90 | //* Enables or Disables Depth Buffer Writting 91 | //************************************************* 92 | FX_ENTRY void FX_CALL 93 | grDepthMask( FxBool enable ) 94 | { 95 | #ifdef OGL_DONE 96 | GlideMsg( "grDepthMask( %d )\n", enable ); 97 | #endif 98 | 99 | RenderDrawTriangles( ); 100 | 101 | Glide.State.DepthBufferWritting = OpenGL.DepthBufferWritting = enable; 102 | 103 | glDepthMask( OpenGL.DepthBufferWritting ); 104 | 105 | #ifdef OPENGL_DEBUG 106 | GLErro( "grDepthMask" ); 107 | #endif 108 | } 109 | 110 | //************************************************* 111 | //* Sets the Depth Function to use 112 | //************************************************* 113 | FX_ENTRY void FX_CALL 114 | grDepthBufferFunction( GrCmpFnc_t func ) 115 | { 116 | #ifdef OGL_DONE 117 | GlideMsg( "grDepthBufferFunction( %d )\n", func ); 118 | #endif 119 | 120 | RenderDrawTriangles( ); 121 | 122 | Glide.State.DepthFunction = func; 123 | 124 | // We can do this just because we know the constant values for both OpenGL and Glide 125 | // To port it to anything else than OpenGL we NEED to change this code 126 | OpenGL.DepthFunction = GL_NEVER + func; 127 | 128 | glDepthFunc( OpenGL.DepthFunction ); 129 | 130 | #ifdef OPENGL_DEBUG 131 | GLErro( "grDepthBufferFunction" ); 132 | #endif 133 | } 134 | 135 | //************************************************* 136 | //* Set the depth bias level 137 | //************************************************* 138 | FX_ENTRY void FX_CALL 139 | grDepthBiasLevel( FxI16 level ) 140 | { 141 | #ifdef OGL_PARTDONE 142 | GlideMsg( "grDepthBiasLevel( %d )\n", level ); 143 | #endif 144 | 145 | RenderDrawTriangles( ); 146 | 147 | Glide.State.DepthBiasLevel = level; 148 | //OpenGL.DepthBiasLevel = level * D1OVER65536; 149 | OpenGL.DepthBiasLevel = level * 10.0f; 150 | 151 | glPolygonOffset( 1.0f, OpenGL.DepthBiasLevel ); 152 | 153 | if ( level != 0 ) 154 | { 155 | glEnable( GL_POLYGON_OFFSET_FILL ); 156 | } 157 | else 158 | { 159 | glDisable( GL_POLYGON_OFFSET_FILL ); 160 | } 161 | 162 | #ifdef OPENGL_DEBUG 163 | GLErro( "grDepthBiasLevel" ); 164 | #endif 165 | } 166 | 167 | -------------------------------------------------------------------------------- /sdk2_glideutl.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** Copyright (c) 1995, 3Dfx Interactive, Inc. 3 | ** All Rights Reserved. 4 | ** 5 | ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of 3Dfx Interactive, Inc.; 6 | ** the contents of this file may not be disclosed to third parties, copied or 7 | ** duplicated in any form, in whole or in part, without the prior written 8 | ** permission of 3Dfx Interactive, Inc. 9 | ** 10 | ** RESTRICTED RIGHTS LEGEND: 11 | ** Use, duplication or disclosure by the Government is subject to restrictions 12 | ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data 13 | ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or 14 | ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished - 15 | ** rights reserved under the Copyright Laws of the United States. 16 | ** 17 | ** $Header: /cvsroot/openglide/openglide/sdk2_glideutl.h,v 1.1 2002/12/05 13:50:21 fbarros Exp $ 18 | ** $Log: sdk2_glideutl.h,v $ 19 | ** Revision 1.1 2002/12/05 13:50:21 fbarros 20 | ** 3dfx sdk 2 header file 21 | ** 22 | ** Revision 1.1.1.1 2001/06/25 18:00:50 paul 23 | ** v006 from sourceforge 24 | ** 25 | ** Revision 1.1.1.1 2001/02/01 16:24:51 fbarros 26 | ** Version 0.06 27 | ** 28 | ** CVs: ---------------------------------------------------------------------- 29 | ** 30 | * 31 | * 11 1/07/98 11:18a Atai 32 | * remove GrMipMapInfo and GrGC.mm_table in glide3 33 | * 34 | * 10 1/06/98 6:47p Atai 35 | * undo grSplash and remove gu routines 36 | * 37 | * 9 1/05/98 6:04p Atai 38 | * move 3df gu related data structure from glide.h to glideutl.h 39 | * 40 | * 8 12/18/97 2:13p Peter 41 | * fogTable cataclysm 42 | * 43 | * 7 12/15/97 5:52p Atai 44 | * disable obsolete glide2 api for glide3 45 | * 46 | * 6 8/14/97 5:32p Pgj 47 | * remove dead code per GMT 48 | * 49 | * 5 6/12/97 5:19p Pgj 50 | * Fix bug 578 51 | * 52 | * 4 3/05/97 9:36p Jdt 53 | * Removed guFbWriteRegion added guEncodeRLE16 54 | * 55 | * 3 1/16/97 3:45p Dow 56 | * Embedded fn protos in ifndef FX_GLIDE_NO_FUNC_PROTO 57 | */ 58 | 59 | /* Glide Utility routines */ 60 | 61 | #ifndef __GLIDEUTL_H__ 62 | #define __GLIDEUTL_H__ 63 | 64 | #ifdef __cplusplus 65 | extern "C" { 66 | #endif 67 | 68 | #if defined(GLIDE3) && defined(GLIDE3_ALPHA) 69 | /* 70 | ** 3DF texture file structs 71 | */ 72 | 73 | typedef struct 74 | { 75 | FxU32 width, height; 76 | int small_lod, large_lod; 77 | GrAspectRatio_t aspect_ratio; 78 | GrTextureFormat_t format; 79 | } Gu3dfHeader; 80 | 81 | typedef struct 82 | { 83 | FxU8 yRGB[16]; 84 | FxI16 iRGB[4][3]; 85 | FxI16 qRGB[4][3]; 86 | FxU32 packed_data[12]; 87 | } GuNccTable; 88 | 89 | typedef struct { 90 | FxU32 data[256]; 91 | } GuTexPalette; 92 | 93 | typedef union { 94 | GuNccTable nccTable; 95 | GuTexPalette palette; 96 | } GuTexTable; 97 | 98 | typedef struct 99 | { 100 | Gu3dfHeader header; 101 | GuTexTable table; 102 | void *data; 103 | FxU32 mem_required; /* memory required for mip map in bytes. */ 104 | } Gu3dfInfo; 105 | 106 | #endif 107 | 108 | #ifndef FX_GLIDE_NO_FUNC_PROTO 109 | /* 110 | ** rendering functions 111 | */ 112 | 113 | #ifndef GLIDE3_ALPHA 114 | FX_ENTRY void FX_CALL 115 | guAADrawTriangleWithClip( const GrVertex *a, const GrVertex 116 | *b, const GrVertex *c); 117 | 118 | FX_ENTRY void FX_CALL 119 | guDrawTriangleWithClip( 120 | const GrVertex *a, 121 | const GrVertex *b, 122 | const GrVertex *c 123 | ); 124 | 125 | FX_ENTRY void FX_CALL 126 | guDrawPolygonVertexListWithClip( int nverts, const GrVertex vlist[] ); 127 | 128 | /* 129 | ** hi-level rendering utility functions 130 | */ 131 | FX_ENTRY void FX_CALL 132 | guAlphaSource( GrAlphaSource_t mode ); 133 | 134 | FX_ENTRY void FX_CALL 135 | guColorCombineFunction( GrColorCombineFnc_t fnc ); 136 | 137 | FX_ENTRY int FX_CALL 138 | guEncodeRLE16( void *dst, 139 | void *src, 140 | FxU32 width, 141 | FxU32 height ); 142 | 143 | FX_ENTRY FxU16 * FX_CALL 144 | guTexCreateColorMipMap( void ); 145 | #endif /* !GLIDE3_ALPHA */ 146 | 147 | #ifdef GLIDE3 148 | FX_ENTRY void FX_CALL 149 | guGammaCorrectionRGB( FxFloat red, FxFloat green, FxFloat blue ); 150 | #endif 151 | 152 | /* 153 | ** fog stuff 154 | */ 155 | FX_ENTRY float FX_CALL 156 | guFogTableIndexToW( int i ); 157 | 158 | FX_ENTRY void FX_CALL 159 | guFogGenerateExp( GrFog_t fogtable[], float density ); 160 | 161 | FX_ENTRY void FX_CALL 162 | guFogGenerateExp2( GrFog_t fogtable[], float density ); 163 | 164 | FX_ENTRY void FX_CALL 165 | guFogGenerateLinear(GrFog_t fogtable[], 166 | float nearZ, float farZ ); 167 | 168 | /* 169 | ** endian stuff 170 | */ 171 | #ifndef GLIDE3_ALPHA 172 | FX_ENTRY FxU32 FX_CALL 173 | guEndianSwapWords( FxU32 value ); 174 | 175 | FX_ENTRY FxU16 FX_CALL 176 | guEndianSwapBytes( FxU16 value ); 177 | #endif /* !GLIDE3_ALPHA */ 178 | 179 | /* 180 | ** hi-level texture manipulation tools. 181 | */ 182 | FX_ENTRY FxBool FX_CALL 183 | gu3dfGetInfo( const char *filename, Gu3dfInfo *info ); 184 | 185 | FX_ENTRY FxBool FX_CALL 186 | gu3dfLoad( const char *filename, Gu3dfInfo *data ); 187 | 188 | #endif /* FX_GLIDE_NO_FUNC_PROTO */ 189 | 190 | #ifdef __cplusplus 191 | } 192 | #endif 193 | 194 | #endif /* __GLIDEUTL_H__ */ 195 | -------------------------------------------------------------------------------- /Glide.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Main File 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include 14 | 15 | #include "GlOgl.h" 16 | #include "Glextensions.h" 17 | #include "PGTexture.h" 18 | #include "PGUTexture.h" 19 | 20 | #include "platform/error.h" 21 | 22 | /////////////////////////////////////////////////////////////////////////////////////// 23 | /////////////////////////////////////////////////////////////////////////////////////// 24 | /////////////////////////////////////////////////////////////////////////////////////// 25 | /////////////////////////////// Version /////////////////////////////////////////////// 26 | /////////////////////////////////////////////////////////////////////////////////////// 27 | /////////////////////////////////////////////////////////////////////////////////////// 28 | /////////////////////////////////////////////////////////////////////////////////////// 29 | 30 | 31 | const char * OpenGLideVersion = "0.09rc9"; 32 | 33 | 34 | /////////////////////////////////////////////////////////////////////////////////////// 35 | /////////////////////////////////////////////////////////////////////////////////////// 36 | /////////////////////////////////////////////////////////////////////////////////////// 37 | /////////////////////////////////////////////////////////////////////////////////////// 38 | /////////////////////////////////////////////////////////////////////////////////////// 39 | /////////////////////////////////////////////////////////////////////////////////////// 40 | 41 | // Main Structs 42 | GlideStruct Glide; 43 | OpenGLStruct OpenGL; 44 | 45 | // Classes 46 | PGTexture *Textures; 47 | PGUTexture UTextures; 48 | 49 | #ifdef OGL_DEBUG 50 | // Profiling variables 51 | FxI64 InitialTick; 52 | FxI64 FinalTick; 53 | FxU32 Frame; 54 | double Fps; 55 | double FpsAux; 56 | #endif 57 | 58 | double ClockFreq; 59 | 60 | // Error Function variable 61 | GLIDEERRORFUNCTION ExternErrorFunction; 62 | 63 | // Number of Errors 64 | unsigned long NumberOfErrors; 65 | 66 | // Support DLL functions 67 | 68 | void InitMainVariables( void ) 69 | { 70 | OpenGL.WinOpen = false; 71 | OpenGL.GlideInit = false; 72 | NumberOfErrors = 0; 73 | GetOptions( ); 74 | } 75 | 76 | bool InitWindow( FxU hWnd ) 77 | { 78 | if ( !InitialiseOpenGLWindow( hWnd, 0, 0, OpenGL.WindowWidth, OpenGL.WindowHeight ) ) { 79 | Error( "Failed to Initialise OpenGL Window!\n" ); 80 | return false; 81 | } 82 | 83 | if ( !strcmp( (char*)glGetString( GL_RENDERER ), "GDI Generic" ) ) 84 | ReportWarning("You are running in a Non-Accelerated OpenGL!!!\nThings can become really slow"); 85 | 86 | ValidateUserConfig( ); 87 | 88 | GlideMsg( OGL_LOG_SEPARATE ); 89 | GlideMsg( " Setting in Use: \n" ); 90 | GlideMsg( OGL_LOG_SEPARATE ); 91 | GlideMsg( "Init Full Screen = %s\n", InternalConfig.InitFullScreen ? "true" : "false" ); 92 | GlideMsg( "Fog = %s\n", InternalConfig.FogEnable ? "true" : "false" ); 93 | GlideMsg( "Precision Fix = %s\n", InternalConfig.PrecisionFix ? "true" : "false" ); 94 | GlideMsg( "Wrap 565 to 5551 = %s\n", InternalConfig.Wrap565to5551 ? "true" : "false" ); 95 | GlideMsg( "Texture Memory Size = %d Mb\n", InternalConfig.TextureMemorySize ); 96 | GlideMsg( "Frame Buffer Memory Size = %d Mb\n", InternalConfig.FrameBufferMemorySize ); 97 | GlideMsg( "MMX is %s\n", InternalConfig.MMXEnable ? "present" : "not present" ); 98 | GlideMsg( OGL_LOG_SEPARATE ); 99 | 100 | #ifdef OGL_DEBUG 101 | GlideMsg( OGL_LOG_SEPARATE ); 102 | GlideMsg( "GlideState size = %d\n", sizeof( GlideState ) ); 103 | GlideMsg( "GrState size = %d\n", sizeof( GrState ) ); 104 | GlideMsg( OGL_LOG_SEPARATE ); 105 | #endif 106 | 107 | GlideMsg( OGL_LOG_SEPARATE ); 108 | GlideMsg( "** Glide Calls **\n" ); 109 | GlideMsg( OGL_LOG_SEPARATE ); 110 | 111 | return true; 112 | } 113 | 114 | //************************************************* 115 | //* Initializes OpenGL 116 | //************************************************* 117 | void InitOpenGL( void ) 118 | { 119 | OpenGL.ZNear = ZBUFFERNEAR; 120 | OpenGL.ZFar = ZBUFFERFAR; 121 | 122 | glMatrixMode( GL_PROJECTION ); 123 | glLoadIdentity( ); 124 | glOrtho( 0, Glide.WindowWidth, 0, Glide.WindowHeight, OpenGL.ZNear, OpenGL.ZFar ); 125 | glViewport( 0, 0, OpenGL.WindowWidth, OpenGL.WindowHeight ); 126 | 127 | glMatrixMode( GL_MODELVIEW ); 128 | glLoadIdentity( ); 129 | 130 | glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); 131 | // glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); 132 | // glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND ); 133 | // glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD ); 134 | // glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); 135 | 136 | glPixelStorei( GL_PACK_ALIGNMENT, 2); 137 | glPixelStorei( GL_UNPACK_ALIGNMENT, 2); 138 | } 139 | -------------------------------------------------------------------------------- /TexDB.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* implementation of the TexDB class 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include "GlOgl.h" 14 | #include "TexDB.h" 15 | 16 | ////////////////////////////////////////////////////////////////////// 17 | // Construction/Destruction 18 | ////////////////////////////////////////////////////////////////////// 19 | 20 | TexDB::TexDB( unsigned int MemorySize ) 21 | { 22 | numberOfTexSections = MemorySize >> 15; // ( 32 * 1024 ); 23 | 24 | m_first = new Record*[ numberOfTexSections ]; 25 | 26 | for ( unsigned int i = 0; i < numberOfTexSections; i++ ) 27 | { 28 | m_first[ i ] = NULL; 29 | } 30 | } 31 | 32 | TexDB::~TexDB( void ) 33 | { 34 | Record * r; 35 | 36 | for ( unsigned int i = 0; i < numberOfTexSections; i++ ) 37 | { 38 | r = m_first[ i ]; 39 | 40 | while ( r != NULL ) 41 | { 42 | Record * tmp = r; 43 | r = r->next; 44 | delete tmp; 45 | } 46 | } 47 | delete[] m_first; 48 | } 49 | 50 | GrTexInfo * TexDB::Find( FxU32 startAddress, GrTexInfo *info, FxU32 hash, 51 | GLuint *pTexNum, GLuint *pTex2Num, bool *pal_change ) 52 | { 53 | Record * r; 54 | FxU32 sect = startAddress >> 15; // ( 32 * 1024 ); 55 | 56 | for ( r = m_first[ sect ]; r != NULL; r = r->next ) 57 | { 58 | if ( r->Match( startAddress, info, ( pal_change == NULL ) ? hash : 0 ) ) 59 | { 60 | *pTexNum = r->texNum; 61 | 62 | if ( pTex2Num ) 63 | { 64 | *pTex2Num = r->tex2Num; 65 | } 66 | 67 | if ( ( pal_change != NULL ) && ( r->hash != hash ) ) 68 | { 69 | r->hash = hash; 70 | *pal_change = true; 71 | } 72 | 73 | #ifdef OGL_UTEX 74 | GlideMsg( "Found tex %d\n", r->texNum ); 75 | #endif 76 | return &r->info; 77 | } 78 | } 79 | 80 | #ifdef OGL_UTEX 81 | GlideMsg( "Tex not found\n" ); 82 | #endif 83 | 84 | return NULL; 85 | } 86 | 87 | void TexDB::WipeRange(FxU32 startAddress, FxU32 endAddress, FxU32 hash) 88 | { 89 | Record ** p; 90 | FxU32 stt_sect; 91 | FxU32 end_sect; 92 | 93 | stt_sect = startAddress >> 15; // ( 32 * 1024 ); 94 | 95 | /* 96 | * Textures can be as large as 128K, so 97 | * one that starts 3 sections back can 98 | * extend into this one. 99 | */ 100 | if ( stt_sect < 4 ) 101 | { 102 | stt_sect = 0; 103 | } 104 | else 105 | { 106 | stt_sect -= 4; 107 | } 108 | 109 | end_sect = endAddress >> 15; // ( 32 * 1024 ); 110 | 111 | if ( end_sect >= numberOfTexSections ) 112 | { 113 | end_sect = numberOfTexSections - 1; 114 | } 115 | 116 | for ( FxU32 i = stt_sect; i <= end_sect; i++ ) 117 | { 118 | p = &( m_first[ i ] ); 119 | while ( *p != NULL ) 120 | { 121 | Record * r = *p; 122 | 123 | if ( ( startAddress < r->endAddress ) && 124 | ( r->startAddress < endAddress ) && 125 | ( ( hash == 0 ) || ( r->hash == hash ) ) ) 126 | { 127 | *p = r->next; 128 | #ifdef OGL_UTEX 129 | GlideMsg( "Wipe tex %d\n", r->texNum ); 130 | #endif 131 | delete r; 132 | } 133 | else 134 | { 135 | p = &(r->next); 136 | } 137 | } 138 | } 139 | } 140 | 141 | void TexDB::Add( FxU32 startAddress, FxU32 endAddress, GrTexInfo *info, FxU32 hash, GLuint *pTexNum, GLuint *pTex2Num ) 142 | { 143 | Record *r = new Record( pTex2Num != NULL ); 144 | FxU32 sect; 145 | 146 | sect = startAddress >> 15; // 32 * 1024 147 | 148 | r->startAddress = startAddress; 149 | r->endAddress = endAddress; 150 | r->info = *info; 151 | r->hash = hash; 152 | 153 | r->next = m_first[ sect ]; 154 | m_first[ sect ] = r; 155 | 156 | #ifdef OGL_UTEX 157 | GlideMsg( "Add tex %d\n", r->texNum ); 158 | #endif 159 | 160 | *pTexNum = r->texNum; 161 | 162 | if ( pTex2Num ) 163 | { 164 | *pTex2Num = r->tex2Num; 165 | } 166 | } 167 | 168 | 169 | void TexDB::Clear( void ) 170 | { 171 | Record * r; 172 | 173 | for ( unsigned int i = 0; i < numberOfTexSections; i++ ) 174 | { 175 | r = m_first[ i ]; 176 | 177 | while ( r != NULL ) 178 | { 179 | Record *tmp = r; 180 | r = r->next; 181 | delete tmp; 182 | } 183 | 184 | m_first[ i ] = NULL; 185 | } 186 | } 187 | 188 | // TexDB::Record Class implementation 189 | 190 | TexDB::Record::Record( bool two_tex ) 191 | { 192 | glGenTextures( 1, &texNum ); 193 | 194 | if ( two_tex ) 195 | { 196 | glGenTextures( 1, &tex2Num ); 197 | } 198 | else 199 | { 200 | tex2Num = 0; 201 | } 202 | } 203 | 204 | TexDB::Record::~Record( void ) 205 | { 206 | glDeleteTextures( 1, &texNum ); 207 | 208 | if ( tex2Num != 0 ) 209 | { 210 | glDeleteTextures( 1, &tex2Num ); 211 | } 212 | } 213 | 214 | bool TexDB::Record::Match( FxU32 stt, GrTexInfo *inf, FxU32 h ) 215 | { 216 | return ( ( startAddress == stt ) && 217 | ( inf->largeLod == info.largeLod ) && 218 | ( inf->aspectRatio == info.aspectRatio ) && 219 | ( inf->format == info.format ) && 220 | ( ( hash == h ) || ( h == 0 ) ) ); 221 | } 222 | -------------------------------------------------------------------------------- /Glide2x.def: -------------------------------------------------------------------------------- 1 | LIBRARY glide2x.dll 2 | EXPORTS 3 | _ConvertAndDownloadRle@64 = ConvertAndDownloadRle@64 4 | _grAADrawLine@8 = grAADrawLine@8 5 | _grAADrawPoint@4 = grAADrawPoint@4 6 | _grAADrawPolygon@12 = grAADrawPolygon@12 7 | _grAADrawPolygonVertexList@8 = grAADrawPolygonVertexList@8 8 | _grAADrawTriangle@24 = grAADrawTriangle@24 9 | _grAlphaBlendFunction@16 = grAlphaBlendFunction@16 10 | _grAlphaCombine@20 = grAlphaCombine@20 11 | _grAlphaControlsITRGBLighting@4 = grAlphaControlsITRGBLighting@4 12 | _grAlphaTestFunction@4 = grAlphaTestFunction@4 13 | _grAlphaTestReferenceValue@4 = grAlphaTestReferenceValue@4 14 | _grBufferClear@12 = grBufferClear@12 15 | _grBufferNumPending@0 = grBufferNumPending@0 16 | _grBufferSwap@4 = grBufferSwap@4 17 | _grCheckForRoom@4 = grCheckForRoom@4 18 | _grChromakeyMode@4 = grChromakeyMode@4 19 | _grChromakeyValue@4 = grChromakeyValue@4 20 | _grClipWindow@16 = grClipWindow@16 21 | _grColorCombine@20 = grColorCombine@20 22 | _grColorMask@8 = grColorMask@8 23 | _grConstantColorValue4@16 = grConstantColorValue4@16 24 | _grConstantColorValue@4 = grConstantColorValue@4 25 | _grCullMode@4 = grCullMode@4 26 | _grDepthBiasLevel@4 = grDepthBiasLevel@4 27 | _grDepthBufferFunction@4 = grDepthBufferFunction@4 28 | _grDepthBufferMode@4 = grDepthBufferMode@4 29 | _grDepthMask@4 = grDepthMask@4 30 | _grDisableAllEffects@0 = grDisableAllEffects@0 31 | _grDitherMode@4 = grDitherMode@4 32 | _grDrawLine@8 = grDrawLine@8 33 | _grDrawPlanarPolygon@12 = grDrawPlanarPolygon@12 34 | _grDrawPlanarPolygonVertexList@8= grDrawPlanarPolygonVertexList@8 35 | _grDrawPoint@4 = grDrawPoint@4 36 | _grDrawPolygon@12 = grDrawPolygon@12 37 | _grDrawPolygonVertexList@8 = grDrawPolygonVertexList@8 38 | _grDrawTriangle@12 = grDrawTriangle@12 39 | _grErrorSetCallback@4 = grErrorSetCallback@4 40 | _grFogColorValue@4 = grFogColorValue@4 41 | _grFogMode@4 = grFogMode@4 42 | _grFogTable@4 = grFogTable@4 43 | _grGammaCorrectionValue@4 = grGammaCorrectionValue@4 44 | _grGlideGetState@4 = grGlideGetState@4 45 | _grGlideGetVersion@4 = grGlideGetVersion@4 46 | _grGlideInit@0 = grGlideInit@0 47 | _grGlideSetState@4 = grGlideSetState@4 48 | _grGlideShamelessPlug@4 = grGlideShamelessPlug@4 49 | _grGlideShutdown@0 = grGlideShutdown@0 50 | _grHints@8 = grHints@8 51 | _grLfbConstantAlpha@4 = grLfbConstantAlpha@4 52 | _grLfbConstantDepth@4 = grLfbConstantDepth@4 53 | _grLfbLock@24 = grLfbLock@24 54 | _grLfbReadRegion@28 = grLfbReadRegion@28 55 | _grLfbUnlock@8 = grLfbUnlock@8 56 | _grLfbWriteColorFormat@4 = grLfbWriteColorFormat@4 57 | _grLfbWriteColorSwizzle@8 = grLfbWriteColorSwizzle@8 58 | _grLfbWriteRegion@32 = grLfbWriteRegion@32 59 | _grParameterData@16 = grParameterData@16 60 | _grRenderBuffer@4 = grRenderBuffer@4 61 | _grResetTriStats@0 = grResetTriStats@0 62 | _grSplash@20 = grSplash@20 63 | _grSstControl@4 = grSstControl@4 64 | _grSstControlMode@4 = grSstControlMode@4 65 | _grSstIdle@0 = grSstIdle@0 66 | _grSstIsBusy@0 = grSstIsBusy@0 67 | _grSstOrigin@4 = grSstOrigin@4 68 | _grSstPerfStats@4 = grSstPerfStats@4 69 | _grSstQueryBoards@4 = grSstQueryBoards@4 70 | _grSstQueryHardware@4 = grSstQueryHardware@4 71 | _grSstResetPerfStats@0 = grSstResetPerfStats@0 72 | _grSstScreenHeight@0 = grSstScreenHeight@0 73 | _grSstScreenWidth@0 = grSstScreenWidth@0 74 | _grSstSelect@4 = grSstSelect@4 75 | _grSstStatus@0 = grSstStatus@0 76 | _grSstVRetraceOn@0 = grSstVRetraceOn@0 77 | _grSstVideoLine@0 = grSstVideoLine@0 78 | _grSstWinClose@0 = grSstWinClose@0 79 | _grSstWinOpen@28 = grSstWinOpen@28 80 | _grTexCalcMemRequired@16 = grTexCalcMemRequired@16 81 | _grTexClampMode@12 = grTexClampMode@12 82 | _grTexCombine@28 = grTexCombine@28 83 | _grTexCombineFunction@8 = grTexCombineFunction@8 84 | _grTexDetailControl@16 = grTexDetailControl@16 85 | _grTexDownloadMipMap@16 = grTexDownloadMipMap@16 86 | _grTexDownloadMipMapLevel@32 = grTexDownloadMipMapLevel@32 87 | _grTexDownloadMipMapLevelPartial@40 = grTexDownloadMipMapLevelPartial@40 88 | _grTexDownloadTable@12 = grTexDownloadTable@12 89 | _grTexDownloadTablePartial@20 = grTexDownloadTablePartial@20 90 | _grTexFilterMode@12 = grTexFilterMode@12 91 | _grTexLodBiasValue@8 = grTexLodBiasValue@8 92 | _grTexMaxAddress@4 = grTexMaxAddress@4 93 | _grTexMinAddress@4 = grTexMinAddress@4 94 | _grTexMipMapMode@12 = grTexMipMapMode@12 95 | _grTexMultibase@8 = grTexMultibase@8 96 | _grTexMultibaseAddress@20 = grTexMultibaseAddress@20 97 | _grTexNCCTable@8 = grTexNCCTable@8 98 | _grTexSource@16 = grTexSource@16 99 | _grTexTextureMemRequired@8 = grTexTextureMemRequired@8 100 | _grTriStats@8 = grTriStats@8 101 | _gu3dfGetInfo@8 = gu3dfGetInfo@8 102 | _gu3dfLoad@8 = gu3dfLoad@8 103 | _guAADrawTriangleWithClip@12 = guAADrawTriangleWithClip@12 104 | _guAlphaSource@4 = guAlphaSource@4 105 | _guColorCombineFunction@4 = guColorCombineFunction@4 106 | _guDrawPolygonVertexListWithClip@8 = guDrawPolygonVertexListWithClip@8 107 | _guDrawTriangleWithClip@12 = guDrawTriangleWithClip@12 108 | _guEncodeRLE16@16 = guEncodeRLE16@16 109 | _guEndianSwapBytes@4 = guEndianSwapBytes@4 110 | _guEndianSwapWords@4 = guEndianSwapWords@4 111 | _guFogGenerateExp2@8 = guFogGenerateExp2@8 112 | _guFogGenerateExp@8 = guFogGenerateExp@8 113 | _guFogGenerateLinear@12 = guFogGenerateLinear@12 114 | _guFogTableIndexToW@4 = guFogTableIndexToW@4 115 | _guMovieSetName@4 = guMovieSetName@4 116 | _guMovieStart@0 = guMovieStart@0 117 | _guMovieStop@0 = guMovieStop@0 118 | _guTexAllocateMemory@60 = guTexAllocateMemory@60 119 | _guTexChangeAttributes@48 = guTexChangeAttributes@48 120 | _guTexCombineFunction@8 = guTexCombineFunction@8 121 | _guTexCreateColorMipMap@0 = guTexCreateColorMipMap@0 122 | _guTexDownloadMipMap@12 = guTexDownloadMipMap@12 123 | _guTexDownloadMipMapLevel@12 = guTexDownloadMipMapLevel@12 124 | _guTexGetCurrentMipMap@4 = guTexGetCurrentMipMap@4 125 | _guTexGetMipMapInfo@4 = guTexGetMipMapInfo@4 126 | _guTexMemQueryAvail@4 = guTexMemQueryAvail@4 127 | _guTexMemReset@0 = guTexMemReset@0 128 | _guTexSource@4 = guTexSource@4 129 | _setConfig@4 = setConfig@4 130 | -------------------------------------------------------------------------------- /GLRender.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Render Header 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __GLRENDER_H__ 14 | #define __GLRENDER_H__ 15 | 16 | //************************************************************** 17 | // Defines 18 | //************************************************************** 19 | 20 | #define MAXTRIANGLES 500 21 | 22 | 23 | //************************************************************** 24 | // Structs 25 | //************************************************************** 26 | 27 | struct GlVertex 28 | { 29 | GLfloat x, y, z; 30 | GLfloat s, t, q, oow; 31 | GLfloat r, g, b, a; 32 | GLfloat r2, g2, b2, a2; 33 | GLfloat f; 34 | }; 35 | 36 | struct Triangle 37 | { 38 | GlVertex a, b, c; 39 | }; 40 | 41 | struct ColorStruct 42 | { 43 | GLfloat r, g, b, a; 44 | }; 45 | 46 | struct TColorStruct 47 | { 48 | GLfloat ar, ag, ab, aa; 49 | GLfloat br, bg, bb, ba; 50 | GLfloat cr, cg, cb, ca; 51 | }; 52 | 53 | struct TVertexStruct 54 | { 55 | GLfloat ax, ay, az, aw; 56 | GLfloat bx, by, bz, bw; 57 | GLfloat cx, cy, cz, cw; 58 | }; 59 | 60 | struct TTextureStruct 61 | { 62 | GLfloat as, at, aq, aoow; 63 | GLfloat bs, bt, bq, boow; 64 | GLfloat cs, ct, cq, coow; 65 | }; 66 | 67 | struct TFogStruct 68 | { 69 | GLfloat af; 70 | GLfloat bf; 71 | GLfloat cf; 72 | }; 73 | 74 | struct RenderStruct 75 | { 76 | TColorStruct *TColor; 77 | TColorStruct *TColor2; 78 | TTextureStruct *TTexture; 79 | TVertexStruct *TVertex; 80 | TFogStruct *TFog; 81 | long NumberOfTriangles; 82 | 83 | #ifdef OGL_DEBUG 84 | float MinX, MinY, MinZ, MinW; 85 | float MaxX, MaxY, MaxZ, MaxW; 86 | float MinS, MinT, MaxS, MaxT; 87 | float MinR, MinG, MinB, MinA; 88 | float MaxR, MaxG, MaxB, MaxA; 89 | float MaxF, MinF; 90 | long FrameTriangles, MaxTriangles, MaxSequencedTriangles; 91 | #endif 92 | }; 93 | 94 | typedef float (*ALPHAFACTORFUNCPROC)( float LocalAlpha, float OtherAlpha ); 95 | typedef void (FASTCALL *COLORFACTORFUNCPROC)( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 96 | typedef void (*COLORFUNCTIONPROC)( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 97 | 98 | //************************************************************** 99 | // Function Prototypes 100 | //************************************************************** 101 | 102 | // Main Render functions 103 | void RenderInitialize( void ); 104 | void RenderFree( void ); 105 | void RenderUpdateArrays( void ); 106 | void RenderAddTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c, bool unsnap ); 107 | void RenderAddLine( const GrVertex *a, const GrVertex *b, bool unsnap ); 108 | void RenderAddPoint( const GrVertex *a, bool unsnap ); 109 | void RenderDrawTriangles( void ); 110 | 111 | // Main Render variables 112 | extern RenderStruct OGLRender; 113 | extern ALPHAFACTORFUNCPROC AlphaFactorFunc; 114 | extern COLORFACTORFUNCPROC ColorFactor3Func; 115 | extern COLORFUNCTIONPROC ColorFunctionFunc; 116 | 117 | // Prototypes for the color combining 118 | float AlphaFactorZero( float LocalAlpha, float OtherAlpha ); 119 | float AlphaFactorLocal( float LocalAlpha, float OtherAlpha ); 120 | float AlphaFactorOther( float LocalAlpha, float OtherAlpha ); 121 | float AlphaFactorOneMinusLocal( float LocalAlpha, float OtherAlpha ); 122 | float AlphaFactorOneMinusOther( float LocalAlpha, float OtherAlpha ); 123 | float AlphaFactorOne( float LocalAlpha, float OtherAlpha ); 124 | 125 | void FASTCALL ColorFactor3Zero( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 126 | void FASTCALL ColorFactor3Local( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 127 | void FASTCALL ColorFactor3LocalAlpha( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 128 | void FASTCALL ColorFactor3OneMinusLocal( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 129 | void FASTCALL ColorFactor3OneMinusLocalAlpha( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 130 | void FASTCALL ColorFactor3OtherAlpha( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 131 | void FASTCALL ColorFactor3OneMinusOtherAlpha( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 132 | void FASTCALL ColorFactor3One( TColorStruct *Result, TColorStruct *ColorComponent, TColorStruct *OtherAlpha ); 133 | 134 | void ColorFunctionZero( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 135 | void ColorFunctionLocal( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 136 | void ColorFunctionLocalAlpha( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 137 | void ColorFunctionScaleOther( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 138 | void ColorFunctionScaleOtherAddLocal( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 139 | void ColorFunctionScaleOtherAddLocalAlpha( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 140 | void ColorFunctionScaleOtherMinusLocal( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 141 | void ColorFunctionScaleOtherMinusLocalAddLocal( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 142 | void ColorFunctionScaleOtherMinusLocalAddLocalAlpha( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 143 | void ColorFunctionMinusLocalAddLocal( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 144 | void ColorFunctionMinusLocalAddLocalAlpha( TColorStruct * pC, TColorStruct * pC2, TColorStruct * Local, TColorStruct * Other ); 145 | 146 | #endif 147 | -------------------------------------------------------------------------------- /platform/windows/window.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Windows specific functions for handling display window 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | #ifdef HAVE_CONFIG_H 13 | #include "config.h" 14 | #endif 15 | 16 | #if !defined C_USE_SDL && defined WIN32 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "GlOgl.h" 23 | 24 | #include "platform/window.h" 25 | 26 | static HDC hDC; 27 | static HGLRC hRC; 28 | static HWND hWND; 29 | static struct 30 | { 31 | FxU16 red[ 256 ]; 32 | FxU16 green[ 256 ]; 33 | FxU16 blue[ 256 ]; 34 | } old_ramp; 35 | 36 | static BOOL ramp_stored = false; 37 | static BOOL mode_changed = false; 38 | 39 | bool InitialiseOpenGLWindow(FxU wnd, int x, int y, int width, int height) 40 | { 41 | PIXELFORMATDESCRIPTOR pfd; 42 | int PixFormat; 43 | unsigned int BitsPerPixel; 44 | HWND hwnd = (HWND) wnd; 45 | 46 | if( hwnd == NULL ) 47 | { 48 | hwnd = GetActiveWindow(); 49 | } 50 | 51 | if ( hwnd == NULL ) 52 | { 53 | MessageBox( NULL, "NULL window specified", "Error", MB_OK ); 54 | exit( 1 ); 55 | } 56 | 57 | mode_changed = false; 58 | 59 | if ( UserConfig.InitFullScreen ) 60 | { 61 | SetWindowLong( hwnd, 62 | GWL_STYLE, 63 | WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS ); 64 | MoveWindow( hwnd, 0, 0, width, height, false ); 65 | mode_changed = SetScreenMode( width, height ); 66 | } 67 | else 68 | { 69 | RECT rect; 70 | rect.left = 0; 71 | rect.right = width; 72 | rect.top = 0; 73 | rect.bottom = height; 74 | 75 | AdjustWindowRectEx( &rect, 76 | GetWindowLong( hwnd, GWL_STYLE ), 77 | GetMenu( hwnd ) != NULL, 78 | GetWindowLong( hwnd, GWL_EXSTYLE ) ); 79 | MoveWindow( hwnd, 80 | x, y, 81 | x + ( rect.right - rect.left ), 82 | y + ( rect.bottom - rect.top ), 83 | true ); 84 | } 85 | 86 | hWND = hwnd; 87 | 88 | hDC = GetDC( hwnd ); 89 | BitsPerPixel = GetDeviceCaps( hDC, BITSPIXEL ); 90 | 91 | ZeroMemory( &pfd, sizeof( pfd ) ); 92 | pfd.nSize = sizeof( pfd ); 93 | pfd.nVersion = 1; 94 | pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 95 | pfd.iPixelType = PFD_TYPE_RGBA; 96 | pfd.cColorBits = BitsPerPixel; 97 | pfd.cDepthBits = BitsPerPixel; 98 | 99 | if ( !( PixFormat = ChoosePixelFormat( hDC, &pfd ) ) ) 100 | { 101 | MessageBox( NULL, "ChoosePixelFormat() failed: " 102 | "Cannot find a suitable pixel format.", "Error", MB_OK ); 103 | exit( 1 ); 104 | } 105 | 106 | // the window must have WS_CLIPCHILDREN and WS_CLIPSIBLINGS for this call to 107 | // work correctly, so we SHOULD set this attributes, not doing that yet 108 | if ( !SetPixelFormat( hDC, PixFormat, &pfd ) ) 109 | { 110 | MessageBox( NULL, "SetPixelFormat() failed: " 111 | "Cannot set format specified.", "Error", MB_OK ); 112 | exit( 1 ); 113 | } 114 | 115 | DescribePixelFormat( hDC, PixFormat, sizeof( PIXELFORMATDESCRIPTOR ), &pfd ); 116 | GlideMsg( "ColorBits = %d\n", pfd.cColorBits ); 117 | GlideMsg( "DepthBits = %d\n", pfd.cDepthBits ); 118 | 119 | if ( pfd.cDepthBits > 16 ) 120 | { 121 | UserConfig.PrecisionFix = false; 122 | } 123 | 124 | hRC = wglCreateContext( hDC ); 125 | wglMakeCurrent( hDC, hRC ); 126 | 127 | HDC pDC = GetDC( NULL ); 128 | 129 | ramp_stored = GetDeviceGammaRamp( pDC, &old_ramp ); 130 | 131 | ReleaseDC( NULL, pDC ); 132 | return true; 133 | } 134 | 135 | void FinaliseOpenGLWindow( void) 136 | { 137 | if ( ramp_stored ) 138 | { 139 | HDC pDC = GetDC( NULL ); 140 | 141 | BOOL res = SetDeviceGammaRamp( pDC, &old_ramp ); 142 | 143 | ReleaseDC( NULL, pDC ); 144 | } 145 | 146 | wglMakeCurrent( NULL, NULL ); 147 | wglDeleteContext( hRC ); 148 | ReleaseDC( hWND, hDC ); 149 | 150 | if( mode_changed ) 151 | { 152 | ResetScreenMode( ); 153 | } 154 | } 155 | 156 | void SetGamma(float value) 157 | { 158 | struct 159 | { 160 | WORD red[256]; 161 | WORD green[256]; 162 | WORD blue[256]; 163 | } ramp; 164 | int i; 165 | HDC pDC = GetDC( NULL ); 166 | 167 | for ( i = 0; i < 256; i++ ) 168 | { 169 | WORD v = (WORD)( 0xffff * pow( i / 255.0, 1.0 / value ) ); 170 | 171 | ramp.red[ i ] = ramp.green[ i ] = ramp.blue[ i ] = ( v & 0xff00 ); 172 | } 173 | 174 | BOOL res = SetDeviceGammaRamp( pDC, &ramp ); 175 | 176 | ReleaseDC( NULL, pDC ); 177 | } 178 | 179 | void RestoreGamma() 180 | { 181 | } 182 | 183 | bool SetScreenMode(int &xsize, int &ysize) 184 | { 185 | HDC hdc; 186 | FxU32 bits_per_pixel; 187 | bool found; 188 | DEVMODE DevMode; 189 | 190 | hdc = GetDC( hWND ); 191 | bits_per_pixel = GetDeviceCaps( hdc, BITSPIXEL ); 192 | ReleaseDC( hWND, hdc ); 193 | 194 | found = false; 195 | DevMode.dmSize = sizeof( DEVMODE ); 196 | 197 | for ( int i = 0; 198 | !found && EnumDisplaySettings( NULL, i, &DevMode ) != false; 199 | i++ ) 200 | { 201 | if ( ( DevMode.dmPelsWidth == (FxU32)xsize ) && 202 | ( DevMode.dmPelsHeight == (FxU32)ysize ) && 203 | ( DevMode.dmBitsPerPel == bits_per_pixel ) ) 204 | { 205 | found = true; 206 | } 207 | } 208 | 209 | return ( found && ChangeDisplaySettings( &DevMode, CDS_RESET|CDS_FULLSCREEN ) == DISP_CHANGE_SUCCESSFUL ); 210 | } 211 | 212 | void ResetScreenMode() 213 | { 214 | ChangeDisplaySettings( NULL, 0 ); 215 | } 216 | 217 | void SwapBuffers() 218 | { 219 | SwapBuffers(hDC); 220 | } 221 | 222 | #endif // !C_USE_SDL && WIN32 223 | -------------------------------------------------------------------------------- /grguFog.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Fog Functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include 14 | 15 | #include "GlOgl.h" 16 | #include "GLRender.h" 17 | #include "OGLTables.h" 18 | 19 | 20 | //************************************************* 21 | //* download a fog table 22 | //* Fog is applied after color combining and before alpha blending. 23 | //************************************************* 24 | FX_ENTRY void FX_CALL 25 | grFogTable( const GrFog_t *ft ) 26 | { 27 | #ifdef OGL_DONE 28 | GlideMsg( "grFogTable( --- )\n" ); 29 | #endif 30 | 31 | if ( InternalConfig.FogEnable ) 32 | { 33 | OG_memcpy( Glide.FogTable, (GrFog_t *)ft, GR_FOG_TABLE_SIZE * sizeof( FxU8 ) ); 34 | Glide.FogTable[ GR_FOG_TABLE_SIZE ] = 255; 35 | 36 | for ( int i = 0; i < GR_FOG_TABLE_SIZE; i++ ) 37 | { 38 | for ( unsigned int j = intStartEnd[ i ]; j < intStartEnd[ i + 1 ]; j++ ) 39 | { 40 | OpenGL.FogTable[ j ] = (FxU8)( Glide.FogTable[ i ] + 41 | ( Glide.FogTable[ i + 1 ] - Glide.FogTable[ i ] ) * ( j - intStartEnd[ i ] ) / 42 | intEndMinusStart[ i ] ); 43 | } 44 | } 45 | } 46 | } 47 | 48 | //************************************************* 49 | FX_ENTRY void FX_CALL 50 | grFogColorValue( GrColor_t fogcolor ) 51 | { 52 | #ifdef OGL_PARTDONE 53 | GlideMsg( "grFogColorValue( %x )\n", fogcolor ); 54 | #endif 55 | 56 | RenderDrawTriangles( ); 57 | 58 | Glide.State.FogColorValue = fogcolor; 59 | ConvertColorF( fogcolor, 60 | OpenGL.FogColor[ 0 ], 61 | OpenGL.FogColor[ 1 ], 62 | OpenGL.FogColor[ 2 ], 63 | OpenGL.FogColor[ 3 ] ); 64 | glFogfv( GL_FOG_COLOR, &OpenGL.FogColor[0] ); 65 | } 66 | 67 | //************************************************* 68 | FX_ENTRY void FX_CALL 69 | grFogMode( GrFogMode_t mode ) 70 | { 71 | #ifdef OGL_PARTDONE 72 | GlideMsg( "grFogMode( %d )\n", mode ); 73 | #endif 74 | 75 | static GrFogMode_t modeSource, 76 | modeAdd; 77 | static GLfloat ZeroColor[ 4 ] = { 0.0f, 0.0f, 0.0f, 0.0f }; 78 | 79 | RenderDrawTriangles( ); 80 | 81 | modeSource = mode & ( GR_FOG_WITH_TABLE | GR_FOG_WITH_ITERATED_ALPHA ); 82 | modeAdd = mode & ( GR_FOG_MULT2 | GR_FOG_ADD2 ); 83 | 84 | if ( modeSource ) 85 | { 86 | OpenGL.Fog = true; 87 | if ( InternalConfig.EXT_fog_coord ) 88 | { 89 | glEnable( GL_FOG ); 90 | } 91 | } 92 | else 93 | { 94 | OpenGL.Fog = false; 95 | glDisable( GL_FOG ); 96 | } 97 | 98 | switch ( modeAdd ) 99 | { 100 | case GR_FOG_MULT2: 101 | case GR_FOG_ADD2: 102 | glFogfv( GL_FOG_COLOR, &ZeroColor[ 0 ] ); 103 | break; 104 | 105 | default: 106 | glFogfv( GL_FOG_COLOR, &OpenGL.FogColor[ 0 ] ); 107 | break; 108 | } 109 | 110 | Glide.State.FogMode = modeSource; 111 | // Glide.State.FogMode = mode; 112 | } 113 | 114 | //************************************************* 115 | FX_ENTRY void FX_CALL 116 | guFogGenerateExp( GrFog_t *fogtable, float density ) 117 | { 118 | #ifdef OGL_PARTDONE 119 | GlideMsg( "guFogGenerateExp( ---, %-4.2f )\n", density ); 120 | #endif 121 | 122 | float f; 123 | float scale; 124 | float dp; 125 | 126 | dp = density * guFogTableIndexToW( GR_FOG_TABLE_SIZE - 1 ); 127 | scale = 255.0F / ( 1.0F - (float) exp( -dp ) ); 128 | 129 | for ( int i = 0; i < GR_FOG_TABLE_SIZE; i++ ) 130 | { 131 | dp = density * guFogTableIndexToW( i ); 132 | f = ( 1.0F - (float) exp( -dp ) ) * scale; 133 | 134 | if ( f > 255.0F ) 135 | { 136 | f = 255.0F; 137 | } 138 | else if ( f < 0.0F ) 139 | { 140 | f = 0.0F; 141 | } 142 | 143 | fogtable[ i ] = (GrFog_t) f; 144 | } 145 | } 146 | 147 | //************************************************* 148 | FX_ENTRY void FX_CALL 149 | guFogGenerateExp2( GrFog_t *fogtable, float density ) 150 | { 151 | #ifdef OGL_PARTDONE 152 | GlideMsg( "guFogGenerateExp2( ---, %-4.2f )\n", density ); 153 | #endif 154 | 155 | float Temp; 156 | 157 | for ( int i = 0; i < GR_FOG_TABLE_SIZE; i++ ) 158 | { 159 | Temp = ( 1.0f - (float) exp( ( -density) * guFogTableIndexToW( i ) ) * 160 | (float)exp( (-density) * guFogTableIndexToW( i ) ) ) * 255.0f; 161 | fogtable[ i ] = (FxU8) Temp; 162 | } 163 | } 164 | 165 | //************************************************* 166 | FX_ENTRY void FX_CALL 167 | guFogGenerateLinear( GrFog_t *fogtable, 168 | float nearZ, float farZ ) 169 | { 170 | #ifdef OGL_PARTDONE 171 | GlideMsg( "guFogGenerateLinear( ---, %-4.2f, %-4.2f )\n", nearZ, farZ ); 172 | #endif 173 | 174 | int Start, 175 | End, 176 | i; 177 | 178 | for( Start = 0; Start < GR_FOG_TABLE_SIZE; Start++ ) 179 | { 180 | if ( guFogTableIndexToW( Start ) >= nearZ ) 181 | { 182 | break; 183 | } 184 | } 185 | for( End = 0; End < GR_FOG_TABLE_SIZE; End++ ) 186 | { 187 | if ( guFogTableIndexToW( End ) >= farZ ) 188 | { 189 | break; 190 | } 191 | } 192 | 193 | ZeroMemory( fogtable, GR_FOG_TABLE_SIZE ); 194 | for( i = Start; i <= End; i++ ) 195 | { 196 | fogtable[ i ] = (FxU8)((float)( End - Start ) / 255.0f * (float)( i - Start )); 197 | } 198 | 199 | for( i = End; i < GR_FOG_TABLE_SIZE; i++ ) 200 | { 201 | fogtable[ i ] = 255; 202 | } 203 | } 204 | 205 | //************************************************* 206 | //* convert a fog table index to a floating point eye-space w value 207 | //************************************************* 208 | FX_ENTRY float FX_CALL 209 | guFogTableIndexToW( int i ) 210 | { 211 | #ifdef OGL_DONE 212 | GlideMsg( "guFogTableIndexToW( %d )\n", i ); 213 | #endif 214 | #ifdef OGL_DEBUG 215 | if ( ( i < 0 ) || 216 | ( i >= GR_FOG_TABLE_SIZE ) ) 217 | { 218 | Error( "Error on guFogTableIndexToW( %d )\n", i ); 219 | } 220 | #endif 221 | 222 | return tableIndexToW[ i ]; 223 | } 224 | 225 | -------------------------------------------------------------------------------- /acinclude.m4: -------------------------------------------------------------------------------- 1 | dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) 2 | dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS 3 | dnl 4 | AC_DEFUN([AM_PATH_SDL], 5 | [dnl 6 | dnl Get the cflags and libraries from the sdl-config script 7 | dnl 8 | AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], 9 | sdl_prefix="$withval", sdl_prefix="") 10 | AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], 11 | sdl_exec_prefix="$withval", sdl_exec_prefix="") 12 | AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], 13 | , enable_sdltest=yes) 14 | 15 | if test x$sdl_exec_prefix != x ; then 16 | sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" 17 | if test x${SDL_CONFIG+set} != xset ; then 18 | SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config 19 | fi 20 | fi 21 | if test x$sdl_prefix != x ; then 22 | sdl_args="$sdl_args --prefix=$sdl_prefix" 23 | if test x${SDL_CONFIG+set} != xset ; then 24 | SDL_CONFIG=$sdl_prefix/bin/sdl-config 25 | fi 26 | fi 27 | 28 | AC_PATH_PROG(SDL_CONFIG, sdl-config, no) 29 | min_sdl_version=ifelse([$1], ,0.11.0,$1) 30 | AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) 31 | no_sdl="" 32 | if test "$SDL_CONFIG" = "no" ; then 33 | no_sdl=yes 34 | else 35 | SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` 36 | SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` 37 | 38 | sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ 39 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 40 | sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ 41 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 42 | sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ 43 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 44 | if test "x$enable_sdltest" = "xyes" ; then 45 | ac_save_CFLAGS="$CFLAGS" 46 | ac_save_LIBS="$LIBS" 47 | CFLAGS="$CFLAGS $SDL_CFLAGS" 48 | LIBS="$LIBS $SDL_LIBS" 49 | dnl 50 | dnl Now check if the installed SDL is sufficiently new. (Also sanity 51 | dnl checks the results of sdl-config to some extent 52 | dnl 53 | rm -f conf.sdltest 54 | AC_TRY_RUN([ 55 | #include 56 | #include 57 | #include 58 | #include "SDL.h" 59 | 60 | char* 61 | my_strdup (char *str) 62 | { 63 | char *new_str; 64 | 65 | if (str) 66 | { 67 | new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); 68 | strcpy (new_str, str); 69 | } 70 | else 71 | new_str = NULL; 72 | 73 | return new_str; 74 | } 75 | 76 | int main (int argc, char *argv[]) 77 | { 78 | int major, minor, micro; 79 | char *tmp_version; 80 | 81 | /* This hangs on some systems (?) 82 | system ("touch conf.sdltest"); 83 | */ 84 | { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } 85 | 86 | /* HP/UX 9 (%@#!) writes to sscanf strings */ 87 | tmp_version = my_strdup("$min_sdl_version"); 88 | if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { 89 | printf("%s, bad version string\n", "$min_sdl_version"); 90 | exit(1); 91 | } 92 | 93 | if (($sdl_major_version > major) || 94 | (($sdl_major_version == major) && ($sdl_minor_version > minor)) || 95 | (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) 96 | { 97 | return 0; 98 | } 99 | else 100 | { 101 | printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); 102 | printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); 103 | printf("*** best to upgrade to the required version.\n"); 104 | printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); 105 | printf("*** to point to the correct copy of sdl-config, and remove the file\n"); 106 | printf("*** config.cache before re-running configure\n"); 107 | return 1; 108 | } 109 | } 110 | 111 | ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) 112 | CFLAGS="$ac_save_CFLAGS" 113 | LIBS="$ac_save_LIBS" 114 | fi 115 | fi 116 | if test "x$no_sdl" = x ; then 117 | AC_MSG_RESULT(yes) 118 | ifelse([$2], , :, [$2]) 119 | else 120 | AC_MSG_RESULT(no) 121 | if test "$SDL_CONFIG" = "no" ; then 122 | echo "*** The sdl-config script installed by SDL could not be found" 123 | echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" 124 | echo "*** your path, or set the SDL_CONFIG environment variable to the" 125 | echo "*** full path to sdl-config." 126 | else 127 | if test -f conf.sdltest ; then 128 | : 129 | else 130 | echo "*** Could not run SDL test program, checking why..." 131 | CFLAGS="$CFLAGS $SDL_CFLAGS" 132 | LIBS="$LIBS $SDL_LIBS" 133 | AC_TRY_LINK([ 134 | #include 135 | #include "SDL.h" 136 | ], [ return 0; ], 137 | [ echo "*** The test program compiled, but did not run. This usually means" 138 | echo "*** that the run-time linker is not finding SDL or finding the wrong" 139 | echo "*** version of SDL. If it is not finding SDL, you'll need to set your" 140 | echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" 141 | echo "*** to the installed location Also, make sure you have run ldconfig if that" 142 | echo "*** is required on your system" 143 | echo "***" 144 | echo "*** If you have an old version installed, it is best to remove it, although" 145 | echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], 146 | [ echo "*** The test program failed to compile or link. See the file config.log for the" 147 | echo "*** exact error that occured. This usually means SDL was incorrectly installed" 148 | echo "*** or that you have moved SDL since it was installed. In the latter case, you" 149 | echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) 150 | CFLAGS="$ac_save_CFLAGS" 151 | LIBS="$ac_save_LIBS" 152 | fi 153 | fi 154 | SDL_CFLAGS="" 155 | SDL_LIBS="" 156 | ifelse([$3], , :, [$3]) 157 | fi 158 | AC_SUBST(SDL_CFLAGS) 159 | AC_SUBST(SDL_LIBS) 160 | rm -f conf.sdltest 161 | ]) 162 | 163 | AH_TOP([ 164 | //************************************************************** 165 | //* OpenGLide - Glide to OpenGL Wrapper 166 | //* http://openglide.sourceforge.net 167 | //* 168 | //* OpenGLide is OpenSource under LGPL license 169 | //* Originaly made by Fabio Barros 170 | //* Modified by Paul for Glidos (http://www.glidos.net) 171 | //* Linux version by Simon White 172 | //************************************************************** 173 | #ifndef __CONFIG_H__ 174 | #define __CONFIG_H__ 175 | ]) 176 | 177 | AH_BOTTOM([ 178 | #endif /* __CONFIG_H__ */ 179 | ]) 180 | -------------------------------------------------------------------------------- /PGUTexture.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* implementation of the PGUexture class 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | 14 | #include "GlOgl.h" 15 | #include "PGTexture.h" 16 | #include "PGUTexture.h" 17 | 18 | 19 | ////////////////////////////////////////////////////////////////////// 20 | // Construction/Destruction 21 | ////////////////////////////////////////////////////////////////////// 22 | 23 | PGUTexture::PGUTexture( void ) 24 | { 25 | for ( int i = 0; i < MAX_MM; i++ ) 26 | { 27 | mm_info[ i ].valid = false; 28 | } 29 | 30 | m_free_mem = 0; 31 | m_free_id = 0; 32 | m_current_id = GR_NULL_MIPMAP_HANDLE; 33 | } 34 | 35 | PGUTexture::~PGUTexture( void ) 36 | { 37 | } 38 | 39 | GrMipMapId_t PGUTexture::AllocateMemory( GrChipID_t tmu, FxU8 odd_even_mask, 40 | int width, int height, 41 | GrTextureFormat_t fmt, GrMipMapMode_t mm_mode, 42 | GrLOD_t smallest_lod, GrLOD_t largest_lod, 43 | GrAspectRatio_t aspect, 44 | GrTextureClampMode_t s_clamp_mode, 45 | GrTextureClampMode_t t_clamp_mode, 46 | GrTextureFilterMode_t minfilter_mode, 47 | GrTextureFilterMode_t magfilter_mode, 48 | float lod_bias, FxBool trilinear ) 49 | { 50 | FxU32 size = 0; 51 | GrLOD_t lod; 52 | 53 | for ( lod = largest_lod; lod <= smallest_lod; lod++ ) 54 | { 55 | size += PGTexture::MipMapMemRequired( lod, aspect, fmt ); 56 | } 57 | 58 | size = ((size + 7) & ~7); 59 | 60 | #ifdef OGL_UTEX 61 | GlideMsg( "Allocate id = %d size = %d\n", m_free_id, size ); 62 | #endif 63 | 64 | if ( ( m_free_id >= MAX_MM ) || 65 | ( ( m_free_mem + size ) >= Textures->GetMemorySize( ) ) ) 66 | { 67 | #ifdef OGL_UTEX 68 | GlideMsg("Allocation failed\n"); 69 | #endif 70 | return GR_NULL_MIPMAP_HANDLE; 71 | } 72 | 73 | mm_info[ m_free_id ].odd_even_mask = odd_even_mask; 74 | mm_info[ m_free_id ].width = width; 75 | mm_info[ m_free_id ].height = height; 76 | mm_info[ m_free_id ].format = fmt; 77 | mm_info[ m_free_id ].mipmap_mode = mm_mode; 78 | mm_info[ m_free_id ].lod_min = smallest_lod; 79 | mm_info[ m_free_id ].lod_max = largest_lod; 80 | mm_info[ m_free_id ].aspect_ratio = aspect; 81 | mm_info[ m_free_id ].s_clamp_mode = s_clamp_mode; 82 | mm_info[ m_free_id ].t_clamp_mode = t_clamp_mode; 83 | mm_info[ m_free_id ].minfilter_mode = minfilter_mode; 84 | mm_info[ m_free_id ].magfilter_mode = magfilter_mode; 85 | //mm_info[ m_free_id ].lod_bias = lod_bias; 86 | mm_info[ m_free_id ].trilinear = trilinear; 87 | mm_info[ m_free_id ].valid = FXTRUE; 88 | 89 | mm_start[ m_free_id ] = m_free_mem; 90 | 91 | m_free_mem += size; 92 | 93 | return m_free_id++; 94 | } 95 | 96 | void PGUTexture::DownloadMipMap( GrMipMapId_t mmid, const void *src, const GuNccTable *table ) 97 | { 98 | #ifdef OGL_UTEX 99 | GlideMsg("Download id = %d ", mmid); 100 | #endif 101 | 102 | if ( ( mmid >=0 ) && ( mmid < MAX_MM ) && ( mm_info[ mmid ].valid ) ) 103 | { 104 | GrTexInfo info; 105 | 106 | info.aspectRatio = mm_info[ mmid ].aspect_ratio; 107 | info.format = mm_info[ mmid ].format; 108 | info.largeLod = mm_info[ mmid ].lod_max; 109 | info.smallLod = mm_info[ mmid ].lod_min; 110 | info.data = (void *)src; 111 | #ifdef OGL_UTEX 112 | { 113 | FxU32 size = 0; 114 | 115 | for ( GrLOD_t lod = info.largeLod; lod <= info.smallLod; lod++ ) 116 | { 117 | size += PGTexture::MipMapMemRequired( lod, info.aspectRatio, info.format ); 118 | } 119 | 120 | GlideMsg( "size = %d\n", size ); 121 | } 122 | #endif 123 | 124 | grTexDownloadMipMap( 0, mm_start[ mmid ], mm_info[ mmid ].odd_even_mask, &info ); 125 | } 126 | #ifdef OGL_UTEX 127 | else 128 | { 129 | GlideMsg( "failed\n" ); 130 | } 131 | #endif 132 | } 133 | 134 | void PGUTexture::DownloadMipMapLevel( GrMipMapId_t mmid, GrLOD_t lod, const void **src ) 135 | { 136 | } 137 | 138 | void PGUTexture::MemReset( void ) 139 | { 140 | #ifdef OGL_UTEX 141 | GlideMsg("Reset\n"); 142 | #endif 143 | 144 | for ( int i = 0; i < MAX_MM; i++ ) 145 | { 146 | mm_info[ i ].valid = false; 147 | } 148 | 149 | m_free_mem = 0; 150 | m_free_id = 0; 151 | m_current_id = GR_NULL_MIPMAP_HANDLE; 152 | } 153 | 154 | void PGUTexture::Source( GrMipMapId_t id ) 155 | { 156 | if ( ( id >=0 ) && ( id < MAX_MM ) && ( mm_info[ id ].valid ) ) 157 | { 158 | GrTexInfo info; 159 | 160 | info.aspectRatio = mm_info[ id ].aspect_ratio; 161 | info.format = mm_info[ id ].format; 162 | info.largeLod = mm_info[ id ].lod_max; 163 | info.smallLod = mm_info[ id ].lod_min; 164 | 165 | grTexSource( 0, mm_start[ id ], mm_info[ id ].odd_even_mask, &info ); 166 | grTexFilterMode( 0, mm_info[ id ].minfilter_mode, mm_info[ id ].magfilter_mode ); 167 | grTexMipMapMode( 0, mm_info[ id ].mipmap_mode, mm_info[ id ].trilinear ); 168 | grTexClampMode( 0, mm_info[ id ].s_clamp_mode, mm_info[ id ].t_clamp_mode ); 169 | //grTexLodBiasValue( 0, mm_info[ id ].lod_bias ); 170 | 171 | m_current_id = id; 172 | } 173 | #ifdef OGL_UTEX 174 | else 175 | { 176 | GlideMsg( "TexSourcefailed\n" ); 177 | } 178 | #endif 179 | } 180 | 181 | GrMipMapInfo *PGUTexture::GetMipMapInfo( GrMipMapId_t mmid ) 182 | { 183 | return ( ( mmid >= 0 ) && ( mmid < MAX_MM ) && 184 | ( mm_info[mmid].valid ) ? &( mm_info[ mmid ] ) : NULL ); 185 | } 186 | 187 | FxBool PGUTexture::ChangeAttributes( GrMipMapId_t mmid, int width, int height, 188 | GrTextureFormat_t fmt, GrMipMapMode_t mm_mode, 189 | GrLOD_t smallest_lod, GrLOD_t largest_lod, 190 | GrAspectRatio_t aspect, GrTextureClampMode_t s_clamp_mode, 191 | GrTextureClampMode_t t_clamp_mode, 192 | GrTextureFilterMode_t minFilterMode, 193 | GrTextureFilterMode_t magFilterMode ) 194 | { 195 | return FXFALSE; 196 | } 197 | 198 | GrMipMapId_t PGUTexture::GetCurrentMipMap( GrChipID_t tmu ) 199 | { 200 | return m_current_id; 201 | } 202 | 203 | FxU32 PGUTexture::MemQueryAvail( GrChipID_t tmu ) 204 | { 205 | return Textures->GetMemorySize( ) - m_free_mem; 206 | } 207 | -------------------------------------------------------------------------------- /Glide2x.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 13 | 14 | 15 | 23 | 46 | 48 | 57 | 64 | 66 | 68 | 70 | 74 | 76 | 78 | 79 | 86 | 102 | 104 | 115 | 122 | 124 | 126 | 128 | 132 | 134 | 136 | 137 | 138 | 139 | 142 | 144 | 145 | 147 | 148 | 150 | 151 | 153 | 154 | 156 | 157 | 159 | 160 | 162 | 163 | 165 | 166 | 168 | 169 | 171 | 172 | 174 | 175 | 177 | 178 | 180 | 181 | 183 | 184 | 185 | 188 | 190 | 191 | 193 | 194 | 196 | 197 | 199 | 200 | 202 | 203 | 205 | 206 | 208 | 209 | 211 | 212 | 214 | 215 | 217 | 218 | 220 | 221 | 223 | 224 | 226 | 227 | 229 | 230 | 232 | 233 | 235 | 236 | 238 | 239 | 241 | 242 | 244 | 245 | 247 | 248 | 250 | 251 | 253 | 254 | 255 | 257 | 258 | 259 | 260 | 261 | 262 | -------------------------------------------------------------------------------- /grguDraw.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Drawing Functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include "GlOgl.h" 14 | #include "GLRender.h" 15 | 16 | //************************************************* 17 | //* Draws a Triangle on the screen 18 | //************************************************* 19 | FX_ENTRY void FX_CALL 20 | grDrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c ) 21 | { 22 | #ifdef OGL_CRITICAL 23 | GlideMsg( "grDrawTriangle( ---, ---, --- )\n" ); 24 | #endif 25 | 26 | RenderAddTriangle( a, b, c, true ); 27 | 28 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 29 | { 30 | RenderDrawTriangles( ); 31 | glFlush( ); 32 | } 33 | } 34 | 35 | //************************************************* 36 | //* Draws a Triangle on the screen 37 | //************************************************* 38 | FX_ENTRY void FX_CALL 39 | grDrawPlanarPolygonVertexList( int nVertices, const GrVertex vlist[] ) 40 | { 41 | #ifdef OGL_CRITICAL 42 | GlideMsg("grDrawPlanarPolygonVertexList( %d, --- )\n", nVertices ); 43 | #endif 44 | 45 | for ( int i = 2; i < nVertices; i++ ) 46 | { 47 | RenderAddTriangle( &vlist[ 0 ], &vlist[ i - 1 ], &vlist[ i ], true ); 48 | } 49 | 50 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 51 | { 52 | RenderDrawTriangles( ); 53 | glFlush( ); 54 | } 55 | } 56 | 57 | //************************************************* 58 | //* Draws a Line on the screen 59 | //************************************************* 60 | FX_ENTRY void FX_CALL 61 | grDrawLine( const GrVertex *a, const GrVertex *b ) 62 | { 63 | #ifdef OGL_CRITICAL 64 | GlideMsg("grDrawLine( ---, --- )\n"); 65 | #endif 66 | 67 | /* 68 | * RenderAddLine actually renders the line, so 69 | * we must render the queued triangles first to 70 | * avoid out-of-order rendering. 71 | */ 72 | RenderDrawTriangles( ); 73 | RenderAddLine( a, b, true ); 74 | } 75 | 76 | //************************************************* 77 | //* Draws a Point on the screen 78 | //************************************************* 79 | FX_ENTRY void FX_CALL 80 | grDrawPoint( const GrVertex *a ) 81 | { 82 | #ifdef OGL_CRITICAL 83 | GlideMsg( "grDrawPoint( --- )\n" ); 84 | #endif 85 | 86 | RenderAddPoint( a, true ); 87 | } 88 | 89 | //************************************************* 90 | //* Draw a convex non-planar polygon 91 | //************************************************* 92 | FX_ENTRY void FX_CALL 93 | grDrawPolygon( int nverts, const int ilist[], const GrVertex vlist[] ) 94 | { 95 | #ifdef OGL_CRITICAL 96 | GlideMsg( "grDrawPolygon( %d, ---, --- )\n" ); 97 | #endif 98 | 99 | for ( int i = 2; i < nverts; i++ ) 100 | { 101 | RenderAddTriangle( &vlist[ ilist[ 0 ] ], 102 | &vlist[ ilist[ i - 1 ] ], 103 | &vlist[ ilist[ i ] ], 104 | true ); 105 | } 106 | 107 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 108 | { 109 | RenderDrawTriangles( ); 110 | glFlush( ); 111 | } 112 | } 113 | 114 | //************************************************* 115 | //* Draw a convex planar polygon 116 | //************************************************* 117 | FX_ENTRY void FX_CALL 118 | grDrawPlanarPolygon( int nverts, const int ilist[], const GrVertex vlist[] ) 119 | { 120 | #ifdef OGL_CRITICAL 121 | GlideMsg( "grDrawPlanarPolygon( %d, ---, --- )\n", nverts ); 122 | #endif 123 | 124 | for ( int i = 2; i < nverts; i++ ) 125 | { 126 | RenderAddTriangle( &vlist[ ilist[ 0 ] ], 127 | &vlist[ ilist[ i - 1 ] ], 128 | &vlist[ ilist[ i ] ], 129 | true ); 130 | } 131 | 132 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 133 | { 134 | RenderDrawTriangles( ); 135 | glFlush( ); 136 | } 137 | } 138 | 139 | //************************************************* 140 | //* Draw a convex non-planar polygon 141 | //************************************************* 142 | FX_ENTRY void FX_CALL 143 | grDrawPolygonVertexList( int nVertices, const GrVertex vlist[] ) 144 | { 145 | #ifdef OGL_CRITICAL 146 | GlideMsg( "grDrawPolygonVertexList( %d, --- )\n", nVertices ); 147 | #endif 148 | 149 | for ( int i = 2; i < nVertices; i++ ) 150 | { 151 | RenderAddTriangle( &vlist[ 0 ], 152 | &vlist[ i - 1 ], 153 | &vlist[ i ], 154 | true ); 155 | } 156 | 157 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 158 | { 159 | RenderDrawTriangles( ); 160 | glFlush( ); 161 | } 162 | } 163 | 164 | FX_ENTRY void FX_CALL 165 | guAADrawTriangleWithClip( const GrVertex *a, const GrVertex *b, 166 | const GrVertex *c ) 167 | { 168 | #ifdef OGL_CRITICAL 169 | GlideMsg("guAADrawTriangleWithClip( ---, ---, --- )\n"); 170 | #endif 171 | 172 | RenderAddTriangle( a, b, c, false ); 173 | 174 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 175 | { 176 | RenderDrawTriangles( ); 177 | glFlush( ); 178 | } 179 | } 180 | 181 | FX_ENTRY void FX_CALL 182 | guDrawTriangleWithClip( const GrVertex *a, 183 | const GrVertex *b, 184 | const GrVertex *c ) 185 | { 186 | #ifdef OGL_CRITICAL 187 | GlideMsg("guDrawTriangleWithClip( ---, ---, --- )\n"); 188 | #endif 189 | 190 | RenderAddTriangle( a, b, c, false ); 191 | 192 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 193 | { 194 | RenderDrawTriangles( ); 195 | glFlush( ); 196 | } 197 | } 198 | 199 | FX_ENTRY void FX_CALL 200 | guDrawPolygonVertexListWithClip( int nverts, const GrVertex vlist[] ) 201 | { 202 | #ifdef OGL_CRITICAL 203 | GlideMsg( "guDrawPolygonVertexListWithClip( %d, --- )\n", nverts ); 204 | #endif 205 | 206 | for ( int i = 2; i < nverts; i++ ) 207 | { 208 | RenderAddTriangle( &vlist[ 0 ], 209 | &vlist[ i - 1 ], 210 | &vlist[ i ], 211 | false ); 212 | } 213 | 214 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 215 | { 216 | RenderDrawTriangles( ); 217 | glFlush( ); 218 | } 219 | } 220 | 221 | FX_ENTRY void FX_CALL 222 | grAADrawLine( const GrVertex *a, const GrVertex *b ) 223 | { 224 | #ifdef OGL_CRITICAL 225 | GlideMsg( "grAADrawLine( ---, --- )\n" ); 226 | #endif 227 | 228 | RenderAddLine( a, b, true ); 229 | } 230 | 231 | FX_ENTRY void FX_CALL 232 | grAADrawPoint(const GrVertex *a ) 233 | { 234 | #ifdef OGL_CRITICAL 235 | GlideMsg("grAADrawPoint( --- )\n"); 236 | #endif 237 | 238 | RenderAddPoint( a, true ); 239 | } 240 | 241 | FX_ENTRY void FX_CALL 242 | grAADrawPolygon( const int nverts, const int ilist[], const GrVertex vlist[] ) 243 | { 244 | #ifdef OGL_CRITICAL 245 | GlideMsg( "grAADrawPolygon( %d, ---, --- )\n", nverts ); 246 | #endif 247 | 248 | for ( int i = 2; i < nverts; i++ ) 249 | { 250 | RenderAddTriangle( &vlist[ ilist[ 0 ] ], 251 | &vlist[ ilist[ i - 1 ] ], 252 | &vlist[ ilist[ i ] ], 253 | true ); 254 | } 255 | 256 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 257 | { 258 | RenderDrawTriangles( ); 259 | glFlush( ); 260 | } 261 | } 262 | 263 | FX_ENTRY void FX_CALL 264 | grAADrawPolygonVertexList( const int nverts, const GrVertex vlist[] ) 265 | { 266 | #ifdef OGL_CRITICAL 267 | GlideMsg( "grAADrawPolygonVertexList( %d, --- )\n", nverts ); 268 | #endif 269 | 270 | for ( int i = 2; i < nverts; i++ ) 271 | { 272 | RenderAddTriangle( &vlist[ 0 ], 273 | &vlist[ i - 1 ], 274 | &vlist[ i ], 275 | true ); 276 | } 277 | 278 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 279 | { 280 | RenderDrawTriangles( ); 281 | glFlush( ); 282 | } 283 | } 284 | 285 | FX_ENTRY void FX_CALL 286 | grAADrawTriangle( const GrVertex *a, const GrVertex *b, const GrVertex *c, 287 | FxBool ab_antialias, FxBool bc_antialias, FxBool ca_antialias ) 288 | { 289 | #ifdef OGL_CRITICAL 290 | GlideMsg("grAADrawTriangle( ---, ---, ---, %d, %d, %d )\n", 291 | ab_antialias, bc_antialias, ca_antialias ); 292 | #endif 293 | 294 | RenderAddTriangle( a, b, c, true ); 295 | 296 | if ( Glide.State.RenderBuffer == GR_BUFFER_FRONTBUFFER ) 297 | { 298 | RenderDrawTriangles( ); 299 | glFlush( ); 300 | } 301 | } 302 | 303 | -------------------------------------------------------------------------------- /grguMisc.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Other Functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include "GlOgl.h" 14 | #include "GLRender.h" 15 | 16 | 17 | //************************************************* 18 | //* Sets the External Error Function to call if 19 | //* Glides Generates and Error 20 | //************************************************* 21 | FX_ENTRY void FX_CALL 22 | grErrorSetCallback( void (*function)(const char *string, FxBool fatal) ) 23 | { 24 | #ifdef OGL_DONE 25 | GlideMsg( "grErrorSetCallback( --- )\n" ); 26 | #endif 27 | 28 | ExternErrorFunction = function; 29 | } 30 | 31 | //************************************************* 32 | //* Sets the Cull Mode 33 | //************************************************* 34 | FX_ENTRY void FX_CALL 35 | grCullMode( GrCullMode_t mode ) 36 | { 37 | #ifdef OGL_DONE 38 | GlideMsg( "grCullMode( %d )\n", mode ); 39 | #endif 40 | 41 | RenderDrawTriangles( ); 42 | 43 | Glide.State.CullMode = mode; 44 | 45 | switch ( Glide.State.CullMode ) 46 | { 47 | case GR_CULL_DISABLE: 48 | glDisable( GL_CULL_FACE ); 49 | glCullFace( GL_BACK ); // This will be called in initialization 50 | break; 51 | 52 | case GR_CULL_NEGATIVE: 53 | glEnable( GL_CULL_FACE ); 54 | if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT ) 55 | { 56 | glFrontFace( GL_CCW ); 57 | } 58 | else 59 | { 60 | glFrontFace( GL_CW ); 61 | } 62 | break; 63 | 64 | case GR_CULL_POSITIVE: 65 | glEnable( GL_CULL_FACE ); 66 | if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT ) 67 | { 68 | glFrontFace( GL_CW ); 69 | } 70 | else 71 | { 72 | glFrontFace( GL_CCW ); 73 | } 74 | break; 75 | } 76 | 77 | #ifdef OPENGL_DEBUG 78 | GLErro( "grCullMode" ); 79 | #endif 80 | } 81 | 82 | //************************************************* 83 | //* Set the size and location of the hardware clipping window 84 | //************************************************* 85 | FX_ENTRY void FX_CALL 86 | grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy ) 87 | { 88 | #ifdef OGL_PARTDONE 89 | GlideMsg( "grClipWindow( %d, %d, %d, %d )\n", minx, miny, maxx, maxy ); 90 | #endif 91 | 92 | RenderDrawTriangles( ); 93 | 94 | Glide.State.ClipMinX = minx; 95 | Glide.State.ClipMaxX = maxx; 96 | Glide.State.ClipMinY = miny; 97 | Glide.State.ClipMaxY = maxy; 98 | 99 | if ( ( Glide.State.ClipMinX != 0 ) || 100 | ( Glide.State.ClipMinY != 0 ) || 101 | ( Glide.State.ClipMaxX != (FxU32) Glide.WindowWidth ) || 102 | ( Glide.State.ClipMaxY != (FxU32) Glide.WindowHeight ) ) 103 | { 104 | OpenGL.Clipping = true; 105 | } 106 | else 107 | { 108 | OpenGL.Clipping = false; 109 | } 110 | 111 | glMatrixMode( GL_PROJECTION ); 112 | glLoadIdentity(); 113 | 114 | if ( Glide.State.OriginInformation == GR_ORIGIN_LOWER_LEFT ) 115 | { 116 | glOrtho( Glide.State.ClipMinX, Glide.State.ClipMaxX, 117 | Glide.State.ClipMinY, Glide.State.ClipMaxY, 118 | OpenGL.ZNear, OpenGL.ZFar ); 119 | glViewport( Glide.State.ClipMinX, Glide.State.ClipMinY, 120 | Glide.State.ClipMaxX - Glide.State.ClipMinX, 121 | Glide.State.ClipMaxY - Glide.State.ClipMinY ); 122 | // Used for the buffer clearing 123 | glScissor( Glide.State.ClipMinX, Glide.State.ClipMinY, 124 | Glide.State.ClipMaxX - Glide.State.ClipMinX, 125 | Glide.State.ClipMaxY - Glide.State.ClipMinY ); 126 | } 127 | else 128 | { 129 | glOrtho( Glide.State.ClipMinX, Glide.State.ClipMaxX, 130 | Glide.State.ClipMaxY, Glide.State.ClipMinY, 131 | OpenGL.ZNear, OpenGL.ZFar ); 132 | glViewport( Glide.State.ClipMinX, OpenGL.WindowHeight - Glide.State.ClipMaxY, 133 | Glide.State.ClipMaxX - Glide.State.ClipMinX, 134 | Glide.State.ClipMaxY - Glide.State.ClipMinY ); 135 | // Used for the buffer clearing 136 | glScissor( Glide.State.ClipMinX, OpenGL.WindowHeight - Glide.State.ClipMaxY, 137 | Glide.State.ClipMaxX - Glide.State.ClipMinX, 138 | Glide.State.ClipMaxY - Glide.State.ClipMinY ); 139 | } 140 | 141 | glMatrixMode( GL_MODELVIEW ); 142 | } 143 | 144 | //************************************************* 145 | FX_ENTRY void FX_CALL 146 | grDisableAllEffects( void ) 147 | { 148 | #ifdef OGL_PARTDONE 149 | GlideMsg( "grDisableAllEffects( )\n" ); 150 | #endif 151 | 152 | grAlphaBlendFunction( GR_BLEND_ONE, GR_BLEND_ZERO, GR_BLEND_ONE, GR_BLEND_ZERO ); 153 | grAlphaTestFunction( GR_CMP_ALWAYS ); 154 | grChromakeyMode( GR_CHROMAKEY_DISABLE ); 155 | grDepthBufferMode( GR_DEPTHBUFFER_DISABLE ); 156 | grFogMode( GR_FOG_DISABLE ); 157 | } 158 | 159 | //************************************************* 160 | FX_ENTRY void FX_CALL 161 | grResetTriStats( void ) 162 | { 163 | #ifdef OGL_NOTDONE 164 | GlideMsg( "grResetTriStats( )\n" ); 165 | #endif 166 | } 167 | 168 | //************************************************* 169 | FX_ENTRY void FX_CALL 170 | grTriStats( FxU32 *trisProcessed, FxU32 *trisDrawn ) 171 | { 172 | #ifdef OGL_NOTDONE 173 | GlideMsg( "grTriStats( )\n" ); 174 | #endif 175 | } 176 | 177 | //************************************************* 178 | FX_ENTRY void FX_CALL 179 | grHints( GrHint_t hintType, FxU32 hintMask ) 180 | { 181 | #ifdef OGL_PARTDONE 182 | GlideMsg( "grHints( %d, %d )\n", hintType, hintMask ); 183 | #endif 184 | 185 | switch( hintType ) 186 | { 187 | case GR_HINT_STWHINT: 188 | Glide.State.STWHint = hintMask; 189 | break; 190 | } 191 | } 192 | 193 | //************************************************* 194 | /* 195 | FX_ENTRY void FX_CALL 196 | grSplash( float x, float y, float width, float height, FxU32 frame ) 197 | { 198 | #ifdef OGL_NOTDONE 199 | GlideMsg( "grSplash( %-4.2f, %-4.2f, %-4.2f, %-4.2f, %lu )\n", 200 | x, y, width, height, frame ); 201 | #endif 202 | } 203 | */ 204 | 205 | //************************************************* 206 | FX_ENTRY void FX_CALL 207 | ConvertAndDownloadRle( GrChipID_t tmu, 208 | FxU32 startAddress, 209 | GrLOD_t thisLod, 210 | GrLOD_t largeLod, 211 | GrAspectRatio_t aspectRatio, 212 | GrTextureFormat_t format, 213 | FxU32 evenOdd, 214 | FxU8 *bm_data, 215 | long bm_h, 216 | FxU32 u0, 217 | FxU32 v0, 218 | FxU32 width, 219 | FxU32 height, 220 | FxU32 dest_width, 221 | FxU32 dest_height, 222 | FxU16 *tlut ) 223 | { 224 | #ifdef OGL_NOTDONE 225 | GlideMsg( "ConvertAndDownloadRle( %d, %lu, %d, %d, %d, %d, %d, ---, %l, %lu, %lu, %lu, %lu, %lu, %lu, --- )\n", 226 | tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, bm_h, u0, v0, width, height, 227 | dest_width, dest_height ); 228 | #endif 229 | } 230 | 231 | //************************************************* 232 | FX_ENTRY void FX_CALL 233 | grCheckForRoom( FxI32 n ) 234 | { 235 | #ifdef OGL_NOTDONE 236 | GlideMsg( "grCheckForRoom( %l )\n", n ); 237 | #endif 238 | } 239 | 240 | //************************************************* 241 | FX_ENTRY void FX_CALL 242 | grParameterData( FxU32 param, FxU32 components, FxU32 type, FxI32 offset ) 243 | { 244 | #ifdef OGL_NOTDONE 245 | GlideMsg( "grParameterData( %lu, %lu, %lu, %l )\n", 246 | param, components, type, offset ); 247 | #endif 248 | } 249 | 250 | //************************************************* 251 | FX_ENTRY int FX_CALL 252 | guEncodeRLE16( void *dst, 253 | void *src, 254 | FxU32 width, 255 | FxU32 height ) 256 | { 257 | #ifdef OGL_NOTDONE 258 | GlideMsg( "guEncodeRLE16( ---, ---, %lu, %lu ) = 1\n", width, height ); 259 | #endif 260 | 261 | return 1; 262 | } 263 | 264 | //************************************************* 265 | FX_ENTRY FxU32 FX_CALL 266 | guEndianSwapWords( FxU32 value ) 267 | { 268 | #ifdef OGL_DONE 269 | GlideMsg( "guEndianSwapWords( %lu )\n", value ); 270 | #endif 271 | 272 | return ( value << 16 ) | ( value >> 16 ); 273 | } 274 | 275 | //************************************************* 276 | FX_ENTRY FxU16 FX_CALL 277 | guEndianSwapBytes( FxU16 value ) 278 | { 279 | #ifdef OGL_DONE 280 | GlideMsg( "guEndianSwapBytes( %u )\n", value ); 281 | #endif 282 | 283 | return ( value << 8 ) | ( value >> 8 ); 284 | } 285 | 286 | FX_ENTRY void FX_CALL 287 | guMovieStart( void ) 288 | { 289 | #ifdef OGL_NOTDONE 290 | GlideMsg( "guMovieStart( ) - Not Supported\n" ); 291 | #endif 292 | } 293 | 294 | FX_ENTRY void FX_CALL 295 | guMovieStop( void ) 296 | { 297 | #ifdef OGL_NOTDONE 298 | GlideMsg( "guMovieStop( ) - Not Supported\n" ); 299 | #endif 300 | } 301 | 302 | FX_ENTRY void FX_CALL 303 | guMovieSetName( const char *name ) 304 | { 305 | #ifdef OGL_NOTDONE 306 | GlideMsg( "guMovieSetName( ) - Not Supported\n" ); 307 | #endif 308 | } 309 | 310 | -------------------------------------------------------------------------------- /grgu3df.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* 3DF functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include 14 | #include 15 | 16 | #include "GlOgl.h" 17 | 18 | // extern variables and functions 19 | FxU32 GetTexSize( const int Lod, const int aspectRatio, const int format ); 20 | 21 | // prototypes 22 | int Read3dfHeader( const char *filename, Gu3dfInfo *data ); 23 | 24 | //************************************************* 25 | FX_ENTRY FxBool FX_CALL 26 | gu3dfGetInfo( const char *filename, Gu3dfInfo *info ) 27 | { 28 | #ifdef OGL_PARTDONE 29 | GlideMsg( "gu3dfGetInfo( %s, --- )\n", filename ); 30 | #endif 31 | 32 | if ( Read3dfHeader( filename, info ) ) 33 | { 34 | #ifdef OGL_DEBUG 35 | GlideMsg( "==========================================\n" ); 36 | GlideMsg( "3df file Header: %s\n", filename ); 37 | GlideMsg( "Texture Format = %d\n", info->header.format ); 38 | GlideMsg( "Aspect = %d\n", info->header.aspect_ratio ); 39 | GlideMsg( "LargeLod = %d\nSmall Lod = %d\n", info->header.large_lod, info->header.small_lod ); 40 | GlideMsg( "Width = %d Height = %d\n", info->header.width, info->header.height ); 41 | GlideMsg( "MemRequired = %d\n", info->mem_required ); 42 | GlideMsg( "==========================================\n" ); 43 | #endif 44 | return FXTRUE; 45 | } 46 | else 47 | { 48 | return FXFALSE; 49 | } 50 | } 51 | 52 | 53 | static FxU32 ReadDataLong( FILE *fp ) 54 | { 55 | FxU32 data; 56 | FxU8 byte[4]; 57 | 58 | fread( byte, 4, 1, fp ); 59 | data = (((FxU32) byte[ 0 ]) << 24) | 60 | (((FxU32) byte[ 1 ]) << 16) | 61 | (((FxU32) byte[ 2 ]) << 8) | 62 | ((FxU32) byte[ 3 ]); 63 | 64 | return data; 65 | } 66 | 67 | static FxU32 ReadDataShort( FILE *fp ) 68 | { 69 | FxU32 data; 70 | FxU8 byte[2]; 71 | 72 | fread( byte, 2, 1, fp ); 73 | data = (((FxU32) byte[ 0 ]) << 8) | 74 | ((FxU32) byte[ 1 ]); 75 | 76 | return data; 77 | } 78 | 79 | //************************************************* 80 | FX_ENTRY FxBool FX_CALL 81 | gu3dfLoad( const char *filename, Gu3dfInfo *data ) 82 | { 83 | #ifdef OGL_PARTDONE 84 | GlideMsg( "gu3dfLoad( %s, --- )\n", filename ); 85 | #endif 86 | 87 | FILE * file3df; 88 | int jump = Read3dfHeader( filename, data ); 89 | 90 | #ifdef OGL_DEBUG 91 | GlideMsg( "Start of Data (Offset) = %d\n", jump ); 92 | GlideMsg( "Total Bytes to be Read = %d\n", data->mem_required ); 93 | #endif 94 | 95 | file3df = fopen( filename, "rb" ); 96 | 97 | fseek( file3df, jump, SEEK_SET ); 98 | 99 | if ( ( data->header.format == GR_TEXFMT_P_8 ) || 100 | ( data->header.format == GR_TEXFMT_AP_88 ) ) 101 | { 102 | for( int i = 0; i < 256; i++ ) 103 | { 104 | data->table.palette.data[i] = ReadDataLong( file3df ); 105 | } 106 | #ifdef OGL_DEBUG 107 | GlideMsg( "Reading Palette\n" ); 108 | #endif 109 | } 110 | 111 | if ( ( data->header.format == GR_TEXFMT_YIQ_422 ) || 112 | ( data->header.format == GR_TEXFMT_AYIQ_8422 ) ) 113 | { 114 | int i; 115 | int pi; 116 | FxU32 pack; 117 | 118 | GuNccTable *ncc = &(data->table.nccTable); 119 | 120 | for ( i = 0; i < 16; i++ ) 121 | { 122 | ncc->yRGB[i] = (FxU8) ReadDataShort( file3df ); 123 | } 124 | 125 | for ( i = 0; i < 4; i++ ) 126 | { 127 | /* Masking with 0x1ff is strange but correct apparently */ 128 | ncc->iRGB[i][0] = (FxI16) ( ReadDataShort( file3df ) & 0x1ff ); 129 | ncc->iRGB[i][1] = (FxI16) ( ReadDataShort( file3df ) & 0x1ff ); 130 | ncc->iRGB[i][2] = (FxI16) ( ReadDataShort( file3df ) & 0x1ff ); 131 | } 132 | 133 | for ( i = 0; i < 4; i++ ) 134 | { 135 | ncc->qRGB[i][0] = (FxI16) ( ReadDataShort( file3df ) & 0x1ff ); 136 | ncc->qRGB[i][1] = (FxI16) ( ReadDataShort( file3df ) & 0x1ff ); 137 | ncc->qRGB[i][2] = (FxI16) ( ReadDataShort( file3df ) & 0x1ff ); 138 | } 139 | 140 | pi = 0; 141 | 142 | for ( i = 0; i < 4; i++ ) 143 | { 144 | pack = ( ncc->yRGB[i*4 + 0] ); 145 | pack |= ( ncc->yRGB[i*4 + 1] << 8 ); 146 | pack |= ( ncc->yRGB[i*4 + 2] << 16 ); 147 | pack |= ( ncc->yRGB[i*4 + 3] << 24 ); 148 | 149 | ncc->packed_data[pi++] = pack; 150 | } 151 | 152 | for ( i = 0; i < 4; i++ ) 153 | { 154 | pack = ( ncc->iRGB[i][0] << 18 ); 155 | pack |= ( ncc->iRGB[i][1] << 9 ); 156 | pack |= ( ncc->iRGB[i][2] ); 157 | 158 | ncc->packed_data[pi++] = pack; 159 | } 160 | 161 | for ( i = 0; i < 4; i++ ) 162 | { 163 | pack = ( ncc->qRGB[i][0] << 18 ); 164 | pack |= ( ncc->qRGB[i][1] << 9 ); 165 | pack |= ( ncc->qRGB[i][2] ); 166 | 167 | ncc->packed_data[pi++] = pack; 168 | } 169 | } 170 | 171 | switch ( data->header.format ) 172 | { 173 | case GR_TEXFMT_RGB_565: 174 | case GR_TEXFMT_ARGB_8332: 175 | case GR_TEXFMT_ARGB_1555: 176 | case GR_TEXFMT_AYIQ_8422: 177 | case GR_TEXFMT_ARGB_4444: 178 | case GR_TEXFMT_ALPHA_INTENSITY_88: 179 | case GR_TEXFMT_AP_88: 180 | { 181 | FxU16 *d = (FxU16 *) (data->data); 182 | int i; 183 | 184 | for ( i = data->mem_required; i > 0; i -= 2 ) 185 | { 186 | *d++ = (FxU16) ReadDataShort( file3df ); 187 | } 188 | } 189 | break; 190 | 191 | default: 192 | fread( data->data, sizeof( FxU8 ), data->mem_required, file3df ); 193 | break; 194 | } 195 | 196 | fclose( file3df ); 197 | 198 | return FXTRUE; 199 | } 200 | 201 | GrTextureFormat_t ParseTextureFormat( const char * text ) 202 | { 203 | if ( !strcmp( text, "argb1555\n" ) ) 204 | { 205 | return GR_TEXFMT_ARGB_1555; 206 | } 207 | if ( !strcmp( text, "argb4444\n" ) ) 208 | { 209 | return GR_TEXFMT_ARGB_4444; 210 | } 211 | if ( !strcmp( text, "rgb565\n" ) ) 212 | { 213 | return GR_TEXFMT_RGB_565; 214 | } 215 | if ( !strcmp( text, "rgb332\n" ) ) 216 | { 217 | return GR_TEXFMT_RGB_332; 218 | } 219 | if ( !strcmp( text, "argb8332\n" ) ) 220 | { 221 | return GR_TEXFMT_ARGB_8332; 222 | } 223 | if ( !strcmp( text, "p8\n" ) ) 224 | { 225 | return GR_TEXFMT_P_8; 226 | } 227 | if ( !strcmp( text, "ap88\n" ) ) 228 | { 229 | return GR_TEXFMT_AP_88; 230 | } 231 | if ( !strcmp( text, "ai44\n" ) ) 232 | { 233 | return GR_TEXFMT_ALPHA_INTENSITY_44; 234 | } 235 | if ( !strcmp( text, "yiq\n" ) ) 236 | { 237 | return GR_TEXFMT_YIQ_422; 238 | } 239 | if ( !strcmp( text, "ayiq8422\n" ) ) 240 | { 241 | return GR_TEXFMT_AYIQ_8422; 242 | } 243 | 244 | return 0; 245 | } 246 | 247 | int ParseLod( int Lod ) 248 | { 249 | switch( Lod ) 250 | { 251 | case 256: return GR_LOD_256; 252 | case 128: return GR_LOD_128; 253 | case 64: return GR_LOD_64; 254 | case 32: return GR_LOD_32; 255 | case 16: return GR_LOD_16; 256 | case 8: return GR_LOD_8; 257 | case 4: return GR_LOD_4; 258 | case 2: return GR_LOD_2; 259 | case 1: return GR_LOD_1; 260 | } 261 | 262 | return -1; 263 | } 264 | 265 | GrAspectRatio_t ParseAspect( int h, int v ) 266 | { 267 | switch ( h ) 268 | { 269 | case 8: return GR_ASPECT_8x1; 270 | case 4: return GR_ASPECT_4x1; 271 | case 2: return GR_ASPECT_2x1; 272 | case 1: 273 | switch ( v ) 274 | { 275 | case 8: return GR_ASPECT_1x8; 276 | case 4: return GR_ASPECT_1x4; 277 | case 2: return GR_ASPECT_1x2; 278 | case 1: return GR_ASPECT_1x1; 279 | } 280 | } 281 | 282 | return 0; 283 | } 284 | 285 | int Read3dfHeader( const char *filename, Gu3dfInfo *data ) 286 | { 287 | FILE * file3df; 288 | char buffer[255]; 289 | int temp1, 290 | temp2, 291 | lod1, 292 | lod2, 293 | nWidth, 294 | nHeight; 295 | 296 | file3df = fopen( filename, "rb" ); 297 | 298 | if ( file3df == NULL ) 299 | { 300 | return 0; 301 | } 302 | 303 | fgets( buffer, 255, file3df ); 304 | fgets( buffer, 255, file3df ); 305 | 306 | data->header.format = ParseTextureFormat( buffer ); 307 | 308 | fgets( buffer, 255, file3df ); 309 | sscanf( buffer, "lod range: %d %d\n", &lod1, &lod2 ); 310 | 311 | data->header.small_lod = ParseLod( lod1 ); 312 | data->header.large_lod = ParseLod( lod2 ); 313 | 314 | fgets( buffer, 255, file3df ); 315 | sscanf( buffer, "aspect ratio: %d %d\n", &temp1, &temp2 ); 316 | 317 | data->header.aspect_ratio = ParseAspect( temp1, temp2 ); 318 | 319 | switch ( data->header.aspect_ratio ) 320 | { 321 | case GR_ASPECT_8x1: nWidth = lod2; nHeight = lod2 >> 3; break; 322 | case GR_ASPECT_4x1: nWidth = lod2; nHeight = lod2 >> 2; break; 323 | case GR_ASPECT_2x1: nWidth = lod2; nHeight = lod2 >> 1; break; 324 | case GR_ASPECT_1x1: nWidth = lod2; nHeight = lod2; break; 325 | case GR_ASPECT_1x2: nWidth = lod2 >> 1; nHeight = lod2; break; 326 | case GR_ASPECT_1x4: nWidth = lod2 >> 2; nHeight = lod2; break; 327 | case GR_ASPECT_1x8: nWidth = lod2 >> 3; nHeight = lod2; break; 328 | } 329 | 330 | data->header.width = nWidth; 331 | data->header.height = nHeight; 332 | 333 | { 334 | GrLOD_t l; 335 | 336 | data->mem_required = 0; 337 | 338 | for ( l = data->header.large_lod; l <= data->header.small_lod; l++ ) 339 | data->mem_required += GetTexSize( l, data->header.aspect_ratio, data->header.format ); 340 | } 341 | 342 | temp1 = ftell( file3df ); 343 | fclose( file3df ); 344 | 345 | return temp1; 346 | } 347 | -------------------------------------------------------------------------------- /grguLfb.cpp: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Linear Frame Buffer Functions 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #include "GlOgl.h" 14 | #include "Glextensions.h" 15 | #include "GLRender.h" 16 | #include "FormatConversion.h" 17 | 18 | 19 | #define BLUE_SCREEN (0x07FF) 20 | 21 | // Will need to change this later 22 | static FxU32 tempBuf[ 2048 * 2048 ]; 23 | 24 | 25 | //************************************************* 26 | FX_ENTRY FxBool FX_CALL 27 | grLfbLock( GrLock_t dwType, 28 | GrBuffer_t dwBuffer, 29 | GrLfbWriteMode_t dwWriteMode, 30 | GrOriginLocation_t dwOrigin, 31 | FxBool bPixelPipeline, 32 | GrLfbInfo_t *lfbInfo ) 33 | { 34 | #ifdef OGL_CRITICAL 35 | GlideMsg( "grLfbLock( %d, %d, %d, %d, %d, --- )\n", dwType, dwBuffer, dwWriteMode, dwOrigin, bPixelPipeline ); 36 | #endif 37 | 38 | RenderDrawTriangles( ); 39 | 40 | if ( dwType & 1 ) 41 | { 42 | Glide.DstBuffer.Lock = true; 43 | Glide.DstBuffer.Type = dwType; 44 | Glide.DstBuffer.Buffer = dwBuffer; 45 | Glide.DstBuffer.WriteMode = dwWriteMode; 46 | Glide.DstBuffer.PixelPipeline = bPixelPipeline; 47 | 48 | lfbInfo->lfbPtr = Glide.DstBuffer.Address; 49 | } 50 | else 51 | { 52 | FxU32 j; 53 | 54 | glReadBuffer( dwBuffer == GR_BUFFER_BACKBUFFER 55 | ? GL_BACK : GL_FRONT ); 56 | 57 | glReadPixels( 0, 0, 58 | Glide.WindowWidth, Glide.WindowHeight, 59 | GL_BGRA, GL_UNSIGNED_BYTE, 60 | (void *)tempBuf ); 61 | 62 | if ( dwOrigin == GR_ORIGIN_UPPER_LEFT ) 63 | { 64 | for ( j = 0; j < Glide.WindowHeight; j++ ) 65 | { 66 | Convert8888to565( tempBuf + ( ( ( Glide.WindowHeight ) - 1 - j ) * Glide.WindowWidth ), 67 | Glide.SrcBuffer.Address + ( j * Glide.WindowWidth ), 68 | Glide.WindowWidth ); 69 | } 70 | } 71 | else 72 | { 73 | Convert8888to565( tempBuf, Glide.SrcBuffer.Address, Glide.WindowTotalPixels ); 74 | } 75 | Glide.SrcBuffer.Lock = true; 76 | Glide.SrcBuffer.Type = dwType; 77 | Glide.SrcBuffer.Buffer = dwBuffer; 78 | Glide.SrcBuffer.WriteMode = dwWriteMode; 79 | Glide.SrcBuffer.PixelPipeline = bPixelPipeline; 80 | 81 | lfbInfo->lfbPtr = Glide.SrcBuffer.Address; 82 | } 83 | 84 | lfbInfo->writeMode = GR_LFBWRITEMODE_565; 85 | lfbInfo->strideInBytes = Glide.WindowWidth * 2; 86 | 87 | return FXTRUE; 88 | } 89 | 90 | //************************************************* 91 | FX_ENTRY FxBool FX_CALL 92 | grLfbUnlock( GrLock_t dwType, GrBuffer_t dwBuffer ) 93 | { 94 | #ifdef OGL_CRITICAL 95 | GlideMsg("grLfbUnlock( %d, %d )\n", dwType, dwBuffer ); 96 | #endif 97 | 98 | if ( dwType & 1 ) 99 | { 100 | if ( ! Glide.DstBuffer.Lock ) 101 | { 102 | return FXFALSE; 103 | } 104 | 105 | FxU32 ii, 106 | x, 107 | y, 108 | maxx = 0, 109 | maxy = 0, 110 | minx = 2048, 111 | miny = 2048; 112 | 113 | for ( ii = 0, x = 0, y = 0; ii < Glide.WindowTotalPixels; ii++ ) 114 | { 115 | if ( Glide.DstBuffer.Address[ ii ] != BLUE_SCREEN ) 116 | { 117 | if ( x > maxx ) maxx = x; 118 | if ( y > maxy ) maxy = y; 119 | if ( x < minx ) minx = x; 120 | if ( y < miny ) miny = y; 121 | 122 | tempBuf[ ii ] = 0x0 | // A 123 | ( Glide.DstBuffer.Address[ ii ] & 0x001F ) << 19 | // B 124 | ( Glide.DstBuffer.Address[ ii ] & 0x07E0 ) << 5 | // G 125 | ( Glide.DstBuffer.Address[ ii ] >> 8 ); // R 126 | Glide.DstBuffer.Address[ ii ] = BLUE_SCREEN; 127 | } else 128 | tempBuf[ ii ] = 0xFFFFFFFF; 129 | 130 | x++; 131 | if ( x == Glide.WindowWidth ) 132 | { 133 | x = 0; 134 | y++; 135 | } 136 | } 137 | 138 | if ( maxx >= minx ) 139 | { 140 | maxx++; maxy++; 141 | FxU32 xsize = maxx - minx; 142 | FxU32 ysize = maxy - miny; 143 | 144 | // Draw a textured quad 145 | glPushAttrib( GL_COLOR_BUFFER_BIT|GL_TEXTURE_BIT|GL_DEPTH_BUFFER_BIT ); 146 | 147 | glDisable( GL_BLEND ); 148 | glEnable( GL_TEXTURE_2D ); 149 | 150 | if ( Glide.DstBuffer.PixelPipeline ) 151 | glEnable( GL_SCISSOR_TEST ); 152 | 153 | glAlphaFunc( GL_EQUAL, 0.0f ); 154 | glEnable( GL_ALPHA_TEST ); 155 | 156 | glDepthMask( GL_FALSE ); 157 | glDisable( GL_DEPTH_TEST ); 158 | 159 | glBindTexture( GL_TEXTURE_2D, Glide.LFBTexture ); 160 | glTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, Glide.WindowWidth, ysize, GL_RGBA, 161 | GL_UNSIGNED_BYTE, tempBuf + ( miny * Glide.WindowWidth ) ); 162 | 163 | glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); 164 | glDrawBuffer( Glide.DstBuffer.Buffer == GR_BUFFER_BACKBUFFER 165 | ? GL_BACK : GL_FRONT ); 166 | 167 | glBegin( GL_QUADS ); 168 | glColor3f( 1.0f, 1.0f, 1.0f ); 169 | 170 | glTexCoord2f( (float)minx/Glide.LFBTextureSize, 0.0f ); 171 | glVertex2f( (float)minx, (float)miny ); 172 | 173 | glTexCoord2f((float)maxx/Glide.LFBTextureSize, 0.0f ); 174 | glVertex2f( (float)maxx, (float)miny ); 175 | 176 | glTexCoord2f( (float)maxx/Glide.LFBTextureSize, (float)ysize/Glide.LFBTextureSize ); 177 | glVertex2f( (float)maxx, (float)maxy ); 178 | 179 | glTexCoord2f( (float)minx/Glide.LFBTextureSize, (float)ysize/Glide.LFBTextureSize ); 180 | glVertex2f( (float)minx, (float)maxy ); 181 | glEnd( ); 182 | 183 | glPopAttrib( ); 184 | glDrawBuffer( OpenGL.RenderBuffer ); 185 | 186 | if ( Glide.DstBuffer.Buffer != GR_BUFFER_BACKBUFFER ) 187 | { 188 | glFlush( ); 189 | } 190 | } 191 | 192 | Glide.DstBuffer.Lock = false; 193 | 194 | return FXTRUE; 195 | } 196 | else 197 | { 198 | if ( Glide.SrcBuffer.Lock ) 199 | { 200 | Glide.SrcBuffer.Lock = false; 201 | 202 | return FXTRUE; 203 | } 204 | else 205 | { 206 | return FXFALSE; 207 | } 208 | } 209 | } 210 | 211 | //************************************************* 212 | FX_ENTRY FxBool FX_CALL 213 | grLfbReadRegion( GrBuffer_t src_buffer, 214 | FxU32 src_x, FxU32 src_y, 215 | FxU32 src_width, FxU32 src_height, 216 | FxU32 dst_stride, void *dst_data ) 217 | { 218 | #ifdef OGL_NOTDONE 219 | GlideMsg("grLfbReadRegion( %d, %d, %d, %d, %d, %d, --- )\n", 220 | src_buffer, src_x, src_y, src_width, src_height, dst_stride ); 221 | #endif 222 | 223 | RenderDrawTriangles( ); 224 | 225 | switch ( src_buffer ) 226 | { 227 | case GR_BUFFER_FRONTBUFFER: glReadBuffer( GL_FRONT ); break; 228 | case GR_BUFFER_BACKBUFFER: 229 | case GR_BUFFER_AUXBUFFER: glReadBuffer( GL_BACK ); break; 230 | } 231 | 232 | glReadPixels( src_x, src_y, src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)Glide.SrcBuffer.Address ); 233 | // glReadPixels( 320, 230, 300, 200, GL_RED, GL_UNSIGNED_BYTE, &Glide.SrcBuffer.Address ); 234 | // glDrawPixels( 300, 200, GL_RED , GL_UNSIGNED_BYTE, Glide.SrcBuffer.Address ); 235 | 236 | #ifdef OPENGL_DEBUG 237 | GLErro( "grLfbReadRegion" ); 238 | #endif 239 | 240 | return FXTRUE; 241 | } 242 | 243 | //************************************************* 244 | FX_ENTRY FxBool FX_CALL 245 | grLfbWriteRegion( GrBuffer_t dst_buffer, 246 | FxU32 dst_x, FxU32 dst_y, 247 | GrLfbSrcFmt_t src_format, 248 | FxU32 src_width, FxU32 src_height, 249 | FxI32 src_stride, void *src_data ) 250 | { 251 | #ifdef OGL_NOTDONE 252 | GlideMsg("grLfbWriteRegion( %d, %d, %d, %d, %d, %d, %d, --- )\n", 253 | dst_buffer, dst_x, dst_y, src_format, src_width, src_height, src_stride ); 254 | #endif 255 | 256 | RenderDrawTriangles( ); 257 | 258 | if ( src_stride != (FxI32)src_width ) 259 | { 260 | // Error( "grLfbWriteRegion: different width and stride.\n" ); 261 | return FXTRUE; 262 | } 263 | 264 | switch ( dst_buffer ) 265 | { 266 | case GR_BUFFER_FRONTBUFFER: glDrawBuffer( GL_FRONT ); break; 267 | case GR_BUFFER_BACKBUFFER: 268 | case GR_BUFFER_AUXBUFFER: glDrawBuffer( GL_BACK ); break; 269 | } 270 | 271 | glRasterPos2i( dst_x, dst_y ); 272 | 273 | switch ( src_format ) 274 | { 275 | case GR_LFB_SRC_FMT_565: 276 | case GR_LFB_SRC_FMT_555: 277 | case GR_LFB_SRC_FMT_1555: 278 | case GR_LFB_SRC_FMT_888: 279 | break; 280 | 281 | case GR_LFB_SRC_FMT_8888: 282 | break; 283 | 284 | case GR_LFB_SRC_FMT_565_DEPTH: 285 | case GR_LFB_SRC_FMT_555_DEPTH: 286 | case GR_LFB_SRC_FMT_1555_DEPTH: 287 | case GR_LFB_SRC_FMT_ZA16: 288 | case GR_LFB_SRC_FMT_RLE16: 289 | break; 290 | } 291 | 292 | // glDrawPixels( src_width, src_height, GL_RGBA, GL_UNSIGNED_BYTE, Glide.SrcBuffer.Buffer ); 293 | 294 | glDrawBuffer( OpenGL.RenderBuffer ); 295 | 296 | #ifdef OPENGL_DEBUG 297 | GLErro( "grLfbWriteRegion" ); 298 | #endif 299 | 300 | return FXTRUE; 301 | } 302 | 303 | FX_ENTRY void FX_CALL 304 | grLfbConstantAlpha( GrAlpha_t alpha ) 305 | { 306 | #ifdef OGL_CRITICAL 307 | GlideMsg("grLfbConstantAlpha( %lu )\n", alpha ); 308 | #endif 309 | } 310 | 311 | FX_ENTRY void FX_CALL 312 | grLfbConstantDepth( FxU16 depth ) 313 | { 314 | #ifdef OGL_CRITICAL 315 | GlideMsg("grLfbConstantDepth( %u )\n", depth ); 316 | #endif 317 | } 318 | 319 | FX_ENTRY void FX_CALL 320 | grLfbWriteColorSwizzle( FxBool swizzleBytes, FxBool swapWords ) 321 | { 322 | #ifdef OGL_CRITICAL 323 | GlideMsg("grLfbWriteColorSwizzle( %d, %d )\n", 324 | swizzleBytes, swapWords ); 325 | #endif 326 | } 327 | 328 | FX_ENTRY void FX_CALL 329 | grLfbWriteColorFormat( GrColorFormat_t colorFormat ) 330 | { 331 | #ifdef OGL_CRITICAL 332 | GlideMsg("grLfbWriteColorFormat( %u )\n", colorFormat ); 333 | #endif 334 | } 335 | 336 | -------------------------------------------------------------------------------- /GlOgl.h: -------------------------------------------------------------------------------- 1 | //************************************************************** 2 | //* OpenGLide - Glide to OpenGL Wrapper 3 | //* http://openglide.sourceforge.net 4 | //* 5 | //* Main Header 6 | //* 7 | //* OpenGLide is OpenSource under LGPL license 8 | //* Originaly made by Fabio Barros 9 | //* Modified by Paul for Glidos (http://www.glidos.net) 10 | //* Linux version by Simon White 11 | //************************************************************** 12 | 13 | #ifndef __GLOGL_H__ 14 | #define __GLOGL_H__ 15 | 16 | //#define OGL_ALL 17 | //#define OGL_PARTDONE 18 | //#define OGL_NOTDONE 19 | //#define OGL_DEBUG 20 | //#define OGL_CRITICAL 21 | //#define OPENGL_DEBUG 22 | //#define OGL_PROFILING 23 | //#define OGL_UTEX 24 | //#define OGL_COMBINE 25 | 26 | #ifdef OGL_ALL 27 | #define OGL_DONE 28 | #define OGL_PARTDONE 29 | #define OGL_NOTDONE 30 | #define OGL_DEBUG 31 | #define OGL_CRITICAL 32 | #define OPENGL_DEBUG 33 | #define OGL_PROFILING 34 | #define OGL_UTEX 35 | #define OGL_COMBINE 36 | #endif 37 | 38 | #include "platform.h" 39 | #include "platform/window.h" 40 | 41 | #include 42 | 43 | #include "sdk2_glide.h" 44 | 45 | #ifdef _MSC_VER 46 | #define RDTSC(v) __asm _emit 0x0f \ 47 | __asm _emit 0x31 \ 48 | __asm mov dword ptr v, eax \ 49 | __asm mov dword ptr v+4, edx 50 | #endif 51 | 52 | #ifdef __GNUC__ 53 | #define RDTSC(v) asm volatile ("rdtsc;" : "=A" (v) ) 54 | #endif 55 | 56 | #define ERRORFILE "OpenGLid.err" 57 | #define GLIDEFILE "OpenGLid.log" 58 | #define INIFILE "OpenGLid.ini" 59 | 60 | #define OGL_LOG_SEPARATE "--------------------------------------------------------\n" 61 | 62 | #define OGL_MIN_FRAME_BUFFER 2 63 | #define OGL_MAX_FRAME_BUFFER 16 64 | #define OGL_MIN_TEXTURE_BUFFER 2 65 | #define OGL_MAX_TEXTURE_BUFFER 32 66 | 67 | #define OGL_VER_1_1 101 68 | 69 | #define OPENGLBUFFERMEMORY OpenGL.WindowWidth * OpenGL.WindowHeight 70 | 71 | #define OPENGLFOGTABLESIZE 64 * 1024 72 | 73 | #define D1OVER255 0.003921568627451f // 1 / 255 74 | #define D1OVER65536 0.0000152587890625f // 1 / 65536 75 | #define D1OVER65535 0.000015259021896696421759365224689097f // 1 / 65535 76 | #define D1OVER256 0.00390625f // 1 / 256 77 | #define D2OVER256 0.0078125f // 2 / 256 78 | #define D4OVER256 0.015625f // 4 / 256 79 | #define D8OVER256 0.03125f // 8 / 256 80 | 81 | #define WBUFFERNEAR -1.0f 82 | #define WBUFFERFAR 0.0f 83 | #define ZBUFFERNEAR 0.0f 84 | #define ZBUFFERFAR -1.0f 85 | 86 | // Class declarations 87 | 88 | typedef void (*GLIDEERRORFUNCTION)( const char *string, FxBool fatal ); 89 | 90 | struct BufferStruct 91 | { 92 | bool Lock; 93 | GrLock_t Type; 94 | GrLfbWriteMode_t WriteMode; 95 | GrBuffer_t Buffer; 96 | FxBool PixelPipeline; 97 | FxU16 *Address; 98 | }; 99 | 100 | struct TexSourceStruct 101 | { 102 | FxU32 StartAddress; 103 | FxU32 EvenOdd; 104 | GrTexInfo Info; 105 | }; 106 | 107 | /* 108 | * Anonymous structs are not Ansi and 109 | * only support by Visual C++. They must 110 | * be removed. Luckily we don't use the 111 | * individual bytes which would be prown 112 | * to endian and compiler ordering problems! 113 | union OGLByteColor 114 | { 115 | struct 116 | { 117 | BYTE B; 118 | BYTE G; 119 | BYTE R; 120 | BYTE A; 121 | }; 122 | DWORD C; 123 | }; 124 | */ 125 | typedef FxU32 OGLByteColor; 126 | 127 | struct GlideState 128 | { 129 | GrBuffer_t RenderBuffer; 130 | GrDepthBufferMode_t DepthBufferMode; 131 | GrCmpFnc_t DepthFunction; 132 | FxBool DepthBufferWritting; 133 | FxI16 DepthBiasLevel; 134 | GrDitherMode_t DitherMode; 135 | GrColor_t ChromakeyValue; 136 | GrChromakeyMode_t ChromaKeyMode; 137 | GrAlpha_t AlphaReferenceValue; 138 | GrCmpFnc_t AlphaTestFunction; 139 | FxBool AlphaMask; 140 | FxBool ColorMask; 141 | GrColor_t ConstantColorValue; 142 | GrColor_t FogColorValue; 143 | GrFogMode_t FogMode; 144 | GrCullMode_t CullMode; 145 | GrTextureClampMode_t SClampMode; 146 | GrTextureClampMode_t TClampMode; 147 | GrTextureFilterMode_t MinFilterMode; 148 | GrTextureFilterMode_t MagFilterMode; 149 | GrMipMapMode_t MipMapMode; 150 | FxBool LodBlend; 151 | GrCombineFunction_t ColorCombineFunction; 152 | GrCombineFactor_t ColorCombineFactor; 153 | GrCombineLocal_t ColorCombineLocal; 154 | GrCombineOther_t ColorCombineOther; 155 | FxBool ColorCombineInvert; 156 | GrCombineFunction_t AlphaFunction; 157 | GrCombineFactor_t AlphaFactor; 158 | GrCombineLocal_t AlphaLocal; 159 | GrCombineOther_t AlphaOther; 160 | FxBool AlphaInvert; 161 | GrCombineFunction_t TextureCombineCFunction; 162 | GrCombineFactor_t TextureCombineCFactor; 163 | GrCombineFunction_t TextureCombineAFunction; 164 | GrCombineFactor_t TextureCombineAFactor; 165 | FxBool TextureCombineRGBInvert; 166 | FxBool TextureCombineAInvert; 167 | GrOriginLocation_t OriginInformation; 168 | TexSourceStruct TexSource; 169 | GrAlphaBlendFnc_t AlphaBlendRgbSf; 170 | GrAlphaBlendFnc_t AlphaBlendRgbDf; 171 | GrAlphaBlendFnc_t AlphaBlendAlphaSf; 172 | GrAlphaBlendFnc_t AlphaBlendAlphaDf; 173 | FxU32 ClipMinX; 174 | FxU32 ClipMaxX; 175 | FxU32 ClipMinY; 176 | FxU32 ClipMaxY; 177 | GrColorFormat_t ColorFormat; 178 | FxU32 STWHint; 179 | FxBool VRetrace; 180 | }; 181 | 182 | struct GlideStruct 183 | { 184 | int ActiveVoodoo; 185 | // Frame Buffer Stuff 186 | FxU32 WindowWidth; 187 | FxU32 WindowHeight; 188 | FxU32 WindowTotalPixels; 189 | int NumBuffers; 190 | int AuxBuffers; 191 | // States and Constants 192 | FxU8 FogTable[ GR_FOG_TABLE_SIZE + 1 ]; 193 | FxU32 TexMemoryMaxPosition; 194 | bool CLocal; 195 | bool COther; 196 | bool ALocal; 197 | bool AOther; 198 | GlideState State; 199 | BufferStruct SrcBuffer; 200 | BufferStruct DstBuffer; 201 | GLuint LFBTexture; 202 | FxU32 LFBTextureSize; 203 | int TextureMemory; 204 | }; 205 | 206 | struct OpenGLStruct 207 | { 208 | bool GlideInit; 209 | bool WinOpen; 210 | GLsizei WindowWidth; 211 | GLsizei WindowHeight; 212 | GLfloat Gamma; 213 | GLfloat AlphaReferenceValue; 214 | GLenum AlphaTestFunction; 215 | GLboolean DepthBufferWritting; 216 | GLfloat DepthBiasLevel; 217 | GLenum DepthFunction; 218 | GLenum RenderBuffer; 219 | GLenum SClampMode; 220 | GLenum TClampMode; 221 | GLenum MinFilterMode; 222 | GLenum MagFilterMode; 223 | GLenum TextureMode; 224 | GLenum SrcBlend; 225 | GLenum DstBlend; 226 | GLenum SrcAlphaBlend; 227 | GLenum DstAlphaBlend; 228 | GLuint Refresh; 229 | GLboolean ColorMask; 230 | GLfloat ConstantColor[ 4 ]; 231 | GLfloat AlphaColor[ 4 ]; 232 | GLfloat ZNear; 233 | GLfloat ZFar; 234 | GLfloat FogColor[ 4 ]; 235 | FxU8 FogTable[ OPENGLFOGTABLESIZE ]; 236 | OGLByteColor ChromaColor; 237 | bool Fog; 238 | bool Texture; 239 | bool ColorTexture; 240 | bool AlphaTexture; 241 | bool Blend; 242 | bool AlphaBuffer; 243 | bool ChromaKey; 244 | bool Clipping; 245 | int MultiTextureTMUs; 246 | int DepthBufferType; 247 | int WaitSignal; 248 | }; 249 | 250 | struct ConfigStruct 251 | { 252 | int OGLVersion; 253 | int Priority; 254 | int TextureMemorySize; 255 | int FrameBufferMemorySize; 256 | 257 | bool FogEnable; 258 | bool InitFullScreen; 259 | bool PrecisionFix; 260 | bool EnableMipMaps; 261 | bool BuildMipMaps; 262 | bool IgnorePaletteChange; 263 | bool Wrap565to5551; 264 | bool TextureEnv; 265 | bool MMXEnable; 266 | bool CreateWindow; 267 | 268 | bool EXT_secondary_color; 269 | bool ARB_multitexture; 270 | bool EXT_fog_coord; 271 | bool EXT_texture_env_add; 272 | bool EXT_texture_env_combine; 273 | bool EXT_texture_lod_bias; 274 | bool SGIS_generate_mipmap; 275 | bool EXT_paletted_texture; 276 | bool EXT_vertex_array; 277 | bool EXT_blend_func_separate; 278 | 279 | bool NoSplash; 280 | bool ShamelessPlug; 281 | }; 282 | 283 | // Extern variables 284 | extern const char * OpenGLideVersion; 285 | extern double ClockFreq; 286 | extern GlideStruct Glide; // Glide Internal 287 | extern OpenGLStruct OpenGL; // OpenGL equivalents 288 | extern ConfigStruct UserConfig; 289 | extern ConfigStruct InternalConfig; 290 | extern GLIDEERRORFUNCTION ExternErrorFunction; 291 | 292 | #ifdef OGL_DEBUG 293 | // Profiling variables 294 | extern FxI64 InitialTick; 295 | extern FxI64 FinalTick; 296 | extern FxU32 Frame; 297 | extern double Fps; 298 | extern double FpsAux; 299 | #endif 300 | 301 | // Genral Prototypes 302 | VARARGDECL(void) GlideMsg( const char *szString, ... ); 303 | VARARGDECL(void) Error( const char *szString, ... ); 304 | void GLErro( const char *Funcao ); 305 | void ConvertColor4B( GrColor_t GlideColor, FxU32 &C ); 306 | void ConvertColorB( GrColor_t GlideColor, FxU8 &R, FxU8 &G, FxU8 &B, FxU8 &A ); 307 | void ConvertColorF( GrColor_t GlideColor, float &R, float &G, float &B, float &A ); 308 | GrColor_t ConvertConstantColor( float R, float G, float B, float A ); 309 | bool GenerateErrorFile( void ); 310 | bool ClearAndGenerateLogFile( void ); 311 | void CloseLogFile( void ); 312 | bool InitWindow( FxU hWnd ); 313 | void InitOpenGL( void ); 314 | void GetOptions( void ); 315 | void InitMainVariables( void ); 316 | 317 | void MMXCopyMemory( void *Dst, void *Src, FxU32 NumberOfBytes ); 318 | 319 | int DetectMMX(); 320 | 321 | #endif 322 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------