2008-02-24 00:46:57 +00:00
|
|
|
#include "compat.h"
|
2018-02-16 06:38:21 +00:00
|
|
|
#include "glad/glad.h"
|
2006-04-23 06:44:19 +00:00
|
|
|
#include "glbuild.h"
|
|
|
|
#include "baselayer.h"
|
|
|
|
|
2006-05-12 21:55:05 +00:00
|
|
|
#if defined USE_OPENGL
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#ifdef RENDERTYPESDL
|
|
|
|
# include "sdlayer.h"
|
|
|
|
#endif
|
|
|
|
|
2016-02-29 06:34:16 +00:00
|
|
|
GLenum BuildGLError;
|
|
|
|
void BuildGLErrorCheck(void)
|
|
|
|
{
|
|
|
|
volatile GLenum err;
|
2018-02-16 06:38:21 +00:00
|
|
|
while ((err = glGetError()) != GL_NO_ERROR)
|
2016-02-29 06:34:16 +00:00
|
|
|
{
|
|
|
|
BuildGLError = err; // set a watchpoint/breakpoint here
|
|
|
|
}
|
|
|
|
}
|
2015-05-16 09:12:12 +00:00
|
|
|
|
2014-02-10 10:56:14 +00:00
|
|
|
#if defined DYNAMIC_GL
|
|
|
|
|
2018-02-16 06:38:21 +00:00
|
|
|
#if !defined RENDERTYPESDL && defined _WIN32
|
2015-05-16 09:12:12 +00:00
|
|
|
bwglCreateContextProcPtr bwglCreateContext;
|
|
|
|
bwglDeleteContextProcPtr bwglDeleteContext;
|
|
|
|
bwglGetProcAddressProcPtr bwglGetProcAddress;
|
|
|
|
bwglMakeCurrentProcPtr bwglMakeCurrent;
|
|
|
|
|
|
|
|
bwglChoosePixelFormatProcPtr bwglChoosePixelFormat;
|
|
|
|
bwglDescribePixelFormatProcPtr bwglDescribePixelFormat;
|
|
|
|
bwglGetPixelFormatProcPtr bwglGetPixelFormat;
|
|
|
|
bwglSetPixelFormatProcPtr bwglSetPixelFormat;
|
2006-04-23 06:44:19 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined DYNAMIC_GLU
|
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
// GLU
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluTessBeginContourProcPtr bgluTessBeginContour;
|
|
|
|
bgluTessBeginPolygonProcPtr bgluTessBeginPolygon;
|
|
|
|
bgluTessCallbackProcPtr bgluTessCallback;
|
|
|
|
bgluTessEndContourProcPtr bgluTessEndContour;
|
|
|
|
bgluTessEndPolygonProcPtr bgluTessEndPolygon;
|
|
|
|
bgluTessNormalProcPtr bgluTessNormal;
|
|
|
|
bgluTessPropertyProcPtr bgluTessProperty;
|
|
|
|
bgluTessVertexProcPtr bgluTessVertex;
|
|
|
|
bgluNewTessProcPtr bgluNewTess;
|
|
|
|
bgluDeleteTessProcPtr bgluDeleteTess;
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluPerspectiveProcPtr bgluPerspective;
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluErrorStringProcPtr bgluErrorString;
|
2007-01-16 03:19:04 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluProjectProcPtr bgluProject;
|
|
|
|
bgluUnProjectProcPtr bgluUnProject;
|
2009-07-11 22:20:15 +00:00
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#endif
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#if defined DYNAMIC_GL || defined DYNAMIC_GLEXT || defined DYNAMIC_GLU
|
|
|
|
# if !defined _WIN32
|
|
|
|
# include <dlfcn.h>
|
|
|
|
# endif
|
2013-10-07 10:06:09 +00:00
|
|
|
#endif
|
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#if defined DYNAMIC_GL || defined DYNAMIC_GLEXT
|
|
|
|
|
2013-10-07 10:06:09 +00:00
|
|
|
#if !defined RENDERTYPESDL && defined _WIN32
|
|
|
|
static HMODULE hGLDLL;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
char *gldriver = NULL;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2011-01-16 02:50:27 +00:00
|
|
|
static void *getproc_(const char *s, int32_t *err, int32_t fatal, int32_t extension)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
void *t;
|
2006-04-23 06:44:19 +00:00
|
|
|
#if defined RENDERTYPESDL
|
2008-03-23 00:06:42 +00:00
|
|
|
UNREFERENCED_PARAMETER(extension);
|
2011-01-16 02:50:27 +00:00
|
|
|
t = (void *)SDL_GL_GetProcAddress(s);
|
2006-04-23 06:44:19 +00:00
|
|
|
#elif defined _WIN32
|
2011-01-16 02:50:27 +00:00
|
|
|
if (extension) t = (void *)bwglGetProcAddress(s);
|
|
|
|
else t = (void *)GetProcAddress(hGLDLL,s);
|
2006-04-23 06:44:19 +00:00
|
|
|
#else
|
|
|
|
#error Need a dynamic loader for this platform...
|
|
|
|
#endif
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!t && fatal)
|
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
initprintf("Failed to find %s in %s\n", s, gldriver);
|
|
|
|
*err = 1;
|
|
|
|
}
|
|
|
|
return t;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
|
|
|
#define GETPROC(s) getproc_(s,&err,1,0)
|
2015-05-16 09:12:12 +00:00
|
|
|
|
2018-02-16 06:38:21 +00:00
|
|
|
int32_t loadwgl(const char *driver)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t err=0;
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
if (hGLDLL) return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!driver)
|
|
|
|
{
|
2008-08-22 23:10:54 +00:00
|
|
|
driver = "opengl32.dll";
|
2006-04-24 19:04:22 +00:00
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2006-04-24 19:04:22 +00:00
|
|
|
hGLDLL = LoadLibrary(driver);
|
2013-10-07 10:06:09 +00:00
|
|
|
if (!hGLDLL)
|
|
|
|
{
|
|
|
|
initprintf("Failed loading \"%s\"\n", driver);
|
|
|
|
return -1;
|
|
|
|
}
|
2018-02-16 06:38:21 +00:00
|
|
|
|
2009-10-07 06:47:35 +00:00
|
|
|
gldriver = Bstrdup(driver);
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bwglCreateContext = (bwglCreateContextProcPtr) GETPROC("wglCreateContext");
|
|
|
|
bwglDeleteContext = (bwglDeleteContextProcPtr) GETPROC("wglDeleteContext");
|
|
|
|
bwglGetProcAddress = (bwglGetProcAddressProcPtr) GETPROC("wglGetProcAddress");
|
|
|
|
bwglMakeCurrent = (bwglMakeCurrentProcPtr) GETPROC("wglMakeCurrent");
|
2018-02-16 06:38:21 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bwglChoosePixelFormat = (bwglChoosePixelFormatProcPtr) GETPROC("wglChoosePixelFormat");
|
|
|
|
bwglDescribePixelFormat = (bwglDescribePixelFormatProcPtr) GETPROC("wglDescribePixelFormat");
|
|
|
|
bwglGetPixelFormat = (bwglGetPixelFormatProcPtr) GETPROC("wglGetPixelFormat");
|
|
|
|
bwglSetPixelFormat = (bwglSetPixelFormatProcPtr) GETPROC("wglSetPixelFormat");
|
2018-02-16 06:38:21 +00:00
|
|
|
|
|
|
|
if (err) unloadwgl();
|
2006-04-24 19:04:22 +00:00
|
|
|
return err;
|
2006-04-23 06:44:19 +00:00
|
|
|
}
|
2018-02-16 06:38:21 +00:00
|
|
|
int32_t unloadwgl(void)
|
2006-04-23 06:44:19 +00:00
|
|
|
{
|
2006-04-24 19:04:22 +00:00
|
|
|
if (!hGLDLL) return 0;
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2015-09-23 17:55:31 +00:00
|
|
|
DO_FREE_AND_NULL(gldriver);
|
2006-04-24 19:04:22 +00:00
|
|
|
|
|
|
|
FreeLibrary(hGLDLL);
|
|
|
|
hGLDLL = NULL;
|
2015-05-16 09:12:12 +00:00
|
|
|
|
|
|
|
bwglCreateContext = (bwglCreateContextProcPtr) NULL;
|
|
|
|
bwglDeleteContext = (bwglDeleteContextProcPtr) NULL;
|
|
|
|
bwglGetProcAddress = (bwglGetProcAddressProcPtr) NULL;
|
|
|
|
bwglMakeCurrent = (bwglMakeCurrentProcPtr) NULL;
|
|
|
|
|
|
|
|
bwglChoosePixelFormat = (bwglChoosePixelFormatProcPtr) NULL;
|
|
|
|
bwglDescribePixelFormat = (bwglDescribePixelFormatProcPtr) NULL;
|
|
|
|
bwglGetPixelFormat = (bwglGetPixelFormatProcPtr) NULL;
|
|
|
|
bwglSetPixelFormat = (bwglSetPixelFormatProcPtr) NULL;
|
2018-02-16 06:38:21 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-16 09:12:12 +00:00
|
|
|
#endif
|
2006-04-24 19:04:22 +00:00
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#endif
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2015-05-16 09:12:12 +00:00
|
|
|
#if defined DYNAMIC_GLU
|
|
|
|
#if defined _WIN32
|
|
|
|
static HMODULE hGLUDLL;
|
|
|
|
#else
|
|
|
|
static void *gluhandle = NULL;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
char *glulibrary = NULL;
|
|
|
|
|
2011-01-16 02:50:27 +00:00
|
|
|
static void *glugetproc_(const char *s, int32_t *err, int32_t fatal)
|
2007-01-16 03:19:04 +00:00
|
|
|
{
|
|
|
|
void *t;
|
|
|
|
#if defined _WIN32
|
2011-01-16 02:50:27 +00:00
|
|
|
t = (void *)GetProcAddress(hGLUDLL,s);
|
2007-01-16 03:19:04 +00:00
|
|
|
#else
|
2011-01-16 02:50:27 +00:00
|
|
|
t = (void *)dlsym(gluhandle,s);
|
2007-01-16 03:19:04 +00:00
|
|
|
#endif
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!t && fatal)
|
|
|
|
{
|
2007-01-16 03:19:04 +00:00
|
|
|
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)
|
2015-05-16 09:12:12 +00:00
|
|
|
#endif
|
2007-01-16 03:19:04 +00:00
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t loadglulibrary(const char *driver)
|
2007-01-16 03:19:04 +00:00
|
|
|
{
|
2015-05-16 09:12:12 +00:00
|
|
|
#if defined DYNAMIC_GLU
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t err=0;
|
2007-01-16 03:19:04 +00:00
|
|
|
|
2013-10-07 10:06:09 +00:00
|
|
|
#if defined _WIN32
|
2007-01-16 03:19:04 +00:00
|
|
|
if (hGLUDLL) return 0;
|
|
|
|
#endif
|
|
|
|
|
2007-12-12 17:42:14 +00:00
|
|
|
if (!driver)
|
|
|
|
{
|
2007-01-16 03:19:04 +00:00
|
|
|
#ifdef _WIN32
|
2008-08-22 23:10:54 +00:00
|
|
|
driver = "glu32.dll";
|
2007-01-16 03:19:04 +00:00
|
|
|
#elif defined __APPLE__
|
|
|
|
driver = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; // FIXME: like I know anything about Apple. Hah.
|
2014-07-22 11:18:59 +00:00
|
|
|
#elif defined __OpenBSD__
|
|
|
|
driver = "libGLU.so";
|
2007-01-16 03:19:04 +00:00
|
|
|
#else
|
2008-06-11 02:33:23 +00:00
|
|
|
driver = "libGLU.so.1";
|
2007-01-16 03:19:04 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#if defined _WIN32
|
|
|
|
hGLUDLL = LoadLibrary(driver);
|
2015-05-16 09:12:12 +00:00
|
|
|
if (!hGLUDLL)
|
2007-01-16 03:19:04 +00:00
|
|
|
#else
|
|
|
|
gluhandle = dlopen(driver, RTLD_NOW|RTLD_GLOBAL);
|
2015-05-16 09:12:12 +00:00
|
|
|
if (!gluhandle)
|
2007-01-16 03:19:04 +00:00
|
|
|
#endif
|
2015-05-16 09:12:12 +00:00
|
|
|
{
|
|
|
|
initprintf("Failed loading \"%s\"\n",driver);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-10-07 06:47:35 +00:00
|
|
|
glulibrary = Bstrdup(driver);
|
2007-01-16 03:19:04 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluTessBeginContour = (bgluTessBeginContourProcPtr) GLUGETPROC("gluTessBeginContour");
|
|
|
|
bgluTessBeginPolygon = (bgluTessBeginPolygonProcPtr) GLUGETPROC("gluTessBeginPolygon");
|
|
|
|
bgluTessCallback = (bgluTessCallbackProcPtr) GLUGETPROC("gluTessCallback");
|
|
|
|
bgluTessEndContour = (bgluTessEndContourProcPtr) GLUGETPROC("gluTessEndContour");
|
|
|
|
bgluTessEndPolygon = (bgluTessEndPolygonProcPtr) GLUGETPROC("gluTessEndPolygon");
|
|
|
|
bgluTessNormal = (bgluTessNormalProcPtr) GLUGETPROC("gluTessNormal");
|
|
|
|
bgluTessProperty = (bgluTessPropertyProcPtr) GLUGETPROC("gluTessProperty");
|
|
|
|
bgluTessVertex = (bgluTessVertexProcPtr) GLUGETPROC("gluTessVertex");
|
|
|
|
bgluNewTess = (bgluNewTessProcPtr) GLUGETPROC("gluNewTess");
|
|
|
|
bgluDeleteTess = (bgluDeleteTessProcPtr) GLUGETPROC("gluDeleteTess");
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluPerspective = (bgluPerspectiveProcPtr) GLUGETPROC("gluPerspective");
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluErrorString = (bgluErrorStringProcPtr) GLUGETPROC("gluErrorString");
|
2007-01-16 03:19:04 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluProject = (bgluProjectProcPtr) GLUGETPROC("gluProject");
|
|
|
|
bgluUnProject = (bgluUnProjectProcPtr) GLUGETPROC("gluUnProject");
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
if (err) unloadglulibrary();
|
|
|
|
return err;
|
2015-05-16 09:12:12 +00:00
|
|
|
#else
|
|
|
|
UNREFERENCED_PARAMETER(driver);
|
|
|
|
return 0;
|
|
|
|
#endif
|
2007-01-16 03:19:04 +00:00
|
|
|
}
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
int32_t unloadglulibrary(void)
|
2007-01-16 03:19:04 +00:00
|
|
|
{
|
2015-05-16 09:12:12 +00:00
|
|
|
#if defined DYNAMIC_GLU
|
2013-10-07 10:06:09 +00:00
|
|
|
#if defined _WIN32
|
2007-01-16 03:19:04 +00:00
|
|
|
if (!hGLUDLL) return 0;
|
|
|
|
#endif
|
|
|
|
|
2015-09-23 17:55:31 +00:00
|
|
|
DO_FREE_AND_NULL(glulibrary);
|
2007-01-16 03:19:04 +00:00
|
|
|
|
2013-10-07 10:06:09 +00:00
|
|
|
#if defined _WIN32
|
2007-01-16 03:19:04 +00:00
|
|
|
FreeLibrary(hGLUDLL);
|
|
|
|
hGLUDLL = NULL;
|
|
|
|
#else
|
|
|
|
if (gluhandle) dlclose(gluhandle);
|
|
|
|
gluhandle = NULL;
|
|
|
|
#endif
|
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluTessBeginContour = (bgluTessBeginContourProcPtr) NULL;
|
|
|
|
bgluTessBeginPolygon = (bgluTessBeginPolygonProcPtr) NULL;
|
|
|
|
bgluTessCallback = (bgluTessCallbackProcPtr) NULL;
|
|
|
|
bgluTessEndContour = (bgluTessEndContourProcPtr) NULL;
|
|
|
|
bgluTessEndPolygon = (bgluTessEndPolygonProcPtr) NULL;
|
|
|
|
bgluTessNormal = (bgluTessNormalProcPtr) NULL;
|
|
|
|
bgluTessProperty = (bgluTessPropertyProcPtr) NULL;
|
|
|
|
bgluTessVertex = (bgluTessVertexProcPtr) NULL;
|
|
|
|
bgluNewTess = (bgluNewTessProcPtr) NULL;
|
|
|
|
bgluDeleteTess = (bgluDeleteTessProcPtr) NULL;
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluPerspective = (bgluPerspectiveProcPtr) NULL;
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluErrorString = (bgluErrorStringProcPtr) NULL;
|
2007-07-01 06:32:03 +00:00
|
|
|
|
2012-11-10 06:09:51 +00:00
|
|
|
bgluProject = (bgluProjectProcPtr) NULL;
|
|
|
|
bgluUnProject = (bgluUnProjectProcPtr) NULL;
|
2015-05-16 09:12:12 +00:00
|
|
|
#endif
|
2007-12-12 17:42:14 +00:00
|
|
|
|
2007-01-16 03:19:04 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2006-04-23 06:44:19 +00:00
|
|
|
|
2011-07-24 15:15:57 +00:00
|
|
|
|
|
|
|
//////// glGenTextures/glDeleteTextures debugging ////////
|
|
|
|
# if defined DEBUGGINGAIDS && defined DEBUG_TEXTURE_NAMES
|
|
|
|
static uint8_t *texnameused; // bitmap
|
|
|
|
static uint32_t *texnamefromwhere; // hash of __FILE__
|
|
|
|
static uint32_t texnameallocsize;
|
|
|
|
|
|
|
|
// djb3 algorithm
|
|
|
|
static inline uint32_t texdbg_getcode(const char *s)
|
|
|
|
{
|
|
|
|
uint32_t h = 5381;
|
|
|
|
int32_t ch;
|
|
|
|
|
|
|
|
while ((ch = *s++) != '\0')
|
|
|
|
h = ((h << 5) + h) ^ ch;
|
|
|
|
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void texdbg_realloc(uint32_t maxtexname)
|
|
|
|
{
|
|
|
|
uint32_t newsize = texnameallocsize ? texnameallocsize : 64;
|
|
|
|
|
2012-04-29 20:54:37 +00:00
|
|
|
if (maxtexname < texnameallocsize)
|
2011-07-24 15:15:57 +00:00
|
|
|
return;
|
|
|
|
|
2012-04-29 20:54:37 +00:00
|
|
|
while (maxtexname >= newsize)
|
2011-07-24 15:15:57 +00:00
|
|
|
newsize <<= 1;
|
|
|
|
// initprintf("texdebug: new size %u\n", newsize);
|
|
|
|
|
2014-05-30 00:02:19 +00:00
|
|
|
texnameused = Xrealloc(texnameused, newsize>>3);
|
|
|
|
texnamefromwhere = Xrealloc(texnamefromwhere, newsize*sizeof(uint32_t));
|
2011-07-24 15:15:57 +00:00
|
|
|
|
|
|
|
Bmemset(texnameused + (texnameallocsize>>3), 0, (newsize-texnameallocsize)>>3);
|
|
|
|
Bmemset(texnamefromwhere + texnameallocsize, 0, (newsize-texnameallocsize)*sizeof(uint32_t));
|
|
|
|
|
|
|
|
texnameallocsize = newsize;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef bglGenTextures
|
|
|
|
void texdbg_bglGenTextures(GLsizei n, GLuint *textures, const char *srcfn)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
uint32_t hash = srcfn ? texdbg_getcode(srcfn) : 0;
|
|
|
|
|
|
|
|
for (i=0; i<n; i++)
|
|
|
|
if (textures[i] < texnameallocsize && (texnameused[textures[i]>>3]&(1<<(textures[i]&7))))
|
|
|
|
initprintf("texdebug %x Gen: overwriting used tex name %u from %x\n", hash, textures[i], texnamefromwhere[textures[i]]);
|
|
|
|
|
|
|
|
bglGenTextures(n, textures);
|
|
|
|
|
|
|
|
{
|
|
|
|
GLuint maxtexname = 0;
|
|
|
|
|
|
|
|
for (i=0; i<n; i++)
|
|
|
|
maxtexname = max(maxtexname, textures[i]);
|
|
|
|
|
|
|
|
texdbg_realloc(maxtexname);
|
|
|
|
|
|
|
|
for (i=0; i<n; i++)
|
|
|
|
{
|
|
|
|
texnameused[textures[i]>>3] |= (1<<(textures[i]&7));
|
|
|
|
texnamefromwhere[textures[i]] = hash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef bglDeleteTextures
|
|
|
|
void texdbg_bglDeleteTextures(GLsizei n, const GLuint *textures, const char *srcfn)
|
|
|
|
{
|
|
|
|
int32_t i;
|
|
|
|
uint32_t hash = srcfn ? texdbg_getcode(srcfn) : 0;
|
|
|
|
|
|
|
|
for (i=0; i<n; i++)
|
|
|
|
if (textures[i] < texnameallocsize)
|
|
|
|
{
|
|
|
|
if ((texnameused[textures[i]>>3]&(1<<(textures[i]&7)))==0)
|
|
|
|
initprintf("texdebug %x Del: deleting unused tex name %u\n", hash, textures[i]);
|
|
|
|
else if ((texnameused[textures[i]>>3]&(1<<(textures[i]&7))) &&
|
|
|
|
texnamefromwhere[textures[i]] != hash)
|
|
|
|
initprintf("texdebug %x Del: deleting foreign tex name %u from %x\n", hash,
|
|
|
|
textures[i], texnamefromwhere[textures[i]]);
|
|
|
|
}
|
|
|
|
|
|
|
|
bglDeleteTextures(n, textures);
|
|
|
|
|
|
|
|
if (texnameallocsize)
|
|
|
|
for (i=0; i<n; i++)
|
|
|
|
{
|
|
|
|
texnameused[textures[i]>>3] &= ~(1<<(textures[i]&7));
|
|
|
|
texnamefromwhere[textures[i]] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# endif // defined DEBUGGINGAIDS
|
|
|
|
|
|
|
|
#endif
|