OpenGL2: Use loader for all extension funcs.

This commit is contained in:
SmileTheory 2016-07-26 00:41:31 -07:00
parent 2ef99c8528
commit 716438168f
9 changed files with 158 additions and 288 deletions

View file

@ -438,14 +438,6 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
GLE(void, ValidateProgram, GLuint program) \
GLE(void, VertexAttribPointer, GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer) \
#define GLE(ret, name, ...) typedef ret APIENTRY name##proc(__VA_ARGS__); extern name##proc * qgl##name;
QGL_1_2_PROCS
QGL_1_3_PROCS
QGL_1_4_PROCS
QGL_1_5_PROCS
QGL_2_0_PROCS
#undef GLE
// GL_NVX_gpu_memory_info
#ifndef GL_NVX_gpu_memory_info
#define GL_NVX_gpu_memory_info
@ -495,27 +487,18 @@ QGL_2_0_PROCS
#endif
// GL_EXT_framebuffer_object
extern GLboolean (APIENTRY * qglIsRenderbufferEXT)(GLuint renderbuffer);
extern void (APIENTRY * qglBindRenderbufferEXT)(GLenum target, GLuint renderbuffer);
extern void (APIENTRY * qglDeleteRenderbuffersEXT)(GLsizei n, const GLuint *renderbuffers);
extern void (APIENTRY * qglGenRenderbuffersEXT)(GLsizei n, GLuint *renderbuffers);
extern void (APIENTRY * qglRenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
extern void (APIENTRY * qglGetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint *params);
extern GLboolean (APIENTRY * qglIsFramebufferEXT)(GLuint framebuffer);
extern void (APIENTRY * qglBindFramebufferEXT)(GLenum target, GLuint framebuffer);
extern void (APIENTRY * qglDeleteFramebuffersEXT)(GLsizei n, const GLuint *framebuffers);
extern void (APIENTRY * qglGenFramebuffersEXT)(GLsizei n, GLuint *framebuffers);
extern GLenum (APIENTRY * qglCheckFramebufferStatusEXT)(GLenum target);
extern void (APIENTRY * qglFramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level);
extern void (APIENTRY * qglFramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level);
extern void (APIENTRY * qglFramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level, GLint zoffset);
extern void (APIENTRY * qglFramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint renderbuffer);
extern void (APIENTRY * qglGetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint *params);
extern void (APIENTRY * qglGenerateMipmapEXT)(GLenum target);
#define QGL_EXT_framebuffer_object_PROCS \
GLE(void, BindRenderbufferEXT, GLenum target, GLuint renderbuffer) \
GLE(void, DeleteRenderbuffersEXT, GLsizei n, const GLuint *renderbuffers) \
GLE(void, GenRenderbuffersEXT, GLsizei n, GLuint *renderbuffers) \
GLE(void, RenderbufferStorageEXT, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) \
GLE(void, BindFramebufferEXT, GLenum target, GLuint framebuffer) \
GLE(void, DeleteFramebuffersEXT, GLsizei n, const GLuint *framebuffers) \
GLE(void, GenFramebuffersEXT, GLsizei n, GLuint *framebuffers) \
GLE(GLenum, CheckFramebufferStatusEXT, GLenum target) \
GLE(void, FramebufferTexture2DEXT, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \
GLE(void, FramebufferRenderbufferEXT, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \
GLE(void, GenerateMipmapEXT, GLenum target) \
#ifndef GL_EXT_framebuffer_object
#define GL_EXT_framebuffer_object
@ -572,19 +555,9 @@ extern void (APIENTRY * qglGenerateMipmapEXT)(GLenum target);
#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
#endif
// GL_EXT_packed_depth_stencil
#ifndef GL_EXT_packed_depth_stencil
#define GL_EXT_packed_depth_stencil
#define GL_DEPTH_STENCIL_EXT 0x84F9
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
#endif
// GL_EXT_framebuffer_blit
extern void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
#define QGL_EXT_framebuffer_blit_PROCS \
GLE(void, BlitFramebufferEXT, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) \
#ifndef GL_EXT_framebuffer_blit
#define GL_EXT_framebuffer_blit
@ -595,8 +568,8 @@ extern void (APIENTRY * qglBlitFramebufferEXT)(GLint srcX0, GLint srcY0, GLint s
#endif
// GL_EXT_framebuffer_multisample
extern void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height);
#define QGL_EXT_framebuffer_multisample_PROCS \
GLE(void, RenderbufferStorageMultisampleEXT, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) \
#ifndef GL_EXT_framebuffer_multisample
#define GL_EXT_framebuffer_multisample
@ -605,31 +578,6 @@ extern void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLs
#define GL_MAX_SAMPLES_EXT 0x8D57
#endif
#ifndef GL_EXT_texture_sRGB
#define GL_EXT_texture_sRGB
#define GL_SRGB_EXT 0x8C40
#define GL_SRGB8_EXT 0x8C41
#define GL_SRGB_ALPHA_EXT 0x8C42
#define GL_SRGB8_ALPHA8_EXT 0x8C43
#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
#define GL_SLUMINANCE_EXT 0x8C46
#define GL_SLUMINANCE8_EXT 0x8C47
#define GL_COMPRESSED_SRGB_EXT 0x8C48
#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
#endif
#ifndef GL_EXT_framebuffer_sRGB
#define GL_EXT_framebuffer_sRGB
#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
#endif
#ifndef GL_ARB_texture_compression_rgtc
#define GL_ARB_texture_compression_rgtc
#define GL_COMPRESSED_RED_RGTC1 0x8DBB
@ -657,91 +605,51 @@ extern void (APIENTRY * qglRenderbufferStorageMultisampleEXT)(GLenum target, GLs
#endif
// GL_ARB_vertex_array_object
extern void (APIENTRY * qglBindVertexArrayARB)(GLuint array);
extern void (APIENTRY * qglDeleteVertexArraysARB)(GLsizei n, const GLuint *arrays);
extern void (APIENTRY * qglGenVertexArraysARB)(GLsizei n, GLuint *arrays);
extern GLboolean (APIENTRY * qglIsVertexArrayARB)(GLuint array);
#define QGL_ARB_vertex_array_object_PROCS \
GLE(void, BindVertexArray, GLuint array) \
GLE(void, DeleteVertexArrays, GLsizei n, const GLuint *arrays) \
GLE(void, GenVertexArrays, GLsizei n, GLuint *arrays) \
#ifndef GL_ARB_vertex_array_object
#define GL_ARB_vertex_array_object
#define GL_VERTEX_ARRAY_BINDING_ARB 0x85B5
#endif
// GL_EXT_direct_state_access
extern GLvoid(APIENTRY * qglBindMultiTexture)(GLenum texunit, GLenum target, GLuint texture);
extern GLvoid(APIENTRY * qglTextureParameterf)(GLuint texture, GLenum target, GLenum pname, GLfloat param);
extern GLvoid(APIENTRY * qglTextureParameteri)(GLuint texture, GLenum target, GLenum pname, GLint param);
extern GLvoid(APIENTRY * qglTextureImage2D)(GLuint texture, GLenum target, GLint level, GLint internalformat,
GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
extern GLvoid(APIENTRY * qglTextureSubImage2D)(GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
extern GLvoid(APIENTRY * qglCopyTextureImage2D)(GLuint texture, GLenum target, GLint level, GLenum internalformat,
GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
extern GLvoid(APIENTRY * qglCompressedTextureImage2D)(GLuint texture, GLenum target, GLint level, GLenum internalformat,
GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
extern GLvoid(APIENTRY * qglCompressedTextureSubImage2D)(GLuint texture, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format,
GLsizei imageSize, const GLvoid *data);
extern GLvoid(APIENTRY * qglGenerateTextureMipmap)(GLuint texture, GLenum target);
#define QGL_EXT_direct_state_access_PROCS \
GLE(GLvoid, BindMultiTexture, GLenum texunit, GLenum target, GLuint texture) \
GLE(GLvoid, TextureParameterf, GLuint texture, GLenum target, GLenum pname, GLfloat param) \
GLE(GLvoid, TextureParameteri, GLuint texture, GLenum target, GLenum pname, GLint param) \
GLE(GLvoid, TextureImage2D, GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) \
GLE(GLvoid, TextureSubImage2D, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) \
GLE(GLvoid, CopyTextureImage2D, GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) \
GLE(GLvoid, CompressedTextureImage2D, GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) \
GLE(GLvoid, CompressedTextureSubImage2D, GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) \
GLE(GLvoid, GenerateTextureMipmap, GLuint texture, GLenum target) \
GLE(GLvoid, ProgramUniform1i, GLuint program, GLint location, GLint v0) \
GLE(GLvoid, ProgramUniform1f, GLuint program, GLint location, GLfloat v0) \
GLE(GLvoid, ProgramUniform2f, GLuint program, GLint location, GLfloat v0, GLfloat v1) \
GLE(GLvoid, ProgramUniform3f, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2) \
GLE(GLvoid, ProgramUniform4f, GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) \
GLE(GLvoid, ProgramUniform1fv, GLuint program, GLint location, GLsizei count, const GLfloat *value) \
GLE(GLvoid, ProgramUniformMatrix4fv, GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) \
GLE(GLvoid, NamedRenderbufferStorage, GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height) \
GLE(GLvoid, NamedRenderbufferStorageMultisample, GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) \
GLE(GLenum, CheckNamedFramebufferStatus, GLuint framebuffer, GLenum target) \
GLE(GLvoid, NamedFramebufferTexture2D, GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \
GLE(GLvoid, NamedFramebufferRenderbuffer, GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \
extern GLvoid(APIENTRY * qglProgramUniform1i)(GLuint program, GLint location, GLint v0);
extern GLvoid(APIENTRY * qglProgramUniform1f)(GLuint program, GLint location, GLfloat v0);
extern GLvoid(APIENTRY * qglProgramUniform2f)(GLuint program, GLint location,
GLfloat v0, GLfloat v1);
extern GLvoid(APIENTRY * qglProgramUniform3f)(GLuint program, GLint location,
GLfloat v0, GLfloat v1, GLfloat v2);
extern GLvoid(APIENTRY * qglProgramUniform4f)(GLuint program, GLint location,
GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
extern GLvoid(APIENTRY * qglProgramUniform1fv)(GLuint program, GLint location,
GLsizei count, const GLfloat *value);
extern GLvoid(APIENTRY * qglProgramUniformMatrix4fv)(GLuint program, GLint location,
GLsizei count, GLboolean transpose,
const GLfloat *value);
extern GLvoid(APIENTRY * qglNamedRenderbufferStorage)(GLuint renderbuffer,
GLenum internalformat, GLsizei width, GLsizei height);
extern GLvoid(APIENTRY * qglNamedRenderbufferStorageMultisample)(GLuint renderbuffer,
GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
extern GLenum(APIENTRY * qglCheckNamedFramebufferStatus)(GLuint framebuffer, GLenum target);
extern GLvoid(APIENTRY * qglNamedFramebufferTexture2D)(GLuint framebuffer,
GLenum attachment, GLenum textarget, GLuint texture, GLint level);
extern GLvoid(APIENTRY * qglNamedFramebufferRenderbuffer)(GLuint framebuffer,
GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
#if defined(WIN32)
// WGL_ARB_create_context
#ifndef WGL_ARB_create_context
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#define ERROR_INVALID_VERSION_ARB 0x2095
#define ERROR_INVALID_PROFILE_ARB 0x2096
#endif
extern HGLRC(APIENTRY * qwglCreateContextAttribsARB) (HDC hdC, HGLRC hShareContext, const int *attribList);
#endif
#if 0 //defined(__linux__)
// GLX_ARB_create_context
#ifndef GLX_ARB_create_context
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
#define GLX_CONTEXT_FLAGS_ARB 0x2094
#endif
extern GLXContext (APIENTRY * qglXCreateContextAttribsARB) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
#endif
#define GLE(ret, name, ...) typedef ret APIENTRY name##proc(__VA_ARGS__); extern name##proc * qgl##name;
QGL_1_2_PROCS;
QGL_1_3_PROCS;
QGL_1_4_PROCS;
QGL_1_5_PROCS;
QGL_2_0_PROCS;
QGL_EXT_framebuffer_object_PROCS;
QGL_EXT_framebuffer_blit_PROCS;
QGL_EXT_framebuffer_multisample_PROCS;
QGL_ARB_vertex_array_object_PROCS;
QGL_EXT_direct_state_access_PROCS;
#undef GLE
#endif

View file

@ -1184,7 +1184,7 @@ const void *RB_DrawSurfs( const void *data ) {
RB_DrawSun(0.1, tr.sunShader);
}
if (r_drawSunRays->integer)
if (glRefConfig.framebufferObject && r_drawSunRays->integer)
{
FBO_t *oldFbo = glState.currentFBO;
FBO_Bind(tr.sunRaysFbo);

View file

@ -3526,7 +3526,7 @@ void RE_LoadWorldMap( const char *name ) {
R_BindNullVao();
// Render or load all cubemaps
if (r_cubeMapping->integer && tr.numCubemaps)
if (r_cubeMapping->integer && tr.numCubemaps && glRefConfig.framebufferObject)
{
R_LoadCubemaps();
R_RenderMissingCubemaps();

View file

@ -36,6 +36,11 @@ QGL_1_3_PROCS;
QGL_1_4_PROCS;
QGL_1_5_PROCS;
QGL_2_0_PROCS;
QGL_EXT_framebuffer_object_PROCS;
QGL_EXT_framebuffer_blit_PROCS;
QGL_EXT_framebuffer_multisample_PROCS;
QGL_ARB_vertex_array_object_PROCS;
QGL_EXT_direct_state_access_PROCS;
#undef GLE
// GL_EXT_framebuffer_object
@ -142,18 +147,23 @@ void GLimp_InitExtraExtensions()
char *extension;
const char* result[3] = { "...ignoring %s\n", "...using %s\n", "...%s not found\n" };
// Check OpenGL version
sscanf(glConfig.version_string, "%d.%d", &glRefConfig.openglMajorVersion, &glRefConfig.openglMinorVersion);
if (glRefConfig.openglMajorVersion < 2)
ri.Error(ERR_FATAL, "OpenGL 2.0 required!");
ri.Printf(PRINT_ALL, "...using OpenGL %s\n", glConfig.version_string);
// GL function loader, based on https://gist.github.com/rygorous/16796a0c876cf8a5f542caddb55bce8a
// set DSA fallbacks
#define GLE(ret, name, ...) qgl##name = GLDSA_##name;
QGL_EXT_direct_state_access_PROCS;
#undef GLE
// GL function loader, based on https://gist.github.com/rygorous/16796a0c876cf8a5f542caddb55bce8a
#define GLE(ret, name, ...) qgl##name = (name##proc *) SDL_GL_GetProcAddress("gl" #name);
// OpenGL 1.2, was GL_EXT_draw_range_elements
QGL_1_2_PROCS;
glRefConfig.drawRangeElements = r_ext_draw_range_elements->integer ? qtrue : qfalse;
glRefConfig.drawRangeElements = !!r_ext_draw_range_elements->integer;
ri.Printf(PRINT_ALL, result[glRefConfig.drawRangeElements], "glDrawRangeElements()");
// OpenGL 1.3, was GL_ARB_texture_compression
@ -161,8 +171,8 @@ void GLimp_InitExtraExtensions()
// OpenGL 1.4, was GL_EXT_multi_draw_arrays
QGL_1_4_PROCS;
glRefConfig.drawRangeElements = r_ext_multi_draw_arrays->integer ? qtrue : qfalse;
ri.Printf(PRINT_ALL, result[glRefConfig.drawRangeElements], "glMultiDrawElements()");
glRefConfig.multiDrawArrays = !!r_ext_multi_draw_arrays->integer;
ri.Printf(PRINT_ALL, result[glRefConfig.multiDrawArrays], "glMultiDrawElements()");
// OpenGL 1.5, was GL_ARB_vertex_buffer_object and GL_ARB_occlusion_query
QGL_1_5_PROCS;
@ -171,8 +181,7 @@ void GLimp_InitExtraExtensions()
// OpenGL 2.0, was GL_ARB_shading_language_100, GL_ARB_vertex_program, GL_ARB_shader_objects, and GL_ARB_vertex_shader
QGL_2_0_PROCS;
#undef GLE
// Determine GLSL version
if (1)
{
char version[256];
@ -186,23 +195,45 @@ void GLimp_InitExtraExtensions()
glRefConfig.memInfo = MI_NONE;
if( GLimp_HaveExtension( "GL_NVX_gpu_memory_info" ) )
// GL_NVX_gpu_memory_info
extension = "GL_NVX_gpu_memory_info";
if( GLimp_HaveExtension( extension ) )
{
glRefConfig.memInfo = MI_NVX;
ri.Printf(PRINT_ALL, result[1], extension);
}
else if( GLimp_HaveExtension( "GL_ATI_meminfo" ) )
else
{
glRefConfig.memInfo = MI_ATI;
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_ATI_meminfo
extension = "GL_ATI_meminfo";
if( GLimp_HaveExtension( extension ) )
{
if (glRefConfig.memInfo == MI_NONE)
{
glRefConfig.memInfo = MI_ATI;
ri.Printf(PRINT_ALL, result[1], extension);
}
else
{
ri.Printf(PRINT_ALL, result[0], extension);
}
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_ARB_texture_non_power_of_two
extension = "GL_ARB_texture_non_power_of_two";
glRefConfig.textureNonPowerOfTwo = qfalse;
if( GLimp_HaveExtension( extension ) )
{
if(1) //(r_ext_texture_non_power_of_two->integer)
{
glRefConfig.textureNonPowerOfTwo = qtrue;
}
glRefConfig.textureNonPowerOfTwo = qtrue; // !!r_ext_texture_non_power_of_two->integer
ri.Printf(PRINT_ALL, result[glRefConfig.textureNonPowerOfTwo], extension);
}
@ -216,10 +247,7 @@ void GLimp_InitExtraExtensions()
glRefConfig.textureFloat = qfalse;
if( GLimp_HaveExtension( extension ) )
{
if( r_ext_texture_float->integer )
{
glRefConfig.textureFloat = qtrue;
}
glRefConfig.textureFloat = !!r_ext_texture_float->integer;
ri.Printf(PRINT_ALL, result[glRefConfig.textureFloat], extension);
}
@ -233,8 +261,7 @@ void GLimp_InitExtraExtensions()
glRefConfig.halfFloatPixel = qfalse;
if( GLimp_HaveExtension( extension ) )
{
if( r_arb_half_float_pixel->integer )
glRefConfig.halfFloatPixel = qtrue;
glRefConfig.halfFloatPixel = !!r_arb_half_float_pixel->integer;
ri.Printf(PRINT_ALL, result[glRefConfig.halfFloatPixel], extension);
}
@ -248,29 +275,12 @@ void GLimp_InitExtraExtensions()
glRefConfig.framebufferObject = qfalse;
if( GLimp_HaveExtension( extension ) )
{
glRefConfig.framebufferObject = !!r_ext_framebuffer_object->integer;
glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE_EXT, &glRefConfig.maxRenderbufferSize);
glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &glRefConfig.maxColorAttachments);
qglIsRenderbufferEXT = (PFNGLISRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsRenderbufferEXT");
qglBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindRenderbufferEXT");
qglDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteRenderbuffersEXT");
qglGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenRenderbuffersEXT");
qglRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) SDL_GL_GetProcAddress("glRenderbufferStorageEXT");
qglGetRenderbufferParameterivEXT = (PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetRenderbufferParameterivEXT");
qglIsFramebufferEXT = (PFNGLISFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glIsFramebufferEXT");
qglBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) SDL_GL_GetProcAddress("glBindFramebufferEXT");
qglDeleteFramebuffersEXT = (PFNGLDELETEFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glDeleteFramebuffersEXT");
qglGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) SDL_GL_GetProcAddress("glGenFramebuffersEXT");
qglCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
qglFramebufferTexture1DEXT = (PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture1DEXT");
qglFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture2DEXT");
qglFramebufferTexture3DEXT = (PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) SDL_GL_GetProcAddress("glFramebufferTexture3DEXT");
qglFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) SDL_GL_GetProcAddress("glFramebufferRenderbufferEXT");
qglGetFramebufferAttachmentParameterivEXT = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameterivEXT");
qglGenerateMipmapEXT = (PFNGLGENERATEMIPMAPEXTPROC) SDL_GL_GetProcAddress("glGenerateMipmapEXT");
if(r_ext_framebuffer_object->value)
glRefConfig.framebufferObject = qtrue;
QGL_EXT_framebuffer_object_PROCS;
ri.Printf(PRINT_ALL, result[glRefConfig.framebufferObject], extension);
}
@ -279,26 +289,15 @@ void GLimp_InitExtraExtensions()
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_EXT_packed_depth_stencil
extension = "GL_EXT_packed_depth_stencil";
glRefConfig.packedDepthStencil = qfalse;
if( GLimp_HaveExtension(extension))
{
glRefConfig.packedDepthStencil = qtrue;
ri.Printf(PRINT_ALL, result[glRefConfig.packedDepthStencil], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
// GL_EXT_framebuffer_blit
extension = "GL_EXT_framebuffer_blit";
glRefConfig.framebufferBlit = qfalse;
if (GLimp_HaveExtension(extension))
{
qglBlitFramebufferEXT = (void *)SDL_GL_GetProcAddress("glBlitFramebufferEXT");
glRefConfig.framebufferBlit = qtrue;
QGL_EXT_framebuffer_blit_PROCS;
ri.Printf(PRINT_ALL, result[glRefConfig.framebufferBlit], extension);
}
else
@ -311,8 +310,10 @@ void GLimp_InitExtraExtensions()
glRefConfig.framebufferMultisample = qfalse;
if (GLimp_HaveExtension(extension))
{
qglRenderbufferStorageMultisampleEXT = (void *)SDL_GL_GetProcAddress("glRenderbufferStorageMultisampleEXT");
glRefConfig.framebufferMultisample = qtrue;
QGL_EXT_framebuffer_multisample_PROCS;
ri.Printf(PRINT_ALL, result[glRefConfig.framebufferMultisample], extension);
}
else
@ -326,10 +327,12 @@ void GLimp_InitExtraExtensions()
extension = "GL_ARB_texture_compression_rgtc";
if (GLimp_HaveExtension(extension))
{
if (r_ext_compressed_textures->integer)
qboolean useRgtc = r_ext_compressed_textures->integer >= 1;
if (useRgtc)
glRefConfig.textureCompression |= TCR_RGTC;
ri.Printf(PRINT_ALL, result[r_ext_compressed_textures->integer ? 1 : 0], extension);
ri.Printf(PRINT_ALL, result[useRgtc], extension);
}
else
{
@ -342,10 +345,12 @@ void GLimp_InitExtraExtensions()
extension = "GL_ARB_texture_compression_bptc";
if (GLimp_HaveExtension(extension))
{
if (r_ext_compressed_textures->integer >= 2)
qboolean useBptc = r_ext_compressed_textures->integer >= 2;
if (useBptc)
glRefConfig.textureCompression |= TCR_BPTC;
ri.Printf(PRINT_ALL, result[(r_ext_compressed_textures->integer >= 2) ? 1 : 0], extension);
ri.Printf(PRINT_ALL, result[useBptc], extension);
}
else
{
@ -358,7 +363,8 @@ void GLimp_InitExtraExtensions()
if( GLimp_HaveExtension( extension ) )
{
glRefConfig.depthClamp = qtrue;
ri.Printf(PRINT_ALL, result[1], extension);
ri.Printf(PRINT_ALL, result[glRefConfig.depthClamp], extension);
}
else
{
@ -370,8 +376,7 @@ void GLimp_InitExtraExtensions()
glRefConfig.seamlessCubeMap = qfalse;
if( GLimp_HaveExtension( extension ) )
{
if (r_arb_seamless_cube_map->integer)
glRefConfig.seamlessCubeMap = qtrue;
glRefConfig.seamlessCubeMap = !!r_arb_seamless_cube_map->integer;
ri.Printf(PRINT_ALL, result[glRefConfig.seamlessCubeMap], extension);
}
@ -385,10 +390,12 @@ void GLimp_InitExtraExtensions()
glRefConfig.packedNormalDataType = GL_BYTE;
if( GLimp_HaveExtension( extension ) )
{
if (r_arb_vertex_type_2_10_10_10_rev->integer)
qboolean useExt = !!r_arb_vertex_type_2_10_10_10_rev->integer;
if (useExt)
glRefConfig.packedNormalDataType = GL_INT_2_10_10_10_REV;
ri.Printf(PRINT_ALL, result[r_arb_vertex_type_2_10_10_10_rev->integer ? 1 : 0], extension);
ri.Printf(PRINT_ALL, result[useExt], extension);
}
else
{
@ -403,15 +410,11 @@ void GLimp_InitExtraExtensions()
glRefConfig.vertexArrayObject = qfalse;
if( GLimp_HaveExtension( extension ) )
{
qglBindVertexArrayARB = (void *) SDL_GL_GetProcAddress("glBindVertexArray");
qglDeleteVertexArraysARB = (void *) SDL_GL_GetProcAddress("glDeleteVertexArrays");
qglGenVertexArraysARB = (void *) SDL_GL_GetProcAddress("glGenVertexArrays");
qglIsVertexArrayARB = (void *) SDL_GL_GetProcAddress("glIsVertexArray");
glRefConfig.vertexArrayObject = !!r_arb_vertex_array_object->integer;
if (r_arb_vertex_array_object->integer)
glRefConfig.vertexArrayObject = qtrue;
QGL_ARB_vertex_array_object_PROCS;
ri.Printf(PRINT_ALL, result[glRefConfig.vertexArrayObject ? 1 : 0], extension);
ri.Printf(PRINT_ALL, result[glRefConfig.vertexArrayObject], extension);
}
else
{
@ -426,7 +429,9 @@ void GLimp_InitExtraExtensions()
glRefConfig.packedColorDataSize = sizeof(float) * 4;
if( GLimp_HaveExtension( extension ) )
{
if (r_arb_half_float_vertex->integer)
qboolean useExt = !!r_arb_half_float_vertex->integer;
if (useExt)
{
glRefConfig.packedTexcoordDataType = GL_HALF_FLOAT;
glRefConfig.packedTexcoordDataSize = sizeof(uint16_t) * 2;
@ -434,7 +439,7 @@ void GLimp_InitExtraExtensions()
glRefConfig.packedColorDataSize = sizeof(uint16_t) * 4;
}
ri.Printf(PRINT_ALL, result[r_arb_half_float_vertex->integer ? 1 : 0], extension);
ri.Printf(PRINT_ALL, result[useExt], extension);
}
else
{
@ -443,66 +448,23 @@ void GLimp_InitExtraExtensions()
// GL_EXT_direct_state_access
extension = "GL_EXT_direct_state_access";
qglBindMultiTexture = GLDSA_BindMultiTexture;
qglTextureParameterf = GLDSA_TextureParameterf;
qglTextureParameteri = GLDSA_TextureParameteri;
qglTextureImage2D = GLDSA_TextureImage2D;
qglTextureSubImage2D = GLDSA_TextureSubImage2D;
qglCopyTextureImage2D = GLDSA_CopyTextureImage2D;
qglCompressedTextureImage2D = GLDSA_CompressedTextureImage2D;
qglCompressedTextureSubImage2D = GLDSA_CompressedTextureSubImage2D;
qglGenerateTextureMipmap = GLDSA_GenerateTextureMipmap;
qglProgramUniform1i = GLDSA_ProgramUniform1i;
qglProgramUniform1f = GLDSA_ProgramUniform1f;
qglProgramUniform2f = GLDSA_ProgramUniform2f;
qglProgramUniform3f = GLDSA_ProgramUniform3f;
qglProgramUniform4f = GLDSA_ProgramUniform4f;
qglProgramUniform1fv = GLDSA_ProgramUniform1fv;
qglProgramUniformMatrix4fv = GLDSA_ProgramUniformMatrix4fv;
qglNamedRenderbufferStorage = GLDSA_NamedRenderbufferStorage;
qglNamedRenderbufferStorageMultisample = GLDSA_NamedRenderbufferStorageMultisample;
qglCheckNamedFramebufferStatus = GLDSA_CheckNamedFramebufferStatus;
qglNamedFramebufferTexture2D = GLDSA_NamedFramebufferTexture2D;
qglNamedFramebufferRenderbuffer = GLDSA_NamedFramebufferRenderbuffer;
glRefConfig.directStateAccess = qfalse;
if (GLimp_HaveExtension(extension))
{
if (r_ext_direct_state_access->integer)
glRefConfig.directStateAccess = !!r_ext_direct_state_access->integer;
// QGL_*_PROCS becomes several functions, do not remove {}
if (glRefConfig.directStateAccess)
{
glRefConfig.directStateAccess = qtrue;
qglBindMultiTexture = (void *)SDL_GL_GetProcAddress("glBindMultiTextureEXT");
qglTextureParameterf = (void *)SDL_GL_GetProcAddress("glTextureParameterfEXT");
qglTextureParameteri = (void *)SDL_GL_GetProcAddress("glTextureParameteriEXT");
qglTextureImage2D = (void *)SDL_GL_GetProcAddress("glTextureImage2DEXT");
qglTextureSubImage2D = (void *)SDL_GL_GetProcAddress("glTextureSubImage2DEXT");
qglCopyTextureImage2D = (void *)SDL_GL_GetProcAddress("glCopyTextureImage2DEXT");
qglCompressedTextureImage2D = (void *)SDL_GL_GetProcAddress("glCompressedTextureImage2DEXT");
qglCompressedTextureSubImage2D = (void *)SDL_GL_GetProcAddress("glCompressedTextureSubImage2DEXT");
qglGenerateTextureMipmap = (void *)SDL_GL_GetProcAddress("glGenerateTextureMipmapEXT");
qglProgramUniform1i = (void *)SDL_GL_GetProcAddress("glProgramUniform1iEXT");
qglProgramUniform1f = (void *)SDL_GL_GetProcAddress("glProgramUniform1fEXT");
qglProgramUniform2f = (void *)SDL_GL_GetProcAddress("glProgramUniform2fEXT");
qglProgramUniform3f = (void *)SDL_GL_GetProcAddress("glProgramUniform3fEXT");
qglProgramUniform4f = (void *)SDL_GL_GetProcAddress("glProgramUniform4fEXT");
qglProgramUniform1fv = (void *)SDL_GL_GetProcAddress("glProgramUniform1fvEXT");
qglProgramUniformMatrix4fv = (void *)SDL_GL_GetProcAddress("glProgramUniformMatrix4fvEXT");
qglNamedRenderbufferStorage = (void *)SDL_GL_GetProcAddress("glNamedRenderbufferStorageEXT");
qglNamedRenderbufferStorageMultisample = (void *)SDL_GL_GetProcAddress("glNamedRenderbufferStorageMultisampleEXT");
qglCheckNamedFramebufferStatus = (void *)SDL_GL_GetProcAddress("glCheckNamedFramebufferStatusEXT");
qglNamedFramebufferTexture2D = (void *)SDL_GL_GetProcAddress("glNamedFramebufferTexture2DEXT");
qglNamedFramebufferRenderbuffer = (void *)SDL_GL_GetProcAddress("glNamedFramebufferRenderbufferEXT");
QGL_EXT_direct_state_access_PROCS;
}
ri.Printf(PRINT_ALL, result[glRefConfig.directStateAccess ? 1 : 0], extension);
ri.Printf(PRINT_ALL, result[glRefConfig.directStateAccess], extension);
}
else
{
ri.Printf(PRINT_ALL, result[2], extension);
}
#undef GLE
}

View file

@ -2763,11 +2763,8 @@ void R_CreateBuiltinImages( void ) {
if (r_drawSunRays->integer)
tr.sunRaysImage = R_CreateImage("*sunRays", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);
if (glRefConfig.framebufferObject)
{
tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
}
tr.renderDepthImage = R_CreateImage("*renderdepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
tr.textureDepthImage = R_CreateImage("*texturedepth", NULL, PSHADOW_MAP_SIZE, PSHADOW_MAP_SIZE, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24_ARB);
{
unsigned short sdata[4];

View file

@ -974,7 +974,7 @@ void GL_SetDefaultState( void )
GL_BindNullProgram();
if (glRefConfig.vertexArrayObject)
qglBindVertexArrayARB(0);
qglBindVertexArray(0);
qglBindBuffer(GL_ARRAY_BUFFER, 0);
qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

View file

@ -1402,7 +1402,6 @@ typedef struct {
qboolean textureNonPowerOfTwo;
qboolean textureFloat;
qboolean halfFloatPixel;
qboolean packedDepthStencil;
textureCompressionRef_t textureCompression;
qboolean swizzleNormalmap;

View file

@ -1292,7 +1292,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
if (r_sunlightMode->integer && (backEnd.viewParms.flags & VPF_USESUNLIGHT) && (pStage->glslShaderIndex & LIGHTDEF_LIGHTTYPE_MASK))
{
GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP);
// FIXME: screenShadowImage is NULL if no framebuffers
if (tr.screenShadowImage)
GL_BindToTMU(tr.screenShadowImage, TB_SHADOWMAP);
GLSL_SetUniformVec3(sp, UNIFORM_PRIMARYLIGHTAMBIENT, backEnd.refdef.sunAmbCol);
if (r_pbr->integer)
{
@ -1404,7 +1406,9 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
vec4_t vec;
cubemap_t *cubemap = &tr.cubemaps[input->cubemapIndex - 1];
GL_BindToTMU( cubemap->image, TB_CUBEMAP);
// FIXME: cubemap image could be NULL if cubemap isn't renderer or loaded
if (cubemap->image)
GL_BindToTMU( cubemap->image, TB_CUBEMAP);
VectorSubtract(cubemap->origin, backEnd.viewParms.or.origin, vec);
vec[3] = 1.0f;

View file

@ -262,8 +262,8 @@ vao_t *R_CreateVao(const char *name, byte *vertexes, int vertexesSize, byte *ind
if (glRefConfig.vertexArrayObject)
{
qglGenVertexArraysARB(1, &vao->vao);
qglBindVertexArrayARB(vao->vao);
qglGenVertexArrays(1, &vao->vao);
qglBindVertexArray(vao->vao);
}
@ -383,8 +383,8 @@ vao_t *R_CreateVao2(const char *name, int numVertexes, srfVert_t *verts, int num
if (glRefConfig.vertexArrayObject)
{
qglGenVertexArraysARB(1, &vao->vao);
qglBindVertexArrayARB(vao->vao);
qglGenVertexArrays(1, &vao->vao);
qglBindVertexArray(vao->vao);
}
@ -480,7 +480,7 @@ void R_BindVao(vao_t * vao)
if (glRefConfig.vertexArrayObject)
{
qglBindVertexArrayARB(vao->vao);
qglBindVertexArray(vao->vao);
// why you no save GL_ELEMENT_ARRAY_BUFFER binding, Intel?
if (1)
@ -515,7 +515,7 @@ void R_BindNullVao(void)
{
if (glRefConfig.vertexArrayObject)
{
qglBindVertexArrayARB(0);
qglBindVertexArray(0);
// why you no save GL_ELEMENT_ARRAY_BUFFER binding, Intel?
if (1) qglBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
@ -654,7 +654,7 @@ void R_ShutdownVaos(void)
vao = tr.vaos[i];
if(vao->vao)
qglDeleteVertexArraysARB(1, &vao->vao);
qglDeleteVertexArrays(1, &vao->vao);
if(vao->vertexesVBO)
{