mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 06:31:47 +00:00
Don't load non-core GL functions for OpenGL 3.2 core context
Also declare the GL functions in tr_local.h so there is compile error for non-core GL functions instead of SEGFAULT from dereferencing a NULL pointer. Disable the non-functional stencil shadow code that hasn't been updated to use OpenGL 3.2 core compatible drawing.
This commit is contained in:
parent
255c33b367
commit
7391215bd4
5 changed files with 74 additions and 27 deletions
|
@ -45,27 +45,22 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
|
|||
// GL function loader, based on https://gist.github.com/rygorous/16796a0c876cf8a5f542caddb55bce8a
|
||||
// get missing functions from code/SDL2/include/SDL_opengl.h
|
||||
|
||||
// OpenGL 1.0/1.1 and OpenGL ES 1.0
|
||||
// OpenGL 1.0/1.1, OpenGL ES 1.0, and OpenGL 3.2 core profile
|
||||
#define QGL_1_1_PROCS \
|
||||
GLE(void, AlphaFunc, GLenum func, GLclampf ref) \
|
||||
GLE(void, BindTexture, GLenum target, GLuint texture) \
|
||||
GLE(void, BlendFunc, GLenum sfactor, GLenum dfactor) \
|
||||
GLE(void, ClearColor, GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) \
|
||||
GLE(void, Clear, GLbitfield mask) \
|
||||
GLE(void, ClearStencil, GLint s) \
|
||||
GLE(void, Color4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) \
|
||||
GLE(void, ColorMask, GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) \
|
||||
GLE(void, ColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
|
||||
GLE(void, CopyTexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) \
|
||||
GLE(void, CullFace, GLenum mode) \
|
||||
GLE(void, DeleteTextures, GLsizei n, const GLuint *textures) \
|
||||
GLE(void, DepthFunc, GLenum func) \
|
||||
GLE(void, DepthMask, GLboolean flag) \
|
||||
GLE(void, DisableClientState, GLenum cap) \
|
||||
GLE(void, Disable, GLenum cap) \
|
||||
GLE(void, DrawArrays, GLenum mode, GLint first, GLsizei count) \
|
||||
GLE(void, DrawElements, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices) \
|
||||
GLE(void, EnableClientState, GLenum cap) \
|
||||
GLE(void, Enable, GLenum cap) \
|
||||
GLE(void, Finish, void) \
|
||||
GLE(void, Flush, void) \
|
||||
|
@ -75,42 +70,53 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
|
|||
GLE(void, GetIntegerv, GLenum pname, GLint *params) \
|
||||
GLE(const GLubyte *, GetString, GLenum name) \
|
||||
GLE(void, LineWidth, GLfloat width) \
|
||||
GLE(void, LoadIdentity, void) \
|
||||
GLE(void, LoadMatrixf, const GLfloat *m) \
|
||||
GLE(void, MatrixMode, GLenum mode) \
|
||||
GLE(void, PolygonOffset, GLfloat factor, GLfloat units) \
|
||||
GLE(void, PopMatrix, void) \
|
||||
GLE(void, PushMatrix, void) \
|
||||
GLE(void, ReadPixels, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) \
|
||||
GLE(void, Scissor, GLint x, GLint y, GLsizei width, GLsizei height) \
|
||||
GLE(void, ShadeModel, GLenum mode) \
|
||||
GLE(void, StencilFunc, GLenum func, GLint ref, GLuint mask) \
|
||||
GLE(void, StencilMask, GLuint mask) \
|
||||
GLE(void, StencilOp, GLenum fail, GLenum zfail, GLenum zpass) \
|
||||
GLE(void, TexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
|
||||
GLE(void, TexEnvf, GLenum target, GLenum pname, GLfloat param) \
|
||||
GLE(void, TexImage2D, GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) \
|
||||
GLE(void, TexParameterf, GLenum target, GLenum pname, GLfloat param) \
|
||||
GLE(void, TexParameteri, GLenum target, GLenum pname, GLint param) \
|
||||
GLE(void, TexSubImage2D, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) \
|
||||
GLE(void, Translatef, GLfloat x, GLfloat y, GLfloat z) \
|
||||
GLE(void, VertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
|
||||
GLE(void, Viewport, GLint x, GLint y, GLsizei width, GLsizei height) \
|
||||
|
||||
// OpenGL 1.0/1.1 but not OpenGL ES 1.x
|
||||
// OpenGL 1.0/1.1 and OpenGL ES 1.x but not OpenGL 3.2 core profile
|
||||
#define QGL_1_1_FIXED_FUNCTION_PROCS \
|
||||
GLE(void, AlphaFunc, GLenum func, GLclampf ref) \
|
||||
GLE(void, Color4f, GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) \
|
||||
GLE(void, ColorPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
|
||||
GLE(void, DisableClientState, GLenum cap) \
|
||||
GLE(void, EnableClientState, GLenum cap) \
|
||||
GLE(void, LoadIdentity, void) \
|
||||
GLE(void, LoadMatrixf, const GLfloat *m) \
|
||||
GLE(void, MatrixMode, GLenum mode) \
|
||||
GLE(void, PopMatrix, void) \
|
||||
GLE(void, PushMatrix, void) \
|
||||
GLE(void, ShadeModel, GLenum mode) \
|
||||
GLE(void, TexCoordPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
|
||||
GLE(void, TexEnvf, GLenum target, GLenum pname, GLfloat param) \
|
||||
GLE(void, VertexPointer, GLint size, GLenum type, GLsizei stride, const GLvoid *ptr) \
|
||||
|
||||
// OpenGL 1.0/1.1 and 3.2 core profile but not OpenGL ES 1.x
|
||||
#define QGL_DESKTOP_1_1_PROCS \
|
||||
GLE(void, ClearDepth, GLclampd depth) \
|
||||
GLE(void, DepthRange, GLclampd near_val, GLclampd far_val) \
|
||||
GLE(void, DrawBuffer, GLenum mode) \
|
||||
GLE(void, PolygonMode, GLenum face, GLenum mode) \
|
||||
|
||||
// OpenGL 1.0/1.1 but not OpenGL 3.2 core profile or OpenGL ES 1.x
|
||||
#define QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS \
|
||||
GLE(void, ArrayElement, GLint i) \
|
||||
GLE(void, Begin, GLenum mode) \
|
||||
GLE(void, ClearDepth, GLclampd depth) \
|
||||
GLE(void, ClipPlane, GLenum plane, const GLdouble *equation) \
|
||||
GLE(void, Color3f, GLfloat red, GLfloat green, GLfloat blue) \
|
||||
GLE(void, Color4ubv, const GLubyte *v) \
|
||||
GLE(void, DepthRange, GLclampd near_val, GLclampd far_val) \
|
||||
GLE(void, DrawBuffer, GLenum mode) \
|
||||
GLE(void, End, void) \
|
||||
GLE(void, Frustum, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) \
|
||||
GLE(void, Ortho, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val) \
|
||||
GLE(void, PolygonMode, GLenum face, GLenum mode) \
|
||||
GLE(void, TexCoord2f, GLfloat s, GLfloat t) \
|
||||
GLE(void, TexCoord2fv, const GLfloat *v) \
|
||||
GLE(void, Vertex2f, GLfloat x, GLfloat y) \
|
||||
|
@ -301,9 +307,11 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
|
|||
GLE(GLvoid, NamedFramebufferTexture2DEXT, GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \
|
||||
GLE(GLvoid, NamedFramebufferRenderbufferEXT, GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \
|
||||
|
||||
#define GLE(ret, name, ...) typedef ret APIENTRY name##proc(__VA_ARGS__); extern name##proc * qgl##name;
|
||||
#define GLE(ret, name, ...) typedef ret APIENTRY name##proc(__VA_ARGS__);
|
||||
QGL_1_1_PROCS;
|
||||
QGL_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_ES_1_1_PROCS;
|
||||
QGL_1_3_PROCS;
|
||||
QGL_1_5_PROCS;
|
||||
|
|
|
@ -32,6 +32,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../renderercommon/iqm.h"
|
||||
#include "../renderercommon/qgl.h"
|
||||
|
||||
#define GLE(ret, name, ...) extern name##proc * qgl##name;
|
||||
QGL_1_1_PROCS;
|
||||
QGL_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_3_0_PROCS;
|
||||
#undef GLE
|
||||
|
||||
#define GL_INDEX_TYPE GL_UNSIGNED_INT
|
||||
typedef unsigned int glIndex_t;
|
||||
|
||||
|
|
|
@ -36,6 +36,18 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../renderercommon/iqm.h"
|
||||
#include "../renderercommon/qgl.h"
|
||||
|
||||
#define GLE(ret, name, ...) extern name##proc * qgl##name;
|
||||
QGL_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
QGL_1_3_PROCS;
|
||||
QGL_1_5_PROCS;
|
||||
QGL_2_0_PROCS;
|
||||
QGL_3_0_PROCS;
|
||||
QGL_ARB_framebuffer_object_PROCS;
|
||||
QGL_ARB_vertex_array_object_PROCS;
|
||||
QGL_EXT_direct_state_access_PROCS;
|
||||
#undef GLE
|
||||
|
||||
#define GL_INDEX_TYPE GL_UNSIGNED_INT
|
||||
typedef unsigned int glIndex_t;
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ typedef struct {
|
|||
|
||||
static edgeDef_t edgeDefs[SHADER_MAX_VERTEXES][MAX_EDGE_DEFS];
|
||||
static int numEdgeDefs[SHADER_MAX_VERTEXES];
|
||||
static int facing[SHADER_MAX_INDEXES/3];
|
||||
static vec3_t shadowXyz[SHADER_MAX_VERTEXES];
|
||||
//static int facing[SHADER_MAX_INDEXES/3];
|
||||
//static vec3_t shadowXyz[SHADER_MAX_VERTEXES];
|
||||
|
||||
void R_AddEdgeDef( int i1, int i2, int facing ) {
|
||||
int c;
|
||||
|
@ -60,6 +60,8 @@ void R_AddEdgeDef( int i1, int i2, int facing ) {
|
|||
}
|
||||
|
||||
void R_RenderShadowEdges( void ) {
|
||||
// FIXME: implement this
|
||||
#if 0
|
||||
int i;
|
||||
|
||||
#if 0
|
||||
|
@ -138,6 +140,7 @@ void R_RenderShadowEdges( void ) {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -153,6 +156,8 @@ triangleFromEdge[ v1 ][ v2 ]
|
|||
=================
|
||||
*/
|
||||
void RB_ShadowTessEnd( void ) {
|
||||
// FIXME: implement this
|
||||
#if 0
|
||||
int i;
|
||||
int numTris;
|
||||
vec3_t lightDir;
|
||||
|
@ -230,6 +235,7 @@ void RB_ShadowTessEnd( void ) {
|
|||
|
||||
// reenable writing to the color buffer
|
||||
qglColorMask(rgba[0], rgba[1], rgba[2], rgba[3]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,6 +250,8 @@ overlap and double darken.
|
|||
=================
|
||||
*/
|
||||
void RB_ShadowFinish( void ) {
|
||||
// FIXME: implement this
|
||||
#if 0
|
||||
if ( r_shadows->integer != 2 ) {
|
||||
return;
|
||||
}
|
||||
|
@ -275,6 +283,7 @@ void RB_ShadowFinish( void ) {
|
|||
|
||||
qglColor4f(1,1,1,1);
|
||||
qglDisable( GL_STENCIL_TEST );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -65,7 +65,9 @@ void (APIENTRYP qglUnlockArraysEXT) (void);
|
|||
|
||||
#define GLE(ret, name, ...) name##proc * qgl##name;
|
||||
QGL_1_1_PROCS;
|
||||
QGL_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_ES_1_1_PROCS;
|
||||
QGL_3_0_PROCS;
|
||||
#undef GLE
|
||||
|
@ -227,7 +229,7 @@ GLimp_GetProcAddresses
|
|||
Get addresses for OpenGL functions.
|
||||
===============
|
||||
*/
|
||||
static qboolean GLimp_GetProcAddresses( void ) {
|
||||
static qboolean GLimp_GetProcAddresses( qboolean coreContext ) {
|
||||
qboolean success = qtrue;
|
||||
const char *version;
|
||||
|
||||
|
@ -266,12 +268,18 @@ static qboolean GLimp_GetProcAddresses( void ) {
|
|||
sscanf( version, "%d.%d", &qglMajorVersion, &qglMinorVersion );
|
||||
}
|
||||
|
||||
if ( QGL_VERSION_ATLEAST( 1, 2 ) ) {
|
||||
if ( coreContext && QGL_VERSION_ATLEAST( 3, 2 ) ) {
|
||||
QGL_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
} else if ( QGL_VERSION_ATLEAST( 1, 2 ) ) {
|
||||
QGL_1_1_PROCS;
|
||||
QGL_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
|
||||
} else if ( qglesMajorVersion == 1 && qglesMinorVersion >= 1 ) {
|
||||
// OpenGL ES 1.1 (2.0 is not backward compatible)
|
||||
QGL_1_1_PROCS;
|
||||
QGL_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_ES_1_1_PROCS;
|
||||
// error so this doesn't segfault due to NULL desktop GL functions being used
|
||||
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version );
|
||||
|
@ -304,7 +312,9 @@ static void GLimp_ClearProcAddresses( void ) {
|
|||
qglesMinorVersion = 0;
|
||||
|
||||
QGL_1_1_PROCS;
|
||||
QGL_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_DESKTOP_1_1_PROCS;
|
||||
QGL_DESKTOP_1_1_FIXED_FUNCTION_PROCS;
|
||||
QGL_ES_1_1_PROCS;
|
||||
QGL_3_0_PROCS;
|
||||
|
||||
|
@ -613,7 +623,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
|
||||
ri.Printf(PRINT_ALL, "SDL_GL_CreateContext succeeded.\n");
|
||||
|
||||
if ( GLimp_GetProcAddresses() )
|
||||
if ( GLimp_GetProcAddresses( qtrue ) )
|
||||
{
|
||||
renderer = (const char *)qglGetString(GL_RENDERER);
|
||||
}
|
||||
|
@ -653,7 +663,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( !GLimp_GetProcAddresses() )
|
||||
if ( !GLimp_GetProcAddresses( qfalse ) )
|
||||
{
|
||||
ri.Printf( PRINT_ALL, "GLimp_GetProcAddresses() failed\n" );
|
||||
GLimp_ClearProcAddresses();
|
||||
|
|
Loading…
Reference in a new issue