mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 02:30:46 +00:00
Dynamically loaded GLU
git-svn-id: https://svn.eduke32.com/eduke32@462 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
43657d4f56
commit
a94063e0be
8 changed files with 155 additions and 29 deletions
|
@ -62,13 +62,6 @@ ifeq ($(PLATFORM),WINDOWS)
|
|||
RENDERTYPE ?= WIN
|
||||
EXESUFFIX=.exe
|
||||
LIBS+= -lmingwex -lwinmm -L$(DXROOT)/lib -lwsock32 -lcomctl32 #-lshfolder
|
||||
ifneq (0,$(USE_OPENGL))
|
||||
LIBS+= -lglu32
|
||||
endif
|
||||
else
|
||||
ifneq (0,$(USE_OPENGL))
|
||||
LIBS+= -lGLU
|
||||
endif
|
||||
endif
|
||||
ifeq ($(PLATFORM),BSD)
|
||||
RENDERTYPE=SDL
|
||||
|
|
|
@ -155,6 +155,19 @@ extern void (APIENTRY * bglBindFramebufferEXT)(GLenum target, GLuint framebuffer
|
|||
extern void (APIENTRY * bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
extern GLenum (APIENTRY * bglCheckFramebufferStatusEXT)(GLenum target);
|
||||
extern void (APIENTRY * bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers);
|
||||
|
||||
// GLU
|
||||
extern void (APIENTRY * bgluTessBeginContour) (GLUtesselator* tess);
|
||||
extern void (APIENTRY * bgluTessBeginPolygon) (GLUtesselator* tess, GLvoid* data);
|
||||
extern void (APIENTRY * bgluTessCallback) (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
extern void (APIENTRY * bgluTessEndContour) (GLUtesselator* tess);
|
||||
extern void (APIENTRY * bgluTessEndPolygon) (GLUtesselator* tess);
|
||||
extern void (APIENTRY * bgluTessNormal) (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
|
||||
extern void (APIENTRY * bgluTessProperty) (GLUtesselator* tess, GLenum which, GLdouble data);
|
||||
extern void (APIENTRY * bgluTessVertex) (GLUtesselator* tess, GLdouble *location, GLvoid* data);
|
||||
extern GLUtesselator* (APIENTRY * bgluNewTess) (void);
|
||||
extern void (APIENTRY * bgluPerspective) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
|
||||
extern const GLubyte * (APIENTRY * bgluErrorString) (GLenum error);
|
||||
|
||||
#ifdef RENDERTYPEWIN
|
||||
// Windows
|
||||
|
@ -177,4 +190,5 @@ extern char *gldriver;
|
|||
int loadgldriver(const char *driver);
|
||||
int loadglextensions(void);
|
||||
int unloadgldriver(void);
|
||||
|
||||
int loadglulibrary(const char *driver);
|
||||
int unloadglulibrary(void);
|
||||
|
|
|
@ -133,6 +133,19 @@ void (APIENTRY * bglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, G
|
|||
GLenum (APIENTRY * bglCheckFramebufferStatusEXT)(GLenum target);
|
||||
void (APIENTRY * bglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers);
|
||||
|
||||
// GLU
|
||||
void (APIENTRY * bgluTessBeginContour) (GLUtesselator* tess);
|
||||
void (APIENTRY * bgluTessBeginPolygon) (GLUtesselator* tess, GLvoid* data);
|
||||
void (APIENTRY * bgluTessCallback) (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
|
||||
void (APIENTRY * bgluTessEndContour) (GLUtesselator* tess);
|
||||
void (APIENTRY * bgluTessEndPolygon) (GLUtesselator* tess);
|
||||
void (APIENTRY * bgluTessNormal) (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
|
||||
void (APIENTRY * bgluTessProperty) (GLUtesselator* tess, GLenum which, GLdouble data);
|
||||
void (APIENTRY * bgluTessVertex) (GLUtesselator* tess, GLdouble *location, GLvoid* data);
|
||||
GLUtesselator* (APIENTRY * bgluNewTess) (void);
|
||||
void (APIENTRY * bgluPerspective) (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
|
||||
const GLubyte * (APIENTRY * bgluErrorString) (GLenum error);
|
||||
|
||||
#ifdef RENDERTYPEWIN
|
||||
// Windows
|
||||
HGLRC (WINAPI * bwglCreateContext)(HDC);
|
||||
|
@ -146,11 +159,14 @@ int (WINAPI * bwglDescribePixelFormat)(HDC,int,UINT,LPPIXELFORMATDESCRIPTOR);
|
|||
int (WINAPI * bwglGetPixelFormat)(HDC);
|
||||
BOOL (WINAPI * bwglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*);
|
||||
|
||||
static HANDLE hGLDLL;
|
||||
static HANDLE hGLDLL, hGLUDLL;
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void *gluhandle = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
char *gldriver = NULL;
|
||||
char *gldriver = NULL, *glulibrary = NULL;
|
||||
|
||||
static void * getproc_(const char *s, int *err, int fatal, int extension)
|
||||
{
|
||||
|
@ -496,5 +512,99 @@ int unloadgldriver(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void * glugetproc_(const char *s, int *err, int fatal)
|
||||
{
|
||||
void *t;
|
||||
#if defined _WIN32
|
||||
t = (void*)GetProcAddress(hGLUDLL,s);
|
||||
#else
|
||||
t = (void*)dlsym(gluhandle,s);
|
||||
#endif
|
||||
if (!t && fatal) {
|
||||
initprintf("Failed to find %s in %s\n", s, glulibrary);
|
||||
*err = 1;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
#define GLUGETPROC(s) glugetproc_(s,&err,1)
|
||||
#define GLUGETPROCSOFT(s) glugetproc_(s,&err,0)
|
||||
|
||||
int loadglulibrary(const char *driver)
|
||||
{
|
||||
void *t;
|
||||
int err=0;
|
||||
|
||||
#ifdef RENDERTYPEWIN
|
||||
if (hGLUDLL) return 0;
|
||||
#endif
|
||||
|
||||
if (!driver) {
|
||||
#ifdef _WIN32
|
||||
driver = "GLU32.DLL";
|
||||
#elif defined __APPLE__
|
||||
driver = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; // FIXME: like I know anything about Apple. Hah.
|
||||
#else
|
||||
driver = "libGLU.so";
|
||||
#endif
|
||||
}
|
||||
|
||||
initprintf("Loading %s\n",driver);
|
||||
|
||||
#if defined _WIN32
|
||||
hGLUDLL = LoadLibrary(driver);
|
||||
if (!hGLUDLL) return -1;
|
||||
#else
|
||||
gluhandle = dlopen(driver, RTLD_NOW|RTLD_GLOBAL);
|
||||
if (!gluhandle) return 0;
|
||||
#endif
|
||||
glulibrary = strdup(driver);
|
||||
|
||||
bgluTessBeginContour = GLUGETPROC("gluTessBeginContour");
|
||||
bgluTessBeginPolygon = GLUGETPROC("gluTessBeginPolygon");
|
||||
bgluTessCallback = GLUGETPROC("gluTessCallback");
|
||||
bgluTessEndContour = GLUGETPROC("gluTessEndContour");
|
||||
bgluTessEndPolygon = GLUGETPROC("gluTessEndPolygon");
|
||||
bgluTessNormal = GLUGETPROC("gluTessNormal");
|
||||
bgluTessProperty = GLUGETPROC("gluTessProperty");
|
||||
bgluTessVertex = GLUGETPROC("gluTessVertex");
|
||||
bgluNewTess = GLUGETPROC("gluNewTess");
|
||||
bgluPerspective = GLUGETPROC("gluPerspective");
|
||||
bgluErrorString = GLUGETPROC("gluErrorString");
|
||||
|
||||
if (err) unloadglulibrary();
|
||||
return err;
|
||||
}
|
||||
|
||||
int unloadglulibrary(void)
|
||||
{
|
||||
#ifdef RENDERTYPEWIN
|
||||
if (!hGLUDLL) return 0;
|
||||
#endif
|
||||
|
||||
free(glulibrary);
|
||||
glulibrary = NULL;
|
||||
|
||||
#ifdef RENDERTYPEWIN
|
||||
FreeLibrary(hGLUDLL);
|
||||
hGLUDLL = NULL;
|
||||
#else
|
||||
if (gluhandle) dlclose(gluhandle);
|
||||
gluhandle = NULL;
|
||||
#endif
|
||||
|
||||
bgluTessBeginContour = NULL;
|
||||
bgluTessBeginPolygon = NULL;
|
||||
bgluTessCallback = NULL;
|
||||
bgluTessEndContour = NULL;
|
||||
bgluTessEndPolygon = NULL;
|
||||
bgluTessNormal = NULL;
|
||||
bgluTessProperty = NULL;
|
||||
bgluTessVertex = NULL;
|
||||
bgluNewTess = NULL;
|
||||
bgluPerspective = NULL;
|
||||
bgluErrorString = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ int polymer_init(void)
|
|||
cliplanes = NULL;
|
||||
cliplanecount = maxcliplanecount = 0;
|
||||
|
||||
prtess = gluNewTess();
|
||||
prtess = bgluNewTess();
|
||||
if (prtess == 0)
|
||||
{
|
||||
if (pr_verbosity >= 1) OSD_Printf("PR : Tesselator initialization failed.\n");
|
||||
|
@ -92,7 +92,7 @@ void polymer_glinit(void)
|
|||
|
||||
bglMatrixMode(GL_PROJECTION);
|
||||
bglLoadIdentity();
|
||||
gluPerspective((float)(pr_fov) / (2048.0f / 360.0f), (float)xdim / (float)ydim, 0.001f, 1000000.0f);
|
||||
bgluPerspective((float)(pr_fov) / (2048.0f / 360.0f), (float)xdim / (float)ydim, 0.001f, 1000000.0f);
|
||||
|
||||
bglMatrixMode(GL_MODELVIEW);
|
||||
bglLoadIdentity();
|
||||
|
@ -508,7 +508,7 @@ void PR_CALLBACK polymer_tesscombine(GLdouble v[3], GLdouble *data[4], GLfloa
|
|||
|
||||
void PR_CALLBACK polymer_tesserror(GLenum error)
|
||||
{ // This callback is called by the tesselator whenever it raises an error.
|
||||
if (pr_verbosity >= 1) OSD_Printf("PR : Tesselation error number %i reported : %s.\n", error, gluErrorString(errno));
|
||||
if (pr_verbosity >= 1) OSD_Printf("PR : Tesselation error number %i reported : %s.\n", error, bgluErrorString(errno));
|
||||
}
|
||||
|
||||
|
||||
|
@ -556,29 +556,29 @@ int polymer_buildfloor(short sectnum)
|
|||
|
||||
s->curindice = 0;
|
||||
|
||||
gluTessCallback(prtess, GLU_TESS_VERTEX_DATA, polymer_tessvertex);
|
||||
gluTessCallback(prtess, GLU_TESS_EDGE_FLAG, polymer_tessedgeflag);
|
||||
//gluTessCallback(prtess, GLU_TESS_COMBINE, polymer_tesscombine);
|
||||
gluTessCallback(prtess, GLU_TESS_ERROR, polymer_tesserror);
|
||||
bgluTessCallback(prtess, GLU_TESS_VERTEX_DATA, polymer_tessvertex);
|
||||
bgluTessCallback(prtess, GLU_TESS_EDGE_FLAG, polymer_tessedgeflag);
|
||||
//bgluTessCallback(prtess, GLU_TESS_COMBINE, polymer_tesscombine);
|
||||
bgluTessCallback(prtess, GLU_TESS_ERROR, polymer_tesserror);
|
||||
|
||||
gluTessProperty(prtess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);
|
||||
bgluTessProperty(prtess, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_POSITIVE);
|
||||
|
||||
gluTessBeginPolygon(prtess, s);
|
||||
gluTessBeginContour(prtess);
|
||||
bgluTessBeginPolygon(prtess, s);
|
||||
bgluTessBeginContour(prtess);
|
||||
|
||||
i = 0;
|
||||
while (i < sec->wallnum)
|
||||
{
|
||||
gluTessVertex(prtess, s->verts + (3 * i), (void *)i);
|
||||
bgluTessVertex(prtess, s->verts + (3 * i), (void *)i);
|
||||
if ((i != (sec->wallnum - 1)) && ((sec->wallptr + i) > wall[sec->wallptr + i].point2))
|
||||
{
|
||||
gluTessEndContour(prtess);
|
||||
gluTessBeginContour(prtess);
|
||||
bgluTessEndContour(prtess);
|
||||
bgluTessBeginContour(prtess);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
gluTessEndContour(prtess);
|
||||
gluTessEndPolygon(prtess);
|
||||
bgluTessEndContour(prtess);
|
||||
bgluTessEndPolygon(prtess);
|
||||
|
||||
i = 0;
|
||||
while (i < s->indicescount)
|
||||
|
|
|
@ -220,6 +220,9 @@ int initsystem(void)
|
|||
initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n");
|
||||
nogl = 1;
|
||||
}
|
||||
else if (loadglulibrary(getenv("BUILD_GLULIB"))) {
|
||||
initprintf("Failed loading GLU library.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __APPLE__
|
||||
|
@ -271,6 +274,7 @@ void uninitsystem(void)
|
|||
|
||||
#ifdef USE_OPENGL
|
||||
unloadgldriver();
|
||||
unloadglulibrary();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -430,6 +430,9 @@ int initsystem(void)
|
|||
initprintf("Failed loading OpenGL driver. GL modes will be unavailable.\n");
|
||||
nogl = 1;
|
||||
}
|
||||
else if (loadglulibrary(getenv("BUILD_GLULIB"))) {
|
||||
initprintf("Failed loading GLU library.\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
// try and start DirectDraw
|
||||
|
@ -457,6 +460,7 @@ void uninitsystem(void)
|
|||
|
||||
#if defined(USE_OPENGL) && defined(POLYMOST)
|
||||
unloadgldriver();
|
||||
unloadglulibrary();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -793,7 +793,7 @@ void CONFIG_WriteSetup(void)
|
|||
SCRIPT_PutNumber(scripthandle, "Screen Setup", "GLDepthPeeling",r_depthpeeling,false,false);
|
||||
SCRIPT_PutNumber(scripthandle, "Screen Setup", "GLPeelsCount",r_peelscount,false,false);
|
||||
|
||||
SCRIPT_PutNumber(scripthandle, "Screen Setup", "GLDetailMapping", &r_detailmapping,false,false);
|
||||
SCRIPT_PutNumber(scripthandle, "Screen Setup", "GLDetailMapping", r_detailmapping,false,false);
|
||||
#endif
|
||||
#ifdef RENDERTYPEWIN
|
||||
SCRIPT_PutNumber(scripthandle, "Screen Setup", "MaxRefreshFreq",maxrefreshfreq,false,false);
|
||||
|
|
|
@ -2825,7 +2825,7 @@ static void moveclouds(void)
|
|||
{
|
||||
if (totalclock > cloudtotalclock || totalclock < (cloudtotalclock-7))
|
||||
{
|
||||
short i;
|
||||
int i;
|
||||
|
||||
cloudtotalclock = totalclock+6;
|
||||
|
||||
|
@ -3554,7 +3554,8 @@ void drawbackground(void)
|
|||
if (ud.multimode > 1) y1 += scale(ydim,8,200);
|
||||
if (ud.multimode > 4) y1 += scale(ydim,8,200);
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
// when not rendering a game, fullscreen wipe
|
||||
#define MENUTILE bpp==8?MENUSCREEN:LOADSCREEN
|
||||
|
|
Loading…
Reference in a new issue