- moved GLEXT API out of RenderContext struct.

This commit is contained in:
Christoph Oelckers 2013-09-03 18:29:39 +02:00
parent 26943fe3fd
commit 2885056f46
35 changed files with 379 additions and 348 deletions

View file

@ -3601,6 +3601,14 @@
<Filter <Filter
Name="System" Name="System"
> >
<File
RelativePath=".\src\gl\api\gl_api.cpp"
>
</File>
<File
RelativePath=".\src\gl\api\gl_api.h"
>
</File>
<File <File
RelativePath=".\src\gl\system\gl_cvars.h" RelativePath=".\src\gl\system\gl_cvars.h"
> >

View file

@ -886,6 +886,7 @@ add_executable( zdoom WIN32
menu/playermenu.cpp menu/playermenu.cpp
menu/readthis.cpp menu/readthis.cpp
menu/videomenu.cpp menu/videomenu.cpp
gl/api/gl_api.cpp
gl/data/gl_sections.cpp gl/data/gl_sections.cpp
gl/data/gl_data.cpp gl/data/gl_data.cpp
gl/data/gl_portaldata.cpp gl/data/gl_portaldata.cpp

4
src/gl/api/gl_api.cpp Normal file
View file

@ -0,0 +1,4 @@
#include "gl/system/gl_system.h"
#define __EXTERN
#include "gl_api.h"

100
src/gl/api/gl_api.h Normal file
View file

@ -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

View file

@ -52,6 +52,7 @@
#include "gi.h" #include "gi.h"
#include "g_level.h" #include "g_level.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"

View file

@ -43,6 +43,7 @@
#include "p_local.h" #include "p_local.h"
#include "m_argv.h" #include "m_argv.h"
#include "c_cvars.h" #include "c_cvars.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/data/gl_vertexbuffer.h" #include "gl/data/gl_vertexbuffer.h"
@ -77,7 +78,7 @@ FVertexBuffer::FVertexBuffer()
if (gl.flags&RFL_VBO) if (gl.flags&RFL_VBO)
{ {
if (gl_usevbo == -1) gl_usevbo.Callback(); 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) if (vbo_id != 0)
{ {
gl.DeleteBuffers(1, &vbo_id); glDeleteBuffers(1, &vbo_id);
} }
} }
@ -273,8 +274,8 @@ void FFlatVertexBuffer::MapVBO()
{ {
if (map == NULL) if (map == NULL)
{ {
gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
map = (FFlatVertex*)gl.MapBufferRange(GL_ARRAY_BUFFER, 0, vbo_shadowdata.Size() * sizeof(FFlatVertex), 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); GL_MAP_WRITE_BIT|GL_MAP_FLUSH_EXPLICIT_BIT|GL_MAP_UNSYNCHRONIZED_BIT);
} }
} }
@ -289,7 +290,7 @@ void FFlatVertexBuffer::UnmapVBO()
{ {
if (map != NULL) if (map != NULL)
{ {
gl.UnmapBuffer(GL_ARRAY_BUFFER); glUnmapBuffer(GL_ARRAY_BUFFER);
map = NULL; map = NULL;
} }
} }
@ -316,11 +317,11 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane)
MapVBO(); MapVBO();
if (map == NULL) return; // Error if (map == NULL) return; // Error
memcpy(&map[startvt], &vbo_shadowdata[startvt], countvt * sizeof(FFlatVertex)); 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 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) if (vbo_arg > 0)
{ {
CreateFlatVBO(); CreateFlatVBO();
gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl.BufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW); glBufferData(GL_ARRAY_BUFFER, vbo_shadowdata.Size() * sizeof(FFlatVertex), &vbo_shadowdata[0], GL_DYNAMIC_DRAW);
} }
else if (sectors) else if (sectors)
{ {
@ -362,8 +363,8 @@ void FFlatVertexBuffer::BindVBO()
if (vbo_arg > 0) if (vbo_arg > 0)
{ {
UnmapVBO(); UnmapVBO();
gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x); glVertexPointer(3,GL_FLOAT, sizeof(FFlatVertex), &VTO->x);
glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u); glTexCoordPointer(2,GL_FLOAT, sizeof(FFlatVertex), &VTO->u);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);

View file

@ -45,6 +45,7 @@
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
#include "g_level.h" #include "g_level.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"

View file

@ -66,11 +66,11 @@
FLightBuffer::FLightBuffer() FLightBuffer::FLightBuffer()
{ {
gl.GenBuffers(1, &mIDbuf_RGB); glGenBuffers(1, &mIDbuf_RGB);
gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB);
gl.GenBuffers(1, &mIDbuf_Position); glGenBuffers(1, &mIDbuf_Position);
gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position);
glGenTextures(1, &mIDtex_RGB); glGenTextures(1, &mIDtex_RGB);
glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB);
@ -90,9 +90,9 @@ FLightBuffer::FLightBuffer()
FLightBuffer::~FLightBuffer() FLightBuffer::~FLightBuffer()
{ {
gl.BindBuffer(GL_TEXTURE_BUFFER, 0); glBindBuffer(GL_TEXTURE_BUFFER, 0);
gl.DeleteBuffers(1, &mIDbuf_RGB); glDeleteBuffers(1, &mIDbuf_RGB);
gl.DeleteBuffers(1, &mIDbuf_Position); glDeleteBuffers(1, &mIDbuf_Position);
glBindTexture(GL_TEXTURE_BUFFER, 0); glBindTexture(GL_TEXTURE_BUFFER, 0);
glDeleteTextures(1, &mIDtex_RGB); glDeleteTextures(1, &mIDtex_RGB);
@ -108,11 +108,11 @@ FLightBuffer::~FLightBuffer()
void FLightBuffer::BindTextures(int texunit1, int texunit2) void FLightBuffer::BindTextures(int texunit1, int texunit2)
{ {
gl.ActiveTexture(texunit1); glActiveTexture(texunit1);
glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_RGB);
gl.ActiveTexture(texunit2); glActiveTexture(texunit2);
glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position); glBindTexture(GL_TEXTURE_BUFFER, mIDtex_Position);
gl.ActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
} }
@ -155,11 +155,11 @@ void FLightBuffer::CollectLightSources()
} }
GLRenderer->mLightCount = pPos.Size(); GLRenderer->mLightCount = pPos.Size();
gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB); glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_RGB);
gl.BufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW); glBufferData(GL_TEXTURE_BUFFER, pLights.Size() * sizeof (FLightRGB), &pLights[0], GL_STREAM_DRAW);
gl.BindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position); glBindBuffer(GL_TEXTURE_BUFFER, mIDbuf_Position);
gl.BufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW); glBufferData(GL_TEXTURE_BUFFER, pPos.Size() * sizeof (FLightPosition), &pPos[0], GL_STREAM_DRAW);
} }
} }
@ -173,8 +173,8 @@ void FLightBuffer::CollectLightSources()
FLightIndexBuffer::FLightIndexBuffer() FLightIndexBuffer::FLightIndexBuffer()
{ {
gl.GenBuffers(1, &mIDBuffer); glGenBuffers(1, &mIDBuffer);
gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer);
glGenTextures(1, &mIDTexture); glGenTextures(1, &mIDTexture);
glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); glBindTexture(GL_TEXTURE_BUFFER, mIDTexture);
@ -189,8 +189,8 @@ FLightIndexBuffer::FLightIndexBuffer()
FLightIndexBuffer::~FLightIndexBuffer() FLightIndexBuffer::~FLightIndexBuffer()
{ {
gl.BindBuffer(GL_TEXTURE_BUFFER, 0); glBindBuffer(GL_TEXTURE_BUFFER, 0);
gl.DeleteBuffers(1, &mIDBuffer); glDeleteBuffers(1, &mIDBuffer);
glBindTexture(GL_TEXTURE_BUFFER, 0); glBindTexture(GL_TEXTURE_BUFFER, 0);
glDeleteTextures(1, &mIDTexture); glDeleteTextures(1, &mIDTexture);
@ -219,9 +219,9 @@ void FLightIndexBuffer::AddLight(ADynamicLight *light)
void FLightIndexBuffer::SendBuffer() void FLightIndexBuffer::SendBuffer()
{ {
gl.BindBuffer(GL_TEXTURE_BUFFER, mIDBuffer); glBindBuffer(GL_TEXTURE_BUFFER, mIDBuffer);
gl.BufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW); glBufferData(GL_TEXTURE_BUFFER, mBuffer.Size() * sizeof (short), &mBuffer[0], GL_STREAM_DRAW);
gl.BindBuffer(GL_TEXTURE_BUFFER, 0); glBindBuffer(GL_TEXTURE_BUFFER, 0);
} }
@ -233,9 +233,9 @@ void FLightIndexBuffer::SendBuffer()
void FLightIndexBuffer::BindTexture(int texunit1) void FLightIndexBuffer::BindTexture(int texunit1)
{ {
gl.ActiveTexture(texunit1); glActiveTexture(texunit1);
glBindTexture(GL_TEXTURE_BUFFER, mIDTexture); glBindTexture(GL_TEXTURE_BUFFER, mIDTexture);
gl.ActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
} }

View file

@ -51,6 +51,7 @@
//#include "resources/voxels.h" //#include "resources/voxels.h"
//#include "gl/gl_intern.h" //#include "gl/gl_intern.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_drawinfo.h"
#include "gl/models/gl_models.h" #include "gl/models/gl_models.h"
@ -759,7 +760,7 @@ void gl_RenderModel(GLSprite * spr, int cm)
} }
else 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); glMatrixMode(GL_TEXTURE);
glLoadIdentity(); glLoadIdentity();
} }
@ -794,7 +795,7 @@ void gl_RenderModel(GLSprite * spr, int cm)
glRotatef(smf->pitchoffset, 0, 0, 1); glRotatef(smf->pitchoffset, 0, 0, 1);
glRotatef(-smf->rolloffset, 1, 0, 0); glRotatef(-smf->rolloffset, 1, 0, 0);
if (gl.shadermodel >= 4) gl.ActiveTexture(GL_TEXTURE0); if (gl.shadermodel >= 4) glActiveTexture(GL_TEXTURE0);
#if 0 #if 0
if (gl_light_models) if (gl_light_models)
@ -820,10 +821,10 @@ void gl_RenderModel(GLSprite * spr, int cm)
} }
else else
{ {
gl.ActiveTexture(GL_TEXTURE7); glActiveTexture(GL_TEXTURE7);
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadIdentity(); glLoadIdentity();
gl.ActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
} }

View file

@ -49,6 +49,7 @@
#include "textures/bitmap.h" #include "textures/bitmap.h"
//#include "gl/gl_intern.h" //#include "gl/gl_intern.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/data/gl_vertexbuffer.h" #include "gl/data/gl_vertexbuffer.h"
#include "gl/scene/gl_drawinfo.h" #include "gl/scene/gl_drawinfo.h"
@ -189,14 +190,14 @@ FVoxelVertexBuffer::FVoxelVertexBuffer(TArray<FVoxelVertex> &verts, TArray<unsig
ibo_id = 0; ibo_id = 0;
if (gl.flags&RFL_VBO) if (gl.flags&RFL_VBO)
{ {
gl.GenBuffers(1, &ibo_id); glGenBuffers(1, &ibo_id);
gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl.BufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW); glBufferData(GL_ARRAY_BUFFER, verts.Size() * sizeof(FVoxelVertex), &verts[0], GL_STATIC_DRAW);
gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id);
if (verts.Size() > 65535) if (verts.Size() > 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; isint = true;
} }
else else
@ -206,7 +207,7 @@ FVoxelVertexBuffer::FVoxelVertexBuffer(TArray<FVoxelVertex> &verts, TArray<unsig
{ {
sbuffer[i] = (unsigned short)indices[i]; sbuffer[i] = (unsigned short)indices[i];
} }
gl.BufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned short), sbuffer, GL_STATIC_DRAW); glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.Size() * sizeof(unsigned short), sbuffer, GL_STATIC_DRAW);
delete [] sbuffer; delete [] sbuffer;
isint = false; isint = false;
} }
@ -223,7 +224,7 @@ FVoxelVertexBuffer::~FVoxelVertexBuffer()
{ {
if (ibo_id != 0) if (ibo_id != 0)
{ {
gl.DeleteBuffers(1, &ibo_id); glDeleteBuffers(1, &ibo_id);
} }
} }
@ -236,8 +237,8 @@ FVoxelVertexBuffer::~FVoxelVertexBuffer()
void FVoxelVertexBuffer::BindVBO() void FVoxelVertexBuffer::BindVBO()
{ {
gl.BindBuffer(GL_ARRAY_BUFFER, vbo_id); glBindBuffer(GL_ARRAY_BUFFER, vbo_id);
gl.BindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo_id);
glVertexPointer(3,GL_FLOAT, sizeof(FVoxelVertex), &VVO->x); glVertexPointer(3,GL_FLOAT, sizeof(FVoxelVertex), &VVO->x);
glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u); glTexCoordPointer(2,GL_FLOAT, sizeof(FVoxelVertex), &VVO->u);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);

View file

@ -40,6 +40,7 @@
#include "gl/system/gl_system.h" #include "gl/system/gl_system.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/renderer/gl_colormap.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) if (gl_fixedcolormap)
{ {
gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0);
} }
else else
{ {
float lightlevel = gl_CalcLightLevel(light, rellight, weapon) / 255.0f; 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. // Korshun: fullbright fog like in software renderer.
if (glset.brightfog && fogdensity != 0 && fogcolor != 0) if (glset.brightfog && fogdensity != 0 && fogcolor != 0)
gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0);
} }
} }

View file

@ -50,6 +50,7 @@
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
#include "vectors.h" #include "vectors.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_threads.h" #include "gl/system/gl_threads.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
@ -123,7 +124,7 @@ FGLRenderer::~FGLRenderer()
if (glpart) delete glpart; if (glpart) delete glpart;
if (mirrortexture) delete mirrortexture; if (mirrortexture) delete mirrortexture;
if (gllight) delete gllight; 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 (gl.flags & RFL_FRAMEBUFFER)
{ {
if (mFBID == 0) gl.GenFramebuffers(1, &mFBID); if (mFBID == 0) glGenFramebuffers(1, &mFBID);
gl.BindFramebuffer(GL_FRAMEBUFFER, mFBID); glBindFramebuffer(GL_FRAMEBUFFER, mFBID);
return true; return true;
} }
return false; return false;
@ -230,7 +231,7 @@ void FGLRenderer::EndOffscreen()
{ {
if (gl.flags & RFL_FRAMEBUFFER) if (gl.flags & RFL_FRAMEBUFFER)
{ {
gl.BindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
} }
} }

View file

@ -39,6 +39,7 @@
*/ */
#include "gl/system/gl_system.h" #include "gl/system/gl_system.h"
#include "gl/system/gl_interface.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/shaders/gl_shader.h" #include "gl/shaders/gl_shader.h"
@ -203,15 +204,15 @@ bool FRenderState::ApplyShader()
if (fogset != activeShader->currentfogenabled) if (fogset != activeShader->currentfogenabled)
{ {
gl.Uniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset)); glUniform1i(activeShader->fogenabled_index, (activeShader->currentfogenabled = fogset));
} }
if (mTextureMode != activeShader->currenttexturemode) if (mTextureMode != activeShader->currenttexturemode)
{ {
gl.Uniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode)); glUniform1i(activeShader->texturemode_index, (activeShader->currenttexturemode = mTextureMode));
} }
if (activeShader->currentcamerapos.Update(&mCameraPos)) 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 || /*if (mLightParms[0] != activeShader->currentlightfactor ||
mLightParms[1] != activeShader->currentlightdist || mLightParms[1] != activeShader->currentlightdist ||
@ -223,28 +224,28 @@ bool FRenderState::ApplyShader()
//activeShader->currentfogdensity = mFogDensity; //activeShader->currentfogdensity = mFogDensity;
// premultiply the density with as much as possible here to reduce shader // premultiply the density with as much as possible here to reduce shader
// execution time. // 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) if (mFogColor != activeShader->currentfogcolor)
{ {
activeShader->currentfogcolor = mFogColor; 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); mFogColor.b/255.f, 0);
} }
if (mGlowEnabled) if (mGlowEnabled)
{ {
gl.Uniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec); glUniform4fv(activeShader->glowtopcolor_index, 1, mGlowTop.vec);
gl.Uniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec); glUniform4fv(activeShader->glowbottomcolor_index, 1, mGlowBottom.vec);
} }
if (mLightEnabled) if (mLightEnabled)
{ {
gl.Uniform3iv(activeShader->lightrange_index, 1, mNumLights); glUniform3iv(activeShader->lightrange_index, 1, mNumLights);
gl.Uniform4fv(activeShader->lights_index, mNumLights[2], mLightData); glUniform4fv(activeShader->lights_index, mNumLights[2], mLightData);
} }
if (glset.lightmode == 8) if (glset.lightmode == 8)
{ {
gl.Uniform3fv(activeShader->dlightcolor_index, 1, mDynLight); glUniform3fv(activeShader->dlightcolor_index, 1, mDynLight);
} }
return true; return true;
@ -284,7 +285,7 @@ void FRenderState::Apply(bool forcenoshader)
if (mBlendEquation != glBlendEquation) if (mBlendEquation != glBlendEquation)
{ {
glBlendEquation = mBlendEquation; glBlendEquation = mBlendEquation;
gl.BlendEquation(mBlendEquation); ::glBlendEquation(mBlendEquation);
} }
} }

View file

@ -263,7 +263,7 @@ public:
} }
else else
{ {
gl.BlendEquation(eq); ::glBlendEquation(eq);
} }
} }

View file

@ -368,9 +368,9 @@ void GLWall::DrawDecal(DBaseDecal *decal)
if (glset.lightmode == 8) if (glset.lightmode == 8)
{ {
if (gl_fixedcolormap) if (gl_fixedcolormap)
gl.VertexAttrib1f(VATTR_LIGHTLEVEL, 1.0); glVertexAttrib1f(VATTR_LIGHTLEVEL, 1.0);
else else
gl.VertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0); glVertexAttrib1f(VATTR_LIGHTLEVEL, gl_CalcLightLevel(light, rel, false) / 255.0);
} }
} }
else else

View file

@ -47,6 +47,7 @@
#include "doomstat.h" #include "doomstat.h"
#include "d_player.h" #include "d_player.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"

View file

@ -46,6 +46,7 @@
#include "doomstat.h" #include "doomstat.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_lightdata.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 occlusion query is supported let's use it to avoid rendering portals that aren't visible
if (doquery && gl.flags&RFL_OCCLUSION_QUERY) if (doquery && gl.flags&RFL_OCCLUSION_QUERY)
{ {
if (!QueryObject) gl.GenQueries(1, &QueryObject); if (!QueryObject) glGenQueries(1, &QueryObject);
if (QueryObject) if (QueryObject)
{ {
gl.BeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject); glBeginQuery(GL_SAMPLES_PASSED_ARB, QueryObject);
} }
else doquery = false; // some kind of error happened 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) if (doquery && gl.flags&RFL_OCCLUSION_QUERY)
{ {
gl.EndQuery(GL_SAMPLES_PASSED_ARB); glEndQuery(GL_SAMPLES_PASSED_ARB);
} }
// Clear Z-buffer // Clear Z-buffer
@ -233,7 +234,7 @@ bool GLPortal::Start(bool usestencil, bool doquery)
{ {
GLuint sampleCount; GLuint sampleCount;
gl.GetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount); glGetQueryObjectuiv(QueryObject, GL_QUERY_RESULT_ARB, &sampleCount);
if (sampleCount==0) // not visible if (sampleCount==0) // not visible
{ {

View file

@ -57,6 +57,7 @@
#include "p_local.h" #include "p_local.h"
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
@ -266,11 +267,11 @@ void FGLRenderer::SetViewMatrix(bool mirror, bool planemirror)
{ {
if (gl.shadermodel >= 4) if (gl.shadermodel >= 4)
{ {
gl.ActiveTexture(GL_TEXTURE7); glActiveTexture(GL_TEXTURE7);
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadIdentity(); glLoadIdentity();
} }
gl.ActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glMatrixMode(GL_TEXTURE); glMatrixMode(GL_TEXTURE);
glLoadIdentity(); glLoadIdentity();
@ -441,7 +442,7 @@ void FGLRenderer::RenderScene(int recursion)
{ {
gl_RenderState.BlendFunc(GL_ONE, GL_ONE); gl_RenderState.BlendFunc(GL_ONE, GL_ONE);
glDepthFunc(GL_EQUAL); 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++) for(int i=GLDL_FIRSTLIGHT; i<=GLDL_LASTLIGHT; i++)
{ {
gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT); gl_drawinfo->drawlists[i].Draw(GLPASS_LIGHT);

View file

@ -43,6 +43,7 @@
#include "r_state.h" #include "r_state.h"
//#include "gl/gl_intern.h" //#include "gl/gl_intern.h"
#include "gl/system/gl_interface.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"

View file

@ -47,6 +47,7 @@
#include "r_sky.h" #include "r_sky.h"
#include "r_utility.h" #include "r_utility.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"

View file

@ -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); glColor4f(r, g, b, alpha);
if (glset.lightmode == 8) 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]); gl_RenderState.SetDynLight(result[0], result[1], result[2]);
} }
return lightlevel; return lightlevel;

View file

@ -82,7 +82,7 @@ void GLWall::SplitUpperEdge(texcoord * tcs, bool glow)
float fracfac = sidefrac - glseg.fracleft; 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); ztop[0] - zfloor[0] + (fact - facf) * fracfac);
glTexCoord2f(tcs[1].u + facu * fracfac, tcs[1].v + facv * 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; 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); zbottom[0] - zfloor[0] + (facb - facf) * fracfac);
glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac); glTexCoord2f(tcs[0].u + facu * fracfac, tcs[0].v + facv * fracfac);
@ -150,7 +150,7 @@ void GLWall::SplitLeftEdge(texcoord * tcs, bool glow)
while (i<vi->numheights && vi->heightlist[i] <= zbottom[0] ) i++; while (i<vi->numheights && vi->heightlist[i] <= zbottom[0] ) i++;
while (i<vi->numheights && vi->heightlist[i] < ztop[0]) while (i<vi->numheights && 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, glTexCoord2f(factu1*(vi->heightlist[i] - ztop[0]) + tcs[1].u,
factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v); factv1*(vi->heightlist[i] - ztop[0]) + tcs[1].v);
glVertex3f(glseg.x1, vi->heightlist[i], glseg.y1); 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] >= ztop[1]) i--;
while (i>0 && vi->heightlist[i] > zbottom[1]) 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, glTexCoord2f(factu2 * (vi->heightlist[i] - ztop[1]) + tcs[2].u,
factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v); factv2 * (vi->heightlist[i] - ztop[1]) + tcs[2].v);
glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2); glVertex3f(glseg.x2, vi->heightlist[i], glseg.y2);

View file

@ -44,6 +44,7 @@
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
@ -248,14 +249,14 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light)
glBegin(GL_TRIANGLE_FAN); glBegin(GL_TRIANGLE_FAN);
// lower left corner // 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); if (textured&1) glTexCoord2f(tcs[0].u,tcs[0].v);
glVertex3f(glseg.x1,zbottom[0],glseg.y1); glVertex3f(glseg.x1,zbottom[0],glseg.y1);
if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing); if (split && glseg.fracleft==0) SplitLeftEdge(tcs, glowing);
// upper left corner // 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); if (textured&1) glTexCoord2f(tcs[1].u,tcs[1].v);
glVertex3f(glseg.x1,ztop[0],glseg.y1); glVertex3f(glseg.x1,ztop[0],glseg.y1);
@ -265,14 +266,14 @@ void GLWall::RenderWall(int textured, float * color2, ADynamicLight * light)
if (color2) glColor4fv(color2); if (color2) glColor4fv(color2);
// upper right corner // 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); if (textured&1) glTexCoord2f(tcs[2].u,tcs[2].v);
glVertex3f(glseg.x2,ztop[1],glseg.y2); glVertex3f(glseg.x2,ztop[1],glseg.y2);
if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing); if (split && glseg.fracright==1) SplitRightEdge(tcs, glowing);
// lower right corner // 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); if (textured&1) glTexCoord2f(tcs[3].u,tcs[3].v);
glVertex3f(glseg.x2,zbottom[1],glseg.y2); glVertex3f(glseg.x2,zbottom[1],glseg.y2);
@ -330,7 +331,7 @@ void GLWall::RenderFogBoundary()
gl_RenderState.AlphaFunc(GL_GREATER,0); gl_RenderState.AlphaFunc(GL_GREATER,0);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glColor4f(fc[0],fc[1],fc[2], fogd1); 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; flags &= ~GLWF_GLOW;
RenderWall(4,fc); RenderWall(4,fc);

View file

@ -45,6 +45,7 @@
#include "d_player.h" #include "d_player.h"
#include "g_level.h" #include "g_level.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"

View file

@ -49,6 +49,7 @@
#include "sc_man.h" #include "sc_man.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "gl/system/gl_interface.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderstate.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); hVertProg = glCreateShader(GL_VERTEX_SHADER);
hFragProg = gl.CreateShader(GL_FRAGMENT_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER);
int vp_size = (int)vp_comb.Len(); 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 *vp_ptr = vp_comb.GetChars();
const char *fp_ptr = fp_comb.GetChars(); const char *fp_ptr = fp_comb.GetChars();
gl.ShaderSource(hVertProg, 1, &vp_ptr, &vp_size); glShaderSource(hVertProg, 1, &vp_ptr, &vp_size);
gl.ShaderSource(hFragProg, 1, &fp_ptr, &fp_size); glShaderSource(hFragProg, 1, &fp_ptr, &fp_size);
gl.CompileShader(hVertProg); glCompileShader(hVertProg);
gl.CompileShader(hFragProg); glCompileShader(hFragProg);
hShader = gl.CreateProgram(); hShader = glCreateProgram();
gl.AttachShader(hShader, hVertProg); glAttachShader(hShader, hVertProg);
gl.AttachShader(hShader, hFragProg); glAttachShader(hShader, hFragProg);
gl.BindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance"); glBindAttribLocation(hShader, VATTR_GLOWDISTANCE, "glowdistance");
gl.BindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams"); glBindAttribLocation(hShader, VATTR_FOGPARAMS, "fogparams");
gl.BindAttribLocation(hShader, VATTR_LIGHTLEVEL, "lightlevel_in"); // Korshun. 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) if (*buffer)
{ {
error << "Vertex shader:\n" << buffer << "\n"; error << "Vertex shader:\n" << buffer << "\n";
} }
gl.GetShaderInfoLog(hFragProg, 10000, NULL, buffer); glGetShaderInfoLog(hFragProg, 10000, NULL, buffer);
if (*buffer) if (*buffer)
{ {
error << "Vertex shader:\n" << buffer << "\n"; error << "Vertex shader:\n" << buffer << "\n";
} }
gl.GetProgramInfoLog(hShader, 10000, NULL, buffer); glGetProgramInfoLog(hShader, 10000, NULL, buffer);
if (*buffer) if (*buffer)
{ {
error << "Linking:\n" << buffer << "\n"; error << "Linking:\n" << buffer << "\n";
} }
int linked; int linked;
gl.GetObjectParameteriv(hShader, GL_LINK_STATUS, &linked); glGetObjectParameteriv(hShader, GL_LINK_STATUS, &linked);
if (linked == 0) if (linked == 0)
{ {
// only print message if there's an error. // only print message if there's an error.
Printf("Init Shader '%s':\n%s\n", name, error.GetChars()); Printf("Init Shader '%s':\n%s\n", name, error.GetChars());
} }
timer_index = gl.GetUniformLocation(hShader, "timer"); timer_index = glGetUniformLocation(hShader, "timer");
desaturation_index = gl.GetUniformLocation(hShader, "desaturation_factor"); desaturation_index = glGetUniformLocation(hShader, "desaturation_factor");
fogenabled_index = gl.GetUniformLocation(hShader, "fogenabled"); fogenabled_index = glGetUniformLocation(hShader, "fogenabled");
texturemode_index = gl.GetUniformLocation(hShader, "texturemode"); texturemode_index = glGetUniformLocation(hShader, "texturemode");
camerapos_index = gl.GetUniformLocation(hShader, "camerapos"); camerapos_index = glGetUniformLocation(hShader, "camerapos");
lightparms_index = gl.GetUniformLocation(hShader, "lightparms"); lightparms_index = glGetUniformLocation(hShader, "lightparms");
colormapstart_index = gl.GetUniformLocation(hShader, "colormapstart"); colormapstart_index = glGetUniformLocation(hShader, "colormapstart");
colormaprange_index = gl.GetUniformLocation(hShader, "colormaprange"); colormaprange_index = glGetUniformLocation(hShader, "colormaprange");
lightrange_index = gl.GetUniformLocation(hShader, "lightrange"); lightrange_index = glGetUniformLocation(hShader, "lightrange");
fogcolor_index = gl.GetUniformLocation(hShader, "fogcolor"); fogcolor_index = glGetUniformLocation(hShader, "fogcolor");
lights_index = gl.GetUniformLocation(hShader, "lights"); lights_index = glGetUniformLocation(hShader, "lights");
dlightcolor_index = gl.GetUniformLocation(hShader, "dlightcolor"); dlightcolor_index = glGetUniformLocation(hShader, "dlightcolor");
glowbottomcolor_index = gl.GetUniformLocation(hShader, "bottomglowcolor"); glowbottomcolor_index = glGetUniformLocation(hShader, "bottomglowcolor");
glowtopcolor_index = gl.GetUniformLocation(hShader, "topglowcolor"); glowtopcolor_index = glGetUniformLocation(hShader, "topglowcolor");
gl.UseProgram(hShader); glUseProgram(hShader);
int texture_index = gl.GetUniformLocation(hShader, "texture2"); int texture_index = glGetUniformLocation(hShader, "texture2");
if (texture_index > 0) gl.Uniform1i(texture_index, 1); if (texture_index > 0) glUniform1i(texture_index, 1);
gl.UseProgram(0); glUseProgram(0);
return !!linked; return !!linked;
} }
return false; return false;
@ -204,9 +205,9 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
FShader::~FShader() FShader::~FShader()
{ {
gl.DeleteProgram(hShader); glDeleteProgram(hShader);
gl.DeleteShader(hVertProg); glDeleteShader(hVertProg);
gl.DeleteShader(hFragProg); glDeleteShader(hFragProg);
} }
@ -219,7 +220,7 @@ FShader::~FShader()
bool FShader::Bind(float Speed) bool FShader::Bind(float Speed)
{ {
GLRenderer->mShaderManager->SetActiveShader(this); 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; 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], float m[3]= {map->ColorizeEnd[0] - map->ColorizeStart[0],
map->ColorizeEnd[1] - map->ColorizeStart[1], map->ColorizeEnd[2] - map->ColorizeStart[2]}; map->ColorizeEnd[1] - map->ColorizeStart[1], map->ColorizeEnd[2] - map->ColorizeStart[2]};
gl.Uniform3fv(sh->colormapstart_index, 1, map->ColorizeStart); glUniform3fv(sh->colormapstart_index, 1, map->ColorizeStart);
gl.Uniform3fv(sh->colormaprange_index, 1, m); glUniform3fv(sh->colormaprange_index, 1, m);
} }
} }
else else
@ -390,7 +391,7 @@ FShader *FShaderContainer::Bind(int cm, bool glowing, float Speed, bool lights)
sh->Bind(Speed); sh->Bind(Speed);
if (desat) 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. // shadermodel needs to be tested here because without it UseProgram will be NULL.
if (gl.shadermodel > 0 && mActiveShader != sh) if (gl.shadermodel > 0 && mActiveShader != sh)
{ {
gl.UseProgram(sh == NULL? 0 : sh->GetHandle()); glUseProgram(sh == NULL? 0 : sh->GetHandle());
mActiveShader = sh; mActiveShader = sh;
} }
} }

Binary file not shown.

View file

@ -43,6 +43,7 @@
#include "version.h" #include "version.h"
#include "i_system.h" #include "i_system.h"
#include "v_text.h" #include "v_text.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#if defined (__unix__) || defined (__APPLE__) #if defined (__unix__) || defined (__APPLE__)
@ -116,7 +117,7 @@ static bool CheckExtension(const char *ext)
static void InitContext() static void InitContext()
{ {
gl.flags=0; gl.flags=0;
gl.BlendEquation = glBlendEquationDummy; glBlendEquation = glBlendEquationDummy;
} }
//========================================================================== //==========================================================================
@ -151,11 +152,11 @@ void gl_LoadExtensions()
gl.vendorstring=(char*)glGetString(GL_VENDOR); gl.vendorstring=(char*)glGetString(GL_VENDOR);
// First try the regular function // First try the regular function
gl.BlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation"); glBlendEquation = (PFNGLBLENDEQUATIONPROC)wglGetProcAddress("glBlendEquation");
// If that fails try the EXT version // 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 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_non_power_of_two")) gl.flags|=RFL_NPOT_TEXTURE;
if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION; if (CheckExtension("GL_ARB_texture_compression")) gl.flags|=RFL_TEXTURE_COMPRESSION;
@ -172,64 +173,64 @@ void gl_LoadExtensions()
if (gl.flags & RFL_GL_20) if (gl.flags & RFL_GL_20)
{ {
gl.DeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader"); glDeleteShader = (PFNGLDELETESHADERPROC)wglGetProcAddress("glDeleteShader");
gl.DeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram"); glDeleteProgram = (PFNGLDELETEPROGRAMPROC)wglGetProcAddress("glDeleteProgram");
gl.DetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader"); glDetachShader = (PFNGLDETACHSHADERPROC)wglGetProcAddress("glDetachShader");
gl.CreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader"); glCreateShader = (PFNGLCREATESHADERPROC)wglGetProcAddress("glCreateShader");
gl.ShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource"); glShaderSource = (PFNGLSHADERSOURCEPROC)wglGetProcAddress("glShaderSource");
gl.CompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader"); glCompileShader = (PFNGLCOMPILESHADERPROC)wglGetProcAddress("glCompileShader");
gl.CreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram"); glCreateProgram = (PFNGLCREATEPROGRAMPROC)wglGetProcAddress("glCreateProgram");
gl.AttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader"); glAttachShader = (PFNGLATTACHSHADERPROC)wglGetProcAddress("glAttachShader");
gl.LinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram"); glLinkProgram = (PFNGLLINKPROGRAMPROC)wglGetProcAddress("glLinkProgram");
gl.UseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram"); glUseProgram = (PFNGLUSEPROGRAMPROC)wglGetProcAddress("glUseProgram");
gl.ValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram"); glValidateProgram = (PFNGLVALIDATEPROGRAMPROC)wglGetProcAddress("glValidateProgram");
gl.VertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f"); glVertexAttrib1f = (PFNGLVERTEXATTRIB1FPROC)wglGetProcAddress("glVertexAttrib1f");
gl.VertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f"); glVertexAttrib2f = (PFNGLVERTEXATTRIB2FPROC)wglGetProcAddress("glVertexAttrib2f");
gl.VertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f"); glVertexAttrib4f = (PFNGLVERTEXATTRIB4FPROC)wglGetProcAddress("glVertexAttrib4f");
gl.VertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv"); glVertexAttrib2fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib2fv");
gl.VertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv"); glVertexAttrib3fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib3fv");
gl.VertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv"); glVertexAttrib4fv = (PFNGLVERTEXATTRIB4FVPROC)wglGetProcAddress("glVertexAttrib4fv");
gl.VertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv"); glVertexAttrib4ubv = (PFNGLVERTEXATTRIB4UBVPROC)wglGetProcAddress("glVertexAttrib4ubv");
gl.GetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation"); glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC)wglGetProcAddress("glGetAttribLocation");
gl.BindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation"); glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC)wglGetProcAddress("glBindAttribLocation");
gl.Uniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f"); glUniform1f = (PFNGLUNIFORM1FPROC)wglGetProcAddress("glUniform1f");
gl.Uniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f"); glUniform2f = (PFNGLUNIFORM2FPROC)wglGetProcAddress("glUniform2f");
gl.Uniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f"); glUniform3f = (PFNGLUNIFORM3FPROC)wglGetProcAddress("glUniform3f");
gl.Uniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f"); glUniform4f = (PFNGLUNIFORM4FPROC)wglGetProcAddress("glUniform4f");
gl.Uniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i"); glUniform1i = (PFNGLUNIFORM1IPROC)wglGetProcAddress("glUniform1i");
gl.Uniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i"); glUniform2i = (PFNGLUNIFORM2IPROC)wglGetProcAddress("glUniform2i");
gl.Uniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i"); glUniform3i = (PFNGLUNIFORM3IPROC)wglGetProcAddress("glUniform3i");
gl.Uniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i"); glUniform4i = (PFNGLUNIFORM4IPROC)wglGetProcAddress("glUniform4i");
gl.Uniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv"); glUniform1fv = (PFNGLUNIFORM1FVPROC)wglGetProcAddress("glUniform1fv");
gl.Uniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv"); glUniform2fv = (PFNGLUNIFORM2FVPROC)wglGetProcAddress("glUniform2fv");
gl.Uniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv"); glUniform3fv = (PFNGLUNIFORM3FVPROC)wglGetProcAddress("glUniform3fv");
gl.Uniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv"); glUniform4fv = (PFNGLUNIFORM4FVPROC)wglGetProcAddress("glUniform4fv");
gl.Uniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv"); glUniform1iv = (PFNGLUNIFORM1IVPROC)wglGetProcAddress("glUniform1iv");
gl.Uniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv"); glUniform2iv = (PFNGLUNIFORM2IVPROC)wglGetProcAddress("glUniform2iv");
gl.Uniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv"); glUniform3iv = (PFNGLUNIFORM3IVPROC)wglGetProcAddress("glUniform3iv");
gl.Uniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv"); glUniform4iv = (PFNGLUNIFORM4IVPROC)wglGetProcAddress("glUniform4iv");
gl.UniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv"); glUniformMatrix2fv = (PFNGLUNIFORMMATRIX2FVPROC)wglGetProcAddress("glUniformMatrix2fv");
gl.UniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv"); glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC)wglGetProcAddress("glUniformMatrix3fv");
gl.UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv"); glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC)wglGetProcAddress("glUniformMatrix4fv");
gl.GetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog"); glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC)wglGetProcAddress("glGetProgramInfoLog");
gl.GetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog"); glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC)wglGetProcAddress("glGetShaderInfoLog");
gl.GetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation"); glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC)wglGetProcAddress("glGetUniformLocation");
gl.GetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform"); glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC)wglGetProcAddress("glGetActiveUniform");
gl.GetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv"); glGetUniformfv = (PFNGLGETUNIFORMFVPROC)wglGetProcAddress("glGetUniformfv");
gl.GetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv"); glGetUniformiv = (PFNGLGETUNIFORMIVPROC)wglGetProcAddress("glGetUniformiv");
gl.GetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource"); glGetShaderSource = (PFNGLGETSHADERSOURCEPROC)wglGetProcAddress("glGetShaderSource");
gl.EnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray"); glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glEnableVertexAttribArray");
gl.DisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray"); glDisableVertexAttribArray= (PFNGLDISABLEVERTEXATTRIBARRAYPROC)wglGetProcAddress("glDisableVertexAttribArray");
gl.VertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer"); glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC)wglGetProcAddress("glVertexAttribPointer");
// what'S the equivalent of this in GL 2.0??? // what'S the equivalent of this in GL 2.0???
gl.GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB"); glGetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)wglGetProcAddress("glGetObjectParameterivARB");
// Rules: // Rules:
// SM4 will always use shaders. No option to switch them off is needed here. // 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")) if (CheckExtension("GL_ARB_occlusion_query"))
{ {
gl.GenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB"); glGenQueries = (PFNGLGENQUERIESARBPROC)wglGetProcAddress("glGenQueriesARB");
gl.DeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB"); glDeleteQueries = (PFNGLDELETEQUERIESARBPROC)wglGetProcAddress("glDeleteQueriesARB");
gl.GetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB"); glGetQueryObjectuiv = (PFNGLGETQUERYOBJECTUIVARBPROC)wglGetProcAddress("glGetQueryObjectuivARB");
gl.BeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB"); glBeginQuery = (PFNGLBEGINQUERYARBPROC)wglGetProcAddress("glBeginQueryARB");
gl.EndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB"); glEndQuery = (PFNGLENDQUERYPROC)wglGetProcAddress("glEndQueryARB");
gl.flags|=RFL_OCCLUSION_QUERY; gl.flags|=RFL_OCCLUSION_QUERY;
} }
if (gl.flags & RFL_GL_21) if (gl.flags & RFL_GL_21)
{ {
gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer"); glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBuffer");
gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers"); glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffers");
gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers"); glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffers");
gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData"); glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferData");
gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData"); glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubData");
gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer"); glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBuffer");
gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer"); glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBuffer");
gl.flags |= RFL_VBO; gl.flags |= RFL_VBO;
} }
else if (CheckExtension("GL_ARB_vertex_buffer_object")) else if (CheckExtension("GL_ARB_vertex_buffer_object"))
{ {
gl.BindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB"); glBindBuffer = (PFNGLBINDBUFFERPROC)wglGetProcAddress("glBindBufferARB");
gl.DeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB"); glDeleteBuffers = (PFNGLDELETEBUFFERSPROC)wglGetProcAddress("glDeleteBuffersARB");
gl.GenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB"); glGenBuffers = (PFNGLGENBUFFERSPROC)wglGetProcAddress("glGenBuffersARB");
gl.BufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB"); glBufferData = (PFNGLBUFFERDATAPROC)wglGetProcAddress("glBufferDataARB");
gl.BufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB"); glBufferSubData = (PFNGLBUFFERSUBDATAPROC)wglGetProcAddress("glBufferSubDataARB");
gl.MapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB"); glMapBuffer = (PFNGLMAPBUFFERPROC)wglGetProcAddress("glMapBufferARB");
gl.UnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB"); glUnmapBuffer = (PFNGLUNMAPBUFFERPROC)wglGetProcAddress("glUnmapBufferARB");
gl.flags |= RFL_VBO; gl.flags |= RFL_VBO;
} }
if (CheckExtension("GL_ARB_map_buffer_range")) if (CheckExtension("GL_ARB_map_buffer_range"))
{ {
gl.MapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange"); glMapBufferRange = (PFNGLMAPBUFFERRANGEPROC)wglGetProcAddress("glMapBufferRange");
gl.FlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange"); glFlushMappedBufferRange = (PFNGLFLUSHMAPPEDBUFFERRANGEPROC)wglGetProcAddress("glFlushMappedBufferRange");
gl.flags|=RFL_MAP_BUFFER_RANGE; gl.flags|=RFL_MAP_BUFFER_RANGE;
} }
if (CheckExtension("GL_ARB_framebuffer_object")) if (CheckExtension("GL_ARB_framebuffer_object"))
{ {
gl.GenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers"); glGenFramebuffers = (PFNGLGENFRAMEBUFFERSPROC)wglGetProcAddress("glGenFramebuffers");
gl.DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers"); glDeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSPROC)wglGetProcAddress("glDeleteFramebuffers");
gl.BindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer"); glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC)wglGetProcAddress("glBindFramebuffer");
gl.FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D"); glFramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DPROC)wglGetProcAddress("glFramebufferTexture2D");
gl.GenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers"); glGenRenderbuffers = (PFNGLGENRENDERBUFFERSPROC)wglGetProcAddress("glGenRenderbuffers");
gl.DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers"); glDeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSPROC)wglGetProcAddress("glDeleteRenderbuffers");
gl.BindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer"); glBindRenderbuffer = (PFNGLBINDRENDERBUFFERPROC)wglGetProcAddress("glBindRenderbuffer");
gl.RenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage"); glRenderbufferStorage = (PFNGLRENDERBUFFERSTORAGEPROC)wglGetProcAddress("glRenderbufferStorage");
gl.FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer"); glFramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFERPROC)wglGetProcAddress("glFramebufferRenderbuffer");
gl.flags|=RFL_FRAMEBUFFER; gl.flags|=RFL_FRAMEBUFFER;
} }
@ -310,16 +311,16 @@ void gl_LoadExtensions()
CheckExtension("GL_ARB_texture_rg") && CheckExtension("GL_ARB_texture_rg") &&
gl.shadermodel == 4) gl.shadermodel == 4)
{ {
gl.TexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB"); glTexBufferARB = (PFNGLTEXBUFFERARBPROC)wglGetProcAddress("glTexBufferARB");
gl.flags|=RFL_TEXTUREBUFFER; gl.flags|=RFL_TEXTUREBUFFER;
} }
#endif #endif
gl.ActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB"); glActiveTexture = (PFNGLACTIVETEXTUREPROC)wglGetProcAddress("glActiveTextureARB");
gl.MultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB"); glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FPROC) wglGetProcAddress("glMultiTexCoord2fARB");
gl.MultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB"); glMultiTexCoord2fv = (PFNGLMULTITEXCOORD2FVPROC) wglGetProcAddress("glMultiTexCoord2fvARB");
} }
//========================================================================== //==========================================================================

View file

@ -1,22 +1,7 @@
#ifndef R_RENDER #ifndef R_RENDER
#define R_RENDER #define R_RENDER
#if defined(__APPLE__)
#define APIENTRY
#define APIENTRYP *
#endif // __APPLE__
#include "basictypes.h" #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 enum RenderFlags
{ {
@ -65,98 +50,9 @@ struct RenderContext
{ {
return maxuniforms>=2048? 128:64; 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 #endif

View file

@ -5,6 +5,7 @@
#include "c_dispatch.h" #include "c_dispatch.h"
#include "v_video.h" #include "v_video.h"
#include "version.h" #include "version.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "menu/menu.h" #include "menu/menu.h"

View file

@ -74,6 +74,7 @@
#include <GL/glu.h> #include <GL/glu.h>
#include <GL/glext.h> #include <GL/glext.h>
#endif // __APPLE__ #endif // __APPLE__
#include "gl/api/gl_api.h"
#ifdef _WIN32 #ifdef _WIN32
#define DWORD WINDOWS_DWORD // I don't want to depend on this throughout the GL code! #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 #ifndef _WIN32
#include <SDL.h> #include <SDL.h>
#endif #endif
#include "gl/system/gl_interface.h"
extern RenderContext gl;
#ifdef LoadMenu #ifdef LoadMenu
#undef LoadMenu #undef LoadMenu

View file

@ -49,6 +49,7 @@
#include "templates.h" #include "templates.h"
#include "vectors.h" #include "vectors.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
#include "gl/system/gl_framebuffer.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.SetTextureMode(TM_MODULATE);
gl_RenderState.Apply(true); gl_RenderState.Apply(true);
gl.ActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
// mask out the alpha channel of the wipeendscreen. // 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_SOURCE0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA); 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. // Burn the new screen on top of it.
glColor4f(1.f, 1.f, 1.f, 1.f); 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); glBegin(GL_TRIANGLE_STRIP);
gl.MultiTexCoord2f(GL_TEXTURE0, 0, 0); glMultiTexCoord2f(GL_TEXTURE0, 0, 0);
gl.MultiTexCoord2f(GL_TEXTURE1, 0, vb); glMultiTexCoord2f(GL_TEXTURE1, 0, vb);
glVertex2i(0, 0); glVertex2i(0, 0);
gl.MultiTexCoord2f(GL_TEXTURE0, 0, 1); glMultiTexCoord2f(GL_TEXTURE0, 0, 1);
gl.MultiTexCoord2f(GL_TEXTURE1, 0, 0); glMultiTexCoord2f(GL_TEXTURE1, 0, 0);
glVertex2i(0, fb->Height); glVertex2i(0, fb->Height);
gl.MultiTexCoord2f(GL_TEXTURE0, 1, 0); glMultiTexCoord2f(GL_TEXTURE0, 1, 0);
gl.MultiTexCoord2f(GL_TEXTURE1, ur, vb); glMultiTexCoord2f(GL_TEXTURE1, ur, vb);
glVertex2i(fb->Width, 0); glVertex2i(fb->Width, 0);
gl.MultiTexCoord2f(GL_TEXTURE0, 1, 1); glMultiTexCoord2f(GL_TEXTURE0, 1, 1);
gl.MultiTexCoord2f(GL_TEXTURE1, ur, 0); glMultiTexCoord2f(GL_TEXTURE1, ur, 0);
glVertex2i(fb->Width, fb->Height); glVertex2i(fb->Width, fb->Height);
glEnd(); glEnd();
gl.ActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
gl.ActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
// The fire may not always stabilize, so the wipe is forced to end // The fire may not always stabilize, so the wipe is forced to end
// after an arbitrary maximum time. // after an arbitrary maximum time.

View file

@ -35,6 +35,7 @@
*/ */
#include "gl/system/gl_system.h" #include "gl/system/gl_system.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/textures/gl_texture.h" #include "gl/textures/gl_texture.h"
#include "c_cvars.h" #include "c_cvars.h"

View file

@ -46,6 +46,7 @@
#include "c_dispatch.h" #include "c_dispatch.h"
#include "v_palette.h" #include "v_palette.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/textures/gl_material.h" #include "gl/textures/gl_material.h"
@ -266,7 +267,7 @@ void FHardwareTexture::Clean(bool all)
DeleteTexture(glTexID_Translated[i].glTexID); DeleteTexture(glTexID_Translated[i].glTexID);
} }
glTexID_Translated.Clear(); 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; if (lastbound[texunit]==*pTexID) return *pTexID;
lastbound[texunit]=*pTexID; lastbound[texunit]=*pTexID;
if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit);
glBindTexture(GL_TEXTURE_2D, *pTexID); glBindTexture(GL_TEXTURE_2D, *pTexID);
if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); if (texunit != 0) glActiveTexture(GL_TEXTURE0);
return *pTexID; return *pTexID;
} }
return 0; return 0;
@ -340,9 +341,9 @@ void FHardwareTexture::Unbind(int texunit)
{ {
if (lastbound[texunit] != 0) if (lastbound[texunit] != 0)
{ {
if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0+texunit); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
if (texunit != 0) gl.ActiveTexture(GL_TEXTURE0); if (texunit != 0) glActiveTexture(GL_TEXTURE0);
lastbound[texunit] = 0; lastbound[texunit] = 0;
} }
} }
@ -367,11 +368,11 @@ int FHardwareTexture::GetDepthBuffer()
{ {
if (glDepthID == 0) if (glDepthID == 0)
{ {
gl.GenRenderbuffers(1, &glDepthID); glGenRenderbuffers(1, &glDepthID);
gl.BindRenderbuffer(GL_RENDERBUFFER, glDepthID); glBindRenderbuffer(GL_RENDERBUFFER, glDepthID);
gl.RenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8,
GetTexDimension(texwidth), GetTexDimension(texheight)); GetTexDimension(texwidth), GetTexDimension(texheight));
gl.BindRenderbuffer(GL_RENDERBUFFER, 0); glBindRenderbuffer(GL_RENDERBUFFER, 0);
} }
return glDepthID; return glDepthID;
} }
@ -389,8 +390,8 @@ void FHardwareTexture::BindToFrameBuffer()
{ {
if (gl.flags & RFL_FRAMEBUFFER) if (gl.flags & RFL_FRAMEBUFFER)
{ {
gl.FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID[0], 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID[0], 0);
gl.FramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer()); 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); 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); 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; return *pTexID;
} }

View file

@ -50,6 +50,7 @@
//#include "gl/gl_intern.h" //#include "gl/gl_intern.h"
#include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"

View file

@ -48,6 +48,7 @@
#include "v_palette.h" #include "v_palette.h"
#include "sc_man.h" #include "sc_man.h"
#include "gl/system/gl_interface.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/textures/gl_texture.h" #include "gl/textures/gl_texture.h"
#include "gl/textures/gl_material.h" #include "gl/textures/gl_material.h"