OpenGL library is now loaded dynamically.
This commit is contained in:
parent
c77756e6fe
commit
d97c4252d6
5 changed files with 824 additions and 284 deletions
6
Makefile
6
Makefile
|
@ -4,7 +4,7 @@ NASM = nasm
|
|||
|
||||
#CFLAGS = -g -Wall -pipe
|
||||
CFLAGS = -g -Wall -pipe -O2
|
||||
#CFLAGS = -DNDEBUG -Wall -pipe -O6 -ffast-math -fomit-frame-pointer -march=pentiumpro -mcpu=pentiumpro
|
||||
#CFLAGS = -DNDEBUG -Wall -pipe -O6 -ffast-math -fomit-frame-pointer -march=pentium -mcpu=pentiumpro
|
||||
|
||||
CFLAGS += -DLINUX
|
||||
|
||||
|
@ -12,11 +12,11 @@ CFLAGS += -Dengine=1 -I. -Iinclude -Iwin95 -Iavp -Iavp/win95 -Iavp/support -Iavp
|
|||
CFLAGS += $(shell sdl-config --cflags)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
|
||||
LDLIBS = $(shell sdl-config --libs) -lGL -lopenal
|
||||
LDLIBS = $(shell sdl-config --libs) -lopenal
|
||||
|
||||
AFLAGS = -g -w+macro-params -w+orphan-labels -w+number-overflow
|
||||
|
||||
ROOT = main.c files.c winapi.c stubs.c version.c mathline.c opengl.c openal.c cdplayer.c menus.c net.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.c object.c shpanim.c sphere.c tables.c vdb.c
|
||||
ROOT = main.c files.c winapi.c stubs.c version.c mathline.c opengl.c oglfunc.c openal.c cdplayer.c menus.c net.c frustum.c kshape.c map.c maths.c md5.c mem3dc.c mem3dcpp.cpp module.c morph.c object.c shpanim.c sphere.c tables.c vdb.c
|
||||
AVP = ai_sight.c avpview.c bh_agun.c bh_ais.c bh_alien.c bh_binsw.c bh_cable.c bh_corpse.c bh_deathvol.c bh_debri.c bh_dummy.c bh_fan.c bh_far.c bh_fhug.c bh_gener.c bh_ldoor.c bh_lift.c bh_light.c bh_lnksw.c bh_ltfx.c bh_marin.c bh_mission.c bh_near.c bh_pargen.c bh_plachier.c bh_plift.c bh_pred.c bh_queen.c bh_rubberduck.c bh_selfdest.c bh_snds.c bh_spcl.c bh_swdor.c bh_track.c bh_types.c bh_videoscreen.c bh_waypt.c bh_weap.c bh_xeno.c bonusabilities.c cconvars.cpp cdtrackselection.cpp cheatmodes.c comp_map.c comp_shp.c consolelog.cpp davehook.cpp deaths.c decal.c detaillevels.c dynamics.c dynblock.c equipmnt.c equiputl.cpp extents.c game.c game_statistics.c gamecmds.cpp gamevars.cpp hmodel.c hud.c inventry.c language.c lighting.c load_shp.c los.c maps.c mempool.c messagehistory.c missions.cpp movement.c paintball.c particle.c pfarlocs.c pheromon.c player.c pmove.c psnd.c psndproj.c pvisible.c savegame.c scream.cpp secstats.c sfx.c stratdef.c targeting.c track.c triggers.c weapons.c
|
||||
SHAPES = cube.c
|
||||
SUPPORT = consbind.cpp consbtch.cpp coordstr.cpp daemon.cpp indexfnt.cpp r2base.cpp r2pos666.cpp reflist.cpp refobj.cpp rentrntq.cpp scstring.cpp strtab.cpp strutil.c trig666.cpp wrapstr.cpp
|
||||
|
|
123
src/main.c
123
src/main.c
|
@ -6,10 +6,11 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#include "oglfunc.h"
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <getopt.h>
|
||||
|
||||
#include "fixer.h"
|
||||
|
@ -71,11 +72,8 @@ int WantSound = 1;
|
|||
static int WantCDRom = 1;
|
||||
static int WantJoystick = 1;
|
||||
|
||||
#if 0 /* NVIDIA gl.h breaks this */
|
||||
#if GL_EXT_secondary_color
|
||||
PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT;
|
||||
#endif
|
||||
#endif
|
||||
static const char * opengl_library = "/usr/lib/libGL.so.1";
|
||||
static const char * opengl_library_tls = "/usr/lib/tls/libGL.so.1";
|
||||
|
||||
/* ** */
|
||||
|
||||
|
@ -184,9 +182,9 @@ unsigned char *GetScreenShot24(int *width, int *height)
|
|||
buf = (unsigned char *)malloc(surface->w * surface->h * 3);
|
||||
|
||||
if (surface->flags & SDL_OPENGL) {
|
||||
glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, buf);
|
||||
pglPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
pglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
pglReadPixels(0, 0, surface->w, surface->h, GL_RGB, GL_UNSIGNED_BYTE, buf);
|
||||
} else {
|
||||
unsigned char *ptrd;
|
||||
unsigned short int *ptrs;
|
||||
|
@ -451,6 +449,20 @@ int SetSoftVideoMode(int Width, int Height, int Depth)
|
|||
SDL_GrabMode isgrab;
|
||||
int flags;
|
||||
|
||||
load_ogl_functions(0);
|
||||
|
||||
/*
|
||||
let sdl try loading the opengl library, to see if it is even available
|
||||
this is definitely not enough, but it's a start...
|
||||
*/
|
||||
if (!surface || !(surface->flags & SDL_OPENGL))
|
||||
if (SDL_GL_LoadLibrary(opengl_library) < 0) {
|
||||
if (!opengl_library_tls || SDL_GL_LoadLibrary(opengl_library_tls) < 0) {
|
||||
fprintf(stderr, "unable to initialize opengl library: %s\n", SDL_GetError());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
ScanDrawMode = ScanDrawD3DHardwareRGB;
|
||||
GotMouse = 1;
|
||||
|
||||
|
@ -469,7 +481,6 @@ int SetSoftVideoMode(int Width, int Height, int Depth)
|
|||
|
||||
if ((surface = SDL_SetVideoMode(Width, Height, Depth, flags)) == NULL) {
|
||||
fprintf(stderr, "(Software) SDL SetVideoMode failed: %s\n", SDL_GetError());
|
||||
/* SDL_Quit(); */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -509,6 +520,8 @@ int SetOGLVideoMode(int Width, int Height)
|
|||
ScanDrawMode = ScanDrawD3DHardwareRGB;
|
||||
GotMouse = 1;
|
||||
|
||||
load_ogl_functions(0);
|
||||
|
||||
flags = SDL_OPENGL;
|
||||
if (surface != NULL) {
|
||||
if (surface->flags & SDL_FULLSCREEN)
|
||||
|
@ -517,11 +530,20 @@ int SetOGLVideoMode(int Width, int Height)
|
|||
|
||||
SDL_FreeSurface(surface);
|
||||
} else {
|
||||
if (WantFullscreen)
|
||||
if (WantFullscreen) {
|
||||
flags |= SDL_FULLSCREEN;
|
||||
}
|
||||
|
||||
isgrab = SDL_GRAB_OFF;
|
||||
}
|
||||
|
||||
if (SDL_GL_LoadLibrary(opengl_library) < 0) {
|
||||
if (!opengl_library_tls || SDL_GL_LoadLibrary(opengl_library_tls) < 0) {
|
||||
fprintf(stderr, "unable to initialize opengl library: %s\n", SDL_GetError());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
|
@ -530,10 +552,11 @@ int SetOGLVideoMode(int Width, int Height)
|
|||
|
||||
if ((surface = SDL_SetVideoMode(Width, Height, 0, flags)) == NULL) {
|
||||
fprintf(stderr, "(OpenGL) SDL SetVideoMode failed: %s\n", SDL_GetError());
|
||||
/* SDL_Quit(); */
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
load_ogl_functions(1);
|
||||
|
||||
SDL_WM_SetCaption("Aliens vs Predator", "Aliens vs Predator");
|
||||
|
||||
/* this is for supporting keyboard input processing with little hassle */
|
||||
|
@ -547,30 +570,30 @@ int SetOGLVideoMode(int Width, int Height)
|
|||
(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON))
|
||||
SDL_ShowCursor(0);
|
||||
|
||||
glViewport(0, 0, Width, Height);
|
||||
pglViewport(0, 0, Width, Height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
pglMatrixMode(GL_PROJECTION);
|
||||
pglLoadIdentity();
|
||||
pglMatrixMode(GL_MODELVIEW);
|
||||
pglLoadIdentity();
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
pglEnable(GL_BLEND);
|
||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthMask(GL_TRUE);
|
||||
glDepthRange(0.0, 1.0);
|
||||
pglEnable(GL_DEPTH_TEST);
|
||||
pglDepthFunc(GL_LEQUAL);
|
||||
pglDepthMask(GL_TRUE);
|
||||
pglDepthRange(0.0, 1.0);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
pglEnable(GL_TEXTURE_2D);
|
||||
|
||||
glPolygonMode(GL_FRONT, GL_FILL);
|
||||
glPolygonMode(GL_BACK, GL_FILL);
|
||||
glDisable(GL_CULL_FACE);
|
||||
pglPolygonMode(GL_FRONT, GL_FILL);
|
||||
pglPolygonMode(GL_BACK, GL_FILL);
|
||||
pglDisable(GL_CULL_FACE);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
pglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
pglHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
||||
|
||||
ScreenDescriptorBlock.SDB_Width = Width;
|
||||
ScreenDescriptorBlock.SDB_Height = Height;
|
||||
|
@ -583,28 +606,9 @@ int SetOGLVideoMode(int Width, int Height)
|
|||
ScreenDescriptorBlock.SDB_ClipUp = 0;
|
||||
ScreenDescriptorBlock.SDB_ClipDown = Height;
|
||||
|
||||
ext = (char *)glGetString(GL_EXTENSIONS);
|
||||
/*
|
||||
printf("OpenGL Extensions: %s\n", ext);
|
||||
*/
|
||||
#if 0 /* NVIDIA header problem */
|
||||
#if GL_EXT_secondary_color
|
||||
pglSecondaryColorPointerEXT = NULL;
|
||||
ext = (char *) pglGetString(GL_EXTENSIONS);
|
||||
|
||||
if (CheckToken(ext, "GL_EXT_secondary_color")) {
|
||||
printf("Found GL_EXT_secondary_color... ");
|
||||
|
||||
pglSecondaryColorPointerEXT = SDL_GL_GetProcAddress("glSecondaryColorPointerEXT");
|
||||
if (pglSecondaryColorPointerEXT == NULL) {
|
||||
printf("but the driver lied...\n");
|
||||
} else {
|
||||
printf("and it's good!\n");
|
||||
}
|
||||
} else {
|
||||
printf("GL_EXT_secondary_color not found...\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
load_ogl_functions(1);
|
||||
|
||||
InitOpenGL();
|
||||
|
||||
|
@ -622,9 +626,12 @@ int ExitWindowsSystem()
|
|||
SDL_JoystickClose(joy);
|
||||
}
|
||||
|
||||
/* SDL_Quit(); */
|
||||
if (surface)
|
||||
load_ogl_functions(0);
|
||||
|
||||
if (surface) {
|
||||
SDL_FreeSurface(surface);
|
||||
}
|
||||
|
||||
surface = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -1246,7 +1253,7 @@ void InitGameDirectories(char *argv0)
|
|||
DeleteGameFile("dx_error.log");
|
||||
}
|
||||
|
||||
static struct option getopt_long_options[] = {
|
||||
static const struct option getopt_long_options[] = {
|
||||
{ "help", 0, NULL, 'h' },
|
||||
{ "version", 0, NULL, 'v' },
|
||||
{ "fullscreen", 0, NULL, 'f' },
|
||||
|
@ -1255,6 +1262,7 @@ static struct option getopt_long_options[] = {
|
|||
{ "nocdrom", 0, NULL, 'c' },
|
||||
{ "nojoy", 0, NULL, 'j' },
|
||||
{ "debug", 0, NULL, 'd' },
|
||||
{ "withgl", 1, NULL, 'g' },
|
||||
/*
|
||||
{ "loadrifs", 1, NULL, 'l' },
|
||||
{ "server", 0, someval, 1 },
|
||||
|
@ -1273,6 +1281,7 @@ static const char *usage_string =
|
|||
" [-s | --nosound] Do not access the soundcard\n"
|
||||
" [-c | --nocdrom] Do not access the CD-ROM\n"
|
||||
" [-j | --nojoy] Do not access the joystick\n"
|
||||
" [-g | --withgl] [x] Use [x] instead of /usr/lib/libGL.so.1 for OpenGL\n"
|
||||
;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1280,7 +1289,7 @@ int main(int argc, char *argv[])
|
|||
int c;
|
||||
|
||||
opterr = 0;
|
||||
while ((c = getopt_long(argc, argv, "hvfwscd", getopt_long_options, NULL)) != -1) {
|
||||
while ((c = getopt_long(argc, argv, "hvfwscdg:", getopt_long_options, NULL)) != -1) {
|
||||
switch(c) {
|
||||
case 'h':
|
||||
printf("%s", usage_string);
|
||||
|
@ -1308,6 +1317,10 @@ int main(int argc, char *argv[])
|
|||
DebuggingCommandsActive = 1;
|
||||
}
|
||||
break;
|
||||
case 'g':
|
||||
opengl_library = optarg;
|
||||
opengl_library_tls = NULL;
|
||||
break;
|
||||
default:
|
||||
printf("%s", usage_string);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
308
src/oglfunc.c
Normal file
308
src/oglfunc.c
Normal file
|
@ -0,0 +1,308 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "oglfunc.h"
|
||||
|
||||
PFNGLALPHAFUNCPROC pglAlphaFunc;
|
||||
PFNGLARRAYELEMENTPROC pglArrayElement;
|
||||
PFNGLBEGINPROC pglBegin;
|
||||
PFNGLBINDTEXTUREPROC pglBindTexture;
|
||||
PFNGLBLENDFUNCPROC pglBlendFunc;
|
||||
PFNGLCLEARPROC pglClear;
|
||||
PFNGLCLEARCOLORPROC pglClearColor;
|
||||
PFNGLCOLOR3FPROC pglColor3f;
|
||||
PFNGLCOLOR3FVPROC pglColor3fv;
|
||||
PFNGLCOLOR3UBPROC pglColor3ub;
|
||||
PFNGLCOLOR3UBVPROC pglColor3ubv;
|
||||
PFNGLCOLOR4FPROC pglColor4f;
|
||||
PFNGLCOLOR4FVPROC pglColor4fv;
|
||||
PFNGLCOLOR4UBPROC pglColor4ub;
|
||||
PFNGLCOLOR4UBVPROC pglColor4ubv;
|
||||
PFNGLCOLORPOINTERPROC pglColorPointer;
|
||||
PFNGLCULLFACEPROC pglCullFace;
|
||||
PFNGLDELETETEXTURESPROC pglDeleteTextures;
|
||||
PFNGLDEPTHFUNCPROC pglDepthFunc;
|
||||
PFNGLDEPTHMASKPROC pglDepthMask;
|
||||
PFNGLDEPTHRANGEPROC pglDepthRange;
|
||||
PFNGLDISABLEPROC pglDisable;
|
||||
PFNGLDISABLECLIENTSTATEPROC pglDisableClientState;
|
||||
PFNGLDRAWBUFFERPROC pglDrawBuffer;
|
||||
PFNGLDRAWELEMENTSPROC pglDrawElements;
|
||||
PFNGLDRAWPIXELSPROC pglDrawPixels;
|
||||
PFNGLDRAWRANGEELEMENTSPROC pglDrawRangeElements;
|
||||
PFNGLENABLEPROC pglEnable;
|
||||
PFNGLENABLECLIENTSTATEPROC pglEnableClientState;
|
||||
PFNGLENDPROC pglEnd;
|
||||
PFNGLFRONTFACEPROC pglFrontFace;
|
||||
PFNGLFRUSTUMPROC pglFrustum;
|
||||
PFNGLGENTEXTURESPROC pglGenTextures;
|
||||
PFNGLGETERRORPROC pglGetError;
|
||||
PFNGLGETFLOATVPROC pglGetFloatv;
|
||||
PFNGLGETINTEGERVPROC pglGetIntegerv;
|
||||
PFNGLGETSTRINGPROC pglGetString;
|
||||
PFNGLHINTPROC pglHint;
|
||||
PFNGLLOADIDENTITYPROC pglLoadIdentity;
|
||||
PFNGLLOADMATRIXFPROC pglLoadMatrixf;
|
||||
PFNGLMATRIXMODEPROC pglMatrixMode;
|
||||
PFNGLMULTMATRIXFPROC pglMultMatrixf;
|
||||
PFNGLNORMALPOINTERPROC pglNormalPointer;
|
||||
PFNGLORTHOPROC pglOrtho;
|
||||
PFNGLPIXELSTOREIPROC pglPixelStorei;
|
||||
PFNGLPIXELZOOMPROC pglPixelZoom;
|
||||
PFNGLPOLYGONMODEPROC pglPolygonMode;
|
||||
PFNGLPOLYGONOFFSETPROC pglPolygonOffset;
|
||||
PFNGLPOPATTRIBPROC pglPopAttrib;
|
||||
PFNGLPOPCLIENTATTRIBPROC pglPopClientAttrib;
|
||||
PFNGLPOPMATRIXPROC pglPopMatrix;
|
||||
PFNGLPUSHATTRIBPROC pglPushAttrib;
|
||||
PFNGLPUSHCLIENTATTRIBPROC pglPushClientAttrib;
|
||||
PFNGLPUSHMATRIXPROC pglPushMatrix;
|
||||
PFNGLRASTERPOS2IPROC pglRasterPos2i;
|
||||
PFNGLREADBUFFERPROC pglReadBuffer;
|
||||
PFNGLREADPIXELSPROC pglReadPixels;
|
||||
PFNGLROTATEFPROC pglRotatef;
|
||||
PFNGLSCALEFPROC pglScalef;
|
||||
PFNGLSHADEMODELPROC pglShadeModel;
|
||||
PFNGLTEXCOORD2FPROC pglTexCoord2f;
|
||||
PFNGLTEXCOORD2FVPROC pglTexCoord2fv;
|
||||
PFNGLTEXCOORD3FPROC pglTexCoord3f;
|
||||
PFNGLTEXCOORD3FVPROC pglTexCoord3fv;
|
||||
PFNGLTEXCOORD4FPROC pglTexCoord4f;
|
||||
PFNGLTEXCOORD4FVPROC pglTexCoord4fv;
|
||||
PFNGLTEXCOORDPOINTERPROC pglTexCoordPointer;
|
||||
PFNGLTEXENVFPROC pglTexEnvf;
|
||||
PFNGLTEXENVFVPROC pglTexEnvfv;
|
||||
PFNGLTEXENVIPROC pglTexEnvi;
|
||||
PFNGLTEXIMAGE2DPROC pglTexImage2D;
|
||||
PFNGLTEXPARAMETERFPROC pglTexParameterf;
|
||||
PFNGLTEXPARAMETERIPROC pglTexParameteri;
|
||||
PFNGLTEXSUBIMAGE2DPROC pglTexSubImage2D;
|
||||
PFNGLTRANSLATEFPROC pglTranslatef;
|
||||
PFNGLVERTEX2FPROC pglVertex2f;
|
||||
PFNGLVERTEX2FVPROC pglVertex2fv;
|
||||
PFNGLVERTEX3FPROC pglVertex3f;
|
||||
PFNGLVERTEX3FVPROC pglVertex3fv;
|
||||
PFNGLVERTEX4FPROC pglVertex4f;
|
||||
PFNGLVERTEX4FVPROC pglVertex4fv;
|
||||
PFNGLVERTEXPOINTERPROC pglVertexPointer;
|
||||
PFNGLVIEWPORTPROC pglViewport;
|
||||
|
||||
// GL_EXT_paletted_texture
|
||||
PFNGLCOLORTABLEEXTPROC pglColorTableEXT;
|
||||
PFNGLGETCOLORTABLEPARAMETERIVEXTPROC pglGetColorTableParameterivEXT;
|
||||
|
||||
// GL_EXT_secondary_color
|
||||
PFNGLSECONDARYCOLOR3FEXTPROC pglSecondaryColor3fEXT;
|
||||
PFNGLSECONDARYCOLOR3FVEXTPROC pglSecondaryColor3fvEXT;
|
||||
PFNGLSECONDARYCOLOR3UBEXTPROC pglSecondaryColor3ubEXT;
|
||||
PFNGLSECONDARYCOLOR3UBVEXTPROC pglSecondaryColor3ubvEXT;
|
||||
PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT;
|
||||
|
||||
int ogl_have_paletted_texture;
|
||||
int ogl_have_secondary_color;
|
||||
|
||||
int ogl_use_paletted_texture;
|
||||
int ogl_use_secondary_color;
|
||||
|
||||
static void dummyfunc()
|
||||
{
|
||||
}
|
||||
|
||||
#define LoadOGLProc(type, func) \
|
||||
{ \
|
||||
if (!mode) p##func = (type) dummyfunc; else \
|
||||
p##func = (type) SDL_GL_GetProcAddress(#func); \
|
||||
if (p##func == NULL) { \
|
||||
if (!ogl_missing_func) ogl_missing_func = #func; \
|
||||
} \
|
||||
}
|
||||
|
||||
static int check_token(const char *string, const char *token)
|
||||
{
|
||||
const char *s = string;
|
||||
int len = strlen(token);
|
||||
|
||||
while ((s = strstr(s, token)) != NULL) {
|
||||
const char *next = s + len;
|
||||
|
||||
if ((s == string || *(s-1) == ' ') &&
|
||||
(*next == 0 || *next == ' ')) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
s = next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void load_ogl_functions(int mode)
|
||||
{
|
||||
const char * ogl_missing_func;
|
||||
|
||||
ogl_missing_func = NULL;
|
||||
|
||||
LoadOGLProc(PFNGLALPHAFUNCPROC, glAlphaFunc);
|
||||
LoadOGLProc(PFNGLARRAYELEMENTPROC, glArrayElement);
|
||||
LoadOGLProc(PFNGLBEGINPROC, glBegin);
|
||||
LoadOGLProc(PFNGLBINDTEXTUREPROC, glBindTexture);
|
||||
LoadOGLProc(PFNGLBLENDFUNCPROC, glBlendFunc);
|
||||
LoadOGLProc(PFNGLCLEARPROC, glClear);
|
||||
LoadOGLProc(PFNGLCLEARCOLORPROC, glClearColor);
|
||||
LoadOGLProc(PFNGLCOLOR3FPROC, glColor3f);
|
||||
LoadOGLProc(PFNGLCOLOR3FVPROC, glColor3fv);
|
||||
LoadOGLProc(PFNGLCOLOR3UBPROC, glColor3ub);
|
||||
LoadOGLProc(PFNGLCOLOR3UBVPROC, glColor3ubv);
|
||||
LoadOGLProc(PFNGLCOLOR4FPROC, glColor4f);
|
||||
LoadOGLProc(PFNGLCOLOR4FVPROC, glColor4fv);
|
||||
LoadOGLProc(PFNGLCOLOR4UBPROC, glColor4ub);
|
||||
LoadOGLProc(PFNGLCOLOR4UBVPROC, glColor4ubv);
|
||||
LoadOGLProc(PFNGLCOLORPOINTERPROC, glColorPointer);
|
||||
LoadOGLProc(PFNGLCULLFACEPROC, glCullFace);
|
||||
LoadOGLProc(PFNGLDELETETEXTURESPROC, glDeleteTextures);
|
||||
LoadOGLProc(PFNGLDEPTHFUNCPROC, glDepthFunc);
|
||||
LoadOGLProc(PFNGLDEPTHMASKPROC, glDepthMask);
|
||||
LoadOGLProc(PFNGLDEPTHRANGEPROC, glDepthRange);
|
||||
LoadOGLProc(PFNGLDISABLEPROC, glDisable);
|
||||
LoadOGLProc(PFNGLDISABLECLIENTSTATEPROC, glDisableClientState);
|
||||
LoadOGLProc(PFNGLDRAWBUFFERPROC, glDrawBuffer);
|
||||
LoadOGLProc(PFNGLDRAWELEMENTSPROC, glDrawElements);
|
||||
LoadOGLProc(PFNGLDRAWPIXELSPROC, glDrawPixels);
|
||||
LoadOGLProc(PFNGLDRAWRANGEELEMENTSPROC, glDrawRangeElements);
|
||||
LoadOGLProc(PFNGLENABLEPROC, glEnable);
|
||||
LoadOGLProc(PFNGLENABLECLIENTSTATEPROC, glEnableClientState);
|
||||
LoadOGLProc(PFNGLENDPROC, glEnd);
|
||||
LoadOGLProc(PFNGLFRONTFACEPROC, glFrontFace);
|
||||
LoadOGLProc(PFNGLFRUSTUMPROC, glFrustum);
|
||||
LoadOGLProc(PFNGLGENTEXTURESPROC, glGenTextures);
|
||||
LoadOGLProc(PFNGLGETERRORPROC, glGetError);
|
||||
LoadOGLProc(PFNGLGETFLOATVPROC, glGetFloatv);
|
||||
LoadOGLProc(PFNGLGETINTEGERVPROC, glGetIntegerv);
|
||||
LoadOGLProc(PFNGLGETSTRINGPROC, glGetString);
|
||||
LoadOGLProc(PFNGLHINTPROC, glHint);
|
||||
LoadOGLProc(PFNGLLOADIDENTITYPROC, glLoadIdentity);
|
||||
LoadOGLProc(PFNGLLOADMATRIXFPROC, glLoadMatrixf);
|
||||
LoadOGLProc(PFNGLMATRIXMODEPROC, glMatrixMode);
|
||||
LoadOGLProc(PFNGLMULTMATRIXFPROC, glMultMatrixf);
|
||||
LoadOGLProc(PFNGLNORMALPOINTERPROC, glNormalPointer);
|
||||
LoadOGLProc(PFNGLORTHOPROC, glOrtho);
|
||||
LoadOGLProc(PFNGLPIXELSTOREIPROC, glPixelStorei);
|
||||
LoadOGLProc(PFNGLPIXELZOOMPROC, glPixelZoom);
|
||||
LoadOGLProc(PFNGLPOLYGONMODEPROC, glPolygonMode);
|
||||
LoadOGLProc(PFNGLPOLYGONOFFSETPROC, glPolygonOffset);
|
||||
LoadOGLProc(PFNGLPOPATTRIBPROC, glPopAttrib);
|
||||
LoadOGLProc(PFNGLPOPCLIENTATTRIBPROC, glPopClientAttrib);
|
||||
LoadOGLProc(PFNGLPOPMATRIXPROC, glPopMatrix);
|
||||
LoadOGLProc(PFNGLPUSHATTRIBPROC, glPushAttrib);
|
||||
LoadOGLProc(PFNGLPUSHCLIENTATTRIBPROC, glPushClientAttrib);
|
||||
LoadOGLProc(PFNGLPUSHMATRIXPROC, glPushMatrix);
|
||||
LoadOGLProc(PFNGLRASTERPOS2IPROC, glRasterPos2i);
|
||||
LoadOGLProc(PFNGLREADBUFFERPROC, glReadBuffer);
|
||||
LoadOGLProc(PFNGLREADPIXELSPROC, glReadPixels);
|
||||
LoadOGLProc(PFNGLROTATEFPROC, glRotatef);
|
||||
LoadOGLProc(PFNGLSCALEFPROC, glScalef);
|
||||
LoadOGLProc(PFNGLSHADEMODELPROC, glShadeModel);
|
||||
LoadOGLProc(PFNGLTEXCOORD2FPROC, glTexCoord2f);
|
||||
LoadOGLProc(PFNGLTEXCOORD2FVPROC, glTexCoord2fv);
|
||||
LoadOGLProc(PFNGLTEXCOORD3FPROC, glTexCoord3f);
|
||||
LoadOGLProc(PFNGLTEXCOORD3FVPROC, glTexCoord3fv);
|
||||
LoadOGLProc(PFNGLTEXCOORD4FPROC, glTexCoord4f);
|
||||
LoadOGLProc(PFNGLTEXCOORD4FVPROC, glTexCoord4fv);
|
||||
LoadOGLProc(PFNGLTEXCOORDPOINTERPROC, glTexCoordPointer);
|
||||
LoadOGLProc(PFNGLTEXENVFPROC, glTexEnvf);
|
||||
LoadOGLProc(PFNGLTEXENVFVPROC, glTexEnvfv);
|
||||
LoadOGLProc(PFNGLTEXENVIPROC, glTexEnvi);
|
||||
LoadOGLProc(PFNGLTEXIMAGE2DPROC, glTexImage2D);
|
||||
LoadOGLProc(PFNGLTEXPARAMETERFPROC, glTexParameterf);
|
||||
LoadOGLProc(PFNGLTEXPARAMETERIPROC, glTexParameteri);
|
||||
LoadOGLProc(PFNGLTEXSUBIMAGE2DPROC, glTexSubImage2D);
|
||||
LoadOGLProc(PFNGLTRANSLATEFPROC, glTranslatef);
|
||||
LoadOGLProc(PFNGLVERTEX2FPROC, glVertex2f);
|
||||
LoadOGLProc(PFNGLVERTEX2FVPROC, glVertex2fv);
|
||||
LoadOGLProc(PFNGLVERTEX3FPROC, glVertex3f);
|
||||
LoadOGLProc(PFNGLVERTEX3FVPROC, glVertex3fv);
|
||||
LoadOGLProc(PFNGLVERTEX4FPROC, glVertex4f);
|
||||
LoadOGLProc(PFNGLVERTEX4FVPROC, glVertex4fv);
|
||||
LoadOGLProc(PFNGLVERTEXPOINTERPROC, glVertexPointer);
|
||||
LoadOGLProc(PFNGLVIEWPORTPROC, glViewport);
|
||||
|
||||
if (!mode) {
|
||||
ogl_have_paletted_texture = 0;
|
||||
ogl_have_secondary_color = 0;
|
||||
|
||||
ogl_use_paletted_texture = 0;
|
||||
ogl_use_secondary_color = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (ogl_missing_func) {
|
||||
fprintf(stderr, "Unable to load OpenGL Library: missing function %s\n", ogl_missing_func);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
const char *ext = (const char *) pglGetString(GL_EXTENSIONS);
|
||||
|
||||
ogl_have_paletted_texture = check_token(ext, "GL_EXT_paletted_texture");
|
||||
ogl_have_secondary_color = check_token(ext, "GL_EXT_secondary_color");
|
||||
|
||||
#ifndef GL_COLOR_TABLE_WIDTH_EXT
|
||||
#define GL_COLOR_TABLE_WIDTH_EXT GL_COLOR_TABLE_WIDTH
|
||||
#endif
|
||||
|
||||
if (ogl_have_paletted_texture) {
|
||||
ogl_missing_func = NULL;
|
||||
|
||||
LoadOGLProc(PFNGLCOLORTABLEEXTPROC, glColorTableEXT);
|
||||
LoadOGLProc(PFNGLGETCOLORTABLEPARAMETERIVEXTPROC, glGetColorTableParameterivEXT);
|
||||
|
||||
if (!ogl_missing_func) {
|
||||
GLint size;
|
||||
|
||||
pglColorTableEXT(GL_PROXY_TEXTURE_2D, GL_RGBA, 256, GL_BGRA, GL_UNSIGNED_BYTE, NULL);
|
||||
pglGetColorTableParameterivEXT(GL_PROXY_TEXTURE_2D, GL_COLOR_TABLE_WIDTH_EXT, &size);
|
||||
|
||||
if (size != 256) {
|
||||
ogl_have_paletted_texture = 0;
|
||||
}
|
||||
} else {
|
||||
ogl_have_paletted_texture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ogl_have_secondary_color) {
|
||||
ogl_missing_func = NULL;
|
||||
|
||||
LoadOGLProc(PFNGLSECONDARYCOLOR3FEXTPROC, glSecondaryColor3fEXT);
|
||||
LoadOGLProc(PFNGLSECONDARYCOLOR3FVEXTPROC, glSecondaryColor3fvEXT);
|
||||
LoadOGLProc(PFNGLSECONDARYCOLOR3UBEXTPROC, glSecondaryColor3ubEXT);
|
||||
LoadOGLProc(PFNGLSECONDARYCOLOR3UBVEXTPROC, glSecondaryColor3ubvEXT);
|
||||
LoadOGLProc(PFNGLSECONDARYCOLORPOINTEREXTPROC, glSecondaryColorPointerEXT);
|
||||
|
||||
if (ogl_missing_func) {
|
||||
ogl_have_secondary_color = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ogl_use_paletted_texture = ogl_have_paletted_texture;
|
||||
ogl_use_secondary_color = ogl_have_secondary_color;
|
||||
|
||||
// fprintf(stderr, "RENDER DEBUG: pal:%d sec:%d\n", ogl_use_paletted_texture, ogl_use_secondary_color);
|
||||
}
|
||||
|
||||
int check_for_errors(const char *file, int line)
|
||||
{
|
||||
GLenum error;
|
||||
int diderror = 0;
|
||||
|
||||
while ((error = pglGetError()) != GL_NO_ERROR) {
|
||||
fprintf(stderr, "OPENGL ERROR: %04X (%s:%d)\n", error, file, line);
|
||||
|
||||
diderror = 1;
|
||||
}
|
||||
|
||||
return diderror;
|
||||
}
|
222
src/oglfunc.h
Normal file
222
src/oglfunc.h
Normal file
|
@ -0,0 +1,222 @@
|
|||
#ifndef OGLFUNC_H
|
||||
#define OGLFUNC_H
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
|
||||
typedef void (APIENTRY *PFNGLALPHAFUNCPROC)(GLenum, GLclampf);
|
||||
typedef void (APIENTRY *PFNGLARRAYELEMENTPROC)(GLint);
|
||||
typedef void (APIENTRY *PFNGLBEGINPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLBINDTEXTUREPROC)(GLenum, GLuint);
|
||||
typedef void (APIENTRY *PFNGLBLENDFUNCPROC)(GLenum, GLenum);
|
||||
typedef void (APIENTRY *PFNGLCLEARPROC)(GLbitfield);
|
||||
typedef void (APIENTRY *PFNGLCLEARCOLORPROC)(GLclampf, GLclampf, GLclampf, GLclampf);
|
||||
typedef void (APIENTRY *PFNGLCOLOR3FPROC)(GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLCOLOR3FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLCOLOR3UBPROC)(GLubyte, GLubyte, GLubyte);
|
||||
typedef void (APIENTRY *PFNGLCOLOR3UBVPROC)(const GLubyte *);
|
||||
typedef void (APIENTRY *PFNGLCOLOR4FPROC)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLCOLOR4FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLCOLOR4UBPROC)(GLubyte, GLubyte, GLubyte, GLubyte);
|
||||
typedef void (APIENTRY *PFNGLCOLOR4UBVPROC)(const GLubyte *);
|
||||
typedef void (APIENTRY *PFNGLCOLORPOINTERPROC)(GLint, GLenum, GLsizei, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLCULLFACEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLDELETETEXTURESPROC)(GLsizei,const GLuint*);
|
||||
typedef void (APIENTRY *PFNGLDEPTHFUNCPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLDEPTHMASKPROC)(GLboolean);
|
||||
typedef void (APIENTRY *PFNGLDEPTHRANGEPROC)(GLclampd, GLclampd);
|
||||
typedef void (APIENTRY *PFNGLDISABLEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLDISABLECLIENTSTATEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLDRAWBUFFERPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLDRAWELEMENTSPROC)(GLenum, GLsizei, GLenum, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLDRAWPIXELSPROC)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLDRAWRANGEELEMENTSPROC)(GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLENABLEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLENABLECLIENTSTATEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLENDPROC)(GLvoid);
|
||||
typedef void (APIENTRY *PFNGLFRONTFACEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLFRUSTUMPROC)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
|
||||
typedef void (APIENTRY *PFNGLGENTEXTURESPROC)(GLsizei,GLuint*);
|
||||
typedef GLenum (APIENTRY *PFNGLGETERRORPROC)(void);
|
||||
typedef void (APIENTRY *PFNGLGETFLOATVPROC)(GLenum, GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLGETINTEGERVPROC)(GLenum, GLint *);
|
||||
typedef const GLubyte* (APIENTRY *PFNGLGETSTRINGPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLHINTPROC)(GLenum, GLenum);
|
||||
typedef void (APIENTRY *PFNGLLOADIDENTITYPROC)(void);
|
||||
typedef void (APIENTRY *PFNGLLOADMATRIXFPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLMATRIXMODEPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLMULTMATRIXFPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLNORMALPOINTERPROC)(GLenum, GLsizei, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLORTHOPROC)(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
|
||||
typedef void (APIENTRY *PFNGLPIXELSTOREIPROC)(GLenum, GLint);
|
||||
typedef void (APIENTRY *PFNGLPIXELZOOMPROC)(GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLPOLYGONMODEPROC)(GLenum, GLenum);
|
||||
typedef void (APIENTRY *PFNGLPOLYGONOFFSETPROC)(GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLPOPATTRIBPROC)(void);
|
||||
typedef void (APIENTRY *PFNGLPOPCLIENTATTRIBPROC)(void);
|
||||
typedef void (APIENTRY *PFNGLPOPMATRIXPROC)(void);
|
||||
typedef void (APIENTRY *PFNGLPUSHATTRIBPROC)(GLbitfield);
|
||||
typedef void (APIENTRY *PFNGLPUSHCLIENTATTRIBPROC)(GLbitfield);
|
||||
typedef void (APIENTRY *PFNGLPUSHMATRIXPROC)(void);
|
||||
typedef void (APIENTRY *PFNGLRASTERPOS2IPROC)(GLint, GLint);
|
||||
typedef void (APIENTRY *PFNGLREADBUFFERPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLREADPIXELSPROC)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLROTATEFPROC)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLSCALEFPROC)(GLfloat,GLfloat,GLfloat);
|
||||
typedef void (APIENTRY *PFNGLSHADEMODELPROC)(GLenum);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORD2FPROC)(GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORD2FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORD3FPROC)(GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORD3FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORD4FPROC)(GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORD4FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLTEXCOORDPOINTERPROC)(GLint, GLenum, GLsizei, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLTEXENVFPROC)(GLenum, GLenum, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLTEXENVFVPROC)(GLenum, GLenum, const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLTEXENVIPROC)(GLenum, GLenum, GLint);
|
||||
typedef void (APIENTRY *PFNGLTEXIMAGE2DPROC)(GLenum,GLint,GLint,GLsizei,GLsizei,GLint,GLenum,GLenum,const GLvoid*);
|
||||
typedef void (APIENTRY *PFNGLTEXPARAMETERFPROC)(GLenum, GLenum, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLTEXPARAMETERIPROC)(GLenum, GLenum, GLint);
|
||||
typedef void (APIENTRY *PFNGLTEXSUBIMAGE2DPROC)(GLenum,GLint,GLint,GLint,GLsizei,GLsizei,GLenum,GLenum,const GLvoid*);
|
||||
typedef void (APIENTRY *PFNGLTRANSLATEFPROC)(GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLVERTEX2FPROC)(GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLVERTEX2FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLVERTEX3FPROC)(GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLVERTEX3FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLVERTEX4FPROC)(GLfloat, GLfloat, GLfloat, GLfloat);
|
||||
typedef void (APIENTRY *PFNGLVERTEX4FVPROC)(const GLfloat *);
|
||||
typedef void (APIENTRY *PFNGLVERTEXPOINTERPROC)(GLint, GLenum, GLsizei, const GLvoid *);
|
||||
typedef void (APIENTRY *PFNGLVIEWPORTPROC)(GLint, GLint, GLsizei, GLsizei);
|
||||
|
||||
/*
|
||||
typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
|
||||
typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
|
||||
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
|
||||
*/
|
||||
|
||||
/*
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
|
||||
typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
*/
|
||||
|
||||
extern PFNGLALPHAFUNCPROC pglAlphaFunc;
|
||||
extern PFNGLARRAYELEMENTPROC pglArrayElement;
|
||||
extern PFNGLBEGINPROC pglBegin;
|
||||
extern PFNGLBINDTEXTUREPROC pglBindTexture;
|
||||
extern PFNGLBLENDFUNCPROC pglBlendFunc;
|
||||
extern PFNGLCLEARPROC pglClear;
|
||||
extern PFNGLCLEARCOLORPROC pglClearColor;
|
||||
extern PFNGLCOLOR3FPROC pglColor3f;
|
||||
extern PFNGLCOLOR3FVPROC pglColor3fv;
|
||||
extern PFNGLCOLOR3UBPROC pglColor3ub;
|
||||
extern PFNGLCOLOR3UBVPROC pglColor3ubv;
|
||||
extern PFNGLCOLOR4FPROC pglColor4f;
|
||||
extern PFNGLCOLOR4FVPROC pglColor4fv;
|
||||
extern PFNGLCOLOR4UBPROC pglColor4ub;
|
||||
extern PFNGLCOLOR4UBVPROC pglColor4ubv;
|
||||
extern PFNGLCOLORPOINTERPROC pglColorPointer;
|
||||
extern PFNGLCULLFACEPROC pglCullFace;
|
||||
extern PFNGLDELETETEXTURESPROC pglDeleteTextures;
|
||||
extern PFNGLDEPTHFUNCPROC pglDepthFunc;
|
||||
extern PFNGLDEPTHMASKPROC pglDepthMask;
|
||||
extern PFNGLDEPTHRANGEPROC pglDepthRange;
|
||||
extern PFNGLDISABLEPROC pglDisable;
|
||||
extern PFNGLDISABLECLIENTSTATEPROC pglDisableClientState;
|
||||
extern PFNGLDRAWBUFFERPROC pglDrawBuffer;
|
||||
extern PFNGLDRAWELEMENTSPROC pglDrawElements;
|
||||
extern PFNGLDRAWPIXELSPROC pglDrawPixels;
|
||||
extern PFNGLDRAWRANGEELEMENTSPROC pglDrawRangeElements;
|
||||
extern PFNGLENABLEPROC pglEnable;
|
||||
extern PFNGLENABLECLIENTSTATEPROC pglEnableClientState;
|
||||
extern PFNGLENDPROC pglEnd;
|
||||
extern PFNGLFRONTFACEPROC pglFrontFace;
|
||||
extern PFNGLFRUSTUMPROC pglFrustum;
|
||||
extern PFNGLGENTEXTURESPROC pglGenTextures;
|
||||
extern PFNGLGETERRORPROC pglGetError;
|
||||
extern PFNGLGETFLOATVPROC pglGetFloatv;
|
||||
extern PFNGLGETINTEGERVPROC pglGetIntegerv;
|
||||
extern PFNGLGETSTRINGPROC pglGetString;
|
||||
extern PFNGLHINTPROC pglHint;
|
||||
extern PFNGLLOADIDENTITYPROC pglLoadIdentity;
|
||||
extern PFNGLLOADMATRIXFPROC pglLoadMatrixf;
|
||||
extern PFNGLMATRIXMODEPROC pglMatrixMode;
|
||||
extern PFNGLMULTMATRIXFPROC pglMultMatrixf;
|
||||
extern PFNGLNORMALPOINTERPROC pglNormalPointer;
|
||||
extern PFNGLORTHOPROC pglOrtho;
|
||||
extern PFNGLPIXELSTOREIPROC pglPixelStorei;
|
||||
extern PFNGLPIXELZOOMPROC pglPixelZoom;
|
||||
extern PFNGLPOLYGONMODEPROC pglPolygonMode;
|
||||
extern PFNGLPOLYGONOFFSETPROC pglPolygonOffset;
|
||||
extern PFNGLPOPATTRIBPROC pglPopAttrib;
|
||||
extern PFNGLPOPCLIENTATTRIBPROC pglPopClientAttrib;
|
||||
extern PFNGLPOPMATRIXPROC pglPopMatrix;
|
||||
extern PFNGLPUSHATTRIBPROC pglPushAttrib;
|
||||
extern PFNGLPUSHCLIENTATTRIBPROC pglPushClientAttrib;
|
||||
extern PFNGLPUSHMATRIXPROC pglPushMatrix;
|
||||
extern PFNGLRASTERPOS2IPROC pglRasterPos2i;
|
||||
extern PFNGLREADBUFFERPROC pglReadBuffer;
|
||||
extern PFNGLREADPIXELSPROC pglReadPixels;
|
||||
extern PFNGLROTATEFPROC pglRotatef;
|
||||
extern PFNGLSCALEFPROC pglScalef;
|
||||
extern PFNGLSHADEMODELPROC pglShadeModel;
|
||||
extern PFNGLTEXCOORD2FPROC pglTexCoord2f;
|
||||
extern PFNGLTEXCOORD2FVPROC pglTexCoord2fv;
|
||||
extern PFNGLTEXCOORD3FPROC pglTexCoord3f;
|
||||
extern PFNGLTEXCOORD3FVPROC pglTexCoord3fv;
|
||||
extern PFNGLTEXCOORD4FPROC pglTexCoord4f;
|
||||
extern PFNGLTEXCOORD4FVPROC pglTexCoord4fv;
|
||||
extern PFNGLTEXCOORDPOINTERPROC pglTexCoordPointer;
|
||||
extern PFNGLTEXENVFPROC pglTexEnvf;
|
||||
extern PFNGLTEXENVFVPROC pglTexEnvfv;
|
||||
extern PFNGLTEXENVIPROC pglTexEnvi;
|
||||
extern PFNGLTEXIMAGE2DPROC pglTexImage2D;
|
||||
extern PFNGLTEXPARAMETERFPROC pglTexParameterf;
|
||||
extern PFNGLTEXPARAMETERIPROC pglTexParameteri;
|
||||
extern PFNGLTEXSUBIMAGE2DPROC pglTexSubImage2D;
|
||||
extern PFNGLTRANSLATEFPROC pglTranslatef;
|
||||
extern PFNGLVERTEX2FPROC pglVertex2f;
|
||||
extern PFNGLVERTEX2FVPROC pglVertex2fv;
|
||||
extern PFNGLVERTEX3FPROC pglVertex3f;
|
||||
extern PFNGLVERTEX3FVPROC pglVertex3fv;
|
||||
extern PFNGLVERTEX4FPROC pglVertex4f;
|
||||
extern PFNGLVERTEX4FVPROC pglVertex4fv;
|
||||
extern PFNGLVERTEXPOINTERPROC pglVertexPointer;
|
||||
extern PFNGLVIEWPORTPROC pglViewport;
|
||||
|
||||
// GL_EXT_paletted_texture
|
||||
extern PFNGLCOLORTABLEEXTPROC pglColorTableEXT;
|
||||
extern PFNGLGETCOLORTABLEPARAMETERIVEXTPROC pglGetColorTableParameterivEXT;
|
||||
|
||||
// GL_EXT_secondary_color
|
||||
extern PFNGLSECONDARYCOLOR3FEXTPROC pglSecondaryColor3fEXT;
|
||||
extern PFNGLSECONDARYCOLOR3FVEXTPROC pglSecondaryColor3fvEXT;
|
||||
extern PFNGLSECONDARYCOLOR3UBEXTPROC pglSecondaryColor3ubEXT;
|
||||
extern PFNGLSECONDARYCOLOR3UBVEXTPROC pglSecondaryColor3ubvEXT;
|
||||
extern PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT;
|
||||
|
||||
extern int ogl_have_paletted_texture;
|
||||
extern int ogl_have_secondary_color;
|
||||
|
||||
extern int ogl_use_paletted_texture;
|
||||
extern int ogl_use_secondary_color;
|
||||
|
||||
extern void load_ogl_functions(int mode);
|
||||
extern int check_for_errors(const char *file, int line);
|
||||
|
||||
#endif
|
449
src/opengl.c
449
src/opengl.c
|
@ -2,8 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glext.h>
|
||||
#include "oglfunc.h"
|
||||
|
||||
#include "fixer.h"
|
||||
|
||||
|
@ -55,11 +54,9 @@ static D3DTexture *CurrentlyBoundTexture = NULL;
|
|||
#define TA_MAXVERTICES 2048
|
||||
#define TA_MAXTRIANGLES 2048
|
||||
|
||||
#if 0 /* NVIDIA header problem */
|
||||
#if GL_EXT_secondary_color
|
||||
extern PFNGLSECONDARYCOLORPOINTEREXTPROC pglSecondaryColorPointerEXT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef struct VertexArray
|
||||
{
|
||||
|
@ -93,28 +90,28 @@ static void SetTranslucencyMode(enum TRANSLUCENCY_TYPE mode)
|
|||
switch(mode) {
|
||||
case TRANSLUCENCY_OFF:
|
||||
if (TRIPTASTIC_CHEATMODE||MOTIONBLUR_CHEATMODE) {
|
||||
glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
|
||||
pglBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA);
|
||||
} else {
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
pglBlendFunc(GL_ONE, GL_ZERO);
|
||||
}
|
||||
break;
|
||||
case TRANSLUCENCY_NORMAL:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
break;
|
||||
case TRANSLUCENCY_COLOUR:
|
||||
glBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
||||
pglBlendFunc(GL_ZERO, GL_SRC_COLOR);
|
||||
break;
|
||||
case TRANSLUCENCY_INVCOLOUR:
|
||||
glBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||
pglBlendFunc(GL_ZERO, GL_ONE_MINUS_SRC_COLOR);
|
||||
break;
|
||||
case TRANSLUCENCY_GLOWING:
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
pglBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
break;
|
||||
case TRANSLUCENCY_DARKENINGCOLOUR:
|
||||
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
||||
pglBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
||||
break;
|
||||
case TRANSLUCENCY_JUSTSETZ:
|
||||
glBlendFunc(GL_ZERO, GL_ONE);
|
||||
pglBlendFunc(GL_ZERO, GL_ONE);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "RenderPolygon.TranslucencyMode: invalid %d\n", RenderPolygon.TranslucencyMode);
|
||||
|
@ -133,31 +130,31 @@ A few things:
|
|||
void InitOpenGL()
|
||||
{
|
||||
CurrentTranslucencyMode = TRANSLUCENCY_OFF;
|
||||
glBlendFunc(GL_ONE, GL_ZERO);
|
||||
pglBlendFunc(GL_ONE, GL_ZERO);
|
||||
|
||||
CurrentFilteringMode = FILTERING_BILINEAR_OFF;
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
CurrentlyBoundTexture = NULL;
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
pglBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(4, GL_FLOAT, sizeof(varr[0]), varr[0].v);
|
||||
pglEnableClientState(GL_VERTEX_ARRAY);
|
||||
pglVertexPointer(4, GL_FLOAT, sizeof(varr[0]), varr[0].v);
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glTexCoordPointer(2, GL_FLOAT, sizeof(varr[0]), varr[0].t);
|
||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
pglTexCoordPointer(2, GL_FLOAT, sizeof(varr[0]), varr[0].t);
|
||||
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(varr[0]), varr[0].c);
|
||||
pglEnableClientState(GL_COLOR_ARRAY);
|
||||
pglColorPointer(4, GL_UNSIGNED_BYTE, sizeof(varr[0]), varr[0].c);
|
||||
|
||||
#if 0
|
||||
#if GL_EXT_secondary_color
|
||||
if (useseparate) {
|
||||
glEnableClientState(GL_SEPARATE_COLOR_ARRAY_EXT);
|
||||
pglEnableClientState(GL_SEPARATE_COLOR_ARRAY_EXT);
|
||||
pglSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(svarr[0]), svarr[0].c);
|
||||
} else {
|
||||
glDisableClientState(GL_SEPARATE_COLOR_ARRAY_EXT);
|
||||
pglDisableClientState(GL_SEPARATE_COLOR_ARRAY_EXT);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -181,15 +178,15 @@ static void FlushTriangleBuffers(int backup)
|
|||
|
||||
if (tarrc) {
|
||||
#if 1
|
||||
glBegin(GL_TRIANGLES);
|
||||
pglBegin(GL_TRIANGLES);
|
||||
for (i = 0; i < tarrc; i++) {
|
||||
glArrayElement(tarr[i].a);
|
||||
glArrayElement(tarr[i].b);
|
||||
glArrayElement(tarr[i].c);
|
||||
pglArrayElement(tarr[i].a);
|
||||
pglArrayElement(tarr[i].b);
|
||||
pglArrayElement(tarr[i].c);
|
||||
}
|
||||
glEnd();
|
||||
pglEnd();
|
||||
#else
|
||||
glDrawElements(GL_TRIANGLES, tarrc*3, GL_UNSIGNED_INT, tarr);
|
||||
pglDrawElements(GL_TRIANGLES, tarrc*3, GL_UNSIGNED_INT, tarr);
|
||||
#endif
|
||||
|
||||
tarrc = 0;
|
||||
|
@ -202,36 +199,36 @@ static void FlushTriangleBuffers(int backup)
|
|||
if (starrc) {
|
||||
if (CurrentlyBoundTexture != NULL) {
|
||||
if (!backup) CurrentlyBoundTexture = NULL;
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
pglBindTexture(GL_TEXTURE_2D, 0);
|
||||
}
|
||||
|
||||
if (CurrentTranslucencyMode != TRANSLUCENCY_GLOWING) {
|
||||
if (!backup) CurrentTranslucencyMode = TRANSLUCENCY_GLOWING;
|
||||
SetTranslucencyMode(TRANSLUCENCY_GLOWING);
|
||||
//if (CurrentTranslucencyMode == TRANSLUCENCY_OFF)
|
||||
// glEnable(GL_BLEND);
|
||||
// pglEnable(GL_BLEND);
|
||||
//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||
}
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
pglDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
#if 1
|
||||
glBegin(GL_TRIANGLES);
|
||||
pglBegin(GL_TRIANGLES);
|
||||
for (i = 0; i < starrc; i++) {
|
||||
glArrayElement(starr[i].a);
|
||||
glArrayElement(starr[i].b);
|
||||
glArrayElement(starr[i].c);
|
||||
pglArrayElement(starr[i].a);
|
||||
pglArrayElement(starr[i].b);
|
||||
pglArrayElement(starr[i].c);
|
||||
}
|
||||
glEnd();
|
||||
pglEnd();
|
||||
#else
|
||||
glDrawElements(GL_TRIANGLES, starrc*3, GL_UNSIGNED_INT, starr);
|
||||
pglDrawElements(GL_TRIANGLES, starrc*3, GL_UNSIGNED_INT, starr);
|
||||
#endif
|
||||
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
pglEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
if (backup) {
|
||||
if (CurrentlyBoundTexture)
|
||||
glBindTexture(GL_TEXTURE_2D, CurrentlyBoundTexture->id);
|
||||
pglBindTexture(GL_TEXTURE_2D, CurrentlyBoundTexture->id);
|
||||
if (CurrentTranslucencyMode != TRANSLUCENCY_GLOWING)
|
||||
SetTranslucencyMode(CurrentTranslucencyMode);
|
||||
} else {
|
||||
|
@ -256,24 +253,24 @@ static void CheckBoundTextureIsCorrect(D3DTexture *tex)
|
|||
FlushTriangleBuffers(1);
|
||||
|
||||
if (tex == NULL) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
pglBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
CurrentlyBoundTexture = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex->id);
|
||||
pglBindTexture(GL_TEXTURE_2D, tex->id);
|
||||
|
||||
if (tex->filter != CurrentFilteringMode) {
|
||||
switch(CurrentFilteringMode) {
|
||||
case FILTERING_BILINEAR_OFF:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case FILTERING_BILINEAR_ON:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -294,12 +291,12 @@ static void CheckFilteringModeIsCorrect(enum FILTERING_MODE_ID filter)
|
|||
|
||||
switch(CurrentFilteringMode) {
|
||||
case FILTERING_BILINEAR_OFF:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
break;
|
||||
case FILTERING_BILINEAR_ON:
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -430,14 +427,14 @@ static void SelectPolygonBeginType(int points)
|
|||
|
||||
switch(points) {
|
||||
case 3:
|
||||
glBegin(GL_TRIANGLES);
|
||||
pglBegin(GL_TRIANGLES);
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
glBegin(GL_TRIANGLE_FAN);
|
||||
pglBegin(GL_TRIANGLE_FAN);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "SelectPolygonBeginType: points = %d\n", points);
|
||||
|
@ -451,24 +448,24 @@ GLuint CreateOGLTexture(D3DTexture *tex, unsigned char *buf)
|
|||
|
||||
FlushTriangleBuffers(1);
|
||||
|
||||
glGenTextures(1, &h);
|
||||
pglGenTextures(1, &h);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, h);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
pglBindTexture(GL_TEXTURE_2D, h);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
pglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex->w, tex->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
|
||||
|
||||
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
tex->id = h;
|
||||
tex->filter = FILTERING_BILINEAR_ON;
|
||||
|
||||
if (CurrentlyBoundTexture)
|
||||
glBindTexture(GL_TEXTURE_2D, CurrentlyBoundTexture->id); /* restore current */
|
||||
pglBindTexture(GL_TEXTURE_2D, CurrentlyBoundTexture->id); /* restore current */
|
||||
|
||||
return h;
|
||||
}
|
||||
|
@ -477,7 +474,7 @@ void ReleaseD3DTexture(void *tex)
|
|||
{
|
||||
D3DTexture *TextureHandle = (D3DTexture *)tex;
|
||||
|
||||
glDeleteTextures(1, &(TextureHandle->id));
|
||||
pglDeleteTextures(1, &(TextureHandle->id));
|
||||
|
||||
free(TextureHandle);
|
||||
}
|
||||
|
@ -500,34 +497,34 @@ void ThisFramesRenderingHasFinished()
|
|||
|
||||
void FlushD3DZBuffer()
|
||||
{
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
pglClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void SecondFlushD3DZBuffer()
|
||||
{
|
||||
FlushTriangleBuffers(0);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
pglClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void D3D_DecalSystem_Setup()
|
||||
{
|
||||
FlushTriangleBuffers(0);
|
||||
|
||||
glDepthMask(GL_FALSE);
|
||||
pglDepthMask(GL_FALSE);
|
||||
|
||||
/* this does stop zfighting with bulletmarks on walls... */
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(-8.0, -8.0);
|
||||
pglEnable(GL_POLYGON_OFFSET_FILL);
|
||||
pglPolygonOffset(-8.0, -8.0);
|
||||
}
|
||||
|
||||
void D3D_DecalSystem_End()
|
||||
{
|
||||
FlushTriangleBuffers(0);
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
pglDepthMask(GL_TRUE);
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
pglDisable(GL_POLYGON_OFFSET_FILL);
|
||||
}
|
||||
|
||||
/* ** */
|
||||
|
@ -542,7 +539,7 @@ void D3D_Rectangle(int x0, int y0, int x1, int y1, int r, int g, int b, int a)
|
|||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING);
|
||||
CheckBoundTextureIsCorrect(NULL);
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
x[0] = x0;
|
||||
x[0] = (x[0] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX;
|
||||
|
@ -566,15 +563,15 @@ void D3D_Rectangle(int x0, int y0, int x1, int y1, int r, int g, int b, int a)
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
/* ** */
|
||||
|
@ -1097,7 +1094,7 @@ void D3D_PlayerOnFireOverlay()
|
|||
CheckBoundTextureIsCorrect(TextureHandle);
|
||||
CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON);
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
u = (FastRandom()&255)/256.0f;
|
||||
v = (FastRandom()&255)/256.0f;
|
||||
|
@ -1121,21 +1118,21 @@ void D3D_PlayerOnFireOverlay()
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glTexCoord2f(s[0], t[0]);
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglTexCoord2f(s[0], t[0]);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glTexCoord2f(s[2], t[2]);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglTexCoord2f(s[2], t[2]);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
void D3D_PlayerDamagedOverlay(int intensity)
|
||||
|
@ -1174,7 +1171,7 @@ void D3D_PlayerDamagedOverlay(int intensity)
|
|||
r = (colour >> 16) & 0xFF;
|
||||
a = (colour >> 24) & 0xFF;
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_INVCOLOUR);
|
||||
for (i = 0; i < 2; i++) {
|
||||
|
@ -1202,21 +1199,21 @@ void D3D_PlayerDamagedOverlay(int intensity)
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glTexCoord2f(s[0], t[0]);
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglTexCoord2f(s[0], t[0]);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glTexCoord2f(s[2], t[2]);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglTexCoord2f(s[2], t[2]);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
|
||||
colour = baseColour + (intensity<<24);
|
||||
|
||||
|
@ -1225,7 +1222,7 @@ void D3D_PlayerDamagedOverlay(int intensity)
|
|||
r = (colour >> 16) & 0xFF;
|
||||
a = (colour >> 24) & 0xFF;
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING);
|
||||
}
|
||||
|
@ -1249,7 +1246,7 @@ void DrawNoiseOverlay(int tr)
|
|||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING);
|
||||
CheckBoundTextureIsCorrect(tex);
|
||||
CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
pglDepthFunc(GL_ALWAYS);
|
||||
|
||||
u = FastRandom()&255;
|
||||
v = FastRandom()&255;
|
||||
|
@ -1272,25 +1269,25 @@ void DrawNoiseOverlay(int tr)
|
|||
t[3] = (v + size) / 256.0f;
|
||||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
glColor4ub(r, g, b, tr);
|
||||
pglColor4ub(r, g, b, tr);
|
||||
|
||||
glTexCoord2f(s[0], t[0]);
|
||||
glVertex3f(x[0], y[0], 1.0f);
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], 1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], 1.0f);
|
||||
pglTexCoord2f(s[0], t[0]);
|
||||
pglVertex3f(x[0], y[0], 1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], 1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], 1.0f);
|
||||
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], 1.0f);
|
||||
glTexCoord2f(s[2], t[2]);
|
||||
glVertex3f(x[2], y[2], 1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], 1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], 1.0f);
|
||||
pglTexCoord2f(s[2], t[2]);
|
||||
pglVertex3f(x[2], y[2], 1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], 1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
pglDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
|
||||
void D3D_ScreenInversionOverlay()
|
||||
|
@ -1308,7 +1305,7 @@ void D3D_ScreenInversionOverlay()
|
|||
CheckBoundTextureIsCorrect(tex);
|
||||
CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON);
|
||||
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
GLfloat x[4], y[4], s[4], t[4];
|
||||
|
@ -1335,21 +1332,21 @@ void D3D_ScreenInversionOverlay()
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glTexCoord2f(s[0], t[0]);
|
||||
glVertex3f(x[0], y[0], 1.0f);
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], 1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], 1.0f);
|
||||
pglTexCoord2f(s[0], t[0]);
|
||||
pglVertex3f(x[0], y[0], 1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], 1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], 1.0f);
|
||||
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], 1.0f);
|
||||
glTexCoord2f(s[2], t[2]);
|
||||
glVertex3f(x[2], y[2], 1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], 1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], 1.0f);
|
||||
pglTexCoord2f(s[2], t[2]);
|
||||
pglVertex3f(x[2], y[2], 1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], 1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
|
||||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_COLOUR);
|
||||
}
|
||||
|
@ -1359,22 +1356,22 @@ void D3D_PredatorScreenInversionOverlay()
|
|||
{
|
||||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_DARKENINGCOLOUR);
|
||||
CheckBoundTextureIsCorrect(NULL);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
pglDepthFunc(GL_ALWAYS);
|
||||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
pglColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
|
||||
glVertex3f(-1.0f, -1.0f, 1.0f);
|
||||
glVertex3f( 1.0f, -1.0f, 1.0f);
|
||||
glVertex3f(-1.0f, 1.0f, 1.0f);
|
||||
pglVertex3f(-1.0f, -1.0f, 1.0f);
|
||||
pglVertex3f( 1.0f, -1.0f, 1.0f);
|
||||
pglVertex3f(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
glVertex3f( 1.0f, -1.0f, 1.0f);
|
||||
glVertex3f( 1.0f, 1.0f, 1.0f);
|
||||
glVertex3f(-1.0f, 1.0f, 1.0f);
|
||||
pglVertex3f( 1.0f, -1.0f, 1.0f);
|
||||
pglVertex3f( 1.0f, 1.0f, 1.0f);
|
||||
pglVertex3f(-1.0f, 1.0f, 1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
pglDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
|
||||
void DrawScanlinesOverlay(float level)
|
||||
|
@ -1390,7 +1387,7 @@ void DrawScanlinesOverlay(float level)
|
|||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
|
||||
CheckBoundTextureIsCorrect(tex);
|
||||
CheckFilteringModeIsCorrect(FILTERING_BILINEAR_ON);
|
||||
glDepthFunc(GL_ALWAYS);
|
||||
pglDepthFunc(GL_ALWAYS);
|
||||
|
||||
c = 255;
|
||||
a = 64.0f+level*64.0f;
|
||||
|
@ -1398,7 +1395,7 @@ void DrawScanlinesOverlay(float level)
|
|||
v = 128.0f;
|
||||
size = 128.0f*(1.0f-level*0.8f);
|
||||
|
||||
glColor4ub(c, c, c, a);
|
||||
pglColor4ub(c, c, c, a);
|
||||
|
||||
x[0] = -1.0f;
|
||||
y[0] = -1.0f;
|
||||
|
@ -1419,22 +1416,22 @@ void DrawScanlinesOverlay(float level)
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glTexCoord2f(s[0], t[0]);
|
||||
glVertex3f(x[0], y[0], 1.0f);
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], 1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], 1.0f);
|
||||
pglTexCoord2f(s[0], t[0]);
|
||||
pglVertex3f(x[0], y[0], 1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], 1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], 1.0f);
|
||||
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], 1.0f);
|
||||
glTexCoord2f(s[2], t[2]);
|
||||
glVertex3f(x[2], y[2], 1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], 1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], 1.0f);
|
||||
pglTexCoord2f(s[2], t[2]);
|
||||
pglVertex3f(x[2], y[2], 1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], 1.0f);
|
||||
|
||||
glEnd();
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
pglEnd();
|
||||
pglDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
|
||||
void D3D_FadeDownScreen(int brightness, int colour)
|
||||
|
@ -1454,7 +1451,7 @@ void D3D_FadeDownScreen(int brightness, int colour)
|
|||
r = (colour >> 16) & 0xFF;
|
||||
a = (colour >> 24) & 0xFF;
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
x[0] = -1.0f;
|
||||
y[0] = -1.0f;
|
||||
|
@ -1467,15 +1464,15 @@ void D3D_FadeDownScreen(int brightness, int colour)
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
void D3D_HUD_Setup()
|
||||
|
@ -1484,7 +1481,7 @@ void D3D_HUD_Setup()
|
|||
|
||||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING);
|
||||
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
pglDepthFunc(GL_LEQUAL);
|
||||
}
|
||||
|
||||
void D3D_HUDQuad_Output(int imageNumber, struct VertexTag *quadVerticesPtr, unsigned int colour)
|
||||
|
@ -1519,7 +1516,7 @@ void D3D_HUDQuad_Output(int imageNumber, struct VertexTag *quadVerticesPtr, unsi
|
|||
r = (colour >> 16) & 0xFF;
|
||||
a = (colour >> 24) & 0xFF;
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
x[i] = quadVerticesPtr[i].X;
|
||||
|
@ -1533,21 +1530,21 @@ void D3D_HUDQuad_Output(int imageNumber, struct VertexTag *quadVerticesPtr, unsi
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glTexCoord2f(s[0], t[0]);
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglTexCoord2f(s[0], t[0]);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glTexCoord2f(s[1], t[1]);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glTexCoord2f(s[2], t[2]);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glTexCoord2f(s[3], t[3]);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglTexCoord2f(s[1], t[1]);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglTexCoord2f(s[2], t[2]);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglTexCoord2f(s[3], t[3]);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
void D3D_RenderHUDNumber_Centred(unsigned int number,int x,int y,int colour)
|
||||
|
@ -2339,7 +2336,7 @@ void D3D_DrawColourBar(int yTop, int yBottom, int rScale, int gScale, int bScale
|
|||
unsigned int c;
|
||||
|
||||
c = GammaValues[i];
|
||||
glColor4ub(MUL_FIXED(c,rScale), MUL_FIXED(c,gScale), MUL_FIXED(c,bScale), 0);
|
||||
pglColor4ub(MUL_FIXED(c,rScale), MUL_FIXED(c,gScale), MUL_FIXED(c,bScale), 0);
|
||||
|
||||
x[0] = (Global_VDB_Ptr->VDB_ClipRight*i)/255;
|
||||
x[0] = (x[0] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX;
|
||||
|
@ -2353,7 +2350,7 @@ void D3D_DrawColourBar(int yTop, int yBottom, int rScale, int gScale, int bScale
|
|||
|
||||
i++;
|
||||
c = GammaValues[i];
|
||||
glColor4ub(MUL_FIXED(c,rScale), MUL_FIXED(c,gScale), MUL_FIXED(c,bScale), 0);
|
||||
pglColor4ub(MUL_FIXED(c,rScale), MUL_FIXED(c,gScale), MUL_FIXED(c,bScale), 0);
|
||||
x[2] = (Global_VDB_Ptr->VDB_ClipRight*i)/255;
|
||||
x[2] = (x[2] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX;
|
||||
y[2] = yBottom;
|
||||
|
@ -2365,16 +2362,16 @@ void D3D_DrawColourBar(int yTop, int yBottom, int rScale, int gScale, int bScale
|
|||
y[3] = -(y[3] - ScreenDescriptorBlock.SDB_CentreY)/ScreenDescriptorBlock.SDB_CentreY;
|
||||
|
||||
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
}
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
void ColourFillBackBuffer(int FillColour)
|
||||
|
@ -2386,9 +2383,9 @@ void ColourFillBackBuffer(int FillColour)
|
|||
r = ((FillColour >> 16) & 0xFF) / 255.0f;
|
||||
a = ((FillColour >> 24) & 0xFF) / 255.0f;
|
||||
|
||||
glClearColor(r, g, b, a);
|
||||
pglClearColor(r, g, b, a);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
pglClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
void ColourFillBackBufferQuad(int FillColour, int x0, int y0, int x1, int y1)
|
||||
|
@ -2407,7 +2404,7 @@ void ColourFillBackBufferQuad(int FillColour, int x0, int y0, int x1, int y1)
|
|||
r = ((FillColour >> 16) & 0xFF);
|
||||
a = ((FillColour >> 24) & 0xFF);
|
||||
|
||||
glColor4ub(r, g, b, a);
|
||||
pglColor4ub(r, g, b, a);
|
||||
|
||||
x[0] = x0;
|
||||
x[0] = (x[0] - ScreenDescriptorBlock.SDB_CentreX)/ScreenDescriptorBlock.SDB_CentreX;
|
||||
|
@ -2431,15 +2428,15 @@ void ColourFillBackBufferQuad(int FillColour, int x0, int y0, int x1, int y1)
|
|||
|
||||
SelectPolygonBeginType(3); /* triangles */
|
||||
|
||||
glVertex3f(x[0], y[0], -1.0f);
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[0], y[0], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glVertex3f(x[1], y[1], -1.0f);
|
||||
glVertex3f(x[2], y[2], -1.0f);
|
||||
glVertex3f(x[3], y[3], -1.0f);
|
||||
pglVertex3f(x[1], y[1], -1.0f);
|
||||
pglVertex3f(x[2], y[2], -1.0f);
|
||||
pglVertex3f(x[3], y[3], -1.0f);
|
||||
|
||||
glEnd();
|
||||
pglEnd();
|
||||
}
|
||||
|
||||
void D3D_DrawBackdrop()
|
||||
|
@ -2509,30 +2506,30 @@ void BltImage(RECT *dest, DDSurface *image, RECT *src)
|
|||
height = dest->bottom - dest->top + 1;
|
||||
height1 = src->bottom - src->top + 1;
|
||||
|
||||
glPushAttrib(GL_COLOR_BUFFER_BIT | GL_PIXEL_MODE_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT);
|
||||
glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
||||
pglPushAttrib(GL_COLOR_BUFFER_BIT | GL_PIXEL_MODE_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT);
|
||||
pglPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
pglDisable(GL_BLEND);
|
||||
pglDisable(GL_DEPTH_TEST);
|
||||
pglDisable(GL_TEXTURE_2D);
|
||||
|
||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, image->w);
|
||||
glPixelZoom((double)width/(double)width1, (double)height/(double)height1);
|
||||
pglPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
pglPixelStorei(GL_UNPACK_ROW_LENGTH, image->w);
|
||||
pglPixelZoom((double)width/(double)width1, (double)height/(double)height1);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
pglMatrixMode(GL_PROJECTION);
|
||||
pglPushMatrix();
|
||||
pglLoadIdentity();
|
||||
|
||||
glOrtho(0.0, ScreenDescriptorBlock.SDB_Width, 0.0, ScreenDescriptorBlock.SDB_Height, -1.0, 1.0);
|
||||
glRasterPos2i(dest->left, ScreenDescriptorBlock.SDB_Height-dest->bottom);
|
||||
pglOrtho(0.0, ScreenDescriptorBlock.SDB_Width, 0.0, ScreenDescriptorBlock.SDB_Height, -1.0, 1.0);
|
||||
pglRasterPos2i(dest->left, ScreenDescriptorBlock.SDB_Height-dest->bottom);
|
||||
|
||||
glDrawPixels(width1, height1, GL_RGBA, GL_UNSIGNED_BYTE, image->buf);
|
||||
pglDrawPixels(width1, height1, GL_RGBA, GL_UNSIGNED_BYTE, image->buf);
|
||||
|
||||
glPopMatrix();
|
||||
pglPopMatrix();
|
||||
|
||||
glPopClientAttrib();
|
||||
glPopAttrib();;
|
||||
pglPopClientAttrib();
|
||||
pglPopAttrib();;
|
||||
}
|
||||
|
||||
/* ** */
|
||||
|
@ -2696,7 +2693,7 @@ void PostLandscapeRendering()
|
|||
// CheckTranslucencyModeIsCorrect(TRANSLUCENCY_NORMAL);
|
||||
|
||||
FlushTriangleBuffers(1);
|
||||
glDepthMask(GL_FALSE);
|
||||
pglDepthMask(GL_FALSE);
|
||||
|
||||
WaterFallBase = 109952;
|
||||
|
||||
|
@ -2709,7 +2706,7 @@ void PostLandscapeRendering()
|
|||
// D3D_DrawWaterPatch(-100000, WaterFallBase, 538490);
|
||||
|
||||
FlushTriangleBuffers(1);
|
||||
glDepthMask(GL_TRUE);
|
||||
pglDepthMask(GL_TRUE);
|
||||
}
|
||||
if (drawStream)
|
||||
{
|
||||
|
@ -4881,7 +4878,7 @@ void D3D_DrawCable(VECTORCH *centrePtr, MATRIXCH *orientationPtr)
|
|||
CurrTextureHandle = NULL;
|
||||
CheckBoundTextureIsCorrect(NULL);
|
||||
CheckTranslucencyModeIsCorrect(TRANSLUCENCY_GLOWING);
|
||||
glDepthMask(GL_FALSE);
|
||||
pglDepthMask(GL_FALSE);
|
||||
|
||||
MeshXScale = 4096/16;
|
||||
MeshZScale = 4096/16;
|
||||
|
@ -4967,5 +4964,5 @@ void D3D_DrawCable(VECTORCH *centrePtr, MATRIXCH *orientationPtr)
|
|||
}
|
||||
}
|
||||
|
||||
glDepthMask(GL_TRUE);
|
||||
pglDepthMask(GL_TRUE);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue