1
0
forked from mirrors/0ad

Use GLAD2 a multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator.

Comments by: @nwtour, @Langbart, @bb
Based on patch by: @echotangoecho
Tested on Windows 7 & 10, Ubuntu and macos.

Differential Revision: https://code.wildfiregames.com/D721
This was SVN commit r26093.
This commit is contained in:
Stan
2021-12-21 22:03:31 +00:00
parent a32ab00f4d
commit c9bea80e0d
31 changed files with 569 additions and 1050 deletions
+3
View File
@@ -333,6 +333,9 @@ extern_lib_defs = {
})
end,
},
glad = {
add_source_include_paths("glad")
},
gloox = {
compile_settings = function()
if os.istarget("windows") then
+15
View File
@@ -917,6 +917,21 @@ function setup_all_libs ()
setup_static_lib_project("lowlevel", source_dirs, extern_libs, extra_params)
setup_static_lib_project("gladwrapper", {}, { "opengl", "glad" }, { no_pch = 1 })
glad_path = libraries_source_dir.."glad/"
sysincludedirs { glad_path.."include" }
if _OPTIONS["gles"] then
files { glad_path.."src/gles2.cpp" }
else
files { glad_path.."src/gl.cpp" }
if os.istarget("windows") then
files { glad_path.."src/wgl.cpp" }
elseif os.istarget("linux") or os.istarget("bsd") then
files { glad_path.."src/glx.cpp" }
end
end
-- Third-party libraries that are built as part of the main project,
-- not built externally and then linked
source_dirs = {
+3
View File
@@ -20,6 +20,9 @@ win32/ contains headers and precompiled static libs for Windows builds.
source/nvtt
MIT - see src/NVIDIA_Texture_Tools_LICENSE.txt
source/glad
MIT
source/spidermonkey
MPL / GPL / LGPL
+8 -8
View File
@@ -71,7 +71,7 @@ CLOSTexture::CLOSTexture(CSimulation2& simulation)
CLOSTexture::~CLOSTexture()
{
if (m_smoothFbo)
pglDeleteFramebuffersEXT(1, &m_smoothFbo);
glDeleteFramebuffersEXT(1, &m_smoothFbo);
if (m_Texture)
DeleteTexture();
@@ -92,7 +92,7 @@ bool CLOSTexture::CreateShader()
return false;
}
pglGenFramebuffersEXT(1, &m_smoothFbo);
glGenFramebuffersEXT(1, &m_smoothFbo);
return true;
}
@@ -158,11 +158,11 @@ void CLOSTexture::InterpolateLOS()
m_Dirty = false;
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_smoothFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
whichTex ? m_TextureSmooth2 : m_TextureSmooth1, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_smoothFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
whichTex ? m_TextureSmooth2 : m_TextureSmooth1, 0);
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("LOS framebuffer object incomplete: 0x%04X", status);
@@ -212,9 +212,9 @@ void CLOSTexture::InterpolateLOS()
shader->Unbind();
m_smoothShader->EndPass();
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, 0, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
whichTex = !whichTex;
}
+7 -7
View File
@@ -237,17 +237,17 @@ void CMiniMapTexture::CreateTextures(const CTerrain* terrain)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
pglGenFramebuffersEXT(1, &m_FinalTextureFBO);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FinalTextureFBO);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FinalTexture, 0);
glGenFramebuffersEXT(1, &m_FinalTextureFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FinalTextureFBO);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FinalTexture, 0);
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("MiniMapTexture Framebuffer object incomplete (A): 0x%04X", status);
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void CMiniMapTexture::DestroyTextures()
@@ -345,7 +345,7 @@ void CMiniMapTexture::RenderFinalTexture()
return;
m_FinalTextureDirty = false;
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FinalTextureFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FinalTextureFBO);
const SViewPort oldViewPort = g_Renderer.GetViewport();
const SViewPort viewPort = { 0, 0, FINAL_TEXTURE_SIZE, FINAL_TEXTURE_SIZE };
@@ -521,7 +521,7 @@ void CMiniMapTexture::RenderFinalTexture()
tech->EndPass();
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
g_Renderer.SetViewport(oldViewPort);
}
+1 -1
View File
@@ -189,7 +189,7 @@ void CParticleEmitter::Bind(const CShaderProgramPtr& shader)
shader->Uniform(str_fogParams, lightEnv.m_FogFactor, lightEnv.m_FogMax, 0.f, 0.f);
shader->BindTexture(str_baseTex, m_Type->m_Texture);
pglBlendEquationEXT(m_Type->m_BlendEquation);
glBlendEquationEXT(m_Type->m_BlendEquation);
glBlendFunc(m_Type->m_BlendFuncSrc, m_Type->m_BlendFuncDst);
}
+75 -73
View File
@@ -30,6 +30,8 @@
#include "ps/CLogger.h"
#include "ps/Filesystem.h"
#include <algorithm>
#if !CONFIG2_GLES
class CShaderProgramARB : public CShaderProgram
@@ -44,27 +46,27 @@ public:
m_Defines(defines),
m_VertexIndexes(vertexIndexes), m_FragmentIndexes(fragmentIndexes)
{
pglGenProgramsARB(1, &m_VertexProgram);
pglGenProgramsARB(1, &m_FragmentProgram);
glGenProgramsARB(1, &m_VertexProgram);
glGenProgramsARB(1, &m_FragmentProgram);
}
~CShaderProgramARB()
{
Unload();
pglDeleteProgramsARB(1, &m_VertexProgram);
pglDeleteProgramsARB(1, &m_FragmentProgram);
glDeleteProgramsARB(1, &m_VertexProgram);
glDeleteProgramsARB(1, &m_FragmentProgram);
}
bool Compile(GLuint target, const char* targetName, GLuint program, const VfsPath& file, const CStr& code)
{
ogl_WarnIfError();
pglBindProgramARB(target, program);
glBindProgramARB(target, program);
ogl_WarnIfError();
pglProgramStringARB(target, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)code.length(), code.c_str());
glProgramStringARB(target, GL_PROGRAM_FORMAT_ASCII_ARB, (GLsizei)code.length(), code.c_str());
if (ogl_SquelchError(GL_INVALID_OPERATION))
{
@@ -76,7 +78,7 @@ public:
return false;
}
pglBindProgramARB(target, 0);
glBindProgramARB(target, 0);
ogl_WarnIfError();
@@ -119,8 +121,8 @@ public:
{
glEnable(GL_VERTEX_PROGRAM_ARB);
glEnable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, m_VertexProgram);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_FragmentProgram);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, m_VertexProgram);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, m_FragmentProgram);
BindClientStates();
}
@@ -129,8 +131,8 @@ public:
{
glDisable(GL_VERTEX_PROGRAM_ARB);
glDisable(GL_FRAGMENT_PROGRAM_ARB);
pglBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0);
pglBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
glBindProgramARB(GL_VERTEX_PROGRAM_ARB, 0);
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0);
UnbindClientStates();
@@ -171,7 +173,7 @@ public:
{
GLuint h;
ogl_tex_get_texture_id(tex, &h);
pglActiveTextureARB(GL_TEXTURE0+index);
glActiveTextureARB(GL_TEXTURE0+index);
glBindTexture(fPair.second, h);
}
}
@@ -182,7 +184,7 @@ public:
int index = fPair.first;
if (index != -1)
{
pglActiveTextureARB(GL_TEXTURE0+index);
glActiveTextureARB(GL_TEXTURE0+index);
glBindTexture(fPair.second, tex);
}
}
@@ -202,28 +204,28 @@ public:
void Uniform(Binding id, float v0, float v1, float v2, float v3) override
{
if (id.first != -1)
pglProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first, v0, v1, v2, v3);
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first, v0, v1, v2, v3);
if (id.second != -1)
pglProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second, v0, v1, v2, v3);
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second, v0, v1, v2, v3);
}
void Uniform(Binding id, const CMatrix3D& v) override
{
if (id.first != -1)
{
pglProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+0, v._11, v._12, v._13, v._14);
pglProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+1, v._21, v._22, v._23, v._24);
pglProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+2, v._31, v._32, v._33, v._34);
pglProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+3, v._41, v._42, v._43, v._44);
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+0, v._11, v._12, v._13, v._14);
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+1, v._21, v._22, v._23, v._24);
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+2, v._31, v._32, v._33, v._34);
glProgramLocalParameter4fARB(GL_VERTEX_PROGRAM_ARB, (GLuint)id.first+3, v._41, v._42, v._43, v._44);
}
if (id.second != -1)
{
pglProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+0, v._11, v._12, v._13, v._14);
pglProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+1, v._21, v._22, v._23, v._24);
pglProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+2, v._31, v._32, v._33, v._34);
pglProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+3, v._41, v._42, v._43, v._44);
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+0, v._11, v._12, v._13, v._14);
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+1, v._21, v._22, v._23, v._24);
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+2, v._31, v._32, v._33, v._34);
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, (GLuint)id.second+3, v._41, v._42, v._43, v._44);
}
}
@@ -278,8 +280,8 @@ public:
m_VertexAttribs(vertexAttribs)
{
m_Program = 0;
m_VertexShader = pglCreateShaderObjectARB(GL_VERTEX_SHADER);
m_FragmentShader = pglCreateShaderObjectARB(GL_FRAGMENT_SHADER);
m_VertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER);
m_FragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
m_FileDependencies = {m_VertexFile, m_FragmentFile};
}
@@ -287,8 +289,8 @@ public:
{
Unload();
pglDeleteShader(m_VertexShader);
pglDeleteShader(m_FragmentShader);
glDeleteShader(m_VertexShader);
glDeleteShader(m_FragmentShader);
}
bool Compile(GLhandleARB shader, const VfsPath& file, const CStr& code)
@@ -299,15 +301,15 @@ public:
const char* code_string = code.c_str();
GLint code_length = code.length();
pglShaderSourceARB(shader, 1, &code_string, &code_length);
glShaderSourceARB(shader, 1, &code_string, &code_length);
pglCompileShaderARB(shader);
glCompileShaderARB(shader);
GLint ok = 0;
pglGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
glGetShaderiv(shader, GL_COMPILE_STATUS, &ok);
GLint length = 0;
pglGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
// Apparently sometimes GL_INFO_LOG_LENGTH is incorrectly reported as 0
// (http://code.google.com/p/android/issues/detail?id=9953)
@@ -317,7 +319,7 @@ public:
if (length > 1)
{
char* infolog = new char[length];
pglGetShaderInfoLog(shader, length, NULL, infolog);
glGetShaderInfoLog(shader, length, NULL, infolog);
if (ok)
LOGMESSAGE("Info when compiling shader '%s':\n%s", file.string8(), infolog);
@@ -337,26 +339,26 @@ public:
TIMER_ACCRUE(tc_ShaderGLSLLink);
ENSURE(!m_Program);
m_Program = pglCreateProgramObjectARB();
m_Program = glCreateProgramObjectARB();
pglAttachObjectARB(m_Program, m_VertexShader);
glAttachObjectARB(m_Program, m_VertexShader);
ogl_WarnIfError();
pglAttachObjectARB(m_Program, m_FragmentShader);
glAttachObjectARB(m_Program, m_FragmentShader);
ogl_WarnIfError();
// Set up the attribute bindings explicitly, since apparently drivers
// don't always pick the most efficient bindings automatically,
// and also this lets us hardcode indexes into VertexPointer etc
for (std::map<CStrIntern, int>::iterator it = m_VertexAttribs.begin(); it != m_VertexAttribs.end(); ++it)
pglBindAttribLocationARB(m_Program, it->second, it->first.c_str());
glBindAttribLocationARB(m_Program, it->second, it->first.c_str());
pglLinkProgramARB(m_Program);
glLinkProgramARB(m_Program);
GLint ok = 0;
pglGetProgramiv(m_Program, GL_LINK_STATUS, &ok);
glGetProgramiv(m_Program, GL_LINK_STATUS, &ok);
GLint length = 0;
pglGetProgramiv(m_Program, GL_INFO_LOG_LENGTH, &length);
glGetProgramiv(m_Program, GL_INFO_LOG_LENGTH, &length);
if (!ok && length == 0)
length = 4096;
@@ -364,7 +366,7 @@ public:
if (length > 1)
{
char* infolog = new char[length];
pglGetProgramInfoLog(m_Program, length, NULL, infolog);
glGetProgramInfoLog(m_Program, length, NULL, infolog);
if (ok)
LOGMESSAGE("Info when linking program '%s'+'%s':\n%s", m_VertexFile.string8(), m_FragmentFile.string8(), infolog);
@@ -387,7 +389,7 @@ public:
ogl_WarnIfError();
GLint numUniforms = 0;
pglGetProgramiv(m_Program, GL_ACTIVE_UNIFORMS, &numUniforms);
glGetProgramiv(m_Program, GL_ACTIVE_UNIFORMS, &numUniforms);
ogl_WarnIfError();
for (GLint i = 0; i < numUniforms; ++i)
{
@@ -395,10 +397,10 @@ public:
GLsizei nameLength = 0;
GLint size = 0;
GLenum type = 0;
pglGetActiveUniformARB(m_Program, i, ARRAY_SIZE(name), &nameLength, &size, &type, name);
glGetActiveUniformARB(m_Program, i, ARRAY_SIZE(name), &nameLength, &size, &type, name);
ogl_WarnIfError();
GLint loc = pglGetUniformLocationARB(m_Program, name);
GLint loc = glGetUniformLocationARB(m_Program, name);
CStrIntern nameIntern(name);
m_Uniforms[nameIntern] = std::make_pair(loc, type);
@@ -414,7 +416,7 @@ public:
int unit = (int)m_Samplers.size();
m_Samplers[nameIntern].first = (type == GL_SAMPLER_CUBE ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D);
m_Samplers[nameIntern].second = unit;
pglUniform1iARB(loc, unit); // link uniform to unit
glUniform1iARB(loc, unit); // link uniform to unit
ogl_WarnIfError();
}
}
@@ -502,7 +504,7 @@ public:
m_IsValid = false;
if (m_Program)
pglDeleteProgram(m_Program);
glDeleteProgram(m_Program);
m_Program = 0;
// The shader objects can be reused and don't need to be deleted here
@@ -510,18 +512,18 @@ public:
void Bind() override
{
pglUseProgramObjectARB(m_Program);
glUseProgramObjectARB(m_Program);
for (std::map<CStrIntern, int>::iterator it = m_VertexAttribs.begin(); it != m_VertexAttribs.end(); ++it)
pglEnableVertexAttribArrayARB(it->second);
glEnableVertexAttribArrayARB(it->second);
}
void Unbind() override
{
pglUseProgramObjectARB(0);
glUseProgramObjectARB(0);
for (std::map<CStrIntern, int>::iterator it = m_VertexAttribs.begin(); it != m_VertexAttribs.end(); ++it)
pglDisableVertexAttribArrayARB(it->second);
glDisableVertexAttribArrayARB(it->second);
// TODO: should unbind textures, probably
}
@@ -543,7 +545,7 @@ public:
GLuint h;
ogl_tex_get_texture_id(tex, &h);
pglActiveTextureARB(GL_TEXTURE0 + it->second.second);
glActiveTextureARB(GL_TEXTURE0 + it->second.second);
glBindTexture(it->second.first, h);
}
@@ -553,7 +555,7 @@ public:
if (it == m_Samplers.end())
return;
pglActiveTextureARB(GL_TEXTURE0 + it->second.second);
glActiveTextureARB(GL_TEXTURE0 + it->second.second);
glBindTexture(it->second.first, tex);
}
@@ -564,7 +566,7 @@ public:
GLuint h;
ogl_tex_get_texture_id(tex, &h);
pglActiveTextureARB(GL_TEXTURE0 + id.second);
glActiveTextureARB(GL_TEXTURE0 + id.second);
glBindTexture(id.first, h);
}
@@ -582,13 +584,13 @@ public:
if (id.first != -1)
{
if (id.second == GL_FLOAT)
pglUniform1fARB(id.first, v0);
glUniform1fARB(id.first, v0);
else if (id.second == GL_FLOAT_VEC2)
pglUniform2fARB(id.first, v0, v1);
glUniform2fARB(id.first, v0, v1);
else if (id.second == GL_FLOAT_VEC3)
pglUniform3fARB(id.first, v0, v1, v2);
glUniform3fARB(id.first, v0, v1, v2);
else if (id.second == GL_FLOAT_VEC4)
pglUniform4fARB(id.first, v0, v1, v2, v3);
glUniform4fARB(id.first, v0, v1, v2, v3);
else
LOGERROR("CShaderProgramGLSL::Uniform(): Invalid uniform type (expected float, vec2, vec3, vec4)");
}
@@ -599,7 +601,7 @@ public:
if (id.first != -1)
{
if (id.second == GL_FLOAT_MAT4)
pglUniformMatrix4fvARB(id.first, 1, GL_FALSE, &v._11);
glUniformMatrix4fvARB(id.first, 1, GL_FALSE, &v._11);
else
LOGERROR("CShaderProgramGLSL::Uniform(): Invalid uniform type (expected mat4)");
}
@@ -610,7 +612,7 @@ public:
if (id.first != -1)
{
if (id.second == GL_FLOAT_MAT4)
pglUniformMatrix4fvARB(id.first, count, GL_FALSE, &v->_11);
glUniformMatrix4fvARB(id.first, count, GL_FALSE, &v->_11);
else
LOGERROR("CShaderProgramGLSL::Uniform(): Invalid uniform type (expected mat4)");
}
@@ -621,7 +623,7 @@ public:
if (id.first != -1)
{
if (id.second == GL_FLOAT)
pglUniform1fvARB(id.first, count, v);
glUniform1fvARB(id.first, count, v);
else
LOGERROR("CShaderProgramGLSL::Uniform(): Invalid uniform type (expected float)");
}
@@ -632,25 +634,25 @@ public:
void VertexPointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override
{
pglVertexAttribPointerARB(0, size, type, GL_FALSE, stride, pointer);
glVertexAttribPointerARB(0, size, type, GL_FALSE, stride, pointer);
m_ValidStreams |= STREAM_POS;
}
void NormalPointer(GLenum type, GLsizei stride, const void* pointer) override
{
pglVertexAttribPointerARB(2, 3, type, (type == GL_FLOAT ? GL_FALSE : GL_TRUE), stride, pointer);
glVertexAttribPointerARB(2, 3, type, (type == GL_FLOAT ? GL_FALSE : GL_TRUE), stride, pointer);
m_ValidStreams |= STREAM_NORMAL;
}
void ColorPointer(GLint size, GLenum type, GLsizei stride, const void* pointer) override
{
pglVertexAttribPointerARB(3, size, type, (type == GL_FLOAT ? GL_FALSE : GL_TRUE), stride, pointer);
glVertexAttribPointerARB(3, size, type, (type == GL_FLOAT ? GL_FALSE : GL_TRUE), stride, pointer);
m_ValidStreams |= STREAM_COLOR;
}
void TexCoordPointer(GLenum texture, GLint size, GLenum type, GLsizei stride, const void* pointer) override
{
pglVertexAttribPointerARB(8 + texture - GL_TEXTURE0, size, type, GL_FALSE, stride, pointer);
glVertexAttribPointerARB(8 + texture - GL_TEXTURE0, size, type, GL_FALSE, stride, pointer);
m_ValidStreams |= STREAM_UV0 << (texture - GL_TEXTURE0);
}
@@ -659,7 +661,7 @@ public:
std::map<CStrIntern, int>::iterator it = m_VertexAttribs.find(id);
if (it != m_VertexAttribs.end())
{
pglVertexAttribPointerARB(it->second, size, type, normalized, stride, pointer);
glVertexAttribPointerARB(it->second, size, type, normalized, stride, pointer);
}
}
@@ -671,7 +673,7 @@ public:
#if CONFIG2_GLES
debug_warn(L"glVertexAttribIPointer not supported on GLES");
#else
pglVertexAttribIPointerEXT(it->second, size, type, stride, pointer);
glVertexAttribIPointerEXT(it->second, size, type, stride, pointer);
#endif
}
}
@@ -880,9 +882,9 @@ void CShaderProgram::ColorPointer(GLint size, GLenum type, GLsizei stride, const
void CShaderProgram::TexCoordPointer(GLenum texture, GLint size, GLenum type, GLsizei stride, const void* pointer)
{
pglClientActiveTextureARB(texture);
glClientActiveTextureARB(texture);
glTexCoordPointer(size, type, stride, pointer);
pglClientActiveTextureARB(GL_TEXTURE0);
glClientActiveTextureARB(GL_TEXTURE0);
m_ValidStreams |= STREAM_UV0 << (texture - GL_TEXTURE0);
}
@@ -898,15 +900,15 @@ void CShaderProgram::BindClientStates()
if (m_StreamFlags & STREAM_UV0)
{
pglClientActiveTextureARB(GL_TEXTURE0);
glClientActiveTextureARB(GL_TEXTURE0);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (m_StreamFlags & STREAM_UV1)
{
pglClientActiveTextureARB(GL_TEXTURE1);
glClientActiveTextureARB(GL_TEXTURE1);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
pglClientActiveTextureARB(GL_TEXTURE0);
glClientActiveTextureARB(GL_TEXTURE0);
}
// Rendering code must subsequently call VertexPointer etc for all of the streams
@@ -923,15 +925,15 @@ void CShaderProgram::UnbindClientStates()
if (m_StreamFlags & STREAM_UV0)
{
pglClientActiveTextureARB(GL_TEXTURE0);
glClientActiveTextureARB(GL_TEXTURE0);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
if (m_StreamFlags & STREAM_UV1)
{
pglClientActiveTextureARB(GL_TEXTURE1);
glClientActiveTextureARB(GL_TEXTURE1);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
pglClientActiveTextureARB(GL_TEXTURE0);
glClientActiveTextureARB(GL_TEXTURE0);
}
}
-436
View File
@@ -1,436 +0,0 @@
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* OpenGL extension function declarations (X macros).
*/
#include "lib/config2.h" // CONFIG2_GLES
#if CONFIG2_GLES
# include <GLES2/gl2ext.h>
#elif OS_MACOSX
# include <OpenGL/glext.h>
#else
# include <GL/glext.h>
#endif
#if OS_WIN
# include <GL/wglext.h>
#endif
/*
FUNC is used for functions that are only extensions.
FUNC2 is used for functions that have been promoted to core features.
FUNC3 is used for functions that have been promoted to core features
but have slightly changed semantics and need to be referred to by their
core name instead of extension name.
The FUNC2/FUNC3 calls include the version of OpenGL in which the extension was promoted,
and the pre- and post-promotion names (e.g. "glBindBufferARB" vs "glBindBuffer").
If the GL driver is advertising a sufficiently high version, we load the promoted
name; otherwise we use the *ARB name. (The spec says:
"GL implementations of such later revisions should continue to export the name
strings of promoted extensions in the EXTENSIONS string, and continue to support
the ARB-affixed versions of functions and enumerants as a transition aid."
but some drivers might be stupid/buggy and fail to do that, so we don't just use
the ARB names unconditionally.)
The names are made accessible to engine code only via the ARB name, to make it
obvious that care must be taken (i.e. by being certain that the extension is
actually supported).
*/
#if CONFIG2_GLES
// some functions that are extensions in GL are core functions in GLES,
// so we should use them without the function pointer indirection
#define pglActiveTextureARB glActiveTexture
#define pglBlendColorEXT glBlendColor
#define pglBlendEquationEXT glBlendEquation
#define pglClientActiveTextureARB glClientActiveTexture
#define pglCompressedTexImage2DARB glCompressedTexImage2D
#define pglAttachObjectARB glAttachShader
#define pglBindAttribLocationARB glBindAttribLocation
#define pglCompileShaderARB glCompileShader
#define pglCreateProgramObjectARB glCreateProgram
#define pglCreateShaderObjectARB glCreateShader
#define pglDeleteProgram glDeleteProgram
#define pglDeleteShader glDeleteShader
#define pglDisableVertexAttribArrayARB glDisableVertexAttribArray
#define pglEnableVertexAttribArrayARB glEnableVertexAttribArray
#define pglGetActiveUniformARB glGetActiveUniform
#define pglGetProgramiv glGetProgramiv
#define pglGetProgramInfoLog glGetProgramInfoLog
#define pglGetShaderiv glGetShaderiv
#define pglGetShaderInfoLog glGetShaderInfoLog
#define pglGetUniformLocationARB glGetUniformLocation
#define pglLinkProgramARB glLinkProgram
#define pglShaderSourceARB glShaderSource
#define pglUniform1fARB glUniform1f
#define pglUniform2fARB glUniform2f
#define pglUniform3fARB glUniform3f
#define pglUniform4fARB glUniform4f
#define pglUniform1iARB glUniform1i
#define pglUniformMatrix4fvARB glUniformMatrix4fv
#define pglUseProgramObjectARB glUseProgram
#define pglVertexAttribPointerARB glVertexAttribPointer
#define pglBindBufferARB glBindBuffer
#define pglBufferDataARB glBufferData
#define pglBufferSubDataARB glBufferSubData
#define pglDeleteBuffersARB glDeleteBuffers
#define pglGenBuffersARB glGenBuffers
// Those EXT symbols don't exist in GLES 2.0, since it imported the ARB version instead.
#define pglBindFramebufferEXT glBindFramebuffer
#define pglCheckFramebufferStatusEXT glCheckFramebufferStatus
#define pglDeleteFramebuffersEXT glDeleteFramebuffers
#define pglFramebufferTexture2DEXT glFramebufferTexture2D
#define pglGenFramebuffersEXT glGenFramebuffers
#define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
// Those should come from GLES 2.0 core, not from GL_EXT_draw_buffers.
#ifndef GL_COLOR_ATTACHMENT0_EXT
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT1
#endif
#ifndef GL_DEPTH_ATTACHMENT_EXT
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
#endif
// GL_OES_mapbuffer
FUNC(GLvoid*, glMapBufferOES, (GLenum target, GLenum access))
FUNC(GLboolean, glUnmapBufferOES, (GLenum target))
#define pglMapBufferARB pglMapBufferOES
#define pglUnmapBufferARB pglUnmapBufferOES
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
// GL_OES_texture_border_clamp
#define GL_CLAMP_TO_BORDER GL_CLAMP_TO_EDGE
// GL_OES_rgb8_rgba8
#define GL_RGBA8 GL_RGBA8_OES
// GL_OES_depth32
#define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES
typedef GLuint GLhandleARB;
#else
// We might not have multisample on macOS.
#ifndef GL_TEXTURE_2D_MULTISAMPLE
#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
#endif
// were these defined as real functions in gl.h already?
// GL_EXT_draw_range_elements / GL1.2:
FUNC2(void, glDrawRangeElementsEXT, glDrawRangeElements, "1.2", (GLenum, GLuint, GLuint, GLsizei, GLenum, GLvoid*))
// GL_ARB_multitexture / GL1.3:
FUNC2(void, glMultiTexCoord2fARB, glMultiTexCoord2f, "1.3", (int, float, float))
FUNC2(void, glMultiTexCoord3fARB, glMultiTexCoord3f, "1.3", (int, float, float, float))
FUNC2(void, glActiveTextureARB, glActiveTexture, "1.3", (int))
FUNC2(void, glClientActiveTextureARB, glClientActiveTexture, "1.3", (int))
// GL_EXT_blend_color / GL1.4 (optional in 1.2):
FUNC2(void, glBlendColorEXT, glBlendColor, "1.4", (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha))
// GL_EXT_blend_minmax / GL1.4 (optional in 1.2):
FUNC2(void, glBlendEquationEXT, glBlendEquation, "1.4", (GLenum mode))
// GL_ARB_vertex_buffer_object / GL1.5:
FUNC2(void, glBindBufferARB, glBindBuffer, "1.5", (int target, GLuint buffer))
FUNC2(void, glDeleteBuffersARB, glDeleteBuffers, "1.5", (GLsizei n, const GLuint* buffers))
FUNC2(void, glGenBuffersARB, glGenBuffers, "1.5", (GLsizei n, GLuint* buffers))
FUNC2(bool, glIsBufferARB, glIsBuffer, "1.5", (GLuint buffer))
FUNC2(void, glBufferDataARB, glBufferData, "1.5", (int target, GLsizeiptrARB size, const void* data, int usage))
FUNC2(void, glBufferSubDataARB, glBufferSubData, "1.5", (int target, GLintptrARB offset, GLsizeiptrARB size, const void* data))
FUNC2(void, glGetBufferSubDataARB, glGetBufferSubData, "1.5", (int target, GLintptrARB offset, GLsizeiptrARB size, void* data))
FUNC2(void*, glMapBufferARB, glMapBuffer, "1.5", (int target, int access))
FUNC2(bool, glUnmapBufferARB, glUnmapBuffer, "1.5", (int target))
FUNC2(void, glGetBufferParameterivARB, glGetBufferParameteriv, "1.5", (int target, int pname, int* params))
FUNC2(void, glGetBufferPointervARB, glGetBufferPointerv, "1.5", (int target, int pname, void** params))
// GL_ARB_texture_compression / GL1.3
FUNC2(void, glCompressedTexImage3DARB, glCompressedTexImage3D, "1.3", (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*))
FUNC2(void, glCompressedTexImage2DARB, glCompressedTexImage2D, "1.3", (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*))
FUNC2(void, glCompressedTexImage1DARB, glCompressedTexImage1D, "1.3", (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid*))
FUNC2(void, glCompressedTexSubImage3DARB, glCompressedTexSubImage3D, "1.3", (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*))
FUNC2(void, glCompressedTexSubImage2DARB, glCompressedTexSubImage2D, "1.3", (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*))
FUNC2(void, glCompressedTexSubImage1DARB, glCompressedTexSubImage1D, "1.3", (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid*))
FUNC2(void, glGetCompressedTexImageARB, glGetCompressedTexImage, "1.3", (GLenum, GLint, GLvoid*))
// GL_EXT_framebuffer_object
FUNC(GLboolean, glIsRenderbufferEXT, (GLuint renderbuffer))
FUNC(void, glBindRenderbufferEXT, (GLenum target, GLuint renderbuffer))
FUNC(void, glDeleteRenderbuffersEXT, (GLsizei n, const GLuint *renderbuffers))
FUNC(void, glGenRenderbuffersEXT, (GLsizei n, GLuint *renderbuffers))
FUNC(void, glRenderbufferStorageEXT, (GLenum target, GLenum internalformat, GLsizei width, GLsizei height))
FUNC(void, glGetRenderbufferParameterivEXT, (GLenum target, GLenum pname, GLint *params))
FUNC(GLboolean, glIsFramebufferEXT, (GLuint framebuffer))
FUNC(void, glBindFramebufferEXT, (GLenum target, GLuint framebuffer))
FUNC(void, glDeleteFramebuffersEXT, (GLsizei n, const GLuint *framebuffers))
FUNC(void, glGenFramebuffersEXT, (GLsizei n, GLuint *framebuffers))
FUNC(GLenum, glCheckFramebufferStatusEXT, (GLenum target))
FUNC(void, glFramebufferTexture1DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))
FUNC(void, glFramebufferTexture2DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level))
FUNC(void, glFramebufferTexture3DEXT, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset))
FUNC(void, glFramebufferRenderbufferEXT, (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer))
FUNC(void, glGetFramebufferAttachmentParameterivEXT, (GLenum target, GLenum attachment, GLenum pname, GLint *params))
FUNC(void, glGenerateMipmapEXT, (GLenum target))
FUNC(void, glBlitFramebufferEXT, (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter))
FUNC(void, glDrawBuffers, (GLsizei n, const GLenum *bufs))
// GL_ARB_vertex_program, GL_ARB_fragment_program
FUNC(void, glProgramStringARB, (GLenum target, GLenum format, GLsizei len, const GLvoid *string))
FUNC(void, glBindProgramARB, (GLenum target, GLuint program))
FUNC(void, glDeleteProgramsARB, (GLsizei n, const GLuint *programs))
FUNC(void, glGenProgramsARB, (GLsizei n, GLuint *programs))
FUNC(void, glProgramEnvParameter4dARB, (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w))
FUNC(void, glProgramEnvParameter4dvARB, (GLenum target, GLuint index, const GLdouble *params))
FUNC(void, glProgramEnvParameter4fARB, (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
FUNC(void, glProgramEnvParameter4fvARB, (GLenum target, GLuint index, const GLfloat *params))
FUNC(void, glProgramLocalParameter4dARB, (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w))
FUNC(void, glProgramLocalParameter4dvARB, (GLenum target, GLuint index, const GLdouble *params))
FUNC(void, glProgramLocalParameter4fARB, (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w))
FUNC(void, glProgramLocalParameter4fvARB, (GLenum target, GLuint index, const GLfloat *params))
FUNC(void, glGetProgramEnvParameterdvARB, (GLenum target, GLuint index, GLdouble *params))
FUNC(void, glGetProgramEnvParameterfvARB, (GLenum target, GLuint index, GLfloat *params))
FUNC(void, glGetProgramLocalParameterdvARB, (GLenum target, GLuint index, GLdouble *params))
FUNC(void, glGetProgramLocalParameterfvARB, (GLenum target, GLuint index, GLfloat *params))
FUNC(void, glGetProgramivARB, (GLenum target, GLenum pname, GLint *params))
FUNC(void, glGetProgramStringARB, (GLenum target, GLenum pname, GLvoid *string))
FUNC(GLboolean, glIsProgramARB, (GLuint program))
// GL_ARB_shader_objects
// (NOTE: Many of these have "Object" in their ARB names, but "Program" or "Shader" in their core names.
// When both Program and Shader versions exist, we use FUNC3 here and the engine must call the specific
// core name instead of the generic ARB name.)
FUNC3(void, glDeleteObjectARB, glDeleteShader, "2.0", (GLhandleARB obj))
FUNC3(void, glDeleteObjectARB, glDeleteProgram, "2.0", (GLhandleARB obj))
// FUNC2(GLhandleARB, glGetHandleARB, glGetHandle, "2.0", (GLenum pname))
// there is no analog to the ARB function in GL 2.0 (the functionality is probably moved into glGetIntegerv(GL_CURRENT_PROGRAM))
// so we can't represent it in this FUNC2 system, so just pretend it doesn't exist
FUNC2(void, glDetachObjectARB, glDetachShader, "2.0", (GLhandleARB containerObj, GLhandleARB attachedObj))
FUNC2(GLhandleARB, glCreateShaderObjectARB, glCreateShader, "2.0", (GLenum shaderType))
FUNC2(void, glShaderSourceARB, glShaderSource, "2.0", (GLhandleARB shaderObj, GLsizei count, const char **string, const GLint *length))
FUNC2(void, glCompileShaderARB, glCompileShader, "2.0", (GLhandleARB shaderObj))
FUNC2(GLhandleARB, glCreateProgramObjectARB, glCreateProgram, "2.0", (void))
FUNC2(void, glAttachObjectARB, glAttachShader, "2.0", (GLhandleARB containerObj, GLhandleARB obj))
FUNC2(void, glLinkProgramARB, glLinkProgram, "2.0", (GLhandleARB programObj))
FUNC2(void, glUseProgramObjectARB, glUseProgram, "2.0", (GLhandleARB programObj))
FUNC2(void, glValidateProgramARB, glValidateProgram, "2.0", (GLhandleARB programObj))
FUNC2(void, glUniform1fARB, glUniform1f, "2.0", (GLint location, GLfloat v0))
FUNC2(void, glUniform2fARB, glUniform2f, "2.0", (GLint location, GLfloat v0, GLfloat v1))
FUNC2(void, glUniform3fARB, glUniform3f, "2.0", (GLint location, GLfloat v0, GLfloat v1, GLfloat v2))
FUNC2(void, glUniform4fARB, glUniform4f, "2.0", (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3))
FUNC2(void, glUniform1iARB, glUniform1i, "2.0", (GLint location, GLint v0))
FUNC2(void, glUniform2iARB, glUniform2i, "2.0", (GLint location, GLint v0, GLint v1))
FUNC2(void, glUniform3iARB, glUniform3i, "2.0", (GLint location, GLint v0, GLint v1, GLint v2))
FUNC2(void, glUniform4iARB, glUniform4i, "2.0", (GLint location, GLint v0, GLint v1, GLint v2, GLint v3))
FUNC2(void, glUniform1fvARB, glUniform1fv, "2.0", (GLint location, GLsizei count, const GLfloat *value))
FUNC2(void, glUniform2fvARB, glUniform2fv, "2.0", (GLint location, GLsizei count, const GLfloat *value))
FUNC2(void, glUniform3fvARB, glUniform3fv, "2.0", (GLint location, GLsizei count, const GLfloat *value))
FUNC2(void, glUniform4fvARB, glUniform4fv, "2.0", (GLint location, GLsizei count, const GLfloat *value))
FUNC2(void, glUniform1ivARB, glUniform1iv, "2.0", (GLint location, GLsizei count, const GLint *value))
FUNC2(void, glUniform2ivARB, glUniform2iv, "2.0", (GLint location, GLsizei count, const GLint *value))
FUNC2(void, glUniform3ivARB, glUniform3iv, "2.0", (GLint location, GLsizei count, const GLint *value))
FUNC2(void, glUniform4ivARB, glUniform4iv, "2.0", (GLint location, GLsizei count, const GLint *value))
FUNC2(void, glUniformMatrix2fvARB, glUniformMatrix2fv, "2.0", (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
FUNC2(void, glUniformMatrix3fvARB, glUniformMatrix3fv, "2.0", (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
FUNC2(void, glUniformMatrix4fvARB, glUniformMatrix4fv, "2.0", (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value))
FUNC3(void, glGetObjectParameterfvARB, glGetProgramfv, "2.0", (GLhandleARB obj, GLenum pname, GLfloat *params))
FUNC3(void, glGetObjectParameterfvARB, glGetShaderfv, "2.0", (GLhandleARB obj, GLenum pname, GLfloat *params))
FUNC3(void, glGetObjectParameterivARB, glGetProgramiv, "2.0", (GLhandleARB obj, GLenum pname, GLint *params))
FUNC3(void, glGetObjectParameterivARB, glGetShaderiv, "2.0", (GLhandleARB obj, GLenum pname, GLint *params))
FUNC3(void, glGetInfoLogARB, glGetProgramInfoLog, "2.0", (GLhandleARB obj, GLsizei maxLength, GLsizei *length, char *infoLog))
FUNC3(void, glGetInfoLogARB, glGetShaderInfoLog, "2.0", (GLhandleARB obj, GLsizei maxLength, GLsizei *length, char *infoLog))
FUNC2(void, glGetAttachedObjectsARB, glGetAttachedShaders, "2.0", (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj))
FUNC2(GLint, glGetUniformLocationARB, glGetUniformLocation, "2.0", (GLhandleARB programObj, const char *name))
FUNC2(void, glGetActiveUniformARB, glGetActiveUniform, "2.0", (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, char *name))
FUNC2(void, glGetUniformfvARB, glGetUniformfv, "2.0", (GLhandleARB programObj, GLint location, GLfloat *params))
FUNC2(void, glGetUniformivARB, glGetUniformiv, "2.0", (GLhandleARB programObj, GLint location, GLint *params))
FUNC2(void, glGetShaderSourceARB, glGetShaderSource, "2.0", (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source))
// GL_ARB_vertex_shader
FUNC2(void, glVertexAttrib1fARB, glVertexAttrib1f, "2.0", (GLuint index, GLfloat v0))
FUNC2(void, glVertexAttrib1sARB, glVertexAttrib1s, "2.0", (GLuint index, GLshort v0))
FUNC2(void, glVertexAttrib1dARB, glVertexAttrib1d, "2.0", (GLuint index, GLdouble v0))
FUNC2(void, glVertexAttrib2fARB, glVertexAttrib2f, "2.0", (GLuint index, GLfloat v0, GLfloat v1))
FUNC2(void, glVertexAttrib2sARB, glVertexAttrib2s, "2.0", (GLuint index, GLshort v0, GLshort v1))
FUNC2(void, glVertexAttrib2dARB, glVertexAttrib2d, "2.0", (GLuint index, GLdouble v0, GLdouble v1))
FUNC2(void, glVertexAttrib3fARB, glVertexAttrib3f, "2.0", (GLuint index, GLfloat v0, GLfloat v1, GLfloat v2))
FUNC2(void, glVertexAttrib3sARB, glVertexAttrib3s, "2.0", (GLuint index, GLshort v0, GLshort v1, GLshort v2))
FUNC2(void, glVertexAttrib3dARB, glVertexAttrib3d, "2.0", (GLuint index, GLdouble v0, GLdouble v1, GLdouble v2))
FUNC2(void, glVertexAttrib4fARB, glVertexAttrib4f, "2.0", (GLuint index, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3))
FUNC2(void, glVertexAttrib4sARB, glVertexAttrib4s, "2.0", (GLuint index, GLshort v0, GLshort v1, GLshort v2, GLshort v3))
FUNC2(void, glVertexAttrib4dARB, glVertexAttrib4d, "2.0", (GLuint index, GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3))
FUNC2(void, glVertexAttrib4NubARB, glVertexAttrib4Nub, "2.0", (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w))
FUNC2(void, glVertexAttrib1fvARB, glVertexAttrib1fv, "2.0", (GLuint index, const GLfloat *v))
FUNC2(void, glVertexAttrib1svARB, glVertexAttrib1sv, "2.0", (GLuint index, const GLshort *v))
FUNC2(void, glVertexAttrib1dvARB, glVertexAttrib1dv, "2.0", (GLuint index, const GLdouble *v))
FUNC2(void, glVertexAttrib2fvARB, glVertexAttrib2fv, "2.0", (GLuint index, const GLfloat *v))
FUNC2(void, glVertexAttrib2svARB, glVertexAttrib2sv, "2.0", (GLuint index, const GLshort *v))
FUNC2(void, glVertexAttrib2dvARB, glVertexAttrib2dv, "2.0", (GLuint index, const GLdouble *v))
FUNC2(void, glVertexAttrib3fvARB, glVertexAttrib3fv, "2.0", (GLuint index, const GLfloat *v))
FUNC2(void, glVertexAttrib3svARB, glVertexAttrib3sv, "2.0", (GLuint index, const GLshort *v))
FUNC2(void, glVertexAttrib3dvARB, glVertexAttrib3dv, "2.0", (GLuint index, const GLdouble *v))
FUNC2(void, glVertexAttrib4fvARB, glVertexAttrib4fv, "2.0", (GLuint index, const GLfloat *v))
FUNC2(void, glVertexAttrib4svARB, glVertexAttrib4sv, "2.0", (GLuint index, const GLshort *v))
FUNC2(void, glVertexAttrib4dvARB, glVertexAttrib4dv, "2.0", (GLuint index, const GLdouble *v))
FUNC2(void, glVertexAttrib4ivARB, glVertexAttrib4iv, "2.0", (GLuint index, const GLint *v))
FUNC2(void, glVertexAttrib4bvARB, glVertexAttrib4bv, "2.0", (GLuint index, const GLbyte *v))
FUNC2(void, glVertexAttrib4ubvARB, glVertexAttrib4ubv, "2.0", (GLuint index, const GLubyte *v))
FUNC2(void, glVertexAttrib4usvARB, glVertexAttrib4usv, "2.0", (GLuint index, const GLushort *v))
FUNC2(void, glVertexAttrib4uivARB, glVertexAttrib4uiv, "2.0", (GLuint index, const GLuint *v))
FUNC2(void, glVertexAttrib4NbvARB, glVertexAttrib4Nbv, "2.0", (GLuint index, const GLbyte *v))
FUNC2(void, glVertexAttrib4NsvARB, glVertexAttrib4Nsv, "2.0", (GLuint index, const GLshort *v))
FUNC2(void, glVertexAttrib4NivARB, glVertexAttrib4Niv, "2.0", (GLuint index, const GLint *v))
FUNC2(void, glVertexAttrib4NubvARB, glVertexAttrib4Nubv, "2.0", (GLuint index, const GLubyte *v))
FUNC2(void, glVertexAttrib4NusvARB, glVertexAttrib4Nusv, "2.0", (GLuint index, const GLushort *v))
FUNC2(void, glVertexAttrib4NuivARB, glVertexAttrib4Nuiv, "2.0", (GLuint index, const GLuint *v))
FUNC2(void, glVertexAttribPointerARB, glVertexAttribPointer, "2.0", (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer))
FUNC2(void, glEnableVertexAttribArrayARB, glEnableVertexAttribArray, "2.0", (GLuint index))
FUNC2(void, glDisableVertexAttribArrayARB, glDisableVertexAttribArray, "2.0", (GLuint index))
FUNC2(void, glBindAttribLocationARB, glBindAttribLocation, "2.0", (GLhandleARB programObj, GLuint index, const char *name))
FUNC2(void, glGetActiveAttribARB, glGetActiveAttrib, "2.0", (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, int *size, GLenum *type, char *name))
FUNC2(GLint, glGetAttribLocationARB, glGetAttribLocation, "2.0", (GLhandleARB programObj, const char *name))
FUNC2(void, glGetVertexAttribdvARB, glGetVertexAttribdv, "2.0", (GLuint index, GLenum pname, GLdouble *params))
FUNC2(void, glGetVertexAttribfvARB, glGetVertexAttribfv, "2.0", (GLuint index, GLenum pname, GLfloat *params))
FUNC2(void, glGetVertexAttribivARB, glGetVertexAttribiv, "2.0", (GLuint index, GLenum pname, GLint *params))
FUNC2(void, glGetVertexAttribPointervARB, glGetVertexAttribPointerv, "2.0", (GLuint index, GLenum pname, void **pointer))
// GL_EXT_gpu_shader4 / GL3.0:
FUNC2(void, glVertexAttribI1iEXT, glVertexAttribI1i, "3.0", (GLuint index, GLint x))
FUNC2(void, glVertexAttribI2iEXT, glVertexAttribI2i, "3.0", (GLuint index, GLint x, GLint y))
FUNC2(void, glVertexAttribI3iEXT, glVertexAttribI3i, "3.0", (GLuint index, GLint x, GLint y, GLint z))
FUNC2(void, glVertexAttribI4iEXT, glVertexAttribI4i, "3.0", (GLuint index, GLint x, GLint y, GLint z, GLint w))
FUNC2(void, glVertexAttribI1uiEXT, glVertexAttribI1ui, "3.0", (GLuint index, GLuint x))
FUNC2(void, glVertexAttribI2uiEXT, glVertexAttribI2ui, "3.0", (GLuint index, GLuint x, GLuint y))
FUNC2(void, glVertexAttribI3uiEXT, glVertexAttribI3ui, "3.0", (GLuint index, GLuint x, GLuint y, GLuint z))
FUNC2(void, glVertexAttribI4uiEXT, glVertexAttribI4ui, "3.0", (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w))
FUNC2(void, glVertexAttribI1ivEXT, glVertexAttribI1iv, "3.0", (GLuint index, const GLint *v))
FUNC2(void, glVertexAttribI2ivEXT, glVertexAttribI2iv, "3.0", (GLuint index, const GLint *v))
FUNC2(void, glVertexAttribI3ivEXT, glVertexAttribI3iv, "3.0", (GLuint index, const GLint *v))
FUNC2(void, glVertexAttribI4ivEXT, glVertexAttribI4iv, "3.0", (GLuint index, const GLint *v))
FUNC2(void, glVertexAttribI1uivEXT, glVertexAttribI1uiv, "3.0", (GLuint index, const GLuint *v))
FUNC2(void, glVertexAttribI2uivEXT, glVertexAttribI2uiv, "3.0", (GLuint index, const GLuint *v))
FUNC2(void, glVertexAttribI3uivEXT, glVertexAttribI3uiv, "3.0", (GLuint index, const GLuint *v))
FUNC2(void, glVertexAttribI4uivEXT, glVertexAttribI4uiv, "3.0", (GLuint index, const GLuint *v))
FUNC2(void, glVertexAttribI4bvEXT, glVertexAttribI4bv, "3.0", (GLuint index, const GLbyte *v))
FUNC2(void, glVertexAttribI4svEXT, glVertexAttribI4sv, "3.0", (GLuint index, const GLshort *v))
FUNC2(void, glVertexAttribI4ubvEXT, glVertexAttribI4ubv, "3.0", (GLuint index, const GLubyte *v))
FUNC2(void, glVertexAttribI4usvEXT, glVertexAttribI4usv, "3.0", (GLuint index, const GLushort *v))
FUNC2(void, glVertexAttribIPointerEXT, glVertexAttribIPointer, "3.0", (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer))
FUNC2(void, glGetVertexAttribIivEXT, glGetVertexAttribIiv, "3.0", (GLuint index, GLenum pname, GLint *params))
FUNC2(void, glGetVertexAttribIuivEXT, glGetVertexAttribIuiv, "3.0", (GLuint index, GLenum pname, GLuint *params))
FUNC2(void, glUniform1uiEXT, glUniform1ui, "3.0", (GLint location, GLuint v0))
FUNC2(void, glUniform2uiEXT, glUniform2ui, "3.0", (GLint location, GLuint v0, GLuint v1))
FUNC2(void, glUniform3uiEXT, glUniform3ui, "3.0", (GLint location, GLuint v0, GLuint v1, GLuint v2))
FUNC2(void, glUniform4uiEXT, glUniform4ui, "3.0", (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3))
FUNC2(void, glUniform1uivEXT, glUniform1uiv, "3.0", (GLint location, GLsizei count, const GLuint *value))
FUNC2(void, glUniform2uivEXT, glUniform2uiv, "3.0", (GLint location, GLsizei count, const GLuint *value))
FUNC2(void, glUniform3uivEXT, glUniform3uiv, "3.0", (GLint location, GLsizei count, const GLuint *value))
FUNC2(void, glUniform4uivEXT, glUniform4uiv, "3.0", (GLint location, GLsizei count, const GLuint *value))
FUNC2(void, glGetUniformuivEXT, glGetUniformuiv, "3.0", (GLuint program, GLint location, GLuint *params))
FUNC2(void, glBindFragDataLocationEXT, glBindFragDataLocation, "3.0", (GLuint program, GLuint colorNumber, const char *name))
FUNC2(GLint, glGetFragDataLocationEXT, glGetFragDataLocation, "3.0", (GLuint program, const char *name))
// GL_ARB_occlusion_query / GL1.5:
FUNC2(void, glGenQueriesARB, glGenQueries, "1.5", (GLsizei n, GLuint *ids))
FUNC2(void, glDeleteQueriesARB, glDeleteQueries, "1.5", (GLsizei n, const GLuint *ids))
FUNC2(GLboolean, glIsQueryARB, glIsQuery, "1.5", (GLuint id))
FUNC2(void, glBeginQueryARB, glBeginQuery, "1.5", (GLenum target, GLuint id))
FUNC2(void, glEndQueryARB, glEndQuery, "1.5", (GLenum target))
FUNC2(void, glGetQueryivARB, glGetQueryiv, "1.5", (GLenum target, GLenum pname, GLint *params))
FUNC2(void, glGetQueryObjectivARB, glGetQueryObjectiv, "1.5", (GLuint id, GLenum pname, GLint *params))
FUNC2(void, glGetQueryObjectuivARB, glGetQueryObjectuiv, "1.5", (GLuint id, GLenum pname, GLuint *params))
// GL_ARB_sync / GL3.2:
FUNC2(void, glGetInteger64v, glGetInteger64v, "3.2", (GLenum pname, GLint64 *params))
// GL_EXT_timer_query:
FUNC(void, glGetQueryObjecti64vEXT, (GLuint id, GLenum pname, GLint64 *params))
FUNC(void, glGetQueryObjectui64vEXT, (GLuint id, GLenum pname, GLuint64 *params))
// GL_ARB_timer_query / GL3.3:
FUNC2(void, glQueryCounter, glQueryCounter, "3.3", (GLuint id, GLenum target))
FUNC2(void, glGetQueryObjecti64v, glGetQueryObjecti64v, "3.3", (GLuint id, GLenum pname, GLint64 *params))
FUNC2(void, glGetQueryObjectui64v, glGetQueryObjectui64v, "3.3", (GLuint id, GLenum pname, GLuint64 *params))
// GL_ARB_map_buffer_range / GL3.0:
FUNC2(void*, glMapBufferRange, glMapBufferRange, "3.0", (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access))
FUNC2(void, glFlushMappedBufferRange, glFlushMappedBufferRange, "3.0", (GLenum target, GLintptr offset, GLsizeiptr length))
// GL_ARB_texture_multisample / GL3.3:
FUNC2(void, glTexImage2DMultisample, glTexImage2DMultisample, "3.3", (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations))
// GL_GREMEDY_string_marker (from gDEBugger)
FUNC(int, glStringMarkerGREMEDY, (GLsizei len, const GLvoid *string))
// GL_INTEL_performance_queries (undocumented, may be unstable, use at own risk;
// see http://zaynar.co.uk/docs/gl-intel-performance-queries.html)
FUNC(void, glGetFirstPerfQueryIdINTEL, (GLuint *queryId))
FUNC(void, glGetNextPerfQueryIdINTEL, (GLuint prevQueryId, GLuint *queryId))
FUNC(void, glGetPerfQueryInfoINTEL, (GLuint queryId, GLuint nameMaxLength, char *name, GLuint *counterBufferSize, GLuint *numCounters, GLuint *maxQueries, GLuint *))
FUNC(void, glGetPerfCounterInfoINTEL, (GLuint queryId, GLuint counterId, GLuint nameMaxLength, char *name, GLuint descMaxLength, char *desc, GLuint *offset, GLuint *size, GLuint *usage, GLuint *type, GLuint64 *))
FUNC(void, glCreatePerfQueryINTEL, (GLuint queryId, GLuint *id))
FUNC(void, glBeginPerfQueryINTEL, (GLuint id))
FUNC(void, glEndPerfQueryINTEL, (GLuint id))
FUNC(void, glDeletePerfQueryINTEL, (GLuint id))
FUNC(void, glGetPerfQueryDataINTEL, (GLuint id, GLenum requestType, GLuint maxLength, char *buffer, GLuint *length))
#endif // #if CONFIG_GLES2
#if OS_WIN
// WGL_EXT_swap_control
FUNC(int, wglSwapIntervalEXT, (int))
// WGL_ARB_pbuffer
FUNC(HPBUFFERARB, wglCreatePbufferARB, (HDC, int, int, int, const int*))
FUNC(HDC, wglGetPbufferDCARB, (HPBUFFERARB))
FUNC(int, wglReleasePbufferDCARB, (HPBUFFERARB, HDC))
FUNC(int, wglDestroyPbufferARB, (HPBUFFERARB))
FUNC(int, wglQueryPbufferARB, (HPBUFFERARB, int, int*))
// GL_ARB_pixel_format
FUNC(int, wglGetPixelFormatAttribivARB, (HDC, int, int, unsigned int, const int*, int*))
FUNC(int, wglGetPixelFormatAttribfvARB, (HDC, int, int, unsigned int, const int*, float*))
FUNC(int, wglChoosePixelFormatARB, (HDC, const int *, const float*, unsigned int, int*, unsigned int*))
#endif // OS_WIN
// GLX_MESA_query_renderer
FUNC(int /*Bool*/, glXQueryRendererIntegerMESA, (void /*Display*/ *dpy, int screen, int renderer, int attribute, unsigned int *value))
FUNC(int /*Bool*/, glXQueryCurrentRendererIntegerMESA, (int attribute, unsigned int *value))
FUNC(const char *, glXQueryRendererStringMESA, (void /*Display*/ *dpy, int screen, int renderer, int attribute))
FUNC(const char *, glXQueryCurrentRendererStringMESA, (int attribute))
+16 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -28,6 +28,21 @@
#include <SDL_syswm.h>
#if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
void* GetX11Display(SDL_Window* window)
{
SDL_SysWMinfo wminfo;
SDL_VERSION(&wminfo.version);
const int ret = SDL_GetWindowWMInfo(window, &wminfo);
if (ret && wminfo.subsystem == SDL_SYSWM_X11)
{
return reinterpret_cast<void*>(wminfo.info.x11.display);
}
return nullptr;
}
#endif
const char* GetSDLSubsystem(SDL_Window* window)
{
SDL_SysWMinfo wminfo;
+5 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -56,4 +56,8 @@ struct SDL_Event_
// Returns a windowing subsystem used for the window.
const char* GetSDLSubsystem(SDL_Window* window);
#if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
void* GetX11Display(SDL_Window* window);
#endif
#endif // INCLUDED_SDL
-71
View File
@@ -1,71 +0,0 @@
/* Copyright (C) 2011 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* bring in OpenGL header+library, with compatibility fixes
*/
#ifndef INCLUDED_OPENGL
#define INCLUDED_OPENGL
#include "lib/config2.h" // CONFIG2_GLES
#if OS_WIN
// wgl.h is a private header and should only be included from here.
// if this isn't defined, it'll complain.
#define WGL_HEADER_NEEDED
#include "lib/sysdep/os/win/wgl.h"
#endif
#if CONFIG2_GLES
# include <GLES2/gl2.h>
#elif OS_MACOSX || OS_MAC
# include <OpenGL/gl.h>
#else
# include <GL/gl.h>
#endif
// if gl.h provides real prototypes for 1.2 / 1.3 functions,
// exclude the corresponding function pointers in glext_funcs.h
#ifdef GL_VERSION_1_2
#define REAL_GL_1_2
#endif
#ifdef GL_VERSION_1_3
#define REAL_GL_1_3
#endif
// this must come after GL/gl.h include, so we can't combine the
// including GL/glext.h.
#undef GL_GLEXT_PROTOTYPES
#if CONFIG2_GLES
# include <GLES2/gl2ext.h>
#elif OS_MACOSX || OS_MAC
# include <OpenGL/glext.h>
#else
# include <GL/glext.h>
# if OS_WIN
# include <GL/wglext.h>
# endif
#endif
#endif // #ifndef INCLUDED_OPENGL
@@ -0,0 +1,92 @@
/* Copyright (C) 2021 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef INCLUDED_GLES2_WRAPPER
#define INCLUDED_GLES2_WRAPPER
#include "lib/config2.h" // CONFIG2_GLES
#if CONFIG2_GLES
#include <glad/gles2.h>
#define GL_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING
#define GL_FRAMEBUFFER_COMPLETE_EXT GL_FRAMEBUFFER_COMPLETE
#define GL_FRAMEBUFFER_EXT GL_FRAMEBUFFER
#define GL_WRITE_ONLY GL_WRITE_ONLY_OES
#define GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT0
#define GL_DEPTH_ATTACHMENT_EXT GL_DEPTH_ATTACHMENT
// Functions
#define glActiveTextureARB glActiveTexture
#define glBlendColorEXT glBlendColor
#define glBlendEquationEXT glBlendEquation
#define glCompressedTexImage2DARB glCompressedTexImage2D
#define glAttachObjectARB glAttachShader
#define glBindAttribLocationARB glBindAttribLocation
#define glCompileShaderARB glCompileShader
#define glCreateProgramObjectARB glCreateProgram
#define glCreateShaderObjectARB glCreateShader
#define glDisableVertexAttribArrayARB glDisableVertexAttribArray
#define glEnableVertexAttribArrayARB glEnableVertexAttribArray
#define glGetActiveUniformARB glGetActiveUniform
#define glGetUniformLocationARB glGetUniformLocation
#define glLinkProgramARB glLinkProgram
#define glShaderSourceARB glShaderSource
#define glUniform1fARB glUniform1f
#define glUniform2fARB glUniform2f
#define glUniform3fARB glUniform3f
#define glUniform4fARB glUniform4f
#define glUniform1iARB glUniform1i
#define glUniform1fvARB glUniform1fv
#define glUniformMatrix4fvARB glUniformMatrix4fv
#define glUseProgramObjectARB glUseProgram
#define glVertexAttribPointerARB glVertexAttribPointer
#define glBindBufferARB glBindBuffer
#define glBufferDataARB glBufferData
#define glBufferSubDataARB glBufferSubData
#define glDeleteBuffersARB glDeleteBuffers
#define glGenBuffersARB glGenBuffers
#define glBindFramebufferEXT glBindFramebuffer
#define glCheckFramebufferStatusEXT glCheckFramebufferStatus
#define glDeleteFramebuffersEXT glDeleteFramebuffers
#define glFramebufferTexture2DEXT glFramebufferTexture2D
#define glGenFramebuffersEXT glGenFramebuffers
// Extensions
// GL_OES_texture_border_clamp
#define GL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER_OES
// GL_OES_rgb8_rgba8
#define GL_RGBA8 GL_RGBA8_OES
// GL_OES_mapbuffer
#define glMapBufferARB glMapBufferOES
#define glUnmapBufferARB glUnmapBufferOES
// GL_OES_depth32
#define GL_DEPTH_COMPONENT32 GL_DEPTH_COMPONENT32_OES
#endif // CONFIG2_GLES
#endif // !INCLUDED_GLES2_WRAPPER
+117 -96
View File
@@ -27,14 +27,25 @@
#include "precompiled.h"
#include "lib/ogl.h"
#include "lib/code_annotation.h"
#include "lib/config2.h"
#include "lib/debug.h"
#include "lib/external_libraries/libsdl.h"
#include "lib/res/h_mgr.h"
#include "ps/CLogger.h"
#if !CONFIG2_GLES
# if OS_WIN
# include <glad/wgl.h>
# elif !OS_MACOSX && !OS_MAC
# include <glad/glx.h>
# endif
#endif
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "lib/external_libraries/libsdl.h"
#include "lib/debug.h"
#include "lib/res/h_mgr.h"
#if MSC_VERSION
#pragma comment(lib, "opengl32.lib")
#endif
@@ -44,21 +55,15 @@
// extensions
//----------------------------------------------------------------------------
// define extension function pointers
extern "C"
{
#define FUNC(ret, name, params) ret (GL_CALL_CONV *p##name) params;
#define FUNC2(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameARB) params;
#define FUNC3(ret, nameARB, nameCore, version, params) ret (GL_CALL_CONV *p##nameCore) params;
#include "lib/external_libraries/glext_funcs.h"
#undef FUNC3
#undef FUNC2
#undef FUNC
}
static const char* exts = nullptr;
static const char* exts = NULL;
static bool have_30, have_21, have_20, have_15, have_14, have_13, have_12;
static bool have_30 = false;
static bool have_21 = false;
static bool have_20 = false;
static bool have_15 = false;
static bool have_14 = false;
static bool have_13 = false;
static bool have_12 = false;
// return a C string of unspecified length containing a space-separated
@@ -212,35 +217,16 @@ bool ogl_HaveExtension(const char* ext)
}
}
static int GLVersion;
#if OS_WIN
static int WGLVersion;
#elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC
static int GLXVersion;
#endif
// check if the OpenGL implementation is at least at <version>.
// (format: "%d.%d" major minor)
bool ogl_HaveVersion(const char* desired_version)
bool ogl_HaveVersion(int major, int minor)
{
int desired_major, desired_minor;
if(sscanf_s(desired_version, "%d.%d", &desired_major, &desired_minor) != 2)
{
DEBUG_WARN_ERR(ERR::LOGIC); // invalid version string
return false;
}
// guaranteed to be of the form "major.minor[.release][ vendor-specific]"
// or "OpenGL ES major.minor[.release][ vendor-specific]".
// we won't distinguish GLES 2.0 from GL 2.0, but that's okay since
// they're close enough.
const char* version = (const char*)glGetString(GL_VERSION);
int major, minor;
if(!version ||
(sscanf_s(version, "%d.%d", &major, &minor) != 2 &&
sscanf_s(version, "OpenGL ES %d.%d", &major, &minor) != 2))
{
DEBUG_WARN_ERR(ERR::LOGIC); // GL_VERSION invalid
return false;
}
// note: don't just compare characters - major and minor may be >= 10.
return (major > desired_major) ||
(major == desired_major && minor >= desired_minor);
return GLAD_MAKE_VERSION(major, minor) <= GLVersion;
}
@@ -298,25 +284,25 @@ static void enableDummyFunctions()
#else
static void GL_CALL_CONV dummy_glDrawRangeElementsEXT(GLenum mode, GLuint, GLuint, GLsizei count, GLenum type, GLvoid* indices)
static void GLAD_API_PTR dummy_glDrawRangeElementsEXT(GLenum mode, GLuint, GLuint, GLsizei count, GLenum type, GLvoid* indices)
{
glDrawElements(mode, count, type, indices);
}
static void GL_CALL_CONV dummy_glActiveTextureARB(int)
static void GLAD_API_PTR dummy_glActiveTextureARB(GLenum UNUSED(texture))
{
}
static void GL_CALL_CONV dummy_glClientActiveTextureARB(int)
static void GLAD_API_PTR dummy_glClientActiveTextureARB(GLenum UNUSED(texture))
{
}
static void GL_CALL_CONV dummy_glMultiTexCoord2fARB(int, float s, float t)
static void GLAD_API_PTR dummy_glMultiTexCoord2fARB(GLenum UNUSED(target), GLfloat s, GLfloat t)
{
glTexCoord2f(s, t);
}
static void GL_CALL_CONV dummy_glMultiTexCoord3fARB(int, float s, float t, float r)
static void GLAD_API_PTR dummy_glMultiTexCoord3fARB(GLenum UNUSED(target), GLfloat s, GLfloat t, GLfloat r)
{
glTexCoord3f(s, t, r);
}
@@ -327,49 +313,20 @@ static void enableDummyFunctions()
if(!ogl_HaveExtension("GL_EXT_draw_range_elements"))
{
pglDrawRangeElementsEXT = &dummy_glDrawRangeElementsEXT;
glDrawRangeElementsEXT = reinterpret_cast<PFNGLDRAWRANGEELEMENTSEXTPROC>(&dummy_glDrawRangeElementsEXT);
}
if(!ogl_HaveExtension("GL_ARB_multitexture"))
{
pglActiveTextureARB = &dummy_glActiveTextureARB;
pglClientActiveTextureARB = &dummy_glClientActiveTextureARB;
pglMultiTexCoord2fARB = &dummy_glMultiTexCoord2fARB;
pglMultiTexCoord3fARB = &dummy_glMultiTexCoord3fARB;
glActiveTextureARB = reinterpret_cast<PFNGLACTIVETEXTUREARBPROC>(&dummy_glActiveTextureARB);
glClientActiveTextureARB = reinterpret_cast<PFNGLACTIVETEXTUREARBPROC>(&dummy_glClientActiveTextureARB);
glMultiTexCoord2fARB = reinterpret_cast<PFNGLMULTITEXCOORD2FARBPROC>(&dummy_glMultiTexCoord2fARB);
glMultiTexCoord3fARB = reinterpret_cast<PFNGLMULTITEXCOORD3FARBPROC>(&dummy_glMultiTexCoord3fARB);
}
}
#endif // #if CONFIG2_GLES
static void importExtensionFunctions()
{
// It should be safe to load the ARB function pointers even if the
// extension isn't advertised, since we won't actually use them without
// checking for the extension.
// (TODO: this calls ogl_HaveVersion far more times than is necessary -
// we should probably use the have_* variables instead)
// Note: the xorg-x11 implementation of glXGetProcAddress doesn't return NULL
// if the function is unsupported (i.e. the rare case of a driver not reporting
// its supported version correctly, see http://trac.wildfiregames.com/ticket/171)
#define FUNC(ret, name, params) p##name = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#name);
#define FUNC23(pname, ret, nameARB, nameCore, version, params) \
pname = NULL; \
if(ogl_HaveVersion(version)) \
pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameCore); \
if(!pname) /* use the ARB name if the driver lied about what version it supports */ \
pname = (ret (GL_CALL_CONV*) params)SDL_GL_GetProcAddress(#nameARB);
#define FUNC2(ret, nameARB, nameCore, version, params) FUNC23(p##nameARB, ret, nameARB, nameCore, version, params)
#define FUNC3(ret, nameARB, nameCore, version, params) FUNC23(p##nameCore, ret, nameARB, nameCore, version, params)
#include "lib/external_libraries/glext_funcs.h"
#undef FUNC3
#undef FUNC2
#undef FUNC23
#undef FUNC
enableDummyFunctions();
}
//----------------------------------------------------------------------------
const char* ogl_GetErrorName(GLenum err)
@@ -468,24 +425,70 @@ bool ogl_SquelchError(GLenum err_to_ignore)
GLint ogl_max_tex_size = -1; // [pixels]
GLint ogl_max_tex_units = -1; // limit on GL_TEXTUREn
// call after each video mode change, since thereafter extension functions
// may have changed [address].
void ogl_Init()
#if OS_WIN
bool ogl_Init(void* (load)(const char*), void* hdc)
#elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC
bool ogl_Init(void* (load)(const char*), void* display)
#else
bool ogl_Init(void* (load)(const char*))
#endif
{
GLADloadfunc loadFunc = reinterpret_cast<GLADloadfunc>(load);
if (!loadFunc)
return false;
#define LOAD_ERROR(ERROR_STRING) \
if (g_Logger) \
LOGERROR(ERROR_STRING); \
else \
debug_printf(ERROR_STRING); \
#if !CONFIG2_GLES
GLVersion = gladLoadGL(loadFunc);
if (!GLVersion)
{
LOAD_ERROR("Failed to load OpenGL functions.");
return false;
}
# if OS_WIN
WGLVersion = gladLoadWGL(reinterpret_cast<HDC>(hdc), loadFunc);
if (!WGLVersion)
{
LOAD_ERROR("Failed to load WGL functions.");
return false;
}
# elif !OS_MACOSX && !OS_MAC
GLXVersion = gladLoadGLX(reinterpret_cast<Display*>(display), DefaultScreen(display), loadFunc);
if (!GLXVersion)
{
LOAD_ERROR("Failed to load GLX functions.");
return false;
}
# endif
#else
GLVersion = gladLoadGLES2(loadFunc);
if (!GLVersion)
{
LOAD_ERROR("Failed to load GLES2 functions.");
return false;
}
#endif
#undef LOAD_ERROR
// cache extension list and versions for oglHave*.
// note: this is less about performance (since the above are not
// time-critical) than centralizing the 'OpenGL is ready' check.
exts = (const char*)glGetString(GL_EXTENSIONS);
exts = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
ENSURE(exts); // else: called before OpenGL is ready for use
have_12 = ogl_HaveVersion("1.2");
have_13 = ogl_HaveVersion("1.3");
have_14 = ogl_HaveVersion("1.4");
have_15 = ogl_HaveVersion("1.5");
have_20 = ogl_HaveVersion("2.0");
have_21 = ogl_HaveVersion("2.1");
have_30 = ogl_HaveVersion("3.0");
have_12 = ogl_HaveVersion(1, 2);
have_13 = ogl_HaveVersion(1, 3);
have_14 = ogl_HaveVersion(1, 4);
have_15 = ogl_HaveVersion(1, 5);
have_20 = ogl_HaveVersion(2, 0);
have_21 = ogl_HaveVersion(2, 1);
have_30 = ogl_HaveVersion(3, 0);
importExtensionFunctions();
enableDummyFunctions();
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &ogl_max_tex_size);
#if !CONFIG2_GLES
@@ -493,4 +496,22 @@ void ogl_Init()
#endif
glEnable(GL_TEXTURE_2D);
return true;
}
void ogl_SetVsyncEnabled(bool enabled)
{
#if !CONFIG2_GLES && OS_WIN
int interval = enabled ? 1 : 0;
if (ogl_HaveExtension("WGL_EXT_swap_control"))
wglSwapIntervalEXT(interval);
#elif !CONFIG2_GLES && !OS_MACOSX && !OS_MAC
int interval = enabled ? 1 : 0;
if (ogl_HaveExtension("GLX_SGI_swap_control"))
glXSwapIntervalSGI(interval);
#else
UNUSED2(enabled);
#endif
}
+24 -65
View File
@@ -27,25 +27,41 @@
#ifndef INCLUDED_OGL
#define INCLUDED_OGL
#include "lib/external_libraries/opengl.h"
#include "lib/config2.h" // CONFIG2_GLES
#include "lib/sysdep/os.h" // OS_WIN
#if CONFIG2_GLES
# include "external_libraries/opengles2_wrapper.h"
#else
# include <glad/gl.h>
#endif
/**
* initialization: import extension function pointers and do feature detect.
* call before using any other function.
* fails if OpenGL not ready for use.
**/
extern void ogl_Init();
#if OS_WIN
extern bool ogl_Init(void* (load)(const char*), void* hdc);
#elif !OS_MACOSX && !OS_MAC && !CONFIG2_GLES
extern bool ogl_Init(void* (load)(const char*), void* display);
#else
extern bool ogl_Init(void* (load)(const char*));
#endif
/**
* Change vsync state.
**/
extern void ogl_SetVsyncEnabled(bool enabled);
//-----------------------------------------------------------------------------
// extensions
/**
* check if an extension is supported by the OpenGL implementation.
*
* takes subsequently added core support for some extensions into account
* (in case drivers forget to advertise extensions).
* Check whether the given OpenGL extension is supported.
* NOTE: this does not check whether the extensions is *loaded*.
* for that, check whether GLAD_<extension name> is not null.
*
* @param ext extension string; exact case.
* @return bool.
@@ -55,12 +71,8 @@ extern bool ogl_HaveExtension(const char* ext);
/**
* make sure the OpenGL implementation version matches or is newer than
* the given version.
*
* @param version version string; format: ("%d.%d", major, minor).
* example: "1.2".
**/
extern bool ogl_HaveVersion(const char* version);
*/
extern bool ogl_HaveVersion(int major, int minor);
/**
* check if a list of extensions are all supported (as determined by
* ogl_HaveExtension).
@@ -83,59 +95,6 @@ extern const char* ogl_HaveExtensions(int dummy, ...) SENTINEL_ARG;
**/
extern const char* ogl_ExtensionString();
// The game wants to use some extension constants that aren't provided by
// glext.h on some old systems.
// Manually define all the necessary ones that are missing from
// GL_GLEXT_VERSION 39 (Mesa 7.0) since that's probably an old enough baseline:
#ifndef GL_VERSION_3_0
# define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
# define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
#endif
#ifndef GL_EXT_transform_feedback
# define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A
# define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B
# define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80
#endif
#ifndef GL_ARB_geometry_shader4
# define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
# define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
# define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
# define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
# define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
# define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
#endif
#ifndef GL_ARB_timer_query
# define GL_TIME_ELAPSED 0x88BF
# define GL_TIMESTAMP 0x8E28
#endif
#ifndef GL_ARB_framebuffer_object
# define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
#endif
// Also need some more for OS X 10.5:
#ifndef GL_EXT_texture_array
# define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
#endif
// Also need some types not in old glext.h:
#ifndef GL_ARB_sync
typedef int64_t GLint64;
typedef uint64_t GLuint64;
#endif
// declare extension function pointers
#if OS_WIN
# define GL_CALL_CONV __stdcall
#else
# define GL_CALL_CONV
#endif
#define FUNC(ret, name, params) EXTERN_C ret (GL_CALL_CONV *p##name) params;
#define FUNC2(ret, nameARB, nameCore, version, params) EXTERN_C ret (GL_CALL_CONV *p##nameARB) params;
#define FUNC3(ret, nameARB, nameCore, version, params) EXTERN_C ret (GL_CALL_CONV *p##nameCore) params;
#include "lib/external_libraries/glext_funcs.h"
#undef FUNC3
#undef FUNC2
#undef FUNC
// leave GL_CALL_CONV defined for ogl.cpp
//-----------------------------------------------------------------------------
// errors
+3 -3
View File
@@ -58,8 +58,8 @@ static bool wrap_valid(GLint wrap)
{
#if !CONFIG2_GLES
case GL_CLAMP:
case GL_CLAMP_TO_BORDER:
#endif
case GL_CLAMP_TO_BORDER:
case GL_CLAMP_TO_EDGE:
case GL_REPEAT:
case GL_MIRRORED_REPEAT:
@@ -844,7 +844,7 @@ static void upload_level(size_t level, size_t level_w, size_t level_h, const u8*
static void upload_compressed_level(size_t level, size_t level_w, size_t level_h, const u8* RESTRICT level_data, size_t level_data_size, void* RESTRICT cbData)
{
const UploadParams* up = (const UploadParams*)cbData;
pglCompressedTexImage2DARB(GL_TEXTURE_2D, (GLint)level, up->fmt, (GLsizei)level_w, (GLsizei)level_h, 0, (GLsizei)level_data_size, level_data);
glCompressedTexImage2DARB(GL_TEXTURE_2D, (GLint)level, up->fmt, (GLsizei)level_w, (GLsizei)level_h, 0, (GLsizei)level_data_size, level_data);
*up->uploaded_size += (u32)level_data_size;
}
@@ -1029,7 +1029,7 @@ Status ogl_tex_bind(Handle ht, size_t unit)
{
// note: there are many call sites of glActiveTextureARB, so caching
// those and ignoring redundant sets isn't feasible.
pglActiveTextureARB((int)(GL_TEXTURE0+unit));
glActiveTextureARB((int)(GL_TEXTURE0+unit));
// special case: resets the active texture.
if(ht == 0)
-92
View File
@@ -1,92 +0,0 @@
/* Copyright (C) 2010 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* Windows definitions required for GL/gl.h
*/
// RAGE! Win32 OpenGL headers are full of crap we have to emulate
// (must not include windows.h)
#ifndef WGL_HEADER_NEEDED
#error "wgl.h: why is this included from anywhere but ogl.h?"
#endif
#ifndef WINGDIAPI
#define WINGDIAPI __declspec(dllimport)
#endif
#ifndef CALLBACK
#define CALLBACK __stdcall
#endif
#ifndef APIENTRY
#define APIENTRY __stdcall
#endif
#ifndef WINAPI
#define WINAPI __stdcall
#endif
#ifndef DECLARE_HANDLE
typedef void VOID;
typedef void* LPVOID;
typedef int BOOL;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long LONG;
typedef unsigned long DWORD;
typedef int INT32;
typedef __int64 INT64;
typedef float FLOAT;
typedef char CHAR;
typedef const char* LPCSTR;
typedef void* HANDLE;
typedef int (*PROC)();
struct RECT
{
LONG left;
LONG top;
LONG right;
LONG bottom;
};
#define DECLARE_HANDLE(name) typedef HANDLE name
DECLARE_HANDLE(HDC);
DECLARE_HANDLE(HGLRC);
#endif
// VC6 doesn't define wchar_t as built-in type
#ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t; // for glu.h
#define _WCHAR_T_DEFINED
#endif
WINGDIAPI BOOL WINAPI wglCopyContext(HGLRC, HGLRC, UINT);
WINGDIAPI HGLRC WINAPI wglCreateContext(HDC);
WINGDIAPI HGLRC WINAPI wglCreateLayerContext(HDC, int);
WINGDIAPI BOOL WINAPI wglDeleteContext(HGLRC);
WINGDIAPI HGLRC WINAPI wglGetCurrentContext();
WINGDIAPI HDC WINAPI wglGetCurrentDC();
WINGDIAPI PROC WINAPI wglGetProcAddress(LPCSTR);
WINGDIAPI BOOL WINAPI wglMakeCurrent(HDC, HGLRC);
WINGDIAPI BOOL WINAPI wglShareLists(HGLRC, HGLRC);
WINGDIAPI BOOL WINAPI wglUseFontBitmapsA(HDC, DWORD, DWORD, DWORD);
WINGDIAPI BOOL WINAPI wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD);
+5
View File
@@ -414,6 +414,11 @@ void wutil_SetAppWindow(SDL_Window* window)
hAppWindow = wmInfo.info.win.window;
}
void* wutil_GetAppHDC()
{
return GetDC(hAppWindow);
}
void wutil_SetAppWindow(void* hwnd)
{
hAppWindow = reinterpret_cast<HWND>(hwnd);
+21 -21
View File
@@ -71,7 +71,7 @@ protected:
~CProfiler2GPU_timer_query()
{
if (!m_FreeQueries.empty())
pglDeleteQueriesARB(m_FreeQueries.size(), &m_FreeQueries[0]);
glDeleteQueriesARB(m_FreeQueries.size(), &m_FreeQueries[0]);
ogl_WarnIfError();
}
@@ -82,7 +82,7 @@ protected:
{
// Generate a batch of new queries
m_FreeQueries.resize(8);
pglGenQueriesARB(m_FreeQueries.size(), &m_FreeQueries[0]);
glGenQueriesARB(m_FreeQueries.size(), &m_FreeQueries[0]);
ogl_WarnIfError();
}
@@ -169,7 +169,7 @@ public:
{
PROFILE2("profile timestamp resync");
pglGetInteger64v(GL_TIMESTAMP, &frame.syncTimestampStart);
glGetInteger64v(GL_TIMESTAMP, &frame.syncTimestampStart);
ogl_WarnIfError();
frame.syncTimeStart = m_Profiler.GetTime();
@@ -203,7 +203,7 @@ public:
event.query = NewQuery();
event.isEnter = isEnter;
pglQueryCounter(event.query, GL_TIMESTAMP);
glQueryCounter(event.query, GL_TIMESTAMP);
ogl_WarnIfError();
frame.events.push_back(event);
@@ -229,7 +229,7 @@ private:
// Queries become available in order so we only need to check the last one
GLint available = 0;
pglGetQueryObjectivARB(frame.events.back().query, GL_QUERY_RESULT_AVAILABLE, &available);
glGetQueryObjectivARB(frame.events.back().query, GL_QUERY_RESULT_AVAILABLE, &available);
ogl_WarnIfError();
if (!available)
break;
@@ -239,7 +239,7 @@ private:
for (size_t i = 0; i < frame.events.size(); ++i)
{
GLuint64 queryTimestamp = 0;
pglGetQueryObjectui64v(frame.events[i].query, GL_QUERY_RESULT, &queryTimestamp);
glGetQueryObjectui64v(frame.events[i].query, GL_QUERY_RESULT, &queryTimestamp);
// (use the non-suffixed function here, as defined by GL_ARB_timer_query)
ogl_WarnIfError();
@@ -339,7 +339,7 @@ public:
{
RegionLeave("frame");
pglEndQueryARB(GL_TIME_ELAPSED);
glEndQueryARB(GL_TIME_ELAPSED);
ogl_WarnIfError();
}
@@ -356,7 +356,7 @@ public:
if (!frame.events.empty())
{
pglEndQueryARB(GL_TIME_ELAPSED);
glEndQueryARB(GL_TIME_ELAPSED);
ogl_WarnIfError();
}
@@ -365,7 +365,7 @@ public:
event.query = NewQuery();
event.isEnter = isEnter;
pglBeginQueryARB(GL_TIME_ELAPSED, event.query);
glBeginQueryARB(GL_TIME_ELAPSED, event.query);
ogl_WarnIfError();
frame.events.push_back(event);
@@ -390,7 +390,7 @@ private:
// Queries become available in order so we only need to check the last one
GLint available = 0;
pglGetQueryObjectivARB(frame.events.back().query, GL_QUERY_RESULT_AVAILABLE, &available);
glGetQueryObjectivARB(frame.events.back().query, GL_QUERY_RESULT_AVAILABLE, &available);
ogl_WarnIfError();
if (!available)
break;
@@ -413,7 +413,7 @@ private:
// Advance by the elapsed time to the next event
GLuint64 queryElapsed = 0;
pglGetQueryObjectui64vEXT(frame.events[i].query, GL_QUERY_RESULT, &queryElapsed);
glGetQueryObjectui64vEXT(frame.events[i].query, GL_QUERY_RESULT, &queryElapsed);
// (use the EXT-suffixed function here, as defined by GL_EXT_timer_query)
ogl_WarnIfError();
t += (double)queryElapsed / 1e9;
@@ -518,7 +518,7 @@ public:
for (size_t i = 0; i < m_QueryTypes.size(); ++i)
for (size_t j = 0; j < m_QueryTypes[i].freeQueries.size(); ++j)
pglDeletePerfQueryINTEL(m_QueryTypes[i].freeQueries[j]);
glDeletePerfQueryINTEL(m_QueryTypes[i].freeQueries[j]);
ogl_WarnIfError();
}
@@ -553,7 +553,7 @@ public:
for (size_t i = 0; i < m_QueryTypes.size(); ++i)
{
GLuint local_id = NewQuery(i);
pglBeginPerfQueryINTEL(local_id);
glBeginPerfQueryINTEL(local_id);
ogl_WarnIfError();
event.queries.push_back(local_id);
}
@@ -573,7 +573,7 @@ public:
for (size_t i = 0; i < m_QueryTypes.size(); ++i)
{
pglEndPerfQueryINTEL(activeEvent.queries[i]);
glEndPerfQueryINTEL(activeEvent.queries[i]);
ogl_WarnIfError();
}
@@ -593,7 +593,7 @@ private:
if (m_QueryTypes[queryIdx].freeQueries.empty())
{
GLuint id;
pglCreatePerfQueryINTEL(m_QueryTypes[queryIdx].queryTypeId, &id);
glCreatePerfQueryINTEL(m_QueryTypes[queryIdx].queryTypeId, &id);
ogl_WarnIfError();
return id;
}
@@ -623,7 +623,7 @@ private:
continue;
GLuint length = 0;
pglGetPerfQueryDataINTEL(frame.events[i].queries[j], INTEL_PERFQUERIES_NONBLOCK, size, buffer.data(), &length);
glGetPerfQueryDataINTEL(frame.events[i].queries[j], INTEL_PERFQUERIES_NONBLOCK, size, buffer.data(), &length);
ogl_WarnIfError();
if (length == 0)
return;
@@ -650,7 +650,7 @@ private:
{
GLuint length;
buffer.resize(m_QueryTypes[j].counterBufferSize);
pglGetPerfQueryDataINTEL(frame.events[i].queries[j], INTEL_PERFQUERIES_BLOCK, m_QueryTypes[j].counterBufferSize, buffer.data(), &length);
glGetPerfQueryDataINTEL(frame.events[i].queries[j], INTEL_PERFQUERIES_BLOCK, m_QueryTypes[j].counterBufferSize, buffer.data(), &length);
ogl_WarnIfError();
ENSURE(length == m_QueryTypes[j].counterBufferSize);
@@ -727,13 +727,13 @@ private:
void LoadPerfCounters()
{
GLuint queryTypeId;
pglGetFirstPerfQueryIdINTEL(&queryTypeId);
glGetFirstPerfQueryIdINTEL(&queryTypeId);
ogl_WarnIfError();
do
{
char queryName[256];
GLuint counterBufferSize, numCounters, maxQueries, unknown;
pglGetPerfQueryInfoINTEL(queryTypeId, ARRAY_SIZE(queryName), queryName, &counterBufferSize, &numCounters, &maxQueries, &unknown);
glGetPerfQueryInfoINTEL(queryTypeId, ARRAY_SIZE(queryName), queryName, &counterBufferSize, &numCounters, &maxQueries, &unknown);
ogl_WarnIfError();
ENSURE(unknown == 1);
@@ -748,7 +748,7 @@ private:
char counterDesc[2048];
GLuint counterOffset, counterSize, counterUsage, counterType;
GLuint64 unknown2;
pglGetPerfCounterInfoINTEL(queryTypeId, counterId, ARRAY_SIZE(counterName), counterName, ARRAY_SIZE(counterDesc), counterDesc, &counterOffset, &counterSize, &counterUsage, &counterType, &unknown2);
glGetPerfCounterInfoINTEL(queryTypeId, counterId, ARRAY_SIZE(counterName), counterName, ARRAY_SIZE(counterDesc), counterDesc, &counterOffset, &counterSize, &counterUsage, &counterType, &unknown2);
ogl_WarnIfError();
ENSURE(unknown2 == 0 || unknown2 == 1);
@@ -763,7 +763,7 @@ private:
m_QueryTypes.push_back(query);
pglGetNextPerfQueryIdINTEL(queryTypeId, &queryTypeId);
glGetNextPerfQueryIdINTEL(queryTypeId, &queryTypeId);
ogl_WarnIfError();
} while (queryTypeId);
+1 -1
View File
@@ -232,7 +232,7 @@ void ShaderModelVertexRenderer::RenderModel(const CShaderProgramPtr& shader, int
#if CONFIG2_GLES
glDrawElements(GL_TRIANGLES, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase);
#else
pglDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)mdldef->GetNumVertices()-1,
glDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)mdldef->GetNumVertices()-1,
(GLsizei)numFaces*3, GL_UNSIGNED_SHORT, indexBase);
#endif
}
+1 -1
View File
@@ -380,7 +380,7 @@ void InstancingModelRenderer::RenderModel(const CShaderProgramPtr& shader, int U
#if CONFIG2_GLES
glDrawElements(GL_TRIANGLES, (GLsizei)numFaces*3, GL_UNSIGNED_SHORT, m->imodeldefIndexBase);
#else
pglDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)m->imodeldef->m_Array.GetNumVertices()-1,
glDrawRangeElementsEXT(GL_TRIANGLES, 0, (GLuint)m->imodeldef->m_Array.GetNumVertices()-1,
(GLsizei)numFaces*3, GL_UNSIGNED_SHORT, m->imodeldefIndexBase);
#endif
}
+3 -3
View File
@@ -415,7 +415,7 @@ void OverlayRenderer::RenderTexturedOverlayLines()
ogl_WarnIfError();
pglActiveTextureARB(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_BLEND);
glDepthMask(0);
@@ -522,7 +522,7 @@ void OverlayRenderer::RenderQuadOverlays()
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
#endif
pglActiveTextureARB(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_BLEND);
glDepthMask(0);
@@ -602,7 +602,7 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
if (g_Renderer.GetOverlayRenderMode() == WIREFRAME)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
pglActiveTextureARB(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
+1 -1
View File
@@ -142,7 +142,7 @@ void ParticleRenderer::RenderParticles(int cullGroup, bool solidColor)
CVertexBuffer::Unbind();
pglBlendEquationEXT(GL_FUNC_ADD);
glBlendEquationEXT(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_BLEND);
+68 -68
View File
@@ -58,9 +58,9 @@ void CPostprocManager::Cleanup()
if (!m_IsInitialized) // Only cleanup if previously used
return;
if (m_PingFbo) pglDeleteFramebuffersEXT(1, &m_PingFbo);
if (m_PongFbo) pglDeleteFramebuffersEXT(1, &m_PongFbo);
if (m_BloomFbo) pglDeleteFramebuffersEXT(1, &m_BloomFbo);
if (m_PingFbo) glDeleteFramebuffersEXT(1, &m_PingFbo);
if (m_PongFbo) glDeleteFramebuffersEXT(1, &m_PongFbo);
if (m_BloomFbo) glDeleteFramebuffersEXT(1, &m_BloomFbo);
m_PingFbo = m_PongFbo = m_BloomFbo = 0;
if (m_ColorTex1) glDeleteTextures(1, &m_ColorTex1);
@@ -165,44 +165,44 @@ void CPostprocManager::RecreateBuffers()
// Set up the framebuffers with some initial textures.
pglGenFramebuffersEXT(1, &m_PingFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glGenFramebuffersEXT(1, &m_PingFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, m_ColorTex1, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, m_DepthTex, 0);
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Framebuffer object incomplete (A): 0x%04X", status);
}
pglGenFramebuffersEXT(1, &m_PongFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glGenFramebuffersEXT(1, &m_PongFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, m_ColorTex2, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D, m_DepthTex, 0);
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Framebuffer object incomplete (B): 0x%04X", status);
}
pglGenFramebuffersEXT(1, &m_BloomFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
glGenFramebuffersEXT(1, &m_BloomFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
/*
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D, m_BloomTex1, 0);
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Framebuffer object incomplete (B): 0x%04X", status);
@@ -215,15 +215,15 @@ void CPostprocManager::RecreateBuffers()
CreateMultisampleBuffer();
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void CPostprocManager::ApplyBlurDownscale2x(GLuint inTex, GLuint outTex, int inWidth, int inHeight)
{
// Bind inTex to framebuffer for rendering.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, outTex, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, outTex, 0);
// Get bloom shader with instructions to simply copy texels.
CShaderDefines defines;
@@ -238,7 +238,7 @@ void CPostprocManager::ApplyBlurDownscale2x(GLuint inTex, GLuint outTex, int inW
// Cheat by creating high quality mipmaps for inTex, so the copying operation actually
// produces good scaling due to hardware filtering.
glBindTexture(GL_TEXTURE_2D, renderedTex);
pglGenerateMipmapEXT(GL_TEXTURE_2D);
glGenerateMipmapEXT(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
@@ -280,8 +280,8 @@ void CPostprocManager::ApplyBlurDownscale2x(GLuint inTex, GLuint outTex, int inW
void CPostprocManager::ApplyBlurGauss(GLuint inOutTex, GLuint tempTex, int inWidth, int inHeight)
{
// Set tempTex as our rendering target.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tempTex, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, tempTex, 0);
// Get bloom shader, for a horizontal Gaussian blur pass.
CShaderDefines defines2;
@@ -325,8 +325,8 @@ void CPostprocManager::ApplyBlurGauss(GLuint inOutTex, GLuint tempTex, int inWid
tech->EndPass();
// Set result texture as our render target.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, inOutTex, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_BloomFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, inOutTex, 0);
// Get bloom shader, for a vertical Gaussian blur pass.
CShaderDefines defines3;
@@ -378,20 +378,20 @@ void CPostprocManager::CaptureRenderOutput()
ENSURE(m_IsInitialized);
// Leaves m_PingFbo selected for rendering; m_WhichBuffer stays true at this point.
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
pglDrawBuffers(1, buffers);
glDrawBuffers(1, buffers);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglDrawBuffers(1, buffers);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glDrawBuffers(1, buffers);
m_WhichBuffer = true;
if (m_UsingMultisampleBuffer)
{
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_MultisampleFBO);
pglDrawBuffers(1, buffers);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_MultisampleFBO);
glDrawBuffers(1, buffers);
}
}
@@ -400,30 +400,30 @@ void CPostprocManager::ReleaseRenderOutput()
{
ENSURE(m_IsInitialized);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
// we blit to screen from the previous active buffer
if (m_WhichBuffer)
pglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_PingFbo);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_PingFbo);
else
pglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_PongFbo);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, m_PongFbo);
pglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
pglBlitFramebufferEXT(0, 0, m_Width, m_Height, 0, 0, m_Width, m_Height,
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, 0);
glBlitFramebufferEXT(0, 0, m_Width, m_Height, 0, 0, m_Width, m_Height,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
pglBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void CPostprocManager::ApplyEffect(CShaderTechniquePtr &shaderTech1, int pass)
{
// select the other FBO for rendering
if (!m_WhichBuffer)
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
else
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
@@ -504,28 +504,28 @@ void CPostprocManager::ApplyPostproc()
if (!hasEffects && !hasAA && !hasSharp)
return;
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT };
pglDrawBuffers(1, buffers);
glDrawBuffers(1, buffers);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
pglDrawBuffers(1, buffers);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, GL_TEXTURE_2D, 0, 0);
glDrawBuffers(1, buffers);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
if (hasEffects)
{
// First render blur textures. Note that this only happens ONLY ONCE, before any effects are applied!
// (This may need to change depending on future usage, however that will have a fps hit)
ApplyBlur();
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
for (int pass = 0; pass < m_PostProcTech->GetNumPasses(); ++pass)
ApplyEffect(m_PostProcTech, pass);
}
@@ -542,11 +542,11 @@ void CPostprocManager::ApplyPostproc()
ApplyEffect(m_SharpTech, pass);
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PongFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_DepthTex, 0);
}
@@ -620,7 +620,7 @@ void CPostprocManager::UpdateAntiAliasingTechnique()
if (g_AtlasGameLoop && g_AtlasGameLoop->running)
return;
const bool is_msaa_supported =
ogl_HaveVersion("3.3") &&
ogl_HaveVersion(3, 3) &&
ogl_HaveExtension("GL_ARB_multisample") &&
ogl_HaveExtension("GL_ARB_texture_multisample") &&
!m_AllowedSampleCounts.empty();
@@ -681,28 +681,28 @@ void CPostprocManager::CreateMultisampleBuffer()
glGenTextures(1, &m_MultisampleColorTex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleColorTex);
pglTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleCount, GL_RGBA, m_Width, m_Height, GL_TRUE);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleCount, GL_RGBA, m_Width, m_Height, GL_TRUE);
// Allocate the Depth/Stencil texture.
glGenTextures(1, &m_MultisampleDepthTex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleDepthTex);
pglTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleCount, GL_DEPTH24_STENCIL8_EXT, m_Width, m_Height, GL_TRUE);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleCount, GL_DEPTH24_STENCIL8_EXT, m_Width, m_Height, GL_TRUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
ogl_WarnIfError();
// Set up the framebuffers with some initial textures.
pglGenFramebuffersEXT(1, &m_MultisampleFBO);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_MultisampleFBO);
glGenFramebuffersEXT(1, &m_MultisampleFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_MultisampleFBO);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleColorTex, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_STENCIL_ATTACHMENT,
GL_TEXTURE_2D_MULTISAMPLE, m_MultisampleDepthTex, 0);
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Multisample framebuffer object incomplete (A): 0x%04X", status);
@@ -710,7 +710,7 @@ void CPostprocManager::CreateMultisampleBuffer()
DestroyMultisampleBuffer();
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
@@ -721,7 +721,7 @@ void CPostprocManager::DestroyMultisampleBuffer()
if (m_UsingMultisampleBuffer)
return;
if (m_MultisampleFBO)
pglDeleteFramebuffersEXT(1, &m_MultisampleFBO);
glDeleteFramebuffersEXT(1, &m_MultisampleFBO);
if (m_MultisampleColorTex)
glDeleteTextures(1, &m_MultisampleColorTex);
if (m_MultisampleDepthTex)
@@ -739,11 +739,11 @@ void CPostprocManager::ResolveMultisampleFramebuffer()
if (!m_UsingMultisampleBuffer)
return;
pglBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_PingFbo);
pglBlitFramebufferEXT(0, 0, m_Width, m_Height, 0, 0, m_Width, m_Height,
glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, m_PingFbo);
glBlitFramebufferEXT(0, 0, m_Width, m_Height, 0, 0, m_Width, m_Height,
GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_PingFbo);
}
#else
+8 -8
View File
@@ -729,7 +729,7 @@ void CRenderer::RenderPatches(const CShaderDefines& context, int cullGroup)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
// setup some renderstate ..
pglActiveTextureARB(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
glLineWidth(2.0f);
// render tiles edges
@@ -987,7 +987,7 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding
glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1);
// try binding the framebuffer
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_ReflectionFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_ReflectionFbo);
glClearColor(0.5f, 0.5f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1025,7 +1025,7 @@ void CRenderer::RenderReflections(const CShaderDefines& context, const CBounding
m_ViewCamera = normalCamera;
SetViewport(m_ViewCamera.GetViewPort());
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
@@ -1067,7 +1067,7 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding
glScissor(screenScissor.x1, screenScissor.y1, screenScissor.x2 - screenScissor.x1, screenScissor.y2 - screenScissor.y1);
// try binding the framebuffer
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_RefractionFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, wm.m_RefractionFbo);
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -1086,7 +1086,7 @@ void CRenderer::RenderRefractions(const CShaderDefines& context, const CBounding
m_ViewCamera = normalCamera;
SetViewport(m_ViewCamera.GetViewPort());
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
void CRenderer::RenderSilhouettes(const CShaderDefines& context)
@@ -1141,7 +1141,7 @@ void CRenderer::RenderSilhouettes(const CShaderDefines& context)
glEnable(GL_BLEND);
glBlendFunc(GL_CONSTANT_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA);
const float silhouetteAlpha = 0.75f;
pglBlendColorEXT(0, 0, 0, silhouetteAlpha);
glBlendColorEXT(0, 0, 0, silhouetteAlpha);
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_NOTEQUAL, 1, (GLuint)-1);
@@ -1161,7 +1161,7 @@ void CRenderer::RenderSilhouettes(const CShaderDefines& context)
glDepthFunc(GL_LEQUAL);
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
pglBlendColorEXT(0, 0, 0, 0);
glBlendColorEXT(0, 0, 0, 0);
glDisable(GL_STENCIL_TEST);
}
@@ -1634,7 +1634,7 @@ Scene& CRenderer::GetScene()
// BindTexture: bind a GL texture object to current active unit
void CRenderer::BindTexture(int unit, GLuint tex)
{
pglActiveTextureARB(GL_TEXTURE0+unit);
glActiveTextureARB(GL_TEXTURE0+unit);
glBindTexture(GL_TEXTURE_2D, tex);
}
+11 -11
View File
@@ -218,7 +218,7 @@ ShadowMap::~ShadowMap()
if (m->DummyTexture)
glDeleteTextures(1, &m->DummyTexture);
if (m->Framebuffer)
pglDeleteFramebuffersEXT(1, &m->Framebuffer);
glDeleteFramebuffersEXT(1, &m->Framebuffer);
delete m;
}
@@ -232,7 +232,7 @@ void ShadowMap::RecreateTexture()
if (m->DummyTexture)
glDeleteTextures(1, &m->DummyTexture);
if (m->Framebuffer)
pglDeleteFramebuffersEXT(1, &m->Framebuffer);
glDeleteFramebuffersEXT(1, &m->Framebuffer);
m->Texture = 0;
m->DummyTexture = 0;
@@ -495,14 +495,14 @@ void ShadowMapInternals::CreateTexture()
}
if (Framebuffer)
{
pglDeleteFramebuffersEXT(1, &Framebuffer);
glDeleteFramebuffersEXT(1, &Framebuffer);
Framebuffer = 0;
}
// save the caller's FBO
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &SavedViewFBO);
pglGenFramebuffersEXT(1, &Framebuffer);
glGenFramebuffersEXT(1, &Framebuffer);
CFG_GET_VAL("shadowquality", QualityLevel);
@@ -597,13 +597,13 @@ void ShadowMapInternals::CreateTexture()
// bind to framebuffer object
glBindTexture(GL_TEXTURE_2D, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Framebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Framebuffer);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, Texture, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, Texture, 0);
if (g_RenderingOptions.GetShadowAlphaFix())
{
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, DummyTexture, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, DummyTexture, 0);
}
else
{
@@ -620,9 +620,9 @@ void ShadowMapInternals::CreateTexture()
ogl_WarnIfError();
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, SavedViewFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, SavedViewFBO);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
@@ -639,7 +639,7 @@ void ShadowMap::BeginRender()
{
PROFILE("bind framebuffer");
glBindTexture(GL_TEXTURE_2D, 0);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m->Framebuffer);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m->Framebuffer);
}
// clear buffers
@@ -689,7 +689,7 @@ void ShadowMap::EndRender()
{
PROFILE("unbind framebuffer");
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
}
const SViewPort vp = { 0, 0, g_Renderer.GetWidth(), g_Renderer.GetHeight() };
+2 -2
View File
@@ -127,7 +127,7 @@ void TerrainOverlay::RenderBeforeWater()
//glEnable(GL_POLYGON_OFFSET_LINE);
glEnable(GL_POLYGON_OFFSET_FILL);
pglActiveTextureARB(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
StartRender();
@@ -320,7 +320,7 @@ void TerrainTextureOverlay::RenderAfterWater(int cullGroup)
ssize_t w = (ssize_t)(terrain->GetTilesPerSide() * m_TexelsPerTile);
ssize_t h = (ssize_t)(terrain->GetTilesPerSide() * m_TexelsPerTile);
pglActiveTextureARB(GL_TEXTURE0);
glActiveTextureARB(GL_TEXTURE0);
// Recreate the texture with new size if necessary
if (round_up_to_pow2(w) != m_TextureW || round_up_to_pow2(h) != m_TextureH)
+3 -3
View File
@@ -399,7 +399,7 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
GLint fbo;
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &fbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, waterManager->m_FancyEffectsFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, waterManager->m_FancyEffectsFBO);
glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);
@@ -422,7 +422,7 @@ bool TerrainRenderer::RenderFancyWater(const CShaderDefines& context, int cullGr
dummyTech->EndPass();
glEnable(GL_CULL_FACE);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -563,7 +563,7 @@ void TerrainRenderer::RenderSimpleWater(int cullGroup)
waterSimpleShader->Unbind();
g_Renderer.BindTexture(1, 0);
pglActiveTextureARB(GL_TEXTURE0_ARB);
glActiveTextureARB(GL_TEXTURE0_ARB);
waterSimpleTech->EndPass();
#endif
+14 -14
View File
@@ -56,10 +56,10 @@ CVertexBuffer::CVertexBuffer(size_t vertexSize, GLenum usage, GLenum target, siz
m_MaxVertices = m_FreeVertices = size / vertexSize;
// allocate raw buffer
pglGenBuffersARB(1, &m_Handle);
pglBindBufferARB(m_Target, m_Handle);
pglBufferDataARB(m_Target, m_MaxVertices * m_VertexSize, 0, m_Usage);
pglBindBufferARB(m_Target, 0);
glGenBuffersARB(1, &m_Handle);
glBindBufferARB(m_Target, m_Handle);
glBufferDataARB(m_Target, m_MaxVertices * m_VertexSize, 0, m_Usage);
glBindBufferARB(m_Target, 0);
// create sole free chunk
VBChunk* chunk = new VBChunk;
@@ -75,7 +75,7 @@ CVertexBuffer::~CVertexBuffer()
ENSURE(m_AllocList.empty());
if (m_Handle)
pglDeleteBuffersARB(1, &m_Handle);
glDeleteBuffersARB(1, &m_Handle);
for (VBChunk* const& chunk : m_FreeList)
delete chunk;
@@ -207,9 +207,9 @@ void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk, void* data)
}
else
{
pglBindBufferARB(m_Target, m_Handle);
pglBufferSubDataARB(m_Target, chunk->m_Index * m_VertexSize, chunk->m_Count * m_VertexSize, data);
pglBindBufferARB(m_Target, 0);
glBindBufferARB(m_Target, m_Handle);
glBufferSubDataARB(m_Target, chunk->m_Index * m_VertexSize, chunk->m_Count * m_VertexSize, data);
glBindBufferARB(m_Target, 0);
}
}
@@ -218,7 +218,7 @@ void CVertexBuffer::UpdateChunkVertices(VBChunk* chunk, void* data)
// to glVertexPointer ( + etc) calls
u8* CVertexBuffer::Bind()
{
pglBindBufferARB(m_Target, m_Handle);
glBindBufferARB(m_Target, m_Handle);
if (UseStreaming(m_Usage))
{
@@ -240,7 +240,7 @@ u8* CVertexBuffer::Bind()
if (needUpload)
{
// Tell the driver that it can reallocate the whole VBO
pglBufferDataARB(m_Target, m_MaxVertices * m_VertexSize, NULL, m_Usage);
glBufferDataARB(m_Target, m_MaxVertices * m_VertexSize, NULL, m_Usage);
// (In theory, glMapBufferRange with GL_MAP_INVALIDATE_BUFFER_BIT could be used
// here instead of glBufferData(..., NULL, ...) plus glMapBuffer(), but with
@@ -249,7 +249,7 @@ u8* CVertexBuffer::Bind()
while (true)
{
void* p = pglMapBufferARB(m_Target, GL_WRITE_ONLY);
void* p = glMapBufferARB(m_Target, GL_WRITE_ONLY);
if (p == NULL)
{
// This shouldn't happen unless we run out of virtual address space
@@ -272,7 +272,7 @@ u8* CVertexBuffer::Bind()
if (chunk->m_Needed)
memcpy((u8 *)p + chunk->m_Index * m_VertexSize, chunk->m_BackingStore, chunk->m_Count * m_VertexSize);
if (pglUnmapBufferARB(m_Target) == GL_TRUE)
if (glUnmapBufferARB(m_Target) == GL_TRUE)
break;
// Unmap might fail on e.g. resolution switches, so just try again
@@ -308,8 +308,8 @@ u8* CVertexBuffer::Bind()
void CVertexBuffer::Unbind()
{
pglBindBufferARB(GL_ARRAY_BUFFER, 0);
pglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ARRAY_BUFFER, 0);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER, 0);
}
size_t CVertexBuffer::GetBytesReserved() const
+25 -25
View File
@@ -150,9 +150,9 @@ WaterManager::~WaterManager()
glDeleteTextures(1, &m_ReflFboDepthTexture);
glDeleteTextures(1, &m_RefrFboDepthTexture);
pglDeleteFramebuffersEXT(1, &m_FancyEffectsFBO);
pglDeleteFramebuffersEXT(1, &m_RefractionFbo);
pglDeleteFramebuffersEXT(1, &m_ReflectionFbo);
glDeleteFramebuffersEXT(1, &m_FancyEffectsFBO);
glDeleteFramebuffersEXT(1, &m_RefractionFbo);
glDeleteFramebuffersEXT(1, &m_ReflectionFbo);
}
@@ -273,14 +273,14 @@ int WaterManager::LoadWaterTextures()
glGetIntegerv(GL_FRAMEBUFFER_BINDING_EXT, &currentFbo);
m_ReflectionFbo = 0;
pglGenFramebuffersEXT(1, &m_ReflectionFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_ReflectionFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ReflectionTexture, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_ReflFboDepthTexture, 0);
glGenFramebuffersEXT(1, &m_ReflectionFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_ReflectionFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_ReflectionTexture, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_ReflFboDepthTexture, 0);
ogl_WarnIfError();
GLenum status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
GLenum status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Reflection framebuffer object incomplete: 0x%04X", status);
@@ -289,14 +289,14 @@ int WaterManager::LoadWaterTextures()
}
m_RefractionFbo = 0;
pglGenFramebuffersEXT(1, &m_RefractionFbo);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_RefractionFbo);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_RefractionTexture, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_RefrFboDepthTexture, 0);
glGenFramebuffersEXT(1, &m_RefractionFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_RefractionFbo);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_RefractionTexture, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_RefrFboDepthTexture, 0);
ogl_WarnIfError();
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Refraction framebuffer object incomplete: 0x%04X", status);
@@ -304,14 +304,14 @@ int WaterManager::LoadWaterTextures()
UpdateQuality();
}
pglGenFramebuffersEXT(1, &m_FancyEffectsFBO);
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FancyTexture, 0);
pglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_FancyTextureDepth, 0);
glGenFramebuffersEXT(1, &m_FancyEffectsFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_FancyTexture, 0);
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, m_FancyTextureDepth, 0);
ogl_WarnIfError();
status = pglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
if (status != GL_FRAMEBUFFER_COMPLETE_EXT)
{
LOGWARNING("Fancy Effects framebuffer object incomplete: 0x%04X", status);
@@ -319,7 +319,7 @@ int WaterManager::LoadWaterTextures()
UpdateQuality();
}
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, currentFbo);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, currentFbo);
// Enable rendering, now that we've succeeded this far
m_RenderWater = true;
@@ -372,8 +372,8 @@ void WaterManager::UnloadWaterTextures()
glDeleteTextures(1, &m_ReflectionTexture);
glDeleteTextures(1, &m_RefractionTexture);
pglDeleteFramebuffersEXT(1, &m_RefractionFbo);
pglDeleteFramebuffersEXT(1, &m_ReflectionFbo);
glDeleteFramebuffersEXT(1, &m_RefractionFbo);
glDeleteFramebuffersEXT(1, &m_ReflectionFbo);
}
template<bool Transpose>
@@ -847,10 +847,10 @@ void WaterManager::RenderWaves(const CFrustum& frustrum)
if (g_Renderer.DoSkipSubmit() || !m_WaterFancyEffects)
return;
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FancyEffectsFBO);
GLuint attachments[1] = { GL_COLOR_ATTACHMENT0_EXT };
pglDrawBuffers(1, attachments);
glDrawBuffers(1, attachments);
glClearColor(0.0f,0.0f, 0.0f,0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -883,7 +883,7 @@ void WaterManager::RenderWaves(const CFrustum& frustrum)
shader->VertexPointer(3, GL_FLOAT, stride, &base[VBchunk->m_Index].m_BasePosition);
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_UNSIGNED_BYTE, stride, &base[VBchunk->m_Index].m_UV);
// NormalPointer(gl_FLOAT, stride, &base[m_VBWater->m_Index].m_UV)
pglVertexAttribPointerARB(2, 2, GL_FLOAT, GL_FALSE, stride, &base[VBchunk->m_Index].m_PerpVect); // replaces commented above because my normal is vec2
glVertexAttribPointerARB(2, 2, GL_FLOAT, GL_FALSE, stride, &base[VBchunk->m_Index].m_PerpVect); // replaces commented above because my normal is vec2
shader->VertexAttribPointer(str_a_apexPosition, 3, GL_FLOAT, false, stride, &base[VBchunk->m_Index].m_ApexPosition);
shader->VertexAttribPointer(str_a_splashPosition, 3, GL_FLOAT, false, stride, &base[VBchunk->m_Index].m_SplashPosition);
shader->VertexAttribPointer(str_a_retreatPosition, 3, GL_FLOAT, false, stride, &base[VBchunk->m_Index].m_RetreatPosition);
@@ -906,7 +906,7 @@ void WaterManager::RenderWaves(const CFrustum& frustrum)
CVertexBuffer::Unbind();
}
tech->EndPass();
pglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
glDisable(GL_BLEND);
glDepthFunc(GL_LEQUAL);
+37 -31
View File
@@ -31,6 +31,10 @@
#if OS_WIN
#include "lib/sysdep/os/win/wgfx.h"
// We can't include wutil directly because GL headers conflict with Windows
// until we use a proper GL loader.
extern void* wutil_GetAppHDC();
#endif
#include <algorithm>
@@ -39,27 +43,8 @@
// TODO: Support OpenGL platforms which don't use GLX as well.
#if defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
#include <GL/glx.h>
#include <glad/glx.h>
#include <SDL_syswm.h>
// Define the GLX_MESA_query_renderer macros if built with
// an old Mesa (<10.0) that doesn't provide them
#ifndef GLX_MESA_query_renderer
#define GLX_MESA_query_renderer 1
#define GLX_RENDERER_VENDOR_ID_MESA 0x8183
#define GLX_RENDERER_DEVICE_ID_MESA 0x8184
#define GLX_RENDERER_VERSION_MESA 0x8185
#define GLX_RENDERER_ACCELERATED_MESA 0x8186
#define GLX_RENDERER_VIDEO_MEMORY_MESA 0x8187
#define GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA 0x8188
#define GLX_RENDERER_PREFERRED_PROFILE_MESA 0x8189
#define GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA 0x818A
#define GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA 0x818B
#define GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA 0x818C
#define GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA 0x818D
#define GLX_RENDERER_ID_MESA 0x818E
#endif /* GLX_MESA_query_renderer */
#endif
namespace Renderer
@@ -155,9 +140,30 @@ std::unique_ptr<CDevice> CDevice::Create(SDL_Window* window)
LOGERROR("SDL_GL_CreateContext failed: '%s'", SDL_GetError());
return nullptr;
}
#if OS_WIN
ogl_Init(SDL_GL_GetProcAddress, wutil_GetAppHDC());
#elif defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
ogl_Init(SDL_GL_GetProcAddress, GetX11Display(device->m_Window));
#else
ogl_Init(SDL_GL_GetProcAddress);
#endif
}
else
{
// SDL_GL_GetProcAddress is available because we called SDL_GL_LoadLibrary.
#if OS_WIN
ogl_Init(SDL_GL_GetProcAddress, wutil_GetAppHDC());
#elif defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
ogl_Init(SDL_GL_GetProcAddress, XOpenDisplay(NULL));
#else
ogl_Init(SDL_GL_GetProcAddress);
#endif
ogl_Init();
#if OS_WIN || defined(SDL_VIDEO_DRIVER_X11) && !CONFIG2_GLES
// Hack to stop things looking very ugly when scrolling in Atlas.
ogl_SetVsyncEnabled(true);
#endif
}
if ((ogl_HaveExtensions(0, "GL_ARB_vertex_program", "GL_ARB_fragment_program", nullptr) // ARB
&& ogl_HaveExtensions(0, "GL_ARB_vertex_shader", "GL_ARB_fragment_shader", nullptr)) // GLSL
@@ -246,7 +252,7 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
#define QUERY(target, pname) do { \
GLint i = -1; \
pglGetQueryivARB(GL_##target, GL_##pname, &i); \
glGetQueryivARB(GL_##target, GL_##pname, &i); \
if (ogl_SquelchError(GL_INVALID_ENUM)) \
Script::SetProperty(rq, settings, "GL_" #target ".GL_" #pname, errstr); \
else \
@@ -255,7 +261,7 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
#define VERTEXPROGRAM(id) do { \
GLint i = -1; \
pglGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_##id, &i); \
glGetProgramivARB(GL_VERTEX_PROGRAM_ARB, GL_##id, &i); \
if (ogl_SquelchError(GL_INVALID_ENUM)) \
Script::SetProperty(rq, settings, "GL_VERTEX_PROGRAM_ARB.GL_" #id, errstr); \
else \
@@ -264,7 +270,7 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
#define FRAGMENTPROGRAM(id) do { \
GLint i = -1; \
pglGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_##id, &i); \
glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_##id, &i); \
if (ogl_SquelchError(GL_INVALID_ENUM)) \
Script::SetProperty(rq, settings, "GL_FRAGMENT_PROGRAM_ARB.GL_" #id, errstr); \
else \
@@ -370,8 +376,8 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
if (ogl_HaveExtension("GL_EXT_gpu_shader4"))
{
INTEGER(MIN_PROGRAM_TEXEL_OFFSET); // no _EXT version of these in glext.h
INTEGER(MAX_PROGRAM_TEXEL_OFFSET);
INTEGER(MIN_PROGRAM_TEXEL_OFFSET_EXT); // no _EXT version of these in glext.h
INTEGER(MAX_PROGRAM_TEXEL_OFFSET_EXT);
}
if (ogl_HaveExtension("GL_EXT_framebuffer_object"))
@@ -518,13 +524,13 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
#define GLXQCR_INTEGER(id) do { \
unsigned int i = UINT_MAX; \
if (pglXQueryCurrentRendererIntegerMESA(id, &i)) \
if (glXQueryCurrentRendererIntegerMESA(id, &i)) \
Script::SetProperty(rq, settings, #id, i); \
} while (false)
#define GLXQCR_INTEGER2(id) do { \
unsigned int i[2] = { UINT_MAX, UINT_MAX }; \
if (pglXQueryCurrentRendererIntegerMESA(id, i)) { \
if (glXQueryCurrentRendererIntegerMESA(id, i)) { \
Script::SetProperty(rq, settings, #id "[0]", i[0]); \
Script::SetProperty(rq, settings, #id "[1]", i[1]); \
} \
@@ -532,7 +538,7 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
#define GLXQCR_INTEGER3(id) do { \
unsigned int i[3] = { UINT_MAX, UINT_MAX, UINT_MAX }; \
if (pglXQueryCurrentRendererIntegerMESA(id, i)) { \
if (glXQueryCurrentRendererIntegerMESA(id, i)) { \
Script::SetProperty(rq, settings, #id "[0]", i[0]); \
Script::SetProperty(rq, settings, #id "[1]", i[1]); \
Script::SetProperty(rq, settings, #id "[2]", i[2]); \
@@ -540,7 +546,7 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
} while (false)
#define GLXQCR_STRING(id) do { \
const char* str = pglXQueryCurrentRendererStringMESA(id); \
const char* str = glXQueryCurrentRendererStringMESA(id); \
if (str) \
Script::SetProperty(rq, settings, #id ".string", str); \
} while (false)
@@ -558,7 +564,7 @@ void CDevice::Report(const ScriptRequest& rq, JS::HandleValue settings)
Script::SetProperty(rq, settings, "glx_extensions", glxexts);
if (strstr(glxexts, "GLX_MESA_query_renderer") && pglXQueryCurrentRendererIntegerMESA && pglXQueryCurrentRendererStringMESA)
if (strstr(glxexts, "GLX_MESA_query_renderer") && glXQueryCurrentRendererIntegerMESA && glXQueryCurrentRendererStringMESA)
{
GLXQCR_INTEGER(GLX_RENDERER_VENDOR_ID_MESA);
GLXQCR_INTEGER(GLX_RENDERER_DEVICE_ID_MESA);
@@ -114,13 +114,6 @@ MESSAGEHANDLER(InitGraphics)
g_VideoMode.CreateBackendDevice(false);
InitGraphics(g_AtlasGameLoop->args, g_InitFlags, {});
#if OS_WIN
// HACK (to stop things looking very ugly when scrolling) - should
// use proper config system.
if(ogl_HaveExtension("WGL_EXT_swap_control"))
pwglSwapIntervalEXT(1);
#endif
}