2004-08-22 22:29:09 +00:00
|
|
|
#include "quakedef.h"
|
2009-11-04 21:16:50 +00:00
|
|
|
#ifdef GLQUAKE
|
2004-08-22 22:29:09 +00:00
|
|
|
#include "glquake.h"
|
2009-11-04 21:16:50 +00:00
|
|
|
#include "gl_draw.h"
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//standard 1.1 opengl calls
|
|
|
|
void (APIENTRY *qglAlphaFunc) (GLenum func, GLclampf ref);
|
|
|
|
void (APIENTRY *qglBegin) (GLenum mode);
|
|
|
|
void (APIENTRY *qglBlendFunc) (GLenum sfactor, GLenum dfactor);
|
2005-09-09 23:40:55 +00:00
|
|
|
void (APIENTRY *qglCallList) (GLuint list);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglClear) (GLbitfield mask);
|
|
|
|
void (APIENTRY *qglClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
|
|
|
|
void (APIENTRY *qglClearDepth) (GLclampd depth);
|
|
|
|
void (APIENTRY *qglClearStencil) (GLint s);
|
2010-07-11 02:22:39 +00:00
|
|
|
void (APIENTRY *qglClipPlane) (GLenum plane, const GLdouble *equation);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglColor3f) (GLfloat red, GLfloat green, GLfloat blue);
|
|
|
|
void (APIENTRY *qglColor3ub) (GLubyte red, GLubyte green, GLubyte blue);
|
|
|
|
void (APIENTRY *qglColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
|
|
|
|
void (APIENTRY *qglColor4fv) (const GLfloat *v);
|
|
|
|
void (APIENTRY *qglColor4ub) (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
|
|
|
|
void (APIENTRY *qglColor4ubv) (const GLubyte *v);
|
|
|
|
void (APIENTRY *qglColorMask) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
|
2005-01-12 22:15:50 +00:00
|
|
|
void (APIENTRY *qglCopyTexImage2D) (GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
|
2006-03-03 03:31:19 +00:00
|
|
|
void (APIENTRY *qglCopyTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglCullFace) (GLenum mode);
|
|
|
|
void (APIENTRY *qglDepthFunc) (GLenum func);
|
|
|
|
void (APIENTRY *qglDepthMask) (GLboolean flag);
|
|
|
|
void (APIENTRY *qglDepthRange) (GLclampd zNear, GLclampd zFar);
|
|
|
|
void (APIENTRY *qglDisable) (GLenum cap);
|
|
|
|
void (APIENTRY *qglDrawBuffer) (GLenum mode);
|
|
|
|
void (APIENTRY *qglDrawPixels) (GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
|
|
|
|
void (APIENTRY *qglEnable) (GLenum cap);
|
|
|
|
void (APIENTRY *qglEnd) (void);
|
2005-09-09 23:40:55 +00:00
|
|
|
void (APIENTRY *qglEndList) (void);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglFinish) (void);
|
|
|
|
void (APIENTRY *qglFlush) (void);
|
|
|
|
void (APIENTRY *qglFrustum) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
|
2005-09-09 23:40:55 +00:00
|
|
|
GLuint (APIENTRY *qglGenLists) (GLsizei range);
|
2009-11-04 21:16:50 +00:00
|
|
|
void (APIENTRY *qglGenTextures) (GLsizei n, GLuint *textures);
|
2004-09-13 03:20:04 +00:00
|
|
|
GLenum (APIENTRY *qglGetError) (void);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglGetFloatv) (GLenum pname, GLfloat *params);
|
|
|
|
void (APIENTRY *qglGetIntegerv) (GLenum pname, GLint *params);
|
|
|
|
const GLubyte * (APIENTRY *qglGetString) (GLenum name);
|
|
|
|
void (APIENTRY *qglHint) (GLenum target, GLenum mode);
|
|
|
|
void (APIENTRY *qglLoadIdentity) (void);
|
|
|
|
void (APIENTRY *qglLoadMatrixf) (const GLfloat *m);
|
|
|
|
void (APIENTRY *qglNormal3f) (GLfloat nx, GLfloat ny, GLfloat nz);
|
|
|
|
void (APIENTRY *qglNormal3fv) (const GLfloat *v);
|
|
|
|
void (APIENTRY *qglMatrixMode) (GLenum mode);
|
|
|
|
void (APIENTRY *qglMultMatrixf) (const GLfloat *m);
|
2005-09-09 23:40:55 +00:00
|
|
|
void (APIENTRY *qglNewList) (GLuint list, GLenum mode);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglOrtho) (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
|
|
|
|
void (APIENTRY *qglPolygonMode) (GLenum face, GLenum mode);
|
2004-12-11 16:45:38 +00:00
|
|
|
void (APIENTRY *qglPolygonOffset) (GLfloat factor, GLfloat units);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglPopMatrix) (void);
|
|
|
|
void (APIENTRY *qglPushMatrix) (void);
|
|
|
|
void (APIENTRY *qglReadBuffer) (GLenum mode);
|
|
|
|
void (APIENTRY *qglReadPixels) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
|
|
|
|
void (APIENTRY *qglRotatef) (GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void (APIENTRY *qglScalef) (GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void (APIENTRY *qglShadeModel) (GLenum mode);
|
|
|
|
void (APIENTRY *qglTexCoord1f) (GLfloat s);
|
|
|
|
void (APIENTRY *qglTexCoord2f) (GLfloat s, GLfloat t);
|
|
|
|
void (APIENTRY *qglTexCoord2fv) (const GLfloat *v);
|
|
|
|
void (APIENTRY *qglTexEnvf) (GLenum target, GLenum pname, GLfloat param);
|
2004-09-13 03:20:04 +00:00
|
|
|
void (APIENTRY *qglTexEnvfv) (GLenum target, GLenum pname, const GLfloat *param);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglTexEnvi) (GLenum target, GLenum pname, GLint param);
|
|
|
|
void (APIENTRY *qglTexGeni) (GLenum coord, GLenum pname, GLint param);
|
2009-07-05 18:45:53 +00:00
|
|
|
void (APIENTRY *qglTexGenfv) (GLenum coord, GLenum pname, const GLfloat *param);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglTexImage2D) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
|
|
|
|
void (APIENTRY *qglTexParameteri) (GLenum target, GLenum pname, GLint param);
|
|
|
|
void (APIENTRY *qglTexParameterf) (GLenum target, GLenum pname, GLfloat param);
|
2006-06-15 21:40:54 +00:00
|
|
|
void (APIENTRY *qglTexParameteriv) (GLenum target, GLenum pname, const GLint *params);
|
|
|
|
void (APIENTRY *qglTexParameterfv) (GLenum target, GLenum pname, const GLfloat *params);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglTexSubImage2D) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
|
|
|
|
void (APIENTRY *qglTranslatef) (GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void (APIENTRY *qglVertex2f) (GLfloat x, GLfloat y);
|
|
|
|
void (APIENTRY *qglVertex3f) (GLfloat x, GLfloat y, GLfloat z);
|
|
|
|
void (APIENTRY *qglVertex3fv) (const GLfloat *v);
|
|
|
|
void (APIENTRY *qglViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
|
|
|
|
void (APIENTRY *qglGetTexLevelParameteriv) (GLenum target, GLint level, GLenum pname, GLint *params);
|
|
|
|
|
2005-05-13 10:42:48 +00:00
|
|
|
void (APIENTRY *qglDrawRangeElements) (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
2004-10-19 16:10:14 +00:00
|
|
|
void (APIENTRY *qglArrayElement) (GLint i);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
|
|
|
void (APIENTRY *qglNormalPointer) (GLenum type, GLsizei stride, const GLvoid *pointer);
|
|
|
|
void (APIENTRY *qglTexCoordPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
|
|
|
void (APIENTRY *qglColorPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
2004-09-13 03:20:04 +00:00
|
|
|
void (APIENTRY *qglDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglDisableClientState) (GLenum array);
|
|
|
|
void (APIENTRY *qglEnableClientState) (GLenum array);
|
|
|
|
|
2004-10-26 14:55:41 +00:00
|
|
|
void (APIENTRY *qglScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
|
2004-08-22 22:29:09 +00:00
|
|
|
void (APIENTRY *qglStencilOp) (GLenum fail, GLenum zfail, GLenum zpass);
|
|
|
|
void (APIENTRY *qglStencilFunc) (GLenum func, GLint ref, GLuint mask);
|
|
|
|
void (APIENTRY *qglPushAttrib) (GLbitfield mask);
|
|
|
|
void (APIENTRY *qglPopAttrib) (void);
|
2006-06-02 17:42:36 +00:00
|
|
|
|
|
|
|
void (APIENTRY *qglFogf) (GLenum pname, GLfloat param);
|
|
|
|
void (APIENTRY *qglFogi) (GLenum pname, GLint param);
|
|
|
|
void (APIENTRY *qglFogfv) (GLenum pname, const GLfloat *params);
|
|
|
|
|
2008-11-09 22:29:28 +00:00
|
|
|
void (APIENTRY *qglDeleteTextures) (GLsizei n, const GLuint *textures);
|
|
|
|
|
2009-05-24 10:11:17 +00:00
|
|
|
void (APIENTRY *qglGenBuffersARB)(GLsizei n, GLuint* ids);
|
|
|
|
void (APIENTRY *qglDeleteBuffersARB)(GLsizei n, GLuint* ids);
|
|
|
|
void (APIENTRY *qglBindBufferARB)(GLenum target, GLuint id);
|
|
|
|
void (APIENTRY *qglBufferDataARB)(GLenum target, GLsizei size, const void* data, GLenum usage);
|
|
|
|
void (APIENTRY *qglBufferSubDataARB)(GLenum target, GLint offset, GLsizei size, void* data);
|
2009-06-21 17:45:33 +00:00
|
|
|
void *(APIENTRY *qglMapBufferARB)(GLenum target, GLenum access);
|
|
|
|
GLboolean (APIENTRY *qglUnmapBufferARB)(GLenum target);
|
2009-05-24 10:11:17 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
const GLubyte * (APIENTRY * qglGetStringi) (GLenum name, GLuint index);
|
|
|
|
|
|
|
|
void (APIENTRY *qglGenFramebuffersEXT)(GLsizei n, GLuint* ids);
|
|
|
|
void (APIENTRY *qglDeleteFramebuffersEXT)(GLsizei n, const GLuint* ids);
|
|
|
|
void (APIENTRY *qglBindFramebufferEXT)(GLenum target, GLuint id);
|
|
|
|
void (APIENTRY *qglGenRenderbuffersEXT)(GLsizei n, GLuint* ids);
|
|
|
|
void (APIENTRY *qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint* ids);
|
|
|
|
void (APIENTRY *qglBindRenderbufferEXT)(GLenum target, GLuint id);
|
|
|
|
void (APIENTRY *qglRenderbufferStorageEXT)(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
|
|
|
|
void (APIENTRY *qglFramebufferTexture2DEXT)(GLenum target, GLenum attachmentPoint, GLenum textureTarget, GLuint textureId, GLint level);
|
|
|
|
|
2005-04-19 21:09:29 +00:00
|
|
|
/*
|
2004-09-13 03:20:04 +00:00
|
|
|
PFNGLPROGRAMSTRINGARBPROC qglProgramStringARB;
|
|
|
|
PFNGLGETPROGRAMIVARBPROC qglGetProgramivARB;
|
|
|
|
PFNGLBINDPROGRAMARBPROC qglBindProgramARB;
|
|
|
|
PFNGLGENPROGRAMSARBPROC qglGenProgramsARB;
|
2005-04-19 21:09:29 +00:00
|
|
|
*/
|
2007-09-22 19:28:27 +00:00
|
|
|
FTEPFNGLLOCKARRAYSEXTPROC qglLockArraysEXT;
|
|
|
|
FTEPFNGLUNLOCKARRAYSEXTPROC qglUnlockArraysEXT;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-01-04 23:34:42 +00:00
|
|
|
//glslang - arb_shader_objects
|
2007-09-22 19:28:27 +00:00
|
|
|
FTEPFNGLCREATEPROGRAMOBJECTARBPROC qglCreateProgramObjectARB;
|
|
|
|
FTEPFNGLDELETEOBJECTARBPROC qglDeleteObjectARB;
|
|
|
|
FTEPFNGLUSEPROGRAMOBJECTARBPROC qglUseProgramObjectARB;
|
|
|
|
FTEPFNGLCREATESHADEROBJECTARBPROC qglCreateShaderObjectARB;
|
|
|
|
FTEPFNGLSHADERSOURCEARBPROC qglShaderSourceARB;
|
|
|
|
FTEPFNGLCOMPILESHADERARBPROC qglCompileShaderARB;
|
|
|
|
FTEPFNGLGETOBJECTPARAMETERIVARBPROC qglGetObjectParameterivARB;
|
|
|
|
FTEPFNGLATTACHOBJECTARBPROC qglAttachObjectARB;
|
|
|
|
FTEPFNGLGETINFOLOGARBPROC qglGetInfoLogARB;
|
|
|
|
FTEPFNGLLINKPROGRAMARBPROC qglLinkProgramARB;
|
|
|
|
FTEPFNGLGETUNIFORMLOCATIONARBPROC qglGetUniformLocationARB;
|
2009-11-04 21:16:50 +00:00
|
|
|
FTEPFNGLUNIFORMMATRIX4FVARBPROC qglUniformMatrix4fvARB;
|
2007-09-22 19:28:27 +00:00
|
|
|
FTEPFNGLUNIFORM4FARBPROC qglUniform4fARB;
|
|
|
|
FTEPFNGLUNIFORM4FVARBPROC qglUniform4fvARB;
|
|
|
|
FTEPFNGLUNIFORM3FARBPROC qglUniform3fARB;
|
|
|
|
FTEPFNGLUNIFORM3FVARBPROC qglUniform3fvARB;
|
|
|
|
FTEPFNGLUNIFORM1IARBPROC qglUniform1iARB;
|
|
|
|
FTEPFNGLUNIFORM1FARBPROC qglUniform1fARB;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//extensions
|
|
|
|
//arb multitexture
|
|
|
|
qlpSelTexFUNC qglActiveTextureARB;
|
|
|
|
qlpSelTexFUNC qglClientActiveTextureARB;
|
|
|
|
qlpMTex3FUNC qglMultiTexCoord3fARB;
|
|
|
|
qlpMTex2FUNC qglMultiTexCoord2fARB;
|
|
|
|
|
|
|
|
//generic multitexture
|
|
|
|
lpMTexFUNC qglMTexCoord2fSGIS;
|
|
|
|
lpSelTexFUNC qglSelectTextureSGIS;
|
|
|
|
int mtexid0;
|
|
|
|
int mtexid1;
|
|
|
|
|
|
|
|
//ati_truform
|
2007-09-22 19:28:27 +00:00
|
|
|
FTEPFNGLPNTRIANGLESIATIPROC qglPNTrianglesiATI;
|
|
|
|
FTEPFNGLPNTRIANGLESFATIPROC qglPNTrianglesfATI;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//stencil shadowing
|
|
|
|
void (APIENTRY *qglStencilOpSeparateATI) (GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
|
2007-09-22 19:28:27 +00:00
|
|
|
FTEPFNGLACTIVESTENCILFACEEXTPROC qglActiveStencilFaceEXT;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//quick hack that made quake work on both 1 and 1.1 gl implementations.
|
|
|
|
BINDTEXFUNCPTR bindTexFunc;
|
|
|
|
|
|
|
|
|
|
|
|
int gl_mtexarbable=0; //max texture units
|
|
|
|
qboolean gl_mtexable = false;
|
|
|
|
int gl_bumpmappingpossible;
|
|
|
|
|
2004-09-13 03:20:04 +00:00
|
|
|
|
2004-09-26 03:34:26 +00:00
|
|
|
qboolean gammaworks; //if the gl drivers can set proper gamma.
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
gl_config_t gl_config;
|
2004-12-09 23:44:29 +00:00
|
|
|
int gl_canstencil;
|
|
|
|
|
|
|
|
float gldepthmin, gldepthmax;
|
|
|
|
const char *gl_vendor;
|
|
|
|
const char *gl_renderer;
|
|
|
|
const char *gl_version;
|
2009-11-04 21:16:50 +00:00
|
|
|
static const char *gl_extensions;
|
|
|
|
|
|
|
|
unsigned int gl_major_version;
|
|
|
|
unsigned int gl_minor_version;
|
|
|
|
static unsigned int gl_num_extensions;
|
|
|
|
|
|
|
|
|
|
|
|
qboolean GL_CheckExtension(char *extname)
|
|
|
|
{
|
|
|
|
int i;
|
2010-07-11 02:22:39 +00:00
|
|
|
cvar_t *v = Cvar_Get(va("gl_ext_%s", extname), "1", 0, "GL Extensions");
|
|
|
|
if (v && !v->ival)
|
|
|
|
return false;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (gl_num_extensions && qglGetStringi)
|
|
|
|
{
|
|
|
|
for (i = 0; i < gl_num_extensions; i++)
|
|
|
|
if (!strcmp(qglGetStringi(GL_EXTENSIONS, i), extname))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!gl_extensions)
|
|
|
|
return false;
|
2004-10-19 16:10:14 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
//note that this is not actually correct...
|
|
|
|
return !!strstr(gl_extensions, extname);
|
|
|
|
}
|
2009-06-21 17:45:33 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
texid_t GL_AllocNewTexture(void)
|
2009-06-21 17:45:33 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
texid_t r;
|
|
|
|
qglGenTextures(1, &r.num);
|
|
|
|
return r;
|
2009-06-21 17:45:33 +00:00
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2010-07-11 10:53:13 +00:00
|
|
|
void GL_DestroyTexture(texid_t tex)
|
|
|
|
{
|
|
|
|
qglDeleteTextures(1, &tex.num);
|
|
|
|
}
|
|
|
|
|
2005-05-23 05:32:55 +00:00
|
|
|
void APIENTRY GL_DrawRangeElementsEmul(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices)
|
2005-05-21 01:33:58 +00:00
|
|
|
{
|
2005-05-23 05:32:55 +00:00
|
|
|
qglDrawElements(mode, count, type, indices);
|
2005-05-21 01:33:58 +00:00
|
|
|
}
|
2009-07-11 18:23:07 +00:00
|
|
|
void APIENTRY GL_BindBufferARBStub(GLenum target, GLuint id)
|
|
|
|
{
|
|
|
|
}
|
2005-05-21 01:33:58 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
#define getglcore getglfunction
|
|
|
|
#define getglext(name) getglfunction(name)
|
|
|
|
void GL_CheckExtensions (void *(*getglfunction) (char *name))
|
|
|
|
{
|
|
|
|
extern cvar_t gl_bump;
|
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
memset(&gl_config, 0, sizeof(gl_config));
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
//multitexture
|
|
|
|
gl_mtexable = false;
|
|
|
|
gl_mtexarbable = 0;
|
|
|
|
qglActiveTextureARB = NULL;
|
|
|
|
qglMultiTexCoord2fARB = NULL;
|
|
|
|
qglMultiTexCoord3fARB = NULL;
|
|
|
|
qglMTexCoord2fSGIS = NULL;
|
|
|
|
qglSelectTextureSGIS = NULL;
|
|
|
|
mtexid0 = 0;
|
|
|
|
mtexid1 = 0;
|
|
|
|
|
2007-10-08 12:56:17 +00:00
|
|
|
//none of them bumpmapping possibilities.
|
2004-08-22 22:29:09 +00:00
|
|
|
gl_bumpmappingpossible = false;
|
|
|
|
|
|
|
|
//no GL_ATI_separate_stencil
|
|
|
|
qglStencilOpSeparateATI = NULL;
|
|
|
|
|
|
|
|
//no GL_EXT_stencil_two_side
|
|
|
|
qglActiveStencilFaceEXT = NULL;
|
|
|
|
|
|
|
|
//no truform. sorry.
|
|
|
|
qglPNTrianglesfATI = NULL;
|
|
|
|
qglPNTrianglesiATI = NULL;
|
|
|
|
|
2004-09-13 03:20:04 +00:00
|
|
|
//fragment programs
|
2005-04-19 21:09:29 +00:00
|
|
|
/* gl_config.arb_fragment_program = false;
|
2004-09-13 03:20:04 +00:00
|
|
|
qglProgramStringARB = NULL;
|
|
|
|
qglGetProgramivARB = NULL;
|
|
|
|
qglBindProgramARB = NULL;
|
|
|
|
qglGenProgramsARB = NULL;
|
2005-04-19 21:09:29 +00:00
|
|
|
*/
|
2004-09-13 03:20:04 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qglGenFramebuffersEXT = NULL;
|
|
|
|
qglDeleteFramebuffersEXT = NULL;
|
|
|
|
qglBindFramebufferEXT = NULL;
|
|
|
|
qglGenRenderbuffersEXT = NULL;
|
|
|
|
qglDeleteRenderbuffersEXT = NULL;
|
|
|
|
qglBindRenderbufferEXT = NULL;
|
|
|
|
qglRenderbufferStorageEXT = NULL;
|
|
|
|
qglFramebufferTexture2DEXT = NULL;
|
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
gl_config.arb_texture_non_power_of_two = false;
|
|
|
|
gl_config.sgis_generate_mipmap = false;
|
2004-10-10 06:32:29 +00:00
|
|
|
|
2004-11-23 01:23:45 +00:00
|
|
|
gl_config.tex_env_combine = false;
|
|
|
|
gl_config.env_add = false;
|
|
|
|
gl_config.nv_tex_env_combine4 = false;
|
|
|
|
|
|
|
|
gl_config.arb_texture_env_combine = false;
|
|
|
|
gl_config.arb_texture_env_dot3 = false;
|
|
|
|
gl_config.arb_texture_cube_map = false;
|
|
|
|
|
2005-01-04 23:34:42 +00:00
|
|
|
gl_config.arb_shader_objects = false;
|
2010-07-11 02:22:39 +00:00
|
|
|
gl_config.ext_framebuffer_objects = false;
|
2004-11-23 01:23:45 +00:00
|
|
|
|
2006-06-04 02:25:10 +00:00
|
|
|
gl_config.ext_texture_filter_anisotropic = 0;
|
2005-12-01 11:22:20 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_EXT_texture_filter_anisotropic"))
|
2005-12-01 11:22:20 +00:00
|
|
|
{
|
2006-06-04 02:25:10 +00:00
|
|
|
qglGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_config.ext_texture_filter_anisotropic);
|
2005-12-01 11:22:20 +00:00
|
|
|
|
2006-06-04 02:25:10 +00:00
|
|
|
Con_SafePrintf("Anisotropic filter extension found (%dx max).\n",gl_config.ext_texture_filter_anisotropic);
|
2005-12-01 11:22:20 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ARB_texture_non_power_of_two"))
|
2004-10-19 16:10:14 +00:00
|
|
|
gl_config.arb_texture_non_power_of_two = true;
|
2009-11-04 21:16:50 +00:00
|
|
|
// if (GL_CheckExtension("GL_SGIS_generate_mipmap")) //a suprising number of implementations have this broken.
|
2005-01-18 21:10:24 +00:00
|
|
|
// gl_config.sgis_generate_mipmap = true;
|
2004-10-10 06:32:29 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ARB_multitexture") && !COM_CheckParm("-noamtex"))
|
2004-08-22 22:29:09 +00:00
|
|
|
{ //ARB multitexture is the popular choice.
|
|
|
|
qglActiveTextureARB = (void *) getglext("glActiveTextureARB");
|
|
|
|
qglClientActiveTextureARB = (void *) getglext("glClientActiveTextureARB");
|
|
|
|
qglMultiTexCoord2fARB = (void *) getglext("glMultiTexCoord2fARB");
|
2005-09-09 23:40:55 +00:00
|
|
|
qglMultiTexCoord3fARB = (void *) getglext("glMultiTexCoord3fARB");
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-01-07 03:16:44 +00:00
|
|
|
qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &gl_mtexarbable);
|
2004-08-22 22:29:09 +00:00
|
|
|
gl_mtexable = true;
|
|
|
|
|
|
|
|
qglMTexCoord2fSGIS = qglMultiTexCoord2fARB;
|
|
|
|
qglSelectTextureSGIS = qglActiveTextureARB;
|
|
|
|
|
|
|
|
mtexid0 = GL_TEXTURE0_ARB;
|
|
|
|
mtexid1 = GL_TEXTURE1_ARB;
|
|
|
|
|
2005-05-21 01:33:58 +00:00
|
|
|
if (!qglActiveTextureARB || !qglClientActiveTextureARB || !qglMultiTexCoord2fARB)
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
qglActiveTextureARB = NULL;
|
2005-05-20 12:48:06 +00:00
|
|
|
qglClientActiveTextureARB = NULL;
|
2004-08-22 22:29:09 +00:00
|
|
|
qglMultiTexCoord2fARB = NULL;
|
|
|
|
qglMTexCoord2fSGIS = NULL;
|
|
|
|
qglSelectTextureSGIS = NULL;
|
|
|
|
gl_mtexable=false;
|
|
|
|
gl_mtexarbable = false;
|
|
|
|
}
|
2005-05-20 12:48:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Con_SafePrintf("ARB Multitexture extensions found. Use -noamtex to disable.\n");
|
|
|
|
}
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else if (GL_CheckExtension("GL_SGIS_multitexture") && !COM_CheckParm("-nomtex"))
|
2004-08-22 22:29:09 +00:00
|
|
|
{ //SGIS multitexture, limited in many ways but basic functionality is identical to ARB
|
|
|
|
Con_SafePrintf("Multitexture extensions found.\n");
|
|
|
|
qglMTexCoord2fSGIS = (void *) getglext("glMTexCoord2fSGIS");
|
|
|
|
qglSelectTextureSGIS = (void *) getglext("glSelectTextureSGIS");
|
|
|
|
gl_mtexable = true;
|
|
|
|
|
|
|
|
mtexid0 = GL_TEXTURE0_SGIS;
|
|
|
|
mtexid1 = GL_TEXTURE1_SGIS;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_EXT_stencil_wrap"))
|
2004-10-19 16:10:14 +00:00
|
|
|
gl_config.ext_stencil_wrap = true;
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ATI_separate_stencil"))
|
2004-08-22 22:29:09 +00:00
|
|
|
qglStencilOpSeparateATI = (void *) getglext("glStencilOpSeparateATI");
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_EXT_stencil_two_side"))
|
2004-08-22 22:29:09 +00:00
|
|
|
qglActiveStencilFaceEXT = (void *) getglext("glActiveStencilFaceEXT");
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ARB_texture_compression"))
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
qglCompressedTexImage2DARB = (void *)getglext("glCompressedTexImage2DARB");
|
|
|
|
qglGetCompressedTexImageARB = (void *)getglext("glGetCompressedTexImageARB");
|
|
|
|
|
|
|
|
if (!qglCompressedTexImage2DARB || !qglGetCompressedTexImageARB)
|
|
|
|
{
|
|
|
|
qglCompressedTexImage2DARB = NULL;
|
|
|
|
qglGetCompressedTexImageARB = NULL;
|
|
|
|
}
|
|
|
|
else
|
2004-10-19 16:10:14 +00:00
|
|
|
gl_config.arb_texture_compression = true;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ATI_pn_triangles"))
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
qglPNTrianglesfATI = (void *)getglext("glPNTrianglesfATI");
|
|
|
|
qglPNTrianglesiATI = (void *)getglext("glPNTrianglesiATI");
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_EXT_texture_object"))
|
2004-08-22 22:29:09 +00:00
|
|
|
{
|
|
|
|
bindTexFunc = (void *)getglext("glBindTextureEXT");
|
|
|
|
if (!bindTexFunc) //grrr
|
|
|
|
bindTexFunc = (void *)getglext("glBindTexture");
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_EXT_compiled_vertex_array"))
|
2004-10-28 07:07:44 +00:00
|
|
|
{
|
|
|
|
qglLockArraysEXT = (void *)getglext("glLockArraysEXT");
|
|
|
|
qglUnlockArraysEXT = (void *)getglext("glUnlockArraysEXT");
|
|
|
|
}
|
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
/*various combiner features*/
|
2009-11-04 21:16:50 +00:00
|
|
|
gl_config.tex_env_combine = GL_CheckExtension("GL_EXT_texture_env_combine");
|
|
|
|
gl_config.env_add = GL_CheckExtension("GL_EXT_texture_env_add");
|
|
|
|
gl_config.nv_tex_env_combine4 = GL_CheckExtension("GL_NV_texture_env_combine4");
|
|
|
|
gl_config.arb_texture_env_combine = GL_CheckExtension("GL_ARB_texture_env_combine");
|
|
|
|
gl_config.arb_texture_env_dot3 = GL_CheckExtension("GL_ARB_texture_env_dot3");
|
2004-10-19 16:10:14 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
gl_config.arb_texture_cube_map = GL_CheckExtension("GL_ARB_texture_cube_map");
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2004-10-19 16:10:14 +00:00
|
|
|
if (gl_mtexarbable && gl_config.arb_texture_cube_map && gl_config.arb_texture_env_combine && gl_config.arb_texture_env_dot3 && !COM_CheckParm("-nobump") && gl_bump.value)
|
2004-08-22 22:29:09 +00:00
|
|
|
gl_bumpmappingpossible = true;
|
2004-09-13 03:20:04 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
/*vbos*/
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ARB_vertex_buffer_object"))
|
2009-05-24 10:11:17 +00:00
|
|
|
{
|
|
|
|
qglGenBuffersARB = (void *)getglext("glGenBuffersARB");
|
|
|
|
qglDeleteBuffersARB = (void *)getglext("glDeleteBuffersARB");
|
|
|
|
qglBindBufferARB = (void *)getglext("glBindBufferARB");
|
|
|
|
qglBufferDataARB = (void *)getglext("glBufferDataARB");
|
|
|
|
qglBufferSubDataARB = (void *)getglext("glBufferSubDataARB");
|
2009-06-21 17:45:33 +00:00
|
|
|
qglMapBufferARB = (void *)getglext("glMapBufferARB");
|
|
|
|
qglUnmapBufferARB = (void *)getglext("glUnmapBufferARB");
|
2009-05-24 10:11:17 +00:00
|
|
|
}
|
|
|
|
|
2005-04-19 21:09:29 +00:00
|
|
|
/*
|
2009-11-04 21:16:50 +00:00
|
|
|
if (GL_CheckExtension("GL_ARB_fragment_program"))
|
2004-09-13 03:20:04 +00:00
|
|
|
{
|
2004-10-19 16:10:14 +00:00
|
|
|
gl_config.arb_fragment_program = true;
|
2004-09-13 03:20:04 +00:00
|
|
|
qglProgramStringARB = (void *)getglext("glProgramStringARB");
|
|
|
|
qglGetProgramivARB = (void *)getglext("glGetProgramivARB");
|
|
|
|
qglBindProgramARB = (void *)getglext("glBindProgramARB");
|
|
|
|
qglGenProgramsARB = (void *)getglext("glGenProgramsARB");
|
|
|
|
}
|
2005-04-19 21:09:29 +00:00
|
|
|
*/
|
2005-01-04 23:34:42 +00:00
|
|
|
|
|
|
|
// glslang
|
2005-02-28 07:16:19 +00:00
|
|
|
//the gf2 to gf4 cards emulate vertex_shader and thus supports shader_objects.
|
|
|
|
//but our code kinda requires both for clean workings.
|
2010-07-11 02:22:39 +00:00
|
|
|
if (GL_CheckExtension("GL_ARB_fragment_shader")
|
|
|
|
&& GL_CheckExtension("GL_ARB_vertex_shader")
|
|
|
|
&& GL_CheckExtension("GL_ARB_shader_objects"))
|
2005-01-04 23:34:42 +00:00
|
|
|
{
|
|
|
|
gl_config.arb_shader_objects = true;
|
|
|
|
qglCreateProgramObjectARB = (void *)getglext("glCreateProgramObjectARB");
|
|
|
|
qglDeleteObjectARB = (void *)getglext("glDeleteObjectARB");
|
|
|
|
qglUseProgramObjectARB = (void *)getglext("glUseProgramObjectARB");
|
|
|
|
qglCreateShaderObjectARB = (void *)getglext("glCreateShaderObjectARB");
|
|
|
|
qglShaderSourceARB = (void *)getglext("glShaderSourceARB");
|
|
|
|
qglCompileShaderARB = (void *)getglext("glCompileShaderARB");
|
|
|
|
qglGetObjectParameterivARB = (void *)getglext("glGetObjectParameterivARB");
|
|
|
|
qglAttachObjectARB = (void *)getglext("glAttachObjectARB");
|
|
|
|
qglGetInfoLogARB = (void *)getglext("glGetInfoLogARB");
|
|
|
|
qglLinkProgramARB = (void *)getglext("glLinkProgramARB");
|
|
|
|
qglGetUniformLocationARB = (void *)getglext("glGetUniformLocationARB");
|
2009-11-04 21:16:50 +00:00
|
|
|
qglUniformMatrix4fvARB = (void *)getglext("glUniformMatrix4fvARB");
|
2005-01-04 23:34:42 +00:00
|
|
|
qglUniform4fARB = (void *)getglext("glUniform4fARB");
|
2006-03-11 03:12:10 +00:00
|
|
|
qglUniform4fvARB = (void *)getglext("glUniform4fvARB");
|
2005-04-16 16:21:27 +00:00
|
|
|
qglUniform3fARB = (void *)getglext("glUniform3fARB");
|
|
|
|
qglUniform3fvARB = (void *)getglext("glUniform3fvARB");
|
2005-01-04 23:34:42 +00:00
|
|
|
qglUniform1iARB = (void *)getglext("glUniform1iARB");
|
|
|
|
qglUniform1fARB = (void *)getglext("glUniform1fARB");
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
|
2010-07-11 02:22:39 +00:00
|
|
|
if (GL_CheckExtension("GL_EXT_framebuffer_object"))
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
2010-07-11 02:22:39 +00:00
|
|
|
gl_config.ext_framebuffer_objects = true;
|
2009-11-04 21:16:50 +00:00
|
|
|
qglGenFramebuffersEXT = (void *)getglext("glGenFramebuffersEXT");
|
|
|
|
qglDeleteFramebuffersEXT = (void *)getglext("glDeleteFramebuffersEXT");
|
|
|
|
qglBindFramebufferEXT = (void *)getglext("glBindFramebufferEXT");
|
|
|
|
qglGenRenderbuffersEXT = (void *)getglext("glGenRenderbuffersEXT");
|
|
|
|
qglDeleteRenderbuffersEXT = (void *)getglext("glDeleteRenderbuffersEXT");
|
|
|
|
qglBindRenderbufferEXT = (void *)getglext("glBindRenderbufferEXT");
|
|
|
|
qglRenderbufferStorageEXT = (void *)getglext("glRenderbufferStorageEXT");
|
|
|
|
qglFramebufferTexture2DEXT = (void *)getglext("glFramebufferTexture2DEXT");
|
|
|
|
}
|
2005-01-04 23:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// glslang helper api function definitions
|
|
|
|
// type should be GL_FRAGMENT_SHADER_ARB or GL_VERTEX_SHADER_ARB
|
2005-04-16 16:21:27 +00:00
|
|
|
GLhandleARB GLSlang_CreateShader (char *precompilerconstants, char *shadersource, GLenum shadertype)
|
2005-01-04 23:34:42 +00:00
|
|
|
{
|
|
|
|
GLhandleARB shader;
|
|
|
|
GLint compiled;
|
|
|
|
char str[1024];
|
2009-11-17 00:15:44 +00:00
|
|
|
int loglen;
|
2005-01-04 23:34:42 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
char *prstrings[3];
|
2005-04-16 16:21:27 +00:00
|
|
|
if (!precompilerconstants)
|
|
|
|
precompilerconstants = "";
|
2009-07-05 18:45:53 +00:00
|
|
|
switch (shadertype)
|
|
|
|
{
|
|
|
|
case GL_FRAGMENT_SHADER_ARB:
|
|
|
|
prstrings[0] = "#define FRAGMENT_SHADER\n";
|
|
|
|
break;
|
|
|
|
case GL_VERTEX_SHADER_ARB:
|
|
|
|
prstrings[0] = "#define VERTEX_SHADER\n";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
prstrings[0] = "#define UNKNOWN_SHADER\n";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prstrings[1] = precompilerconstants;
|
|
|
|
prstrings[2] = shadersource;
|
2005-01-04 23:34:42 +00:00
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
shader = qglCreateShaderObjectARB(shadertype);
|
2005-01-04 23:34:42 +00:00
|
|
|
|
2009-07-05 18:45:53 +00:00
|
|
|
qglShaderSourceARB(shader, 3, (const GLcharARB**)prstrings, NULL);
|
2005-01-04 23:34:42 +00:00
|
|
|
qglCompileShaderARB(shader);
|
|
|
|
|
|
|
|
qglGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &compiled);
|
|
|
|
if(!compiled)
|
|
|
|
{
|
2009-11-17 00:15:44 +00:00
|
|
|
Con_DPrintf("Shader source:\n%s%s%s\n", prstrings[0], prstrings[1], prstrings[2]);
|
2005-01-04 23:34:42 +00:00
|
|
|
qglGetInfoLogARB(shader, sizeof(str), NULL, str);
|
2009-11-04 21:16:50 +00:00
|
|
|
qglDeleteObjectARB(shader);
|
2005-01-04 23:34:42 +00:00
|
|
|
switch (shadertype)
|
|
|
|
{
|
2005-04-16 16:21:27 +00:00
|
|
|
case GL_FRAGMENT_SHADER_ARB:
|
2005-01-04 23:34:42 +00:00
|
|
|
Con_Printf("Fragment shader compilation error:\n----------\n%s\n----------\n", str);
|
|
|
|
break;
|
2005-04-16 16:21:27 +00:00
|
|
|
case GL_VERTEX_SHADER_ARB:
|
2005-01-04 23:34:42 +00:00
|
|
|
Con_Printf("Vertex shader compilation error:\n----------\n%s\n----------\n", str);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Con_Printf("Shader_CreateShader: This shouldn't happen ever\n");
|
|
|
|
break;
|
|
|
|
}
|
2005-04-16 16:21:27 +00:00
|
|
|
return 0;
|
2005-01-04 23:34:42 +00:00
|
|
|
}
|
|
|
|
|
2009-11-17 00:15:44 +00:00
|
|
|
if (developer.ival)
|
|
|
|
{
|
|
|
|
qglGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &loglen);
|
|
|
|
if (loglen)
|
|
|
|
{
|
|
|
|
qglGetInfoLogARB(shader, sizeof(str), NULL, str);
|
|
|
|
if (strstr(str, "WARNING"))
|
|
|
|
{
|
|
|
|
Con_Printf("Shader source:\n%s%s%s\n", prstrings[0], prstrings[1], prstrings[2]);
|
|
|
|
Con_Printf("%s\n", str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-04 23:34:42 +00:00
|
|
|
return shader;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
GLhandleARB GLSlang_CreateProgramObject (GLhandleARB vert, GLhandleARB frag)
|
2005-01-04 23:34:42 +00:00
|
|
|
{
|
|
|
|
GLhandleARB program;
|
|
|
|
GLint linked;
|
|
|
|
char str[1024];
|
|
|
|
|
|
|
|
program = qglCreateProgramObjectARB();
|
|
|
|
qglAttachObjectARB(program, vert);
|
|
|
|
qglAttachObjectARB(program, frag);
|
|
|
|
|
|
|
|
qglLinkProgramARB(program);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
//flag the source objects for deletion, they'll only be deleted when they're no longer attached to anything
|
|
|
|
qglDeleteObjectARB(vert);
|
|
|
|
qglDeleteObjectARB(frag);
|
|
|
|
|
2005-01-04 23:34:42 +00:00
|
|
|
qglGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB, &linked);
|
|
|
|
|
|
|
|
if(!linked)
|
|
|
|
{
|
|
|
|
qglGetInfoLogARB(program, sizeof(str), NULL, str);
|
|
|
|
Con_Printf("Program link error: %s\n", str);
|
2005-02-28 07:16:19 +00:00
|
|
|
return (GLhandleARB)0;
|
2005-01-04 23:34:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return program;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:21:27 +00:00
|
|
|
GLhandleARB GLSlang_CreateProgram(char *precompilerconstants, char *vert, char *frag)
|
|
|
|
{
|
|
|
|
GLhandleARB vs;
|
|
|
|
GLhandleARB fs;
|
|
|
|
|
|
|
|
if (!gl_config.arb_shader_objects)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
vs = GLSlang_CreateShader(precompilerconstants, vert, GL_VERTEX_SHADER_ARB);
|
|
|
|
fs = GLSlang_CreateShader(precompilerconstants, frag, GL_FRAGMENT_SHADER_ARB);
|
|
|
|
if (!vs || !fs)
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
//delete ignores 0s.
|
|
|
|
qglDeleteObjectARB(vs);
|
|
|
|
qglDeleteObjectARB(fs);
|
2005-04-16 16:21:27 +00:00
|
|
|
return 0;
|
2009-11-04 21:16:50 +00:00
|
|
|
}
|
2005-04-16 16:21:27 +00:00
|
|
|
return GLSlang_CreateProgramObject(vs, fs);
|
|
|
|
}
|
|
|
|
|
2005-01-04 23:34:42 +00:00
|
|
|
GLint GLSlang_GetUniformLocation (int prog, char *name)
|
|
|
|
{
|
|
|
|
int i = qglGetUniformLocationARB(prog, name);
|
|
|
|
if (i == -1)
|
|
|
|
{
|
|
|
|
Con_Printf("Failed to get location of uniform '%s'\n", name);
|
|
|
|
}
|
|
|
|
return i;
|
2004-08-22 22:29:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//the vid routines have initialised a window, and now they are giving us a reference to some of of GetProcAddress to get pointers to the funcs.
|
|
|
|
void GL_Init(void *(*getglfunction) (char *name))
|
|
|
|
{
|
|
|
|
qglAlphaFunc = (void *)getglcore("glAlphaFunc");
|
|
|
|
qglBegin = (void *)getglcore("glBegin");
|
|
|
|
qglBlendFunc = (void *)getglcore("glBlendFunc");
|
|
|
|
bindTexFunc = (void *)getglcore("glBindTexture"); //for compleateness
|
|
|
|
qglClear = (void *)getglcore("glClear");
|
|
|
|
qglClearColor = (void *)getglcore("glClearColor");
|
|
|
|
qglClearDepth = (void *)getglcore("glClearDepth");
|
|
|
|
qglClearStencil = (void *)getglcore("glClearStencil");
|
2010-07-11 02:22:39 +00:00
|
|
|
qglClipPlane = (void *)getglcore("glClipPlane");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglColor3f = (void *)getglcore("glColor3f");
|
|
|
|
qglColor3ub = (void *)getglcore("glColor3ub");
|
|
|
|
qglColor4f = (void *)getglcore("glColor4f");
|
|
|
|
qglColor4fv = (void *)getglcore("glColor4fv");
|
|
|
|
qglColor4ub = (void *)getglcore("glColor4ub");
|
|
|
|
qglColor4ubv = (void *)getglcore("glColor4ubv");
|
|
|
|
qglColorMask = (void *)getglcore("glColorMask");
|
2005-01-12 22:15:50 +00:00
|
|
|
qglCopyTexImage2D = (void *)getglcore("glCopyTexImage2D");
|
2006-03-03 03:31:19 +00:00
|
|
|
qglCopyTexSubImage2D= (void *)getglcore("glCopyTexSubImage2D");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglCullFace = (void *)getglcore("glCullFace");
|
|
|
|
qglDepthFunc = (void *)getglcore("glDepthFunc");
|
|
|
|
qglDepthMask = (void *)getglcore("glDepthMask");
|
|
|
|
qglDepthRange = (void *)getglcore("glDepthRange");
|
|
|
|
qglDisable = (void *)getglcore("glDisable");
|
|
|
|
qglDrawBuffer = (void *)getglcore("glDrawBuffer");
|
|
|
|
qglDrawPixels = (void *)getglcore("glDrawPixels");
|
|
|
|
qglEnable = (void *)getglcore("glEnable");
|
|
|
|
qglEnd = (void *)getglcore("glEnd");
|
|
|
|
qglFinish = (void *)getglcore("glFinish");
|
|
|
|
qglFlush = (void *)getglcore("glFlush");
|
|
|
|
qglFrustum = (void *)getglcore("glFrustum");
|
2009-11-04 21:16:50 +00:00
|
|
|
qglGenTextures = (void *)getglcore("glGenTextures");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglGetFloatv = (void *)getglcore("glGetFloatv");
|
|
|
|
qglGetIntegerv = (void *)getglcore("glGetIntegerv");
|
|
|
|
qglGetString = (void *)getglcore("glGetString");
|
|
|
|
qglGetTexLevelParameteriv = (void *)getglcore("glGetTexLevelParameteriv");
|
|
|
|
qglHint = (void *)getglcore("glHint");
|
|
|
|
qglLoadIdentity = (void *)getglcore("glLoadIdentity");
|
|
|
|
qglLoadMatrixf = (void *)getglcore("glLoadMatrixf");
|
|
|
|
qglNormal3f = (void *)getglcore("glNormal3f");
|
|
|
|
qglNormal3fv = (void *)getglcore("glNormal3fv");
|
|
|
|
qglMatrixMode = (void *)getglcore("glMatrixMode");
|
|
|
|
qglMultMatrixf = (void *)getglcore("glMultMatrixf");
|
|
|
|
qglOrtho = (void *)getglcore("glOrtho");
|
|
|
|
qglPolygonMode = (void *)getglcore("glPolygonMode");
|
|
|
|
qglPopMatrix = (void *)getglcore("glPopMatrix");
|
|
|
|
qglPushMatrix = (void *)getglcore("glPushMatrix");
|
|
|
|
qglReadBuffer = (void *)getglcore("glReadBuffer");
|
|
|
|
qglReadPixels = (void *)getglcore("glReadPixels");
|
|
|
|
qglRotatef = (void *)getglcore("glRotatef");
|
|
|
|
qglScalef = (void *)getglcore("glScalef");
|
|
|
|
qglShadeModel = (void *)getglcore("glShadeModel");
|
|
|
|
qglTexCoord1f = (void *)getglcore("glTexCoord1f");
|
|
|
|
qglTexCoord2f = (void *)getglcore("glTexCoord2f");
|
|
|
|
qglTexCoord2fv = (void *)getglcore("glTexCoord2fv");
|
|
|
|
qglTexEnvf = (void *)getglcore("glTexEnvf");
|
2004-09-13 03:20:04 +00:00
|
|
|
qglTexEnvfv = (void *)getglcore("glTexEnvfv");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglTexEnvi = (void *)getglcore("glTexEnvi");
|
|
|
|
qglTexGeni = (void *)getglcore("glTexGeni");
|
2009-07-05 18:45:53 +00:00
|
|
|
qglTexGenfv = (void *)getglcore("glTexGenfv");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglTexImage2D = (void *)getglcore("glTexImage2D");
|
|
|
|
qglTexParameteri = (void *)getglcore("glTexParameteri");
|
|
|
|
qglTexParameterf = (void *)getglcore("glTexParameterf");
|
2006-06-15 21:40:54 +00:00
|
|
|
qglTexParameteriv = (void *)getglcore("glTexParameteriv");
|
|
|
|
qglTexParameterfv = (void *)getglcore("glTexParameterfv");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglTexSubImage2D = (void *)getglcore("glTexSubImage2D");
|
|
|
|
qglTranslatef = (void *)getglcore("glTranslatef");
|
|
|
|
qglVertex2f = (void *)getglcore("glVertex2f");
|
|
|
|
qglVertex3f = (void *)getglcore("glVertex3f");
|
|
|
|
qglVertex3fv = (void *)getglcore("glVertex3fv");
|
|
|
|
qglViewport = (void *)getglcore("glViewport");
|
|
|
|
|
2004-09-13 03:20:04 +00:00
|
|
|
qglGetError = (void *)getglcore("glGetError");
|
2008-11-09 22:29:28 +00:00
|
|
|
qglDeleteTextures = (void *)getglcore("glDeleteTextures");
|
2004-09-13 03:20:04 +00:00
|
|
|
|
|
|
|
//various vertex array stuff.
|
2004-08-22 22:29:09 +00:00
|
|
|
qglDrawElements = (void *)getglcore("glDrawElements");
|
2004-10-19 16:10:14 +00:00
|
|
|
qglArrayElement = (void *)getglcore("glArrayElement");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglVertexPointer = (void *)getglcore("glVertexPointer");
|
|
|
|
qglNormalPointer = (void *)getglcore("glNormalPointer");
|
|
|
|
qglTexCoordPointer = (void *)getglcore("glTexCoordPointer");
|
|
|
|
qglColorPointer = (void *)getglcore("glColorPointer");
|
2004-09-13 03:20:04 +00:00
|
|
|
qglDrawArrays = (void *)getglcore("glDrawArrays");
|
2004-08-22 22:29:09 +00:00
|
|
|
qglEnableClientState = (void *)getglcore("glEnableClientState");
|
|
|
|
qglDisableClientState = (void *)getglcore("glDisableClientState");
|
|
|
|
|
2005-05-13 10:42:48 +00:00
|
|
|
qglDrawRangeElements = (void *)getglext("glDrawRangeElements");
|
2005-05-21 01:33:58 +00:00
|
|
|
if (qglDrawRangeElements == 0)
|
|
|
|
qglDrawRangeElements = GL_DrawRangeElementsEmul;
|
2005-05-13 10:42:48 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
//fixme: definatly make non-core
|
|
|
|
qglStencilOp = (void *)getglcore("glStencilOp");
|
|
|
|
qglStencilFunc = (void *)getglcore("glStencilFunc");
|
|
|
|
qglPushAttrib = (void *)getglcore("glPushAttrib");
|
|
|
|
qglPopAttrib = (void *)getglcore("glPopAttrib");
|
2004-10-26 14:55:41 +00:00
|
|
|
qglScissor = (void *)getglcore("glScissor");
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2006-06-02 17:42:36 +00:00
|
|
|
//does this need to be non-core as well?
|
|
|
|
qglFogi = (void *)getglcore("glFogi");
|
|
|
|
qglFogf = (void *)getglcore("glFogf");
|
|
|
|
qglFogfv = (void *)getglcore("glFogfv");
|
|
|
|
|
2004-12-11 16:45:38 +00:00
|
|
|
qglPolygonOffset = (void *)getglext("glPolygonOffset");
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qglGetStringi = (void *)getglext("glGetStringi");
|
|
|
|
|
2005-09-09 23:40:55 +00:00
|
|
|
//used by heightmaps
|
|
|
|
qglGenLists = (void*)getglcore("glGenLists");
|
|
|
|
qglNewList = (void*)getglcore("glNewList");
|
|
|
|
qglEndList = (void*)getglcore("glEndList");
|
|
|
|
qglCallList = (void*)getglcore("glCallList");
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-07-11 18:23:07 +00:00
|
|
|
qglBindBufferARB = (void *)getglext("qglBindBufferARB");
|
|
|
|
if (!qglBindBufferARB)
|
|
|
|
qglBindBufferARB = (void *)getglext("qglBindBuffer");
|
|
|
|
if (!qglBindBufferARB)
|
|
|
|
qglBindBufferARB = GL_BindBufferARBStub;
|
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-01-07 03:16:44 +00:00
|
|
|
gl_vendor = qglGetString (GL_VENDOR);
|
2004-08-22 22:29:09 +00:00
|
|
|
Con_SafePrintf ("GL_VENDOR: %s\n", gl_vendor);
|
2005-01-07 03:16:44 +00:00
|
|
|
gl_renderer = qglGetString (GL_RENDERER);
|
2004-08-22 22:29:09 +00:00
|
|
|
Con_SafePrintf ("GL_RENDERER: %s\n", gl_renderer);
|
|
|
|
|
2005-01-07 03:16:44 +00:00
|
|
|
gl_version = qglGetString (GL_VERSION);
|
2004-08-22 22:29:09 +00:00
|
|
|
Con_SafePrintf ("GL_VERSION: %s\n", gl_version);
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
if (qglGetError())
|
|
|
|
Con_Printf("glGetError %s:%i\n", __FILE__, __LINE__);
|
|
|
|
qglGetIntegerv(GL_MAJOR_VERSION, &gl_major_version);
|
|
|
|
qglGetIntegerv(GL_MINOR_VERSION, &gl_minor_version);
|
|
|
|
if (qglGetError())
|
|
|
|
{
|
|
|
|
gl_major_version = 1;
|
|
|
|
gl_minor_version = 1;
|
|
|
|
}
|
|
|
|
qglGetIntegerv(GL_NUM_EXTENSIONS, &gl_num_extensions);
|
|
|
|
if (!qglGetError())
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (developer.value)
|
|
|
|
{
|
|
|
|
Con_DPrintf ("GL_EXTENSIONS:");
|
|
|
|
for (i = 0; i < gl_num_extensions; i++)
|
|
|
|
Con_DPrintf (" %s", qglGetStringi(GL_EXTENSIONS, i));
|
|
|
|
Con_DPrintf ("\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Con_Printf ("GL_EXTENSIONS: %i extensions\n", gl_num_extensions);
|
|
|
|
gl_extensions = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gl_num_extensions = 0;
|
|
|
|
gl_extensions = qglGetString (GL_EXTENSIONS);
|
|
|
|
Con_DPrintf ("GL_EXTENSIONS: %s\n", gl_extensions);
|
|
|
|
|
|
|
|
if (!gl_extensions)
|
|
|
|
Sys_Error("no extensions\n");
|
|
|
|
}
|
2005-04-18 17:12:18 +00:00
|
|
|
|
2004-08-22 22:29:09 +00:00
|
|
|
GL_CheckExtensions (getglfunction);
|
|
|
|
|
2005-01-07 03:16:44 +00:00
|
|
|
qglClearColor (0,0,0,0); //clear to black so that it looks a little nicer on start.
|
|
|
|
qglClear(GL_COLOR_BUFFER_BIT);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2005-01-07 03:16:44 +00:00
|
|
|
qglPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
|
|
|
|
qglShadeModel (GL_FLAT);
|
2004-08-22 22:29:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
|
|
|
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
|
|
|
}
|
2009-06-21 17:45:33 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
unsigned int d_8to24rgbtable[256];
|
2004-08-22 22:29:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
rendererinfo_t openglrendererinfo = {
|
|
|
|
"OpenGL",
|
|
|
|
{
|
|
|
|
"gl",
|
|
|
|
"opengl",
|
|
|
|
"hardware",
|
|
|
|
},
|
|
|
|
QR_OPENGL,
|
|
|
|
|
|
|
|
|
|
|
|
R2D_SafePicFromWad,
|
|
|
|
R2D_SafeCachePic,
|
|
|
|
GLDraw_Init,
|
|
|
|
GLDraw_ReInit,
|
|
|
|
GLDraw_Crosshair,
|
|
|
|
R2D_ScalePic,
|
|
|
|
R2D_SubPic,
|
|
|
|
GLDraw_TransPicTranslate,
|
|
|
|
R2D_ConsoleBackground,
|
|
|
|
R2D_EditorBackground,
|
|
|
|
R2D_TileClear,
|
|
|
|
GLDraw_Fill,
|
|
|
|
GLDraw_FillRGB,
|
|
|
|
GLDraw_FadeScreen,
|
|
|
|
GLDraw_BeginDisc,
|
|
|
|
GLDraw_EndDisc,
|
|
|
|
|
|
|
|
R2D_Image,
|
|
|
|
R2D_ImageColours,
|
|
|
|
|
|
|
|
GLR_Init,
|
|
|
|
GLR_DeInit,
|
|
|
|
GLR_RenderView,
|
|
|
|
|
|
|
|
|
|
|
|
GLR_NewMap,
|
|
|
|
GLR_PreNewMap,
|
|
|
|
GLR_LightPoint,
|
|
|
|
GLR_PushDlights,
|
|
|
|
|
|
|
|
|
2009-11-07 13:29:15 +00:00
|
|
|
Surf_AddStain,
|
|
|
|
Surf_LessenStains,
|
2009-11-04 21:16:50 +00:00
|
|
|
|
|
|
|
RMod_Init,
|
|
|
|
RMod_ClearAll,
|
|
|
|
RMod_ForName,
|
|
|
|
RMod_FindName,
|
|
|
|
RMod_Extradata,
|
|
|
|
RMod_TouchModel,
|
|
|
|
|
|
|
|
RMod_NowLoadExternal,
|
|
|
|
RMod_Think,
|
|
|
|
|
|
|
|
Mod_GetTag,
|
|
|
|
Mod_TagNumForName,
|
|
|
|
Mod_SkinNumForName,
|
|
|
|
Mod_FrameNumForName,
|
|
|
|
Mod_FrameDuration,
|
|
|
|
|
|
|
|
GLVID_Init,
|
|
|
|
GLVID_DeInit,
|
|
|
|
GLVID_LockBuffer,
|
|
|
|
GLVID_UnlockBuffer,
|
|
|
|
GLD_BeginDirectRect,
|
|
|
|
GLD_EndDirectRect,
|
|
|
|
GLVID_ForceLockState,
|
|
|
|
GLVID_ForceUnlockedAndReturnState,
|
|
|
|
GLVID_SetPalette,
|
|
|
|
GLVID_ShiftPalette,
|
|
|
|
GLVID_GetRGBInfo,
|
|
|
|
|
|
|
|
GLVID_SetCaption, //setcaption
|
|
|
|
|
|
|
|
|
|
|
|
GLSCR_UpdateScreen,
|
|
|
|
|
|
|
|
""
|
|
|
|
};
|
|
|
|
|
2004-12-15 19:53:30 +00:00
|
|
|
#endif
|