Factorize gl headers include in a separate file.
It should avoid conflict with Xorg headers
This commit is contained in:
parent
bd7ec06d49
commit
30c91217a7
115
src/graphics/gl_headers.hpp
Normal file
115
src/graphics/gl_headers.hpp
Normal file
@ -0,0 +1,115 @@
|
||||
#ifndef GL_HEADER_HPP
|
||||
#define GL_HEADER_HPP
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# include <OpenGL/gl.h>
|
||||
# include <OpenGL/gl3.h>
|
||||
# define OGL32CTX
|
||||
# ifdef GL_ARB_instanced_arrays
|
||||
# define glVertexAttribDivisor glVertexAttribDivisorARB
|
||||
# endif
|
||||
# ifndef GL_TEXTURE_SWIZZLE_RGBA
|
||||
# define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
|
||||
# endif
|
||||
#elif defined(ANDROID)
|
||||
# include <GLES/gl.h>
|
||||
#elif defined(WIN32)
|
||||
# define _WINSOCKAPI_
|
||||
// has to be included before gl.h because of WINGDIAPI and APIENTRY definitions
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
# include "../../lib/irrlicht/source/Irrlicht/glext.h"
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#define DEBUG_OUTPUT_DECLARED
|
||||
# include <GL/gl.h>
|
||||
# include <GL/glext.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
extern PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks;
|
||||
extern PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback;
|
||||
extern PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback;
|
||||
extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback;
|
||||
extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback;
|
||||
extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings;
|
||||
extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
||||
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
extern PFNGLUNIFORM1FPROC glUniform1f;
|
||||
extern PFNGLUNIFORM3FPROC glUniform3f;
|
||||
extern PFNGLUNIFORM1FVPROC glUniform1fv;
|
||||
extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
extern PFNGLUNIFORM2FPROC glUniform2f;
|
||||
extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||
extern PFNGLUNIFORM3IPROC glUniform3i;
|
||||
extern PFNGLUNIFORM4IPROC glUniform4i;
|
||||
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
||||
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
|
||||
extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
|
||||
extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
|
||||
extern PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
|
||||
extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced;
|
||||
extern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex;
|
||||
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
extern PFNGLFENCESYNCPROC glFenceSync;
|
||||
extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
|
||||
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
||||
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||
extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||
extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
|
||||
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
|
||||
extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
|
||||
extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
|
||||
extern PFNGLBLENDCOLORPROC glBlendColor;
|
||||
extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
|
||||
extern PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage;
|
||||
extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
|
||||
extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
|
||||
extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
|
||||
extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
|
||||
extern PFNGLDISPATCHCOMPUTEPROC glDispatchCompute;
|
||||
extern PFNGLGENSAMPLERSPROC glGenSamplers;
|
||||
extern PFNGLBINDSAMPLERPROC glBindSampler;
|
||||
extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
|
||||
extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
|
||||
#ifdef DEBUG
|
||||
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,28 +1,7 @@
|
||||
#ifndef GLWRAP_HEADER_H
|
||||
#define GLWRAP_HEADER_H
|
||||
|
||||
#if defined(__APPLE__)
|
||||
# include <OpenGL/gl.h>
|
||||
# include <OpenGL/gl3.h>
|
||||
# define OGL32CTX
|
||||
# ifdef GL_ARB_instanced_arrays
|
||||
# define glVertexAttribDivisor glVertexAttribDivisorARB
|
||||
# endif
|
||||
# ifndef GL_TEXTURE_SWIZZLE_RGBA
|
||||
# define GL_TEXTURE_SWIZZLE_RGBA 0x8E46
|
||||
# endif
|
||||
#elif defined(ANDROID)
|
||||
# include <GLES/gl.h>
|
||||
#elif defined(WIN32)
|
||||
# define _WINSOCKAPI_
|
||||
// has to be included before gl.h because of WINGDIAPI and APIENTRY definitions
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
#else
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#define DEBUG_OUTPUT_DECLARED
|
||||
# include <GL/gl.h>
|
||||
#endif
|
||||
#include "gl_headers.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include "irr_driver.hpp"
|
||||
@ -31,91 +10,6 @@
|
||||
// already includes glext.h, which defines useful GL constants.
|
||||
// COpenGLDriver has already loaded the extension GL functions we use (e.g glBeginQuery)
|
||||
#include "../../lib/irrlicht/source/Irrlicht/COpenGLDriver.h"
|
||||
#ifdef WIN32
|
||||
extern PFNGLGENTRANSFORMFEEDBACKSPROC glGenTransformFeedbacks;
|
||||
extern PFNGLBINDTRANSFORMFEEDBACKPROC glBindTransformFeedback;
|
||||
extern PFNGLDRAWTRANSFORMFEEDBACKPROC glDrawTransformFeedback;
|
||||
extern PFNGLBEGINTRANSFORMFEEDBACKPROC glBeginTransformFeedback;
|
||||
extern PFNGLENDTRANSFORMFEEDBACKPROC glEndTransformFeedback;
|
||||
extern PFNGLTRANSFORMFEEDBACKVARYINGSPROC glTransformFeedbackVaryings;
|
||||
extern PFNGLBINDBUFFERBASEPROC glBindBufferBase;
|
||||
extern PFNGLGENBUFFERSPROC glGenBuffers;
|
||||
extern PFNGLBINDBUFFERPROC glBindBuffer;
|
||||
extern PFNGLBUFFERDATAPROC glBufferData;
|
||||
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
|
||||
extern PFNGLCREATESHADERPROC glCreateShader;
|
||||
extern PFNGLCOMPILESHADERPROC glCompileShader;
|
||||
extern PFNGLSHADERSOURCEPROC glShaderSource;
|
||||
extern PFNGLCREATEPROGRAMPROC glCreateProgram;
|
||||
extern PFNGLATTACHSHADERPROC glAttachShader;
|
||||
extern PFNGLLINKPROGRAMPROC glLinkProgram;
|
||||
extern PFNGLUSEPROGRAMPROC glUseProgram;
|
||||
extern PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray;
|
||||
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
|
||||
extern PFNGLGETUNIFORMLOCATIONPROC glGetUniformLocation;
|
||||
extern PFNGLUNIFORMMATRIX4FVPROC glUniformMatrix4fv;
|
||||
extern PFNGLUNIFORM1FPROC glUniform1f;
|
||||
extern PFNGLUNIFORM3FPROC glUniform3f;
|
||||
extern PFNGLUNIFORM1FVPROC glUniform1fv;
|
||||
extern PFNGLUNIFORM4FVPROC glUniform4fv;
|
||||
extern PFNGLDELETESHADERPROC glDeleteShader;
|
||||
extern PFNGLGETSHADERIVPROC glGetShaderiv;
|
||||
extern PFNGLGETSHADERINFOLOGPROC glGetShaderInfoLog;
|
||||
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
|
||||
extern PFNGLUNIFORM2FPROC glUniform2f;
|
||||
extern PFNGLUNIFORM1IPROC glUniform1i;
|
||||
extern PFNGLUNIFORM3IPROC glUniform3i;
|
||||
extern PFNGLUNIFORM4IPROC glUniform4i;
|
||||
extern PFNGLGETPROGRAMIVPROC glGetProgramiv;
|
||||
extern PFNGLGETPROGRAMINFOLOGPROC glGetProgramInfoLog;
|
||||
extern PFNGLGETATTRIBLOCATIONPROC glGetAttribLocation;
|
||||
extern PFNGLBINDATTRIBLOCATIONPROC glBindAttribLocation;
|
||||
extern PFNGLBLENDEQUATIONPROC glBlendEquation;
|
||||
extern PFNGLVERTEXATTRIBDIVISORPROC glVertexAttribDivisor;
|
||||
extern PFNGLDRAWARRAYSINSTANCEDPROC glDrawArraysInstanced;
|
||||
extern PFNGLDRAWELEMENTSBASEVERTEXPROC glDrawElementsBaseVertex;
|
||||
extern PFNGLDRAWELEMENTSINSTANCEDPROC glDrawElementsInstanced;
|
||||
extern PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC glDrawElementsInstancedBaseVertex;
|
||||
extern PFNGLDELETEBUFFERSPROC glDeleteBuffers;
|
||||
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
extern PFNGLTEXBUFFERPROC glTexBuffer;
|
||||
extern PFNGLBUFFERSUBDATAPROC glBufferSubData;
|
||||
extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
extern PFNGLFENCESYNCPROC glFenceSync;
|
||||
extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
|
||||
extern PFNGLVERTEXATTRIBIPOINTERPROC glVertexAttribIPointer;
|
||||
extern PFNGLGENFRAMEBUFFERSPROC glGenFramebuffers;
|
||||
extern PFNGLDELETEFRAMEBUFFERSPROC glDeleteFramebuffers;
|
||||
extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
|
||||
extern PFNGLFRAMEBUFFERTEXTURE2DPROC glFramebufferTexture2D;
|
||||
extern PFNGLFRAMEBUFFERTEXTUREPROC glFramebufferTexture;
|
||||
extern PFNGLTEXIMAGE3DPROC glTexImage3D;
|
||||
extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
|
||||
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC glCheckFramebufferStatus;
|
||||
extern PFNGLTEXIMAGE2DMULTISAMPLEPROC glTexImage2DMultisample;
|
||||
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
|
||||
extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
|
||||
extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
|
||||
extern PFNGLBLENDCOLORPROC glBlendColor;
|
||||
extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
|
||||
extern PFNGLGETCOMPRESSEDTEXIMAGEPROC glGetCompressedTexImage;
|
||||
extern PFNGLTEXSTORAGE1DPROC glTexStorage1D;
|
||||
extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
|
||||
extern PFNGLTEXSTORAGE3DPROC glTexStorage3D;
|
||||
extern PFNGLBINDIMAGETEXTUREPROC glBindImageTexture;
|
||||
extern PFNGLDISPATCHCOMPUTEPROC glDispatchCompute;
|
||||
extern PFNGLGENSAMPLERSPROC glGenSamplers;
|
||||
extern PFNGLBINDSAMPLERPROC glBindSampler;
|
||||
extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
|
||||
extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
|
||||
#ifdef DEBUG
|
||||
extern PFNGLDEBUGMESSAGECALLBACKARBPROC glDebugMessageCallbackARB;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
void initGL();
|
||||
|
@ -600,6 +600,11 @@ bool needsUBO()
|
||||
return irr_driver->needUBOWorkaround();
|
||||
}
|
||||
|
||||
unsigned getGLSLVersion()
|
||||
{
|
||||
return irr_driver->getGLSLVersion();
|
||||
}
|
||||
|
||||
namespace MeshShader
|
||||
{
|
||||
// Solid Normal and depth pass shaders
|
||||
|
@ -23,7 +23,8 @@
|
||||
#include "config/user_config.hpp"
|
||||
#include "utils/singleton.hpp"
|
||||
|
||||
typedef unsigned int GLuint;
|
||||
#include "gl_headers.hpp"
|
||||
|
||||
using namespace irr;
|
||||
class ParticleSystemProxy;
|
||||
|
||||
@ -51,14 +52,10 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
void glUniformMatrix4fvWraper(GLuint, size_t, unsigned, const float *mat);
|
||||
void glUniform3fWraper(GLuint, float, float, float);
|
||||
void glUniform4iWraper(GLuint, int, int, int, int);
|
||||
void glUniform2fWraper(GLuint a, float b, float c);
|
||||
void glUniform1fWrapper(GLuint, float);
|
||||
void glUniform1iWrapper(GLuint, int);
|
||||
bool needsUBO();
|
||||
|
||||
unsigned getGLSLVersion();
|
||||
|
||||
struct UniformHelper
|
||||
{
|
||||
template<unsigned N = 0>
|
||||
@ -69,31 +66,28 @@ struct UniformHelper
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const core::matrix4 &mat, Args... arg)
|
||||
{
|
||||
#ifndef GL_FALSE
|
||||
#define GL_FALSE 0
|
||||
#endif
|
||||
glUniformMatrix4fvWraper(uniforms[N], 1, GL_FALSE, mat.pointer());
|
||||
glUniformMatrix4fv(uniforms[N], 1, GL_FALSE, mat.pointer());
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const video::SColorf &col, Args... arg)
|
||||
{
|
||||
glUniform3fWraper(uniforms[N], col.r, col.g, col.b);
|
||||
glUniform3f(uniforms[N], col.r, col.g, col.b);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const video::SColor &col, Args... arg)
|
||||
{
|
||||
glUniform4iWraper(uniforms[N], col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
glUniform4i(uniforms[N], col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const core::vector3df &v, Args... arg)
|
||||
{
|
||||
glUniform3fWraper(uniforms[N], v.X, v.Y, v.Z);
|
||||
glUniform3f(uniforms[N], v.X, v.Y, v.Z);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
@ -101,35 +95,34 @@ struct UniformHelper
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const core::vector2df &v, Args... arg)
|
||||
{
|
||||
glUniform2fWraper(uniforms[N], v.X, v.Y);
|
||||
glUniform2f(uniforms[N], v.X, v.Y);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, const core::dimension2df &v, Args... arg)
|
||||
{
|
||||
glUniform2fWraper(uniforms[N], v.Width, v.Height);
|
||||
glUniform2f(uniforms[N], v.Width, v.Height);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, float f, Args... arg)
|
||||
{
|
||||
glUniform1fWrapper(uniforms[N], f);
|
||||
glUniform1f(uniforms[N], f);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
template<unsigned N = 0, typename... Args>
|
||||
static void setUniformsHelper(const std::vector<GLuint> &uniforms, int f, Args... arg)
|
||||
{
|
||||
glUniform1iWrapper(uniforms[N], f);
|
||||
glUniform1i(uniforms[N], f);
|
||||
setUniformsHelper<N + 1>(uniforms, arg...);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
void bypassUBO(GLuint Program);
|
||||
GLuint getUniformLocation(GLuint program, const char* name);
|
||||
|
||||
template<typename T, typename... Args>
|
||||
class ShaderHelperSingleton : public Singleton<T>
|
||||
|
Loading…
Reference in New Issue
Block a user