From 2885056f46eefd70fd3f67455249dff37bee8f50 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 3 Sep 2013 18:29:39 +0200 Subject: [PATCH] - moved GLEXT API out of RenderContext struct. --- gzdoom.vcproj | 8 ++ src/CMakeLists.txt | 1 + src/gl/api/gl_api.cpp | 4 + src/gl/api/gl_api.h | 100 ++++++++++++++++ src/gl/data/gl_data.cpp | 1 + src/gl/data/gl_vertexbuffer.cpp | 23 ++-- src/gl/dynlights/gl_dynlight1.cpp | 1 + src/gl/dynlights/gl_lightbuffer.cpp | 46 ++++---- src/gl/models/gl_models.cpp | 9 +- src/gl/models/gl_voxels.cpp | 19 +-- src/gl/renderer/gl_lightdata.cpp | 7 +- src/gl/renderer/gl_renderer.cpp | 9 +- src/gl/renderer/gl_renderstate.cpp | 23 ++-- src/gl/renderer/gl_renderstate.h | 2 +- src/gl/scene/gl_decal.cpp | 4 +- src/gl/scene/gl_flats.cpp | 1 + src/gl/scene/gl_portal.cpp | 9 +- src/gl/scene/gl_scene.cpp | 7 +- src/gl/scene/gl_skydome.cpp | 1 + src/gl/scene/gl_sprite.cpp | 1 + src/gl/scene/gl_spritelight.cpp | 2 +- src/gl/scene/gl_vertex.cpp | 8 +- src/gl/scene/gl_walls_draw.cpp | 11 +- src/gl/scene/gl_weapon.cpp | 1 + src/gl/shaders/gl_shader.cpp | 87 +++++++------- src/gl/system/gl_framebuffer.cpp | Bin 30486 -> 30560 bytes src/gl/system/gl_interface.cpp | 177 ++++++++++++++-------------- src/gl/system/gl_interface.h | 106 +---------------- src/gl/system/gl_menu.cpp | 1 + src/gl/system/gl_system.h | 3 +- src/gl/system/gl_wipe.cpp | 25 ++-- src/gl/textures/gl_hqresize.cpp | 1 + src/gl/textures/gl_hwtexture.cpp | 27 +++-- src/gl/textures/gl_material.cpp | 1 + src/gl/textures/gl_texture.cpp | 1 + 35 files changed, 379 insertions(+), 348 deletions(-) create mode 100644 src/gl/api/gl_api.cpp create mode 100644 src/gl/api/gl_api.h diff --git a/gzdoom.vcproj b/gzdoom.vcproj index b7e52df62..b24dfce18 100644 --- a/gzdoom.vcproj +++ b/gzdoom.vcproj @@ -3601,6 +3601,14 @@ + + + + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e89d1f75f..1189b96c3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -886,6 +886,7 @@ add_executable( zdoom WIN32 menu/playermenu.cpp menu/readthis.cpp menu/videomenu.cpp + gl/api/gl_api.cpp gl/data/gl_sections.cpp gl/data/gl_data.cpp gl/data/gl_portaldata.cpp diff --git a/src/gl/api/gl_api.cpp b/src/gl/api/gl_api.cpp new file mode 100644 index 000000000..67a3fb3e5 --- /dev/null +++ b/src/gl/api/gl_api.cpp @@ -0,0 +1,4 @@ +#include "gl/system/gl_system.h" + +#define __EXTERN +#include "gl_api.h" diff --git a/src/gl/api/gl_api.h b/src/gl/api/gl_api.h new file mode 100644 index 000000000..bcb03c416 --- /dev/null +++ b/src/gl/api/gl_api.h @@ -0,0 +1,100 @@ +#if defined(__APPLE__) +#define APIENTRY +#define APIENTRYP * +#endif // __APPLE__ + +#ifndef __EXTERN +#define __EXTERN extern +#endif + +__EXTERN PFNGLBLENDEQUATIONPROC glBlendEquation; + +// ARB_SHADER_OBJECTS +__EXTERN PFNGLDELETESHADERPROC glDeleteShader; +__EXTERN PFNGLDELETEPROGRAMPROC glDeleteProgram; +__EXTERN PFNGLDETACHSHADERPROC glDetachShader; +__EXTERN PFNGLCREATESHADERPROC glCreateShader; +__EXTERN PFNGLSHADERSOURCEPROC glShaderSource; +__EXTERN PFNGLCOMPILESHADERPROC glCompileShader; +__EXTERN PFNGLCREATEPROGRAMPROC glCreateProgram; +__EXTERN PFNGLATTACHSHADERPROC glAttachShader; +__EXTERN PFNGLLINKPROGRAMPROC glLinkProgram; +__EXTERN PFNGLUSEPROGRAMPROC glUseProgram; +__EXTERN PFNGLVALIDATEPROGRAMPROC glValidateProgram; +__EXTERN PFNGLVERTEXATTRIB1FPROC glVertexAttrib1f; +__EXTERN PFNGLVERTEXATTRIB2FPROC glVertexAttrib2f; +__EXTERN PFNGLVERTEXATTRIB4FPROC glVertexAttrib4f; +__EXTERN PFNGLVERTEXATTRIB2FVPROC glVertexAttrib2fv; +__EXTERN PFNGLVERTEXATTRIB3FVPROC glVertexAttrib3fv; +__EXTERN PFNGLVERTEXATTRIB4FVPROC glVertexAttrib4fv; +__EXTERN PFNGLVERTEXATTRIB4UBVPROC glVertexAttrib4ubv; +__EXTERN PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation; +__EXTERN PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation; + +__EXTERN PFNGLUNIFORM1FPROC glUniform1f; +__EXTERN PFNGLUNIFORM2FPROC glUniform2f; +__EXTERN PFNGLUNIFORM3FPROC glUniform3f; +__EXTERN PFNGLUNIFORM4FPROC glUniform4f; +__EXTERN PFNGLUNIFORM1IPROC glUniform1i; +__EXTERN PFNGLUNIFORM2IPROC glUniform2i; +__EXTERN PFNGLUNIFORM3IPROC glUniform3i; +__EXTERN PFNGLUNIFORM4IPROC glUniform4i; +__EXTERN PFNGLUNIFORM1FVPROC glUniform1fv; +__EXTERN PFNGLUNIFORM2FVPROC glUniform2fv; +__EXTERN PFNGLUNIFORM3FVPROC glUniform3fv; +__EXTERN PFNGLUNIFORM4FVPROC glUniform4fv; +__EXTERN PFNGLUNIFORM1IVPROC glUniform1iv; +__EXTERN PFNGLUNIFORM2IVPROC glUniform2iv; +__EXTERN PFNGLUNIFORM3IVPROC glUniform3iv; +__EXTERN PFNGLUNIFORM4IVPROC glUniform4iv; + +__EXTERN PFNGLUNIFORMMATRIX2FVPROC glUniformMatrix2fv; +__EXTERN PFNGLUNIFORMMATRIX3FVPROC glUniformMatrix3fv; +__EXTERN PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv; + +__EXTERN PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog; +__EXTERN PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog; +__EXTERN PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation; +__EXTERN PFNGLGETACTIVEUNIFORMPROC glGetActiveUniform; +__EXTERN PFNGLGETUNIFORMFVPROC glGetUniformfv; +__EXTERN PFNGLGETUNIFORMIVPROC glGetUniformiv; +__EXTERN PFNGLGETSHADERSOURCEPROC glGetShaderSource; +__EXTERN PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameteriv; + +__EXTERN PFNGLGENQUERIESARBPROC glGenQueries; +__EXTERN PFNGLDELETEQUERIESARBPROC glDeleteQueries; +__EXTERN PFNGLBEGINQUERYARBPROC glBeginQuery; +__EXTERN PFNGLENDQUERYARBPROC glEndQuery; +__EXTERN PFNGLGETQUERYOBJECTUIVARBPROC glGetQueryObjectuiv; + +__EXTERN PFNGLACTIVETEXTUREPROC glActiveTexture; +__EXTERN PFNGLMULTITEXCOORD2FPROC glMultiTexCoord2f; +__EXTERN PFNGLMULTITEXCOORD2FVPROC glMultiTexCoord2fv; + +__EXTERN PFNGLBINDBUFFERPROC glBindBuffer; +__EXTERN PFNGLDELETEBUFFERSPROC glDeleteBuffers; +__EXTERN PFNGLGENBUFFERSPROC glGenBuffers; +__EXTERN PFNGLBUFFERDATAPROC glBufferData; +__EXTERN PFNGLBUFFERSUBDATAPROC glBufferSubData; +__EXTERN PFNGLMAPBUFFERPROC glMapBuffer; +__EXTERN PFNGLUNMAPBUFFERPROC glUnmapBuffer; +__EXTERN PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray; +__EXTERN PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray; +__EXTERN PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer; + +__EXTERN PFNGLMAPBUFFERRANGEPROC glMapBufferRange; +__EXTERN PFNGLFLUSHMAPPEDBUFFERRANGEPROC glFlushMappedBufferRange; + +__EXTERN PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers; +__EXTERN PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers; +__EXTERN PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer; +__EXTERN PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D; +__EXTERN PFNGLGENRENDERBUFFERSPROC glGenRenderbuffers; +__EXTERN PFNGLDELETERENDERBUFFERSPROC glDeleteRenderbuffers; +__EXTERN PFNGLBINDRENDERBUFFERPROC glBindRenderbuffer; +__EXTERN PFNGLRENDERBUFFERSTORAGEPROC glRenderbufferStorage; +__EXTERN PFNGLFRAMEBUFFERRENDERBUFFERPROC glFramebufferRenderbuffer; + +__EXTERN PFNGLTEXBUFFERARBPROC glTexBufferARB; + +#undef __EXTERN diff --git a/src/gl/data/gl_data.cpp b/src/gl/data/gl_data.cpp index 5a2508968..20ec8a3a7 100644 --- a/src/gl/data/gl_data.cpp +++ b/src/gl/data/gl_data.cpp @@ -52,6 +52,7 @@ #include "gi.h" #include "g_level.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" diff --git a/src/gl/data/gl_vertexbuffer.cpp b/src/gl/data/gl_vertexbuffer.cpp index 5c43c256c..cda619ce1 100644 --- a/src/gl/data/gl_vertexbuffer.cpp +++ b/src/gl/data/gl_vertexbuffer.cpp @@ -43,6 +43,7 @@ #include "p_local.h" #include "m_argv.h" #include "c_cvars.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_data.h" #include "gl/data/gl_vertexbuffer.h" @@ -77,7 +78,7 @@ FVertexBuffer::FVertexBuffer() if (gl.flags&RFL_VBO) { if (gl_usevbo == -1) gl_usevbo.Callback(); - gl.GenBuffers(1, &vbo_id); + glGenBuffers(1, &vbo_id); } } @@ -85,7 +86,7 @@ FVertexBuffer::~FVertexBuffer() { if (vbo_id != 0) { - gl.DeleteBuffers(1, &vbo_id); + glDeleteBuffers(1, &vbo_id); } } @@ -273,8 +274,8 @@ void FFlatVertexBuffer::MapVBO() { if (map == NULL) { - gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); - map = (FFlatVertex*)gl.MapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + map = (FFlatVertex*)glMapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), GL_MAP_WRITE_BIT|GL_MAP_FLUSH_EXPLICIT_BIT|GL_MAP_UNSYNCHRONIZED_BIT); } } @@ -289,7 +290,7 @@ void FFlatVertexBuffer::UnmapVBO() { if (map != NULL) { - gl.UnmapBuffer(GL_ARRAY_BUFFER); + glUnmapBuffer(GL_ARRAY_BUFFER); map = NULL; } } @@ -316,11 +317,11 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane) MapVBO(); if (map == NULL) return; // Error memcpy(&map[startvt], &vbo_shadowdata[startvt], countvt * sizeof(FFlatVertex)); - gl.FlushMappedBufferRange(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex)); + glFlushMappedBufferRange(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex)); } else { - gl.BufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); + glBufferSubData(GL_ARRAY_BUFFER, startvt * sizeof(FFlatVertex), countvt * sizeof(FFlatVertex), &vbo_shadowdata[startvt]); } } @@ -336,8 +337,8 @@ void FFlatVertexBuffer::CreateVBO() if (vbo_arg > 0) { CreateFlatVBO(); - gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); - gl.BufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); } else if (sectors) { @@ -362,8 +363,8 @@ void FFlatVertexBuffer::BindVBO() if (vbo_arg > 0) { UnmapVBO(); - gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); - gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindBuffer(GL_ARRAY_BUFFER, vbo_id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); glEnableClientState(GL_VERTEX_ARRAY); diff --git a/src/gl/dynlights/gl_dynlight1.cpp b/src/gl/dynlights/gl_dynlight1.cpp index 386590f61..af2a9f7c6 100644 --- a/src/gl/dynlights/gl_dynlight1.cpp +++ b/src/gl/dynlights/gl_dynlight1.cpp @@ -45,6 +45,7 @@ #include "gl/gl_functions.h" #include "g_level.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" diff --git a/src/gl/dynlights/gl_lightbuffer.cpp b/src/gl/dynlights/gl_lightbuffer.cpp index 6280f650b..9f141e6af 100644 --- a/src/gl/dynlights/gl_lightbuffer.cpp +++ b/src/gl/dynlights/gl_lightbuffer.cpp @@ -66,11 +66,11 @@ FLightBuffer::FLightBuffer() { - gl.GenBuffers(1, &mIDbuf_RGB); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); + glGenBuffers(1, &mIDbuf_RGB); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); - gl.GenBuffers(1, &mIDbuf_Position); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); + glGenBuffers(1, &mIDbuf_Position); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); glGenTextures(1, &mIDtex_RGB); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); @@ -90,9 +90,9 @@ FLightBuffer::FLightBuffer() FLightBuffer::~FLightBuffer() { - gl.BindBuffer(GL_TEXTURE_BUFFER, 0); - gl.DeleteBuffers(1, &mIDbuf_RGB); - gl.DeleteBuffers(1, &mIDbuf_Position); + glBindBuffer(GL_TEXTURE_BUFFER, 0); + glDeleteBuffers(1, &mIDbuf_RGB); + glDeleteBuffers(1, &mIDbuf_Position); glBindTexture(GL_TEXTURE_BUFFER, 0); glDeleteTextures(1, &mIDtex_RGB); @@ -108,11 +108,11 @@ FLightBuffer::~FLightBuffer() void FLightBuffer::BindTextures(int texunit1, int texunit2) { - gl.ActiveTexture(texunit1); + glActiveTexture(texunit1); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); - gl.ActiveTexture(texunit2); + glActiveTexture(texunit2); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); } @@ -155,11 +155,11 @@ void FLightBuffer::CollectLightSources() } GLRenderer->mLightCount = pPos.Size(); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); - gl.BufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); + glBufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); - gl.BufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); + glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); + glBufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); } } @@ -173,8 +173,8 @@ void FLightBuffer::CollectLightSources() FLightIndexBuffer::FLightIndexBuffer() { - gl.GenBuffers(1, &mIDBuffer); - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); + glGenBuffers(1, &mIDBuffer); + glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); glGenTextures(1, &mIDTexture); glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); @@ -189,8 +189,8 @@ FLightIndexBuffer::FLightIndexBuffer() FLightIndexBuffer::~FLightIndexBuffer() { - gl.BindBuffer(GL_TEXTURE_BUFFER, 0); - gl.DeleteBuffers(1, &mIDBuffer); + glBindBuffer(GL_TEXTURE_BUFFER, 0); + glDeleteBuffers(1, &mIDBuffer); glBindTexture(GL_TEXTURE_BUFFER, 0); glDeleteTextures(1, &mIDTexture); @@ -219,9 +219,9 @@ void FLightIndexBuffer::AddLight(ADynamicLight *light) void FLightIndexBuffer::SendBuffer() { - gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); - gl.BufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); - gl.BindBuffer(GL_TEXTURE_BUFFER, 0); + glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); + glBufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); + glBindBuffer(GL_TEXTURE_BUFFER, 0); } @@ -233,9 +233,9 @@ void FLightIndexBuffer::SendBuffer() void FLightIndexBuffer::BindTexture(int texunit1) { - gl.ActiveTexture(texunit1); + glActiveTexture(texunit1); glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); } diff --git a/src/gl/models/gl_models.cpp b/src/gl/models/gl_models.cpp index 3a89bcbbc..a59666d04 100644 --- a/src/gl/models/gl_models.cpp +++ b/src/gl/models/gl_models.cpp @@ -51,6 +51,7 @@ //#include "resources/voxels.h" //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/scene/gl_drawinfo.h" #include "gl/models/gl_models.h" @@ -759,7 +760,7 @@ void gl_RenderModel(GLSprite * spr, int cm) } else { - gl.ActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. + glActiveTexture(GL_TEXTURE7); // Hijack the otherwise unused seventh texture matrix for the model to world transformation. glMatrixMode(GL_TEXTURE); glLoadIdentity(); } @@ -794,7 +795,7 @@ void gl_RenderModel(GLSprite * spr, int cm) glRotatef(smf->pitchoffset, 0, 0, 1); glRotatef(-smf->rolloffset, 1, 0, 0); - if (gl.shadermodel >= 4) gl.ActiveTexture(GL_TEXTURE0); + if (gl.shadermodel >= 4) glActiveTexture(GL_TEXTURE0); #if 0 if (gl_light_models) @@ -820,10 +821,10 @@ void gl_RenderModel(GLSprite * spr, int cm) } else { - gl.ActiveTexture(GL_TEXTURE7); + glActiveTexture(GL_TEXTURE7); glMatrixMode(GL_TEXTURE); glLoadIdentity(); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_MODELVIEW); } diff --git a/src/gl/models/gl_voxels.cpp b/src/gl/models/gl_voxels.cpp index c13ddda5f..e81c6531c 100644 --- a/src/gl/models/gl_voxels.cpp +++ b/src/gl/models/gl_voxels.cpp @@ -49,6 +49,7 @@ #include "textures/bitmap.h" //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/data/gl_vertexbuffer.h" #include "gl/scene/gl_drawinfo.h" @@ -189,14 +190,14 @@ FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArray 65535) { - gl.BufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned int), &indices[0], GL_STATIC_DRAW); isint = true; } else @@ -206,7 +207,7 @@ FVoxelVertexBuffer::FVoxelVertexBuffer(TArray &verts, TArrayx); glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); glEnableClientState(GL_VERTEX_ARRAY); diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index 5be90d3cf..88d24cc02 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -40,6 +40,7 @@ #include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/data/gl_data.h" #include "gl/renderer/gl_colormap.h" @@ -339,12 +340,12 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, Pal if (gl_fixedcolormap) { - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); } else { float lightlevel = gl_CalcLightLevel(light, rellight, weapon) / 255.0f; - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, lightlevel); + glVertexAttrib1f(VATTR_LIGHTLEVEL, lightlevel); } } } @@ -611,7 +612,7 @@ void gl_SetFog(int lightlevel, int rellight, const FColormap *cmap, bool isaddit // Korshun: fullbright fog like in software renderer. if (glset.brightfog && fogdensity != 0 && fogcolor != 0) - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); } } diff --git a/src/gl/renderer/gl_renderer.cpp b/src/gl/renderer/gl_renderer.cpp index b1ef3244f..3ce805351 100644 --- a/src/gl/renderer/gl_renderer.cpp +++ b/src/gl/renderer/gl_renderer.cpp @@ -50,6 +50,7 @@ #include "gl/gl_functions.h" #include "vectors.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_threads.h" #include "gl/renderer/gl_renderer.h" @@ -123,7 +124,7 @@ FGLRenderer::~FGLRenderer() if (glpart) delete glpart; if (mirrortexture) delete mirrortexture; if (gllight) delete gllight; - if (mFBID != 0) gl.DeleteFramebuffers(1, &mFBID); + if (mFBID != 0) glDeleteFramebuffers(1, &mFBID); } //=========================================================================== @@ -213,8 +214,8 @@ bool FGLRenderer::StartOffscreen() { if (gl.flags & RFL_FRAMEBUFFER) { - if (mFBID == 0) gl.GenFramebuffers(1, &mFBID); - gl.BindFramebuffer(GL_FRAMEBUFFER, mFBID); + if (mFBID == 0) glGenFramebuffers(1, &mFBID); + glBindFramebuffer(GL_FRAMEBUFFER, mFBID); return true; } return false; @@ -230,7 +231,7 @@ void FGLRenderer::EndOffscreen() { if (gl.flags & RFL_FRAMEBUFFER) { - gl.BindFramebuffer(GL_FRAMEBUFFER, 0); + glBindFramebuffer(GL_FRAMEBUFFER, 0); } } diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 7f7a2df67..19af11168 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -39,6 +39,7 @@ */ #include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/system/gl_cvars.h" #include "gl/shaders/gl_shader.h" @@ -203,15 +204,15 @@ bool FRenderState::ApplyShader() if (fogset != activeShader->currentfogenabled) { - gl.Uniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); + glUniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); } if (mTextureMode != activeShader->currenttexturemode) { - gl.Uniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); + glUniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); } if (activeShader->currentcamerapos.Update(&mCameraPos)) { - gl.Uniform3fv(activeShader->camerapos_index, 1, mCameraPos.vec); + glUniform3fv(activeShader->camerapos_index, 1, mCameraPos.vec); } /*if (mLightParms[0] != activeShader->currentlightfactor || mLightParms[1] != activeShader->currentlightdist || @@ -223,28 +224,28 @@ bool FRenderState::ApplyShader() //activeShader->currentfogdensity = mFogDensity; // premultiply the density with as much as possible here to reduce shader // execution time. - gl.VertexAttrib4f(VATTR_FOGPARAMS, mLightParms[0], mLightParms[1], mFogDensity * (-LOG2E / 64000.f), 0); + glVertexAttrib4f(VATTR_FOGPARAMS, mLightParms[0], mLightParms[1], mFogDensity * (-LOG2E / 64000.f), 0); } if (mFogColor != activeShader->currentfogcolor) { activeShader->currentfogcolor = mFogColor; - gl.Uniform4f (activeShader->fogcolor_index, mFogColor.r/255.f, mFogColor.g/255.f, + glUniform4f (activeShader->fogcolor_index, mFogColor.r/255.f, mFogColor.g/255.f, mFogColor.b/255.f, 0); } if (mGlowEnabled) { - gl.Uniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); - gl.Uniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); + glUniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); + glUniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); } if (mLightEnabled) { - gl.Uniform3iv(activeShader->lightrange_index, 1, mNumLights); - gl.Uniform4fv(activeShader->lights_index, mNumLights[2], mLightData); + glUniform3iv(activeShader->lightrange_index, 1, mNumLights); + glUniform4fv(activeShader->lights_index, mNumLights[2], mLightData); } if (glset.lightmode == 8) { - gl.Uniform3fv(activeShader->dlightcolor_index, 1, mDynLight); + glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight); } return true; @@ -284,7 +285,7 @@ void FRenderState::Apply(bool forcenoshader) if (mBlendEquation != glBlendEquation) { glBlendEquation = mBlendEquation; - gl.BlendEquation(mBlendEquation); + ::glBlendEquation(mBlendEquation); } } diff --git a/src/gl/renderer/gl_renderstate.h b/src/gl/renderer/gl_renderstate.h index e8a4d1940..dd348ad8c 100644 --- a/src/gl/renderer/gl_renderstate.h +++ b/src/gl/renderer/gl_renderstate.h @@ -263,7 +263,7 @@ public: } else { - gl.BlendEquation(eq); + ::glBlendEquation(eq); } } diff --git a/src/gl/scene/gl_decal.cpp b/src/gl/scene/gl_decal.cpp index 6bb109fa4..bd39f8008 100644 --- a/src/gl/scene/gl_decal.cpp +++ b/src/gl/scene/gl_decal.cpp @@ -368,9 +368,9 @@ void GLWall::DrawDecal(DBaseDecal *decal) if (glset.lightmode == 8) { if (gl_fixedcolormap) - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); else - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); + glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); } } else diff --git a/src/gl/scene/gl_flats.cpp b/src/gl/scene/gl_flats.cpp index 309d5cdfb..441c8b73f 100644 --- a/src/gl/scene/gl_flats.cpp +++ b/src/gl/scene/gl_flats.cpp @@ -47,6 +47,7 @@ #include "doomstat.h" #include "d_player.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/scene/gl_portal.cpp b/src/gl/scene/gl_portal.cpp index b0ee96d88..31b6149d2 100644 --- a/src/gl/scene/gl_portal.cpp +++ b/src/gl/scene/gl_portal.cpp @@ -46,6 +46,7 @@ #include "doomstat.h" #include "a_sharedglobal.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" @@ -199,10 +200,10 @@ bool GLPortal::Start(bool usestencil, bool doquery) // If occlusion query is supported let's use it to avoid rendering portals that aren't visible if (doquery && gl.flags&RFL_OCCLUSION_QUERY) { - if (!QueryObject) gl.GenQueries(1, &QueryObject); + if (!QueryObject) glGenQueries(1, &QueryObject); if (QueryObject) { - gl.BeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); + glBeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); } else doquery = false; // some kind of error happened @@ -212,7 +213,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) if (doquery && gl.flags&RFL_OCCLUSION_QUERY) { - gl.EndQuery(GL_SAMPLES_PASSED_ARB); + glEndQuery(GL_SAMPLES_PASSED_ARB); } // Clear Z-buffer @@ -233,7 +234,7 @@ bool GLPortal::Start(bool usestencil, bool doquery) { GLuint sampleCount; - gl.GetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); + glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); if (sampleCount==0) // not visible { diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 93c8dbbf8..6434e848a 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -57,6 +57,7 @@ #include "p_local.h" #include "gl/gl_functions.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" @@ -266,11 +267,11 @@ void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror) { if (gl.shadermodel >= 4) { - gl.ActiveTexture(GL_TEXTURE7); + glActiveTexture(GL_TEXTURE7); glMatrixMode(GL_TEXTURE); glLoadIdentity(); } - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); glMatrixMode(GL_TEXTURE); glLoadIdentity(); @@ -441,7 +442,7 @@ void FGLRenderer::RenderScene(int recursion) { gl_RenderState.BlendFunc(GL_ONE, GL_ONE); glDepthFunc(GL_EQUAL); - if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. + if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0f); // Korshun. for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++) { gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT); diff --git a/src/gl/scene/gl_skydome.cpp b/src/gl/scene/gl_skydome.cpp index 41182cfb4..dee3ea4e3 100644 --- a/src/gl/scene/gl_skydome.cpp +++ b/src/gl/scene/gl_skydome.cpp @@ -43,6 +43,7 @@ #include "r_state.h" //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 40b55dfef..208507c84 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -47,6 +47,7 @@ #include "r_sky.h" #include "r_utility.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/scene/gl_spritelight.cpp b/src/gl/scene/gl_spritelight.cpp index cdbf1950c..d630ddbc2 100644 --- a/src/gl/scene/gl_spritelight.cpp +++ b/src/gl/scene/gl_spritelight.cpp @@ -159,7 +159,7 @@ static int gl_SetSpriteLight(AActor *self, fixed_t x, fixed_t y, fixed_t z, subs glColor4f(r, g, b, alpha); if (glset.lightmode == 8) { - gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. + glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(lightlevel, rellight, weapon) / 255.0f); // Korshun. gl_RenderState.SetDynLight(result[0], result[1], result[2]); } return lightlevel; diff --git a/src/gl/scene/gl_vertex.cpp b/src/gl/scene/gl_vertex.cpp index a11b06fde..4df381311 100644 --- a/src/gl/scene/gl_vertex.cpp +++ b/src/gl/scene/gl_vertex.cpp @@ -82,7 +82,7 @@ void GLWall::SplitUpperEdge(texcoord * tcs, bool glow) float fracfac = sidefrac - glseg.fracleft; - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0] + (facc - fact) * fracfac, ztop[0] - zfloor[0] + (fact - facf) * fracfac); glTexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * fracfac); @@ -118,7 +118,7 @@ void GLWall::SplitLowerEdge(texcoord * tcs, bool glow) float fracfac = sidefrac - glseg.fracleft; - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0] + (facc - facb) * fracfac, zbottom[0] - zfloor[0] + (facb - facf) * fracfac); glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); @@ -150,7 +150,7 @@ void GLWall::SplitLeftEdge(texcoord * tcs, bool glow) while (inumheights && vi->heightlist[i] <= zbottom[0] ) i++; while (inumheights && vi->heightlist[i] < ztop[0]) { - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - vi->heightlist[i], vi->heightlist[i] - zfloor[0]); glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u, factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); @@ -183,7 +183,7 @@ void GLWall::SplitRightEdge(texcoord * tcs, bool glow) while (i>0 && vi->heightlist[i] >= ztop[1]) i--; while (i>0 && vi->heightlist[i] > zbottom[1]) { - if (glow) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); + if (glow) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - vi->heightlist[i], vi->heightlist[i] - zfloor[1]); glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u, factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); diff --git a/src/gl/scene/gl_walls_draw.cpp b/src/gl/scene/gl_walls_draw.cpp index fbd881982..d97475029 100644 --- a/src/gl/scene/gl_walls_draw.cpp +++ b/src/gl/scene/gl_walls_draw.cpp @@ -44,6 +44,7 @@ #include "a_sharedglobal.h" #include "gl/gl_functions.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_renderstate.h" @@ -248,14 +249,14 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) glBegin(GL_TRIANGLE_FAN); // lower left corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - zbottom[0], zbottom[0] - zfloor[0]); if (textured&1) glTexCoord2f(tcs[0].u,tcs[0].v); glVertex3f(glseg.x1,zbottom[0],glseg.y1); if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing); // upper left corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[0] - ztop[0], ztop[0] - zfloor[0]); if (textured&1) glTexCoord2f(tcs[1].u,tcs[1].v); glVertex3f(glseg.x1,ztop[0],glseg.y1); @@ -265,14 +266,14 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light) if (color2) glColor4fv(color2); // upper right corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - ztop[1], ztop[1] - zfloor[1]); if (textured&1) glTexCoord2f(tcs[2].u,tcs[2].v); glVertex3f(glseg.x2,ztop[1],glseg.y2); if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing); // lower right corner - if (glowing) gl.VertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); + if (glowing) glVertexAttrib2f(VATTR_GLOWDISTANCE, zceil[1] - zbottom[1], zbottom[1] - zfloor[1]); if (textured&1) glTexCoord2f(tcs[3].u,tcs[3].v); glVertex3f(glseg.x2,zbottom[1],glseg.y2); @@ -330,7 +331,7 @@ void GLWall::RenderFogBoundary() gl_RenderState.AlphaFunc(GL_GREATER,0); glDepthFunc(GL_LEQUAL); glColor4f(fc[0],fc[1],fc[2], fogd1); - if (glset.lightmode == 8) gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. + if (glset.lightmode == 8) glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); // Korshun. flags &= ~GLWF_GLOW; RenderWall(4,fc); diff --git a/src/gl/scene/gl_weapon.cpp b/src/gl/scene/gl_weapon.cpp index 83cdf67f6..61289f48b 100644 --- a/src/gl/scene/gl_weapon.cpp +++ b/src/gl/scene/gl_weapon.cpp @@ -45,6 +45,7 @@ #include "d_player.h" #include "g_level.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_lightdata.h" diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 4a3c7ca94..30e3318f3 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -49,6 +49,7 @@ #include "sc_man.h" #include "cmdlib.h" +#include "gl/system/gl_interface.h" #include "gl/data/gl_data.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" @@ -119,8 +120,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * } } - hVertProg = gl.CreateShader(GL_VERTEX_SHADER); - hFragProg = gl.CreateShader(GL_FRAGMENT_SHADER); + hVertProg = glCreateShader(GL_VERTEX_SHADER); + hFragProg = glCreateShader(GL_FRAGMENT_SHADER); int vp_size = (int)vp_comb.Len(); @@ -129,68 +130,68 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * const char *vp_ptr = vp_comb.GetChars(); const char *fp_ptr = fp_comb.GetChars(); - gl.ShaderSource(hVertProg, 1, &vp_ptr, &vp_size); - gl.ShaderSource(hFragProg, 1, &fp_ptr, &fp_size); + glShaderSource(hVertProg, 1, &vp_ptr, &vp_size); + glShaderSource(hFragProg, 1, &fp_ptr, &fp_size); - gl.CompileShader(hVertProg); - gl.CompileShader(hFragProg); + glCompileShader(hVertProg); + glCompileShader(hFragProg); - hShader = gl.CreateProgram(); + hShader = glCreateProgram(); - gl.AttachShader(hShader, hVertProg); - gl.AttachShader(hShader, hFragProg); + glAttachShader(hShader, hVertProg); + glAttachShader(hShader, hFragProg); - gl.BindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); - gl.BindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); - gl.BindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. + glBindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); + glBindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); + glBindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. - gl.LinkProgram(hShader); + glLinkProgram(hShader); - gl.GetShaderInfoLog(hVertProg, 10000, NULL, buffer); + glGetShaderInfoLog(hVertProg, 10000, NULL, buffer); if (*buffer) { error << "Vertex shader:\n" << buffer << "\n"; } - gl.GetShaderInfoLog(hFragProg, 10000, NULL, buffer); + glGetShaderInfoLog(hFragProg, 10000, NULL, buffer); if (*buffer) { error << "Vertex shader:\n" << buffer << "\n"; } - gl.GetProgramInfoLog(hShader, 10000, NULL, buffer); + glGetProgramInfoLog(hShader, 10000, NULL, buffer); if (*buffer) { error << "Linking:\n" << buffer << "\n"; } int linked; - gl.GetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); + glGetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); if (linked == 0) { // only print message if there's an error. Printf("Init Shader '%s':\n%s\n", name, error.GetChars()); } - timer_index = gl.GetUniformLocation(hShader, "timer"); - desaturation_index = gl.GetUniformLocation(hShader, "desaturation_factor"); - fogenabled_index = gl.GetUniformLocation(hShader, "fogenabled"); - texturemode_index = gl.GetUniformLocation(hShader, "texturemode"); - camerapos_index = gl.GetUniformLocation(hShader, "camerapos"); - lightparms_index = gl.GetUniformLocation(hShader, "lightparms"); - colormapstart_index = gl.GetUniformLocation(hShader, "colormapstart"); - colormaprange_index = gl.GetUniformLocation(hShader, "colormaprange"); - lightrange_index = gl.GetUniformLocation(hShader, "lightrange"); - fogcolor_index = gl.GetUniformLocation(hShader, "fogcolor"); - lights_index = gl.GetUniformLocation(hShader, "lights"); - dlightcolor_index = gl.GetUniformLocation(hShader, "dlightcolor"); + timer_index = glGetUniformLocation(hShader, "timer"); + desaturation_index = glGetUniformLocation(hShader, "desaturation_factor"); + fogenabled_index = glGetUniformLocation(hShader, "fogenabled"); + texturemode_index = glGetUniformLocation(hShader, "texturemode"); + camerapos_index = glGetUniformLocation(hShader, "camerapos"); + lightparms_index = glGetUniformLocation(hShader, "lightparms"); + colormapstart_index = glGetUniformLocation(hShader, "colormapstart"); + colormaprange_index = glGetUniformLocation(hShader, "colormaprange"); + lightrange_index = glGetUniformLocation(hShader, "lightrange"); + fogcolor_index = glGetUniformLocation(hShader, "fogcolor"); + lights_index = glGetUniformLocation(hShader, "lights"); + dlightcolor_index = glGetUniformLocation(hShader, "dlightcolor"); - glowbottomcolor_index = gl.GetUniformLocation(hShader, "bottomglowcolor"); - glowtopcolor_index = gl.GetUniformLocation(hShader, "topglowcolor"); + glowbottomcolor_index = glGetUniformLocation(hShader, "bottomglowcolor"); + glowtopcolor_index = glGetUniformLocation(hShader, "topglowcolor"); - gl.UseProgram(hShader); + glUseProgram(hShader); - int texture_index = gl.GetUniformLocation(hShader, "texture2"); - if (texture_index > 0) gl.Uniform1i(texture_index, 1); + int texture_index = glGetUniformLocation(hShader, "texture2"); + if (texture_index > 0) glUniform1i(texture_index, 1); - gl.UseProgram(0); + glUseProgram(0); return !!linked; } return false; @@ -204,9 +205,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * FShader::~FShader() { - gl.DeleteProgram(hShader); - gl.DeleteShader(hVertProg); - gl.DeleteShader(hFragProg); + glDeleteProgram(hShader); + glDeleteShader(hVertProg); + glDeleteShader(hFragProg); } @@ -219,7 +220,7 @@ FShader::~FShader() bool FShader::Bind(float Speed) { GLRenderer->mShaderManager->SetActiveShader(this); - if (timer_index >=0 && Speed > 0.f) gl.Uniform1f(timer_index, gl_frameMS*Speed/1000.f); + if (timer_index >=0 && Speed > 0.f) glUniform1f(timer_index, gl_frameMS*Speed/1000.f); return true; } @@ -376,8 +377,8 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) float m[3]= {map->ColorizeEnd[0] - map->ColorizeStart[0], map->ColorizeEnd[1] - map->ColorizeStart[1], map->ColorizeEnd[2] - map->ColorizeStart[2]}; - gl.Uniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); - gl.Uniform3fv(sh->colormaprange_index, 1, m); + glUniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); + glUniform3fv(sh->colormaprange_index, 1, m); } } else @@ -390,7 +391,7 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights) sh->Bind(Speed); if (desat) { - gl.Uniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); + glUniform1f(sh->desaturation_index, 1.f-float(cm-CM_DESAT0)/(CM_DESAT31-CM_DESAT0)); } } } @@ -578,7 +579,7 @@ void FShaderManager::SetActiveShader(FShader *sh) // shadermodel needs to be tested here because without it UseProgram will be NULL. if (gl.shadermodel > 0 && mActiveShader != sh) { - gl.UseProgram(sh == NULL? 0 : sh->GetHandle()); + glUseProgram(sh == NULL? 0 : sh->GetHandle()); mActiveShader = sh; } } diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index ec717934c0668b702489bbd117d475ee2044c1fd..22f53864d03bdc6b5af20427d05a871aab2c5445 100644 GIT binary patch delta 40 wcmbRCj`6`e#tkjPf|(3?3?&Sy3`GoS42cZM45^b7h2$sqiLh-h5MGuH030w3{Qv*} delta 14 WcmaFxj&a&M#tkjPo6iYPN(KNrJO?EJ diff --git a/src/gl/system/gl_interface.cpp b/src/gl/system/gl_interface.cpp index 536dc194b..cadab5af9 100644 --- a/src/gl/system/gl_interface.cpp +++ b/src/gl/system/gl_interface.cpp @@ -43,6 +43,7 @@ #include "version.h" #include "i_system.h" #include "v_text.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #if defined (__unix__) || defined (__APPLE__) @@ -116,7 +117,7 @@ static bool CheckExtension(const char *ext) static void InitContext() { gl.flags=0; - gl.BlendEquation = glBlendEquationDummy; + glBlendEquation = glBlendEquationDummy; } //========================================================================== @@ -151,11 +152,11 @@ void gl_LoadExtensions() gl.vendorstring=(char*)glGetString(GL_VENDOR); // First try the regular function - gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); + glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); // If that fails try the EXT version - if (!gl.BlendEquation) gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); + if (!glBlendEquation) glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquationEXT"); // If that fails use a no-op dummy - if (!gl.BlendEquation) gl.BlendEquation = glBlendEquationDummy; + if (!glBlendEquation) glBlendEquation = glBlendEquationDummy; if (CheckExtension("GL_ARB_texture_non_power_of_two")) gl.flags|=RFL_NPOT_TEXTURE; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; @@ -172,64 +173,64 @@ void gl_LoadExtensions() if (gl.flags & RFL_GL_20) { - gl.DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); - gl.DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); - gl.DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); - gl.CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); - gl.ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); - gl.CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); - gl.CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); - gl.AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); - gl.LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); - gl.UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); - gl.ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); + glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); + glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); + glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); + glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); + glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); + glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); + glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); + glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); + glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); + glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); + glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); - gl.VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); - gl.VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); - gl.VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); - gl.VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); - gl.VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); - gl.VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); - gl.VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); - gl.GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); - gl.BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); + glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); + glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); + glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); + glVertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); + glVertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); + glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); + glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); + glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); + glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); - gl.Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); - gl.Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); - gl.Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); - gl.Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); - gl.Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); - gl.Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); - gl.Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); - gl.Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); - gl.Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); - gl.Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); - gl.Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); - gl.Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); - gl.Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); - gl.Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); - gl.Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); - gl.Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); + glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); + glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); + glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); + glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); + glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); + glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); + glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); + glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); + glUniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); + glUniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); + glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); + glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); + glUniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); + glUniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); + glUniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); + glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); - gl.UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); - gl.UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); - gl.UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); + glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); + glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); + glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); - gl.GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); - gl.GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); - gl.GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); - gl.GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); - gl.GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); - gl.GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); - gl.GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); + glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); + glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); + glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); + glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); + glGetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); + glGetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); + glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); - gl.EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); - gl.DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); - gl.VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); + glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); + glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); + glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); // what'S the equivalent of this in GL 2.0??? - gl.GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); + glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); // Rules: // SM4 will always use shaders. No option to switch them off is needed here. @@ -250,55 +251,55 @@ void gl_LoadExtensions() if (CheckExtension("GL_ARB_occlusion_query")) { - gl.GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); - gl.DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); - gl.GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); - gl.BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); - gl.EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); + glGenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); + glDeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); + glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); + glBeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); + glEndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); gl.flags|=RFL_OCCLUSION_QUERY; } if (gl.flags & RFL_GL_21) { - gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); - gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); - gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); - gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); - gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); - gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); - gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); + glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); + glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); + glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); + glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); gl.flags |= RFL_VBO; } else if (CheckExtension("GL_ARB_vertex_buffer_object")) { - gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); - gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); - gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); - gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); - gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); - gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); - gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); + glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); + glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); + glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); + glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); + glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); + glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); + glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); gl.flags |= RFL_VBO; } if (CheckExtension("GL_ARB_map_buffer_range")) { - gl.MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); - gl.FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); + glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); + glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); gl.flags|=RFL_MAP_BUFFER_RANGE; } if (CheckExtension("GL_ARB_framebuffer_object")) { - gl.GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); - gl.DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); - gl.BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); - gl.FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); - gl.GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); - gl.DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); - gl.BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); - gl.RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); - gl.FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); + glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); + glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); + glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); + glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); + glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); + glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); + glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); + glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); + glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); gl.flags|=RFL_FRAMEBUFFER; } @@ -310,16 +311,16 @@ void gl_LoadExtensions() CheckExtension("GL_ARB_texture_rg") && gl.shadermodel == 4) { - gl.TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); + glTexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); gl.flags|=RFL_TEXTUREBUFFER; } #endif - gl.ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); - gl.MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); - gl.MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); + glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); + glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); + glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); } //========================================================================== diff --git a/src/gl/system/gl_interface.h b/src/gl/system/gl_interface.h index 7e937dcbf..babbec8fd 100644 --- a/src/gl/system/gl_interface.h +++ b/src/gl/system/gl_interface.h @@ -1,22 +1,7 @@ #ifndef R_RENDER #define R_RENDER -#if defined(__APPLE__) -#define APIENTRY -#define APIENTRYP * -#endif // __APPLE__ - #include "basictypes.h" -#ifndef _WIN32 -typedef bool BOOL; -#endif - -#ifndef PFNGLMULTITEXCOORD2FPROC -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); -#endif -#ifndef PFNGLMULTITEXCOORD2FVPROC -typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); -#endif enum RenderFlags { @@ -65,98 +50,9 @@ struct RenderContext { return maxuniforms>=2048? 128:64; } - - void (APIENTRY * BlendEquation) (GLenum); - - // ARB_SHADER_OBJECTS - PFNGLDELETESHADERPROC DeleteShader; - PFNGLDELETEPROGRAMPROC DeleteProgram; - PFNGLDETACHSHADERPROC DetachShader; - PFNGLCREATESHADERPROC CreateShader; - PFNGLSHADERSOURCEPROC ShaderSource; - PFNGLCOMPILESHADERPROC CompileShader; - PFNGLCREATEPROGRAMPROC CreateProgram; - PFNGLATTACHSHADERPROC AttachShader; - PFNGLLINKPROGRAMPROC LinkProgram; - PFNGLUSEPROGRAMPROC UseProgram; - PFNGLVALIDATEPROGRAMPROC ValidateProgram; - PFNGLVERTEXATTRIB1FPROC VertexAttrib1f; - PFNGLVERTEXATTRIB2FPROC VertexAttrib2f; - PFNGLVERTEXATTRIB4FPROC VertexAttrib4f; - PFNGLVERTEXATTRIB2FVPROC VertexAttrib2fv; - PFNGLVERTEXATTRIB3FVPROC VertexAttrib3fv; - PFNGLVERTEXATTRIB4FVPROC VertexAttrib4fv; - PFNGLVERTEXATTRIB4UBVPROC VertexAttrib4ubv; - PFNGLGETATTRIBLOCATIONPROC GetAttribLocation; - PFNGLBINDATTRIBLOCATIONPROC BindAttribLocation; - - PFNGLUNIFORM1FPROC Uniform1f; - PFNGLUNIFORM2FPROC Uniform2f; - PFNGLUNIFORM3FPROC Uniform3f; - PFNGLUNIFORM4FPROC Uniform4f; - PFNGLUNIFORM1IPROC Uniform1i; - PFNGLUNIFORM2IPROC Uniform2i; - PFNGLUNIFORM3IPROC Uniform3i; - PFNGLUNIFORM4IPROC Uniform4i; - PFNGLUNIFORM1FVPROC Uniform1fv; - PFNGLUNIFORM2FVPROC Uniform2fv; - PFNGLUNIFORM3FVPROC Uniform3fv; - PFNGLUNIFORM4FVPROC Uniform4fv; - PFNGLUNIFORM1IVPROC Uniform1iv; - PFNGLUNIFORM2IVPROC Uniform2iv; - PFNGLUNIFORM3IVPROC Uniform3iv; - PFNGLUNIFORM4IVPROC Uniform4iv; - - PFNGLUNIFORMMATRIX2FVPROC UniformMatrix2fv; - PFNGLUNIFORMMATRIX3FVPROC UniformMatrix3fv; - PFNGLUNIFORMMATRIX4FVPROC UniformMatrix4fv; - - PFNGLGETSHADERINFOLOGPROC GetShaderInfoLog; - PFNGLGETPROGRAMINFOLOGPROC GetProgramInfoLog; - PFNGLGETUNIFORMLOCATIONPROC GetUniformLocation; - PFNGLGETACTIVEUNIFORMPROC GetActiveUniform; - PFNGLGETUNIFORMFVPROC GetUniformfv; - PFNGLGETUNIFORMIVPROC GetUniformiv; - PFNGLGETSHADERSOURCEPROC GetShaderSource; - PFNGLGETOBJECTPARAMETERIVARBPROC GetObjectParameteriv; - - PFNGLGENQUERIESARBPROC GenQueries; - PFNGLDELETEQUERIESARBPROC DeleteQueries; - PFNGLBEGINQUERYARBPROC BeginQuery; - PFNGLENDQUERYARBPROC EndQuery; - PFNGLGETQUERYOBJECTUIVARBPROC GetQueryObjectuiv; - - PFNGLACTIVETEXTUREPROC ActiveTexture; - PFNGLMULTITEXCOORD2FPROC MultiTexCoord2f; - PFNGLMULTITEXCOORD2FVPROC MultiTexCoord2fv; - - PFNGLBINDBUFFERPROC BindBuffer; - PFNGLDELETEBUFFERSPROC DeleteBuffers; - PFNGLGENBUFFERSPROC GenBuffers; - PFNGLBUFFERDATAPROC BufferData; - PFNGLBUFFERSUBDATAPROC BufferSubData; - PFNGLMAPBUFFERPROC MapBuffer; - PFNGLUNMAPBUFFERPROC UnmapBuffer; - PFNGLENABLEVERTEXATTRIBARRAYPROC EnableVertexAttribArray; - PFNGLDISABLEVERTEXATTRIBARRAYPROC DisableVertexAttribArray; - PFNGLVERTEXATTRIBPOINTERPROC VertexAttribPointer; - - PFNGLMAPBUFFERRANGEPROC MapBufferRange; - PFNGLFLUSHMAPPEDBUFFERRANGEPROC FlushMappedBufferRange; - - PFNGLGENFRAMEBUFFERSPROC GenFramebuffers; - PFNGLDELETEFRAMEBUFFERSPROC DeleteFramebuffers; - PFNGLBINDFRAMEBUFFERPROC BindFramebuffer; - PFNGLFRAMEBUFFERTEXTURE2DPROC FramebufferTexture2D; - PFNGLGENRENDERBUFFERSPROC GenRenderbuffers; - PFNGLDELETERENDERBUFFERSPROC DeleteRenderbuffers; - PFNGLBINDRENDERBUFFERPROC BindRenderbuffer; - PFNGLRENDERBUFFERSTORAGEPROC RenderbufferStorage; - PFNGLFRAMEBUFFERRENDERBUFFERPROC FramebufferRenderbuffer; - - PFNGLTEXBUFFERARBPROC TexBufferARB; }; +extern RenderContext gl; #endif diff --git a/src/gl/system/gl_menu.cpp b/src/gl/system/gl_menu.cpp index ba70431da..eae5d7a7e 100644 --- a/src/gl/system/gl_menu.cpp +++ b/src/gl/system/gl_menu.cpp @@ -5,6 +5,7 @@ #include "c_dispatch.h" #include "v_video.h" #include "version.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "menu/menu.h" diff --git a/src/gl/system/gl_system.h b/src/gl/system/gl_system.h index d2430bd63..0a0fc7017 100644 --- a/src/gl/system/gl_system.h +++ b/src/gl/system/gl_system.h @@ -74,6 +74,7 @@ #include #include #endif // __APPLE__ +#include "gl/api/gl_api.h" #ifdef _WIN32 #define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! @@ -92,9 +93,7 @@ inline T max( T a, T b) { return (((a)>(b)) ? (a) : (b)); } #ifndef _WIN32 #include #endif -#include "gl/system/gl_interface.h" -extern RenderContext gl; #ifdef LoadMenu #undef LoadMenu diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp index d290fcc30..c41a1fb24 100644 --- a/src/gl/system/gl_wipe.cpp +++ b/src/gl/system/gl_wipe.cpp @@ -49,6 +49,7 @@ #include "templates.h" #include "vectors.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderstate.h" #include "gl/system/gl_framebuffer.h" @@ -506,7 +507,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) gl_RenderState.SetTextureMode(TM_MODULATE); gl_RenderState.Apply(true); - gl.ActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE1); glEnable(GL_TEXTURE_2D); // mask out the alpha channel of the wipeendscreen. @@ -518,7 +519,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS); glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); // Burn the new screen on top of it. glColor4f(1.f, 1.f, 1.f, 1.f); @@ -533,24 +534,24 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb) glBegin(GL_TRIANGLE_STRIP); - gl.MultiTexCoord2f(GL_TEXTURE0, 0, 0); - gl.MultiTexCoord2f(GL_TEXTURE1, 0, vb); + glMultiTexCoord2f(GL_TEXTURE0, 0, 0); + glMultiTexCoord2f(GL_TEXTURE1, 0, vb); glVertex2i(0, 0); - gl.MultiTexCoord2f(GL_TEXTURE0, 0, 1); - gl.MultiTexCoord2f(GL_TEXTURE1, 0, 0); + glMultiTexCoord2f(GL_TEXTURE0, 0, 1); + glMultiTexCoord2f(GL_TEXTURE1, 0, 0); glVertex2i(0, fb->Height); - gl.MultiTexCoord2f(GL_TEXTURE0, 1, 0); - gl.MultiTexCoord2f(GL_TEXTURE1, ur, vb); + glMultiTexCoord2f(GL_TEXTURE0, 1, 0); + glMultiTexCoord2f(GL_TEXTURE1, ur, vb); glVertex2i(fb->Width, 0); - gl.MultiTexCoord2f(GL_TEXTURE0, 1, 1); - gl.MultiTexCoord2f(GL_TEXTURE1, ur, 0); + glMultiTexCoord2f(GL_TEXTURE0, 1, 1); + glMultiTexCoord2f(GL_TEXTURE1, ur, 0); glVertex2i(fb->Width, fb->Height); glEnd(); - gl.ActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE1); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glDisable(GL_TEXTURE_2D); - gl.ActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE0); // The fire may not always stabilize, so the wipe is forced to end // after an arbitrary maximum time. diff --git a/src/gl/textures/gl_hqresize.cpp b/src/gl/textures/gl_hqresize.cpp index 36861f713..9145ac3f1 100644 --- a/src/gl/textures/gl_hqresize.cpp +++ b/src/gl/textures/gl_hqresize.cpp @@ -35,6 +35,7 @@ */ #include "gl/system/gl_system.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_texture.h" #include "c_cvars.h" diff --git a/src/gl/textures/gl_hwtexture.cpp b/src/gl/textures/gl_hwtexture.cpp index eaf581be4..4737f7717 100644 --- a/src/gl/textures/gl_hwtexture.cpp +++ b/src/gl/textures/gl_hwtexture.cpp @@ -46,6 +46,7 @@ #include "c_dispatch.h" #include "v_palette.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_cvars.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_material.h" @@ -266,7 +267,7 @@ void FHardwareTexture::Clean(bool all) DeleteTexture(glTexID_Translated[i].glTexID); } glTexID_Translated.Clear(); - if (glDepthID != 0) gl.DeleteRenderbuffers(1, &glDepthID); + if (glDepthID != 0) glDeleteRenderbuffers(1, &glDepthID); } //=========================================================================== @@ -327,9 +328,9 @@ unsigned int FHardwareTexture::Bind(int texunit, int cm,int translation) { if (lastbound[texunit]==*pTexID) return *pTexID; lastbound[texunit]=*pTexID; - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); glBindTexture(GL_TEXTURE_2D, *pTexID); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); return *pTexID; } return 0; @@ -340,9 +341,9 @@ void FHardwareTexture::Unbind(int texunit) { if (lastbound[texunit] != 0) { - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); glBindTexture(GL_TEXTURE_2D, 0); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); lastbound[texunit] = 0; } } @@ -367,11 +368,11 @@ int FHardwareTexture::GetDepthBuffer() { if (glDepthID == 0) { - gl.GenRenderbuffers(1, &glDepthID); - gl.BindRenderbuffer(GL_RENDERBUFFER, glDepthID); - gl.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, + glGenRenderbuffers(1, &glDepthID); + glBindRenderbuffer(GL_RENDERBUFFER, glDepthID); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, GetTexDimension(texwidth), GetTexDimension(texheight)); - gl.BindRenderbuffer(GL_RENDERBUFFER, 0); + glBindRenderbuffer(GL_RENDERBUFFER, 0); } return glDepthID; } @@ -389,8 +390,8 @@ void FHardwareTexture::BindToFrameBuffer() { if (gl.flags & RFL_FRAMEBUFFER) { - gl.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID[0], 0); - gl.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID[0], 0); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); } } @@ -407,9 +408,9 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int unsigned int * pTexID=GetTexID(cm, translation); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); + if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); LoadImage(buffer, w, h, *pTexID, wrap? GL_REPEAT:GL_CLAMP, cm==CM_SHADE, texunit); - if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); + if (texunit != 0) glActiveTexture(GL_TEXTURE0); return *pTexID; } diff --git a/src/gl/textures/gl_material.cpp b/src/gl/textures/gl_material.cpp index e124e18ee..b77920d57 100644 --- a/src/gl/textures/gl_material.cpp +++ b/src/gl/textures/gl_material.cpp @@ -50,6 +50,7 @@ //#include "gl/gl_intern.h" +#include "gl/system/gl_interface.h" #include "gl/system/gl_framebuffer.h" #include "gl/renderer/gl_lightdata.h" #include "gl/data/gl_data.h" diff --git a/src/gl/textures/gl_texture.cpp b/src/gl/textures/gl_texture.cpp index 6222c4b1c..68c33f125 100644 --- a/src/gl/textures/gl_texture.cpp +++ b/src/gl/textures/gl_texture.cpp @@ -48,6 +48,7 @@ #include "v_palette.h" #include "sc_man.h" +#include "gl/system/gl_interface.h" #include "gl/renderer/gl_renderer.h" #include "gl/textures/gl_texture.h" #include "gl/textures/gl_material.h"