图形部分增加名字空间graph
This commit is contained in:
parent
382584a81e
commit
8ea38d734d
@ -6,6 +6,7 @@
|
|||||||
#include<hgl/math/Math.h>
|
#include<hgl/math/Math.h>
|
||||||
|
|
||||||
using namespace hgl;
|
using namespace hgl;
|
||||||
|
using namespace hgl::graph;
|
||||||
|
|
||||||
constexpr uint screen_width=1280;
|
constexpr uint screen_width=1280;
|
||||||
constexpr uint screen_height=720;
|
constexpr uint screen_height=720;
|
||||||
|
@ -8,188 +8,191 @@
|
|||||||
// #include<hgl/graph/SSBO.h>
|
// #include<hgl/graph/SSBO.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
constexpr uint HGL_MAX_SHADER_NAME_LENGTH=128; ///<最大Shader名称长度
|
namespace graph
|
||||||
|
|
||||||
/**
|
|
||||||
* 着色程序类型枚举
|
|
||||||
*/
|
|
||||||
enum ShaderType ///着色程序类型
|
|
||||||
{
|
{
|
||||||
stVertex=0, ///<顶点着色程序
|
constexpr uint HGL_MAX_SHADER_NAME_LENGTH=128; ///<最大Shader名称长度
|
||||||
stTessControl, ///<镶嵌控制着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
|
||||||
stTessEval, ///<镶嵌评估着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
|
||||||
stGeometry, ///<几何着色程序
|
|
||||||
stFragment, ///<片断着色程序
|
|
||||||
stCompute, ///<计算着色程序(需OpenGL 4.3或ARB_compute_shader)
|
|
||||||
|
|
||||||
stEnd
|
/**
|
||||||
};//enum ShaderType
|
* 着色程序类型枚举
|
||||||
|
*/
|
||||||
extern const char ShaderTypeName[ShaderType::stEnd][32]; ///<着色程序名称
|
enum ShaderType ///着色程序类型
|
||||||
|
|
||||||
/**
|
|
||||||
* 着色器程序
|
|
||||||
*/
|
|
||||||
class Shader
|
|
||||||
{
|
|
||||||
uint program;
|
|
||||||
|
|
||||||
uint shader_index[ShaderType::stEnd];
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
bool Link(); ///<连接使用当前着色程序
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
Map<UTF8String,int> attrib_location;
|
|
||||||
Map<UTF8String,int> uniform_location;
|
|
||||||
|
|
||||||
// Map<UTF8String,int> uniform_block_index;
|
|
||||||
// MapObject<UTF8String,UBO> uniform_block_object;
|
|
||||||
//
|
|
||||||
// Map<UTF8String,int> ssbo_index;
|
|
||||||
// MapObject<UTF8String,SSBO> ssbo_object;
|
|
||||||
|
|
||||||
int _GetAttribLocation(const char *); ///<取得指定属性地址
|
|
||||||
int _GetUniformLocation(const char *); ///<取得一个变量的地址
|
|
||||||
// int _GetUniformBlockIndex(const char *); ///<取得一个只读数据块的地址索引
|
|
||||||
// int _GetShaderStorageIndex(const char *); ///<取得一个数据存储区的地址索引
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Shader(){program=0;hgl_zero(shader_index,ShaderType::stEnd);}
|
|
||||||
~Shader(){Clear();}
|
|
||||||
|
|
||||||
void Clear(); ///<清除着色程序
|
|
||||||
|
|
||||||
bool AddShader (const int shader_type,const char *); ///<增加一个着色程序
|
|
||||||
|
|
||||||
bool AddVertexShader (const char *code){return AddShader(ShaderType::stVertex,code);} ///<增加一个顶点着色程序
|
|
||||||
bool AddGeometryShader (const char *code){return AddShader(ShaderType::stGeometry,code);} ///<增加一个几何着色程序
|
|
||||||
bool AddFragmentShader (const char *code){return AddShader(ShaderType::stFragment,code);} ///<增加一个片断着色程序
|
|
||||||
bool AddComputeShader (const char *code){return AddShader(ShaderType::stFragment,code);} ///<增加一个计算着色程序
|
|
||||||
|
|
||||||
bool AddTessShader (const char *tess_control_shader,const char *tess_evaluation_shader) ///<增加一个镶嵌着色程序
|
|
||||||
{
|
{
|
||||||
if(!AddShader(ShaderType::stTessControl,tess_control_shader ))return(false);
|
stVertex=0, ///<顶点着色程序
|
||||||
if(!AddShader(ShaderType::stTessEval, tess_evaluation_shader ))return(false);
|
stTessControl, ///<镶嵌控制着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
||||||
return(true);
|
stTessEval, ///<镶嵌评估着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
||||||
}
|
stGeometry, ///<几何着色程序
|
||||||
|
stFragment, ///<片断着色程序
|
||||||
|
stCompute, ///<计算着色程序(需OpenGL 4.3或ARB_compute_shader)
|
||||||
|
|
||||||
bool Build(); ///<构建当前添加的着色程序
|
stEnd
|
||||||
|
};//enum ShaderType
|
||||||
|
|
||||||
bool Use(); ///<使用当前着色程序
|
extern const char ShaderTypeName[ShaderType::stEnd][32]; ///<着色程序名称
|
||||||
|
|
||||||
int GetAttribLocation(const char *); ///<取得指定属性地址
|
/**
|
||||||
int GetUniformLocation(const char *); ///<取得一个变量的地址
|
* 着色器程序
|
||||||
// int GetUniformBlockIndex(const char *); ///<取得一个只读数据块索引
|
*/
|
||||||
// int GetShaderStorageIndex(const char *); ///<取得一个数据存储区索引
|
class Shader
|
||||||
|
{
|
||||||
|
uint program;
|
||||||
|
|
||||||
//bool SetAttrib1f(int,float);
|
uint shader_index[ShaderType::stEnd];
|
||||||
//bool GetAttrib1f(int,float &);
|
|
||||||
|
|
||||||
public: //设置一致变量用函数
|
private:
|
||||||
|
|
||||||
bool SetUniform1f(int,float);
|
bool Link(); ///<连接使用当前着色程序
|
||||||
bool SetUniform2f(int,float,float);
|
|
||||||
bool SetUniform3f(int,float,float,float);
|
|
||||||
bool SetUniform4f(int,float,float,float,float);
|
|
||||||
|
|
||||||
bool SetUniform1i(int,int);
|
protected:
|
||||||
bool SetUniform2i(int,int,int);
|
|
||||||
bool SetUniform3i(int,int,int,int);
|
|
||||||
bool SetUniform4i(int,int,int,int,int);
|
|
||||||
|
|
||||||
bool SetUniform1ui(int,unsigned int);
|
Map<UTF8String,int> attrib_location;
|
||||||
bool SetUniform2ui(int,unsigned int,unsigned int);
|
Map<UTF8String,int> uniform_location;
|
||||||
bool SetUniform3ui(int,unsigned int,unsigned int,unsigned int);
|
|
||||||
bool SetUniform4ui(int,unsigned int,unsigned int,unsigned int,unsigned int);
|
|
||||||
|
|
||||||
bool SetUniform1fv(int,const float *);
|
// Map<UTF8String,int> uniform_block_index;
|
||||||
bool SetUniform2fv(int,const float *);
|
// MapObject<UTF8String,UBO> uniform_block_object;
|
||||||
bool SetUniform3fv(int,const float *);
|
//
|
||||||
bool SetUniform4fv(int,const float *);
|
// Map<UTF8String,int> ssbo_index;
|
||||||
|
// MapObject<UTF8String,SSBO> ssbo_object;
|
||||||
|
|
||||||
bool SetUniform2fv(int index,const Vector2f &v){return SetUniform2fv(index,(const float *)&v);}
|
int _GetAttribLocation(const char *); ///<取得指定属性地址
|
||||||
bool SetUniform3fv(int index,const Vector3f &v){return SetUniform3fv(index,(const float *)&v);}
|
int _GetUniformLocation(const char *); ///<取得一个变量的地址
|
||||||
bool SetUniform4fv(int index,const Vector4f &v){return SetUniform4fv(index,(const float *)&v);}
|
// int _GetUniformBlockIndex(const char *); ///<取得一个只读数据块的地址索引
|
||||||
|
// int _GetShaderStorageIndex(const char *); ///<取得一个数据存储区的地址索引
|
||||||
|
|
||||||
bool SetUniform1iv(int,const int *);
|
public:
|
||||||
bool SetUniform2iv(int,const int *);
|
|
||||||
bool SetUniform3iv(int,const int *);
|
|
||||||
bool SetUniform4iv(int,const int *);
|
|
||||||
|
|
||||||
bool SetUniform1uiv(int,const unsigned int *);
|
Shader(){program=0;hgl_zero(shader_index,ShaderType::stEnd);}
|
||||||
bool SetUniform2uiv(int,const unsigned int *);
|
~Shader(){Clear();}
|
||||||
bool SetUniform3uiv(int,const unsigned int *);
|
|
||||||
bool SetUniform4uiv(int,const unsigned int *);
|
|
||||||
|
|
||||||
bool SetUniformMatrix2fv(int,const float *);
|
void Clear(); ///<清除着色程序
|
||||||
bool SetUniformMatrix3fv(int,const float *);
|
|
||||||
bool SetUniformMatrix4fv(int,const float *);
|
|
||||||
|
|
||||||
bool SetUniformMatrix2x3fv(int,const float *);
|
bool AddShader (const int shader_type,const char *); ///<增加一个着色程序
|
||||||
bool SetUniformMatrix3x2fv(int,const float *);
|
|
||||||
bool SetUniformMatrix2x4fv(int,const float *);
|
|
||||||
bool SetUniformMatrix4x2fv(int,const float *);
|
|
||||||
bool SetUniformMatrix3x4fv(int,const float *);
|
|
||||||
bool SetUniformMatrix4x3fv(int,const float *);
|
|
||||||
|
|
||||||
public:
|
bool AddVertexShader (const char *code){return AddShader(ShaderType::stVertex,code);} ///<增加一个顶点着色程序
|
||||||
|
bool AddGeometryShader (const char *code){return AddShader(ShaderType::stGeometry,code);} ///<增加一个几何着色程序
|
||||||
|
bool AddFragmentShader (const char *code){return AddShader(ShaderType::stFragment,code);} ///<增加一个片断着色程序
|
||||||
|
bool AddComputeShader (const char *code){return AddShader(ShaderType::stFragment,code);} ///<增加一个计算着色程序
|
||||||
|
|
||||||
bool SetUniform1f(const char *,float);
|
bool AddTessShader (const char *tess_control_shader,const char *tess_evaluation_shader) ///<增加一个镶嵌着色程序
|
||||||
bool SetUniform2f(const char *,float,float);
|
{
|
||||||
bool SetUniform3f(const char *,float,float,float);
|
if(!AddShader(ShaderType::stTessControl,tess_control_shader ))return(false);
|
||||||
bool SetUniform4f(const char *,float,float,float,float);
|
if(!AddShader(ShaderType::stTessEval, tess_evaluation_shader ))return(false);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
bool SetUniform1i(const char *,int);
|
bool Build(); ///<构建当前添加的着色程序
|
||||||
bool SetUniform2i(const char *,int,int);
|
|
||||||
bool SetUniform3i(const char *,int,int,int);
|
|
||||||
bool SetUniform4i(const char *,int,int,int,int);
|
|
||||||
|
|
||||||
bool SetUniform1ui(const char *,unsigned int);
|
bool Use(); ///<使用当前着色程序
|
||||||
bool SetUniform2ui(const char *,unsigned int,unsigned int);
|
|
||||||
bool SetUniform3ui(const char *,unsigned int,unsigned int,unsigned int);
|
|
||||||
bool SetUniform4ui(const char *,unsigned int,unsigned int,unsigned int,unsigned int);
|
|
||||||
|
|
||||||
bool SetUniform1fv(const char *,const float *);
|
int GetAttribLocation(const char *); ///<取得指定属性地址
|
||||||
bool SetUniform2fv(const char *,const float *);
|
int GetUniformLocation(const char *); ///<取得一个变量的地址
|
||||||
bool SetUniform3fv(const char *,const float *);
|
// int GetUniformBlockIndex(const char *); ///<取得一个只读数据块索引
|
||||||
bool SetUniform4fv(const char *,const float *);
|
// int GetShaderStorageIndex(const char *); ///<取得一个数据存储区索引
|
||||||
|
|
||||||
bool SetUniform2fv(const char *name,const Vector2f &v){return SetUniform2fv(name,(const float *)&v);}
|
//bool SetAttrib1f(int,float);
|
||||||
bool SetUniform3fv(const char *name,const Vector3f &v){return SetUniform3fv(name,(const float *)&v);}
|
//bool GetAttrib1f(int,float &);
|
||||||
bool SetUniform4fv(const char *name,const Vector4f &v){return SetUniform4fv(name,(const float *)&v);}
|
|
||||||
|
|
||||||
bool SetUniform1iv(const char *,const int *);
|
public: //设置一致变量用函数
|
||||||
bool SetUniform2iv(const char *,const int *);
|
|
||||||
bool SetUniform3iv(const char *,const int *);
|
|
||||||
bool SetUniform4iv(const char *,const int *);
|
|
||||||
|
|
||||||
bool SetUniform1uiv(const char *,const unsigned int *);
|
bool SetUniform1f(int,float);
|
||||||
bool SetUniform2uiv(const char *,const unsigned int *);
|
bool SetUniform2f(int,float,float);
|
||||||
bool SetUniform3uiv(const char *,const unsigned int *);
|
bool SetUniform3f(int,float,float,float);
|
||||||
bool SetUniform4uiv(const char *,const unsigned int *);
|
bool SetUniform4f(int,float,float,float,float);
|
||||||
|
|
||||||
bool SetUniformMatrix2fv(const char *,const float *);
|
bool SetUniform1i(int,int);
|
||||||
bool SetUniformMatrix3fv(const char *,const float *);
|
bool SetUniform2i(int,int,int);
|
||||||
bool SetUniformMatrix4fv(const char *,const float *);
|
bool SetUniform3i(int,int,int,int);
|
||||||
|
bool SetUniform4i(int,int,int,int,int);
|
||||||
|
|
||||||
bool SetUniformMatrix3fv(const char *name,const Matrix3f &m){return SetUniformMatrix3fv(name,(const float *)&m);}
|
bool SetUniform1ui(int,unsigned int);
|
||||||
bool SetUniformMatrix4fv(const char *name,const Matrix4f &m){return SetUniformMatrix4fv(name,(const float *)&m);}
|
bool SetUniform2ui(int,unsigned int,unsigned int);
|
||||||
|
bool SetUniform3ui(int,unsigned int,unsigned int,unsigned int);
|
||||||
|
bool SetUniform4ui(int,unsigned int,unsigned int,unsigned int,unsigned int);
|
||||||
|
|
||||||
bool SetUniformMatrix2x3fv(const char *,const float *);
|
bool SetUniform1fv(int,const float *);
|
||||||
bool SetUniformMatrix3x2fv(const char *,const float *);
|
bool SetUniform2fv(int,const float *);
|
||||||
bool SetUniformMatrix2x4fv(const char *,const float *);
|
bool SetUniform3fv(int,const float *);
|
||||||
bool SetUniformMatrix4x2fv(const char *,const float *);
|
bool SetUniform4fv(int,const float *);
|
||||||
bool SetUniformMatrix3x4fv(const char *,const float *);
|
|
||||||
bool SetUniformMatrix4x3fv(const char *,const float *);
|
|
||||||
|
|
||||||
// public: //Uniform Block
|
bool SetUniform2fv(int index,const Vector2f &v){return SetUniform2fv(index,(const float *)&v);}
|
||||||
//
|
bool SetUniform3fv(int index,const Vector3f &v){return SetUniform3fv(index,(const float *)&v);}
|
||||||
// UBO *GetUniformBlock(const char *,uint=HGL_DYNAMIC_DRAW);
|
bool SetUniform4fv(int index,const Vector4f &v){return SetUniform4fv(index,(const float *)&v);}
|
||||||
// SSBO *GetShaderStorage(const char *,uint=HGL_DYNAMIC_DRAW);
|
|
||||||
};//class Shader
|
bool SetUniform1iv(int,const int *);
|
||||||
|
bool SetUniform2iv(int,const int *);
|
||||||
|
bool SetUniform3iv(int,const int *);
|
||||||
|
bool SetUniform4iv(int,const int *);
|
||||||
|
|
||||||
|
bool SetUniform1uiv(int,const unsigned int *);
|
||||||
|
bool SetUniform2uiv(int,const unsigned int *);
|
||||||
|
bool SetUniform3uiv(int,const unsigned int *);
|
||||||
|
bool SetUniform4uiv(int,const unsigned int *);
|
||||||
|
|
||||||
|
bool SetUniformMatrix2fv(int,const float *);
|
||||||
|
bool SetUniformMatrix3fv(int,const float *);
|
||||||
|
bool SetUniformMatrix4fv(int,const float *);
|
||||||
|
|
||||||
|
bool SetUniformMatrix2x3fv(int,const float *);
|
||||||
|
bool SetUniformMatrix3x2fv(int,const float *);
|
||||||
|
bool SetUniformMatrix2x4fv(int,const float *);
|
||||||
|
bool SetUniformMatrix4x2fv(int,const float *);
|
||||||
|
bool SetUniformMatrix3x4fv(int,const float *);
|
||||||
|
bool SetUniformMatrix4x3fv(int,const float *);
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
bool SetUniform1f(const char *,float);
|
||||||
|
bool SetUniform2f(const char *,float,float);
|
||||||
|
bool SetUniform3f(const char *,float,float,float);
|
||||||
|
bool SetUniform4f(const char *,float,float,float,float);
|
||||||
|
|
||||||
|
bool SetUniform1i(const char *,int);
|
||||||
|
bool SetUniform2i(const char *,int,int);
|
||||||
|
bool SetUniform3i(const char *,int,int,int);
|
||||||
|
bool SetUniform4i(const char *,int,int,int,int);
|
||||||
|
|
||||||
|
bool SetUniform1ui(const char *,unsigned int);
|
||||||
|
bool SetUniform2ui(const char *,unsigned int,unsigned int);
|
||||||
|
bool SetUniform3ui(const char *,unsigned int,unsigned int,unsigned int);
|
||||||
|
bool SetUniform4ui(const char *,unsigned int,unsigned int,unsigned int,unsigned int);
|
||||||
|
|
||||||
|
bool SetUniform1fv(const char *,const float *);
|
||||||
|
bool SetUniform2fv(const char *,const float *);
|
||||||
|
bool SetUniform3fv(const char *,const float *);
|
||||||
|
bool SetUniform4fv(const char *,const float *);
|
||||||
|
|
||||||
|
bool SetUniform2fv(const char *name,const Vector2f &v){return SetUniform2fv(name,(const float *)&v);}
|
||||||
|
bool SetUniform3fv(const char *name,const Vector3f &v){return SetUniform3fv(name,(const float *)&v);}
|
||||||
|
bool SetUniform4fv(const char *name,const Vector4f &v){return SetUniform4fv(name,(const float *)&v);}
|
||||||
|
|
||||||
|
bool SetUniform1iv(const char *,const int *);
|
||||||
|
bool SetUniform2iv(const char *,const int *);
|
||||||
|
bool SetUniform3iv(const char *,const int *);
|
||||||
|
bool SetUniform4iv(const char *,const int *);
|
||||||
|
|
||||||
|
bool SetUniform1uiv(const char *,const unsigned int *);
|
||||||
|
bool SetUniform2uiv(const char *,const unsigned int *);
|
||||||
|
bool SetUniform3uiv(const char *,const unsigned int *);
|
||||||
|
bool SetUniform4uiv(const char *,const unsigned int *);
|
||||||
|
|
||||||
|
bool SetUniformMatrix2fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix3fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix4fv(const char *,const float *);
|
||||||
|
|
||||||
|
bool SetUniformMatrix3fv(const char *name,const Matrix3f &m){return SetUniformMatrix3fv(name,(const float *)&m);}
|
||||||
|
bool SetUniformMatrix4fv(const char *name,const Matrix4f &m){return SetUniformMatrix4fv(name,(const float *)&m);}
|
||||||
|
|
||||||
|
bool SetUniformMatrix2x3fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix3x2fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix2x4fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix4x2fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix3x4fv(const char *,const float *);
|
||||||
|
bool SetUniformMatrix4x3fv(const char *,const float *);
|
||||||
|
|
||||||
|
// public: //Uniform Block
|
||||||
|
//
|
||||||
|
// UBO *GetUniformBlock(const char *,uint=HGL_DYNAMIC_DRAW);
|
||||||
|
// SSBO *GetShaderStorage(const char *,uint=HGL_DYNAMIC_DRAW);
|
||||||
|
};//class Shader
|
||||||
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_SHADER_INCLUDE
|
#endif//HGL_SHADER_INCLUDE
|
||||||
|
@ -1,21 +1,24 @@
|
|||||||
#include<hgl/graph/RenderDriver.h>
|
#include<hgl/graph/RenderDriver.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
class RenderDriverGLCore:public RenderDriver
|
namespace graph
|
||||||
{
|
{
|
||||||
public:
|
class RenderDriverGLCore:public RenderDriver
|
||||||
|
|
||||||
void SetCurStatus(const RenderStatus &rs) override
|
|
||||||
{
|
{
|
||||||
}
|
public:
|
||||||
|
|
||||||
void ClearColorBuffer() override
|
void SetCurStatus(const RenderStatus &rs) override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearDepthBuffer() override
|
void ClearColorBuffer() override
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};//class RenderDriverGLCore:public RenderDriver
|
|
||||||
|
void ClearDepthBuffer() override
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};//class RenderDriverGLCore:public RenderDriver
|
||||||
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include<hgl/graph/Shader.h>
|
#include<hgl/graph/Shader.h>
|
||||||
//#include<hgl/LogInfo.h>
|
//#include<hgl/LogInfo.h>
|
||||||
#include<hgl/type/Smart.h>
|
#include<hgl/type/Smart.h>
|
||||||
#include<malloc.h>
|
#include<malloc.h>
|
||||||
@ -6,388 +6,391 @@
|
|||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
namespace
|
namespace graph
|
||||||
{
|
{
|
||||||
constexpr uint OpenGLShaderType[ShaderType::stEnd]=
|
namespace
|
||||||
{
|
{
|
||||||
GL_VERTEX_SHADER, ///<顶点着色程序
|
constexpr uint OpenGLShaderType[ShaderType::stEnd]=
|
||||||
GL_TESS_CONTROL_SHADER, ///<镶嵌控制着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
{
|
||||||
GL_TESS_EVALUATION_SHADER, ///<镶嵌评估着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
GL_VERTEX_SHADER, ///<顶点着色程序
|
||||||
GL_GEOMETRY_SHADER, ///<几何着色程序
|
GL_TESS_CONTROL_SHADER, ///<镶嵌控制着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
||||||
GL_FRAGMENT_SHADER, ///<片断着色程序
|
GL_TESS_EVALUATION_SHADER, ///<镶嵌评估着色程序(需OpenGL 4.0或ARB_tessellation_shader)
|
||||||
GL_COMPUTE_SHADER ///<计算着色程序(需OpenGL 4.3或ARB_compute_shader)
|
GL_GEOMETRY_SHADER, ///<几何着色程序
|
||||||
|
GL_FRAGMENT_SHADER, ///<片断着色程序
|
||||||
|
GL_COMPUTE_SHADER ///<计算着色程序(需OpenGL 4.3或ARB_compute_shader)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const char ShaderTypeName[ShaderType::stEnd][32]=
|
||||||
|
{
|
||||||
|
"Vertex",
|
||||||
|
"TessControl",
|
||||||
|
"TessEvaluation",
|
||||||
|
"Geometry",
|
||||||
|
"Fragment",
|
||||||
|
"Compute"
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const char ShaderTypeName[ShaderType::stEnd][32]=
|
namespace
|
||||||
{
|
|
||||||
"Vertex",
|
|
||||||
"TessControl",
|
|
||||||
"TessEvaluation",
|
|
||||||
"Geometry",
|
|
||||||
"Fragment",
|
|
||||||
"Compute"
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* 编译一段shader
|
|
||||||
* @param type 类型
|
|
||||||
* @param name 名称
|
|
||||||
* @param shader_source 代码
|
|
||||||
* @return 编译成功的shader句柄
|
|
||||||
* @return 0 编译失败
|
|
||||||
*/
|
|
||||||
GLuint CompileShader(GLenum type,const char *name,const char *shader_source)
|
|
||||||
{
|
{
|
||||||
if(!shader_source)return(0);
|
/**
|
||||||
|
* 编译一段shader
|
||||||
|
* @param type 类型
|
||||||
|
* @param name 名称
|
||||||
|
* @param shader_source 代码
|
||||||
|
* @return 编译成功的shader句柄
|
||||||
|
* @return 0 编译失败
|
||||||
|
*/
|
||||||
|
GLuint CompileShader(GLenum type,const char *name,const char *shader_source)
|
||||||
|
{
|
||||||
|
if(!shader_source)return(0);
|
||||||
|
|
||||||
GLuint shader=glCreateShader(type);
|
GLuint shader=glCreateShader(type);
|
||||||
|
|
||||||
glShaderSource(shader,1,&shader_source,0);
|
glShaderSource(shader,1,&shader_source,0);
|
||||||
|
|
||||||
glCompileShader(shader);
|
glCompileShader(shader);
|
||||||
|
|
||||||
GLint compiled,log_length;
|
GLint compiled,log_length;
|
||||||
|
|
||||||
glGetShaderiv(shader,GL_COMPILE_STATUS,&compiled);
|
glGetShaderiv(shader,GL_COMPILE_STATUS,&compiled);
|
||||||
|
|
||||||
if(compiled)
|
if(compiled)
|
||||||
return(shader);
|
return(shader);
|
||||||
|
|
||||||
glGetShaderiv(shader,GL_INFO_LOG_LENGTH,&log_length);
|
glGetShaderiv(shader,GL_INFO_LOG_LENGTH,&log_length);
|
||||||
|
|
||||||
GLint char_writen;
|
GLint char_writen;
|
||||||
char *log=new char[log_length];
|
char *log=new char[log_length];
|
||||||
|
|
||||||
glGetShaderInfoLog(shader,log_length,&char_writen,log);
|
glGetShaderInfoLog(shader,log_length,&char_writen,log);
|
||||||
|
|
||||||
// LOG_HINT(UTF8String(name)+U8_TEXT(" shader compile error\n\n")+ UTF8String(log));
|
// LOG_HINT(UTF8String(name)+U8_TEXT(" shader compile error\n\n")+ UTF8String(log));
|
||||||
|
|
||||||
|
delete[] log;
|
||||||
|
|
||||||
|
//LOG_ERROR(shader_source);
|
||||||
|
|
||||||
|
glDeleteShader(shader);
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
}//namespace
|
||||||
|
|
||||||
|
void Shader::Clear()
|
||||||
|
{
|
||||||
|
for(int i=0;i<ShaderType::stEnd;i++)
|
||||||
|
if(shader_index[i])
|
||||||
|
{
|
||||||
|
glDeleteShader(shader_index[i]);
|
||||||
|
shader_index[i]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(program)
|
||||||
|
{
|
||||||
|
glDeleteProgram(program);
|
||||||
|
program=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编译一个glsl着色程序
|
||||||
|
* @param shader_type 着色程序类型
|
||||||
|
* @param shader_codes 着色程序代码
|
||||||
|
* @return 是否添加编程成功
|
||||||
|
*/
|
||||||
|
bool Shader::AddShader(const int shader_type,const char *shader_codes)
|
||||||
|
{
|
||||||
|
if(shader_type<0||shader_type>=ShaderType::stEnd)return(false);
|
||||||
|
if(shader_index[shader_type])return(false);
|
||||||
|
|
||||||
|
if(!shader_codes
|
||||||
|
||!(*shader_codes))return(false);
|
||||||
|
|
||||||
|
shader_index[shader_type]=CompileShader(OpenGLShaderType[shader_type],ShaderTypeName[shader_type],shader_codes);
|
||||||
|
|
||||||
|
if(!shader_index[shader_type])
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shader::Build()
|
||||||
|
{
|
||||||
|
program=glCreateProgram();
|
||||||
|
|
||||||
|
for(int i=0;i<ShaderType::stEnd;i++)
|
||||||
|
if(shader_index[i])
|
||||||
|
glAttachShader(program,shader_index[i]);
|
||||||
|
|
||||||
|
return(Link());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shader::Link()
|
||||||
|
{
|
||||||
|
if(!program)return(false);
|
||||||
|
|
||||||
|
glLinkProgram(program);
|
||||||
|
|
||||||
|
GLint linked;
|
||||||
|
|
||||||
|
glGetProgramiv(program,GL_LINK_STATUS,&linked);
|
||||||
|
|
||||||
|
if(linked)
|
||||||
|
return(true);
|
||||||
|
|
||||||
|
GLint log_length,char_written;
|
||||||
|
char *log;
|
||||||
|
|
||||||
|
glGetProgramiv(program,GL_INFO_LOG_LENGTH,&log_length);
|
||||||
|
|
||||||
|
log=new char[log_length];
|
||||||
|
|
||||||
|
glGetProgramInfoLog(program,log_length,&char_written,log);
|
||||||
|
|
||||||
|
// LOG_ERROR(u8"Shader program link error\n\n"+UTF8String(log));
|
||||||
|
|
||||||
delete[] log;
|
delete[] log;
|
||||||
|
|
||||||
//LOG_ERROR(shader_source);
|
Clear();
|
||||||
|
return(false);
|
||||||
glDeleteShader(shader);
|
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
}
|
||||||
}//namespace
|
|
||||||
|
|
||||||
void Shader::Clear()
|
bool Shader::Use() ///<使用当前着色程序
|
||||||
{
|
{
|
||||||
for(int i=0;i<ShaderType::stEnd;i++)
|
if(!program)
|
||||||
if(shader_index[i])
|
return(false);
|
||||||
|
|
||||||
|
glUseProgram(program);
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得属性索引地址
|
||||||
|
* @param name 属性名称
|
||||||
|
* @return 索引地址
|
||||||
|
* @return -1 出错
|
||||||
|
*/
|
||||||
|
int Shader::_GetAttribLocation(const char *name)
|
||||||
|
{
|
||||||
|
if(!program)
|
||||||
{
|
{
|
||||||
glDeleteShader(shader_index[i]);
|
// LOG_ERROR(u8"GetAttribLocation("+UTF8String(name)+u8"),program=0");
|
||||||
shader_index[i]=0;
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(program)
|
return glGetAttribLocation(program,name);
|
||||||
{
|
|
||||||
glDeleteProgram(program);
|
|
||||||
program=0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 编译一个glsl着色程序
|
|
||||||
* @param shader_type 着色程序类型
|
|
||||||
* @param shader_codes 着色程序代码
|
|
||||||
* @return 是否添加编程成功
|
|
||||||
*/
|
|
||||||
bool Shader::AddShader(const int shader_type,const char *shader_codes)
|
|
||||||
{
|
|
||||||
if(shader_type<0||shader_type>=ShaderType::stEnd)return(false);
|
|
||||||
if(shader_index[shader_type])return(false);
|
|
||||||
|
|
||||||
if(!shader_codes
|
|
||||||
||!(*shader_codes))return(false);
|
|
||||||
|
|
||||||
shader_index[shader_type]=CompileShader(OpenGLShaderType[shader_type],ShaderTypeName[shader_type],shader_codes);
|
|
||||||
|
|
||||||
if(!shader_index[shader_type])
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Shader::Build()
|
|
||||||
{
|
|
||||||
program=glCreateProgram();
|
|
||||||
|
|
||||||
for(int i=0;i<ShaderType::stEnd;i++)
|
|
||||||
if(shader_index[i])
|
|
||||||
glAttachShader(program,shader_index[i]);
|
|
||||||
|
|
||||||
return(Link());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Shader::Link()
|
|
||||||
{
|
|
||||||
if(!program)return(false);
|
|
||||||
|
|
||||||
glLinkProgram(program);
|
|
||||||
|
|
||||||
GLint linked;
|
|
||||||
|
|
||||||
glGetProgramiv(program,GL_LINK_STATUS,&linked);
|
|
||||||
|
|
||||||
if(linked)
|
|
||||||
return(true);
|
|
||||||
|
|
||||||
GLint log_length,char_written;
|
|
||||||
char *log;
|
|
||||||
|
|
||||||
glGetProgramiv(program,GL_INFO_LOG_LENGTH,&log_length);
|
|
||||||
|
|
||||||
log=new char[log_length];
|
|
||||||
|
|
||||||
glGetProgramInfoLog(program,log_length,&char_written,log);
|
|
||||||
|
|
||||||
// LOG_ERROR(u8"Shader program link error\n\n"+UTF8String(log));
|
|
||||||
|
|
||||||
delete[] log;
|
|
||||||
|
|
||||||
Clear();
|
|
||||||
return(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Shader::Use() ///<使用当前着色程序
|
|
||||||
{
|
|
||||||
if(!program)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
glUseProgram(program);
|
|
||||||
return(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取得属性索引地址
|
|
||||||
* @param name 属性名称
|
|
||||||
* @return 索引地址
|
|
||||||
* @return -1 出错
|
|
||||||
*/
|
|
||||||
int Shader::_GetAttribLocation(const char *name)
|
|
||||||
{
|
|
||||||
if(!program)
|
|
||||||
{
|
|
||||||
// LOG_ERROR(u8"GetAttribLocation("+UTF8String(name)+u8"),program=0");
|
|
||||||
return(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return glGetAttribLocation(program,name);
|
//bool Shader::SetAttrib1f(int location,float value)
|
||||||
}
|
//{
|
||||||
|
// if(!program)
|
||||||
|
// return(false);
|
||||||
|
|
||||||
//bool Shader::SetAttrib1f(int location,float value)
|
// glVertexAttrib1f(location,value);
|
||||||
//{
|
|
||||||
// if(!program)
|
|
||||||
// return(false);
|
|
||||||
|
|
||||||
// glVertexAttrib1f(location,value);
|
// return(true);
|
||||||
|
//}
|
||||||
|
|
||||||
// return(true);
|
//bool Shader::GetAttrib1f(int location,float &value)
|
||||||
//}
|
//{
|
||||||
|
// if(!program)
|
||||||
|
// return(false);
|
||||||
|
|
||||||
//bool Shader::GetAttrib1f(int location,float &value)
|
// glGetVertexAttribfv(location,GL_CURRENT_VERTEX_ATTRIB,&value);
|
||||||
//{
|
|
||||||
// if(!program)
|
|
||||||
// return(false);
|
|
||||||
|
|
||||||
// glGetVertexAttribfv(location,GL_CURRENT_VERTEX_ATTRIB,&value);
|
// return(true);
|
||||||
|
//}
|
||||||
|
|
||||||
// return(true);
|
/**
|
||||||
//}
|
* 取得一个变量的地址
|
||||||
|
* @param name 变量名称
|
||||||
/**
|
* @return 地址
|
||||||
* 取得一个变量的地址
|
* @return -1 出错
|
||||||
* @param name 变量名称
|
*/
|
||||||
* @return 地址
|
int Shader::_GetUniformLocation(const char *name) ///<取得一个变量的地址
|
||||||
* @return -1 出错
|
|
||||||
*/
|
|
||||||
int Shader::_GetUniformLocation(const char *name) ///<取得一个变量的地址
|
|
||||||
{
|
|
||||||
if(!program)
|
|
||||||
{
|
{
|
||||||
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program=0");
|
if(!program)
|
||||||
return(-1);
|
{
|
||||||
|
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program=0");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
const int result=glGetUniformLocation(program,name);
|
||||||
|
|
||||||
|
if(result==-1)
|
||||||
|
{
|
||||||
|
const int gl_error=glGetError();
|
||||||
|
|
||||||
|
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program="+UTF8String(program)+u8",result=-1,gl_error="+UTF8String(gl_error));
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int result=glGetUniformLocation(program,name);
|
#define HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(func) if(!program) \
|
||||||
|
{ \
|
||||||
|
/*LOG_ERROR(u8"Shader::SetUniform" #func ",program=0"); */\
|
||||||
|
return(false); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
if(location<0) \
|
||||||
|
{ \
|
||||||
|
/*LOG_ERROR(u8"Shader::SetUniform" #func ",location="+UTF8String(location));*/ \
|
||||||
|
return(false); \
|
||||||
|
}
|
||||||
|
|
||||||
if(result==-1)
|
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(int location,type v0) \
|
||||||
{
|
{ \
|
||||||
const int gl_error=glGetError();
|
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(1##func) \
|
||||||
|
\
|
||||||
|
glProgramUniform1##func(program,location,v0); \
|
||||||
|
return(true); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
bool Shader::SetUniform2##func(int location,type v0,type v1) \
|
||||||
|
{ \
|
||||||
|
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(2##func) \
|
||||||
|
\
|
||||||
|
glProgramUniform2##func(program,location,v0,v1); \
|
||||||
|
return(true); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
bool Shader::SetUniform3##func(int location,type v0,type v1,type v2) \
|
||||||
|
{ \
|
||||||
|
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(3##func) \
|
||||||
|
\
|
||||||
|
glProgramUniform3##func(program,location,v0,v1,v2); \
|
||||||
|
return(true); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
bool Shader::SetUniform4##func(int location,type v0,type v1,type v2,type v3) \
|
||||||
|
{ \
|
||||||
|
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(4##func) \
|
||||||
|
\
|
||||||
|
glProgramUniform4##func(program,location,v0,v1,v2,v3); \
|
||||||
|
return(true); \
|
||||||
|
}
|
||||||
|
HGL_GLSL_SetUniform1234(f,float);
|
||||||
|
HGL_GLSL_SetUniform1234(i,int);
|
||||||
|
HGL_GLSL_SetUniform1234(ui,unsigned int);
|
||||||
|
|
||||||
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program="+UTF8String(program)+u8",result=-1,gl_error="+UTF8String(gl_error));
|
#undef HGL_GLSL_SetUniform1234
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(int location,const type *value) \
|
||||||
}
|
|
||||||
|
|
||||||
#define HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(func) if(!program) \
|
|
||||||
{ \
|
{ \
|
||||||
/*LOG_ERROR(u8"Shader::SetUniform" #func ",program=0"); */\
|
if(!program) \
|
||||||
return(false); \
|
{ \
|
||||||
} \
|
/*LOG_ERROR(u8"Shader::SetUniform" #func ",program=0");*/ \
|
||||||
|
return(false); \
|
||||||
|
} \
|
||||||
\
|
\
|
||||||
if(location<0) \
|
if(location<0) \
|
||||||
{ \
|
{ \
|
||||||
/*LOG_ERROR(u8"Shader::SetUniform" #func ",location="+UTF8String(location));*/ \
|
/*LOG_ERROR(u8"Shader::SetUniform" #func ",location="+UTF8String(location));*/ \
|
||||||
return(false); \
|
return(false); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
if(!value) \
|
||||||
|
{ \
|
||||||
|
/*LOG_ERROR(u8"Shader::SetUniform" #func ",value=nullptr");*/ \
|
||||||
|
return(false); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
glProgramUniform##func(program,location,1,value); \
|
||||||
|
return(true); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(int location,type v0) \
|
HGL_GLSL_SetUniformPointer(1fv,float);
|
||||||
{ \
|
HGL_GLSL_SetUniformPointer(2fv,float);
|
||||||
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(1##func) \
|
HGL_GLSL_SetUniformPointer(3fv,float);
|
||||||
\
|
HGL_GLSL_SetUniformPointer(4fv,float);
|
||||||
glProgramUniform1##func(program,location,v0); \
|
|
||||||
return(true); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool Shader::SetUniform2##func(int location,type v0,type v1) \
|
|
||||||
{ \
|
|
||||||
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(2##func) \
|
|
||||||
\
|
|
||||||
glProgramUniform2##func(program,location,v0,v1); \
|
|
||||||
return(true); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool Shader::SetUniform3##func(int location,type v0,type v1,type v2) \
|
|
||||||
{ \
|
|
||||||
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(3##func) \
|
|
||||||
\
|
|
||||||
glProgramUniform3##func(program,location,v0,v1,v2); \
|
|
||||||
return(true); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool Shader::SetUniform4##func(int location,type v0,type v1,type v2,type v3) \
|
|
||||||
{ \
|
|
||||||
HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(4##func) \
|
|
||||||
\
|
|
||||||
glProgramUniform4##func(program,location,v0,v1,v2,v3); \
|
|
||||||
return(true); \
|
|
||||||
}
|
|
||||||
HGL_GLSL_SetUniform1234(f,float);
|
|
||||||
HGL_GLSL_SetUniform1234(i,int);
|
|
||||||
HGL_GLSL_SetUniform1234(ui,unsigned int);
|
|
||||||
|
|
||||||
#undef HGL_GLSL_SetUniform1234
|
HGL_GLSL_SetUniformPointer(1iv,int);
|
||||||
|
HGL_GLSL_SetUniformPointer(2iv,int);
|
||||||
|
HGL_GLSL_SetUniformPointer(3iv,int);
|
||||||
|
HGL_GLSL_SetUniformPointer(4iv,int);
|
||||||
|
|
||||||
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(int location,const type *value) \
|
HGL_GLSL_SetUniformPointer(1uiv,unsigned int);
|
||||||
{ \
|
HGL_GLSL_SetUniformPointer(2uiv,unsigned int);
|
||||||
if(!program) \
|
HGL_GLSL_SetUniformPointer(3uiv,unsigned int);
|
||||||
|
HGL_GLSL_SetUniformPointer(4uiv,unsigned int);
|
||||||
|
|
||||||
|
#undef HGL_GLSL_SetUniformPointer
|
||||||
|
|
||||||
|
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(int location,const float *mat) \
|
||||||
{ \
|
{ \
|
||||||
/*LOG_ERROR(u8"Shader::SetUniform" #func ",program=0");*/ \
|
if(!program) \
|
||||||
return(false); \
|
{ \
|
||||||
} \
|
/*LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",program=0"); */ \
|
||||||
\
|
return(false); \
|
||||||
if(location<0) \
|
} \
|
||||||
{ \
|
\
|
||||||
/*LOG_ERROR(u8"Shader::SetUniform" #func ",location="+UTF8String(location));*/ \
|
if(location<0) \
|
||||||
return(false); \
|
{ \
|
||||||
} \
|
/*LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",location="+UTF8String(location)); */ \
|
||||||
\
|
return(false); \
|
||||||
if(!value) \
|
} \
|
||||||
{ \
|
\
|
||||||
/*LOG_ERROR(u8"Shader::SetUniform" #func ",value=nullptr");*/ \
|
if(!mat) \
|
||||||
return(false); \
|
{ \
|
||||||
} \
|
/*LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",mat=nullptr"); */ \
|
||||||
\
|
return(false); \
|
||||||
glProgramUniform##func(program,location,1,value); \
|
} \
|
||||||
return(true); \
|
\
|
||||||
}
|
glProgramUniformMatrix##func(program,location,1,GL_FALSE,mat); \
|
||||||
|
return(true); \
|
||||||
|
}
|
||||||
|
|
||||||
HGL_GLSL_SetUniformPointer(1fv,float);
|
HGL_GLSL_SetUniformMatrixPointer(2fv);
|
||||||
HGL_GLSL_SetUniformPointer(2fv,float);
|
HGL_GLSL_SetUniformMatrixPointer(3fv);
|
||||||
HGL_GLSL_SetUniformPointer(3fv,float);
|
HGL_GLSL_SetUniformMatrixPointer(4fv);
|
||||||
HGL_GLSL_SetUniformPointer(4fv,float);
|
|
||||||
|
|
||||||
HGL_GLSL_SetUniformPointer(1iv,int);
|
HGL_GLSL_SetUniformMatrixPointer(2x3fv);
|
||||||
HGL_GLSL_SetUniformPointer(2iv,int);
|
HGL_GLSL_SetUniformMatrixPointer(3x2fv);
|
||||||
HGL_GLSL_SetUniformPointer(3iv,int);
|
HGL_GLSL_SetUniformMatrixPointer(2x4fv);
|
||||||
HGL_GLSL_SetUniformPointer(4iv,int);
|
HGL_GLSL_SetUniformMatrixPointer(4x2fv);
|
||||||
|
HGL_GLSL_SetUniformMatrixPointer(3x4fv);
|
||||||
|
HGL_GLSL_SetUniformMatrixPointer(4x3fv);
|
||||||
|
|
||||||
HGL_GLSL_SetUniformPointer(1uiv,unsigned int);
|
#undef HGL_GLSL_SetUniformMatrixPointer
|
||||||
HGL_GLSL_SetUniformPointer(2uiv,unsigned int);
|
|
||||||
HGL_GLSL_SetUniformPointer(3uiv,unsigned int);
|
|
||||||
HGL_GLSL_SetUniformPointer(4uiv,unsigned int);
|
|
||||||
|
|
||||||
#undef HGL_GLSL_SetUniformPointer
|
// int Shader::_GetUniformBlockIndex(const char *uniform_block_name)
|
||||||
|
// {
|
||||||
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(int location,const float *mat) \
|
// if(!program)
|
||||||
{ \
|
// {
|
||||||
if(!program) \
|
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") program=0");
|
||||||
{ \
|
// return(-1);
|
||||||
/*LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",program=0"); */ \
|
// }
|
||||||
return(false); \
|
//
|
||||||
} \
|
// const int index=glGetUniformBlockIndex(program,uniform_block_name);
|
||||||
\
|
//
|
||||||
if(location<0) \
|
// if(index<0)
|
||||||
{ \
|
// {
|
||||||
/*LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",location="+UTF8String(location)); */ \
|
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") block_index error");
|
||||||
return(false); \
|
// return(-1);
|
||||||
} \
|
// }
|
||||||
\
|
//
|
||||||
if(!mat) \
|
// return index;
|
||||||
{ \
|
// }
|
||||||
/*LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",mat=nullptr"); */ \
|
//
|
||||||
return(false); \
|
// int Shader::_GetShaderStorageIndex(const char *ssbo_name)
|
||||||
} \
|
// {
|
||||||
\
|
// if(!program)
|
||||||
glProgramUniformMatrix##func(program,location,1,GL_FALSE,mat); \
|
// {
|
||||||
return(true); \
|
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") program=0");
|
||||||
}
|
// return(-1);
|
||||||
|
// }
|
||||||
HGL_GLSL_SetUniformMatrixPointer(2fv);
|
//
|
||||||
HGL_GLSL_SetUniformMatrixPointer(3fv);
|
// const int index=glGetProgramResourceIndex(program,GL_SHADER_STORAGE_BLOCK,ssbo_name);
|
||||||
HGL_GLSL_SetUniformMatrixPointer(4fv);
|
//
|
||||||
|
// if(index<0)
|
||||||
HGL_GLSL_SetUniformMatrixPointer(2x3fv);
|
// {
|
||||||
HGL_GLSL_SetUniformMatrixPointer(3x2fv);
|
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") block_index error");
|
||||||
HGL_GLSL_SetUniformMatrixPointer(2x4fv);
|
// return(-1);
|
||||||
HGL_GLSL_SetUniformMatrixPointer(4x2fv);
|
// }
|
||||||
HGL_GLSL_SetUniformMatrixPointer(3x4fv);
|
//
|
||||||
HGL_GLSL_SetUniformMatrixPointer(4x3fv);
|
// return index;
|
||||||
|
// }
|
||||||
#undef HGL_GLSL_SetUniformMatrixPointer
|
}//namespace graph
|
||||||
|
|
||||||
// int Shader::_GetUniformBlockIndex(const char *uniform_block_name)
|
|
||||||
// {
|
|
||||||
// if(!program)
|
|
||||||
// {
|
|
||||||
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") program=0");
|
|
||||||
// return(-1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// const int index=glGetUniformBlockIndex(program,uniform_block_name);
|
|
||||||
//
|
|
||||||
// if(index<0)
|
|
||||||
// {
|
|
||||||
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") block_index error");
|
|
||||||
// return(-1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return index;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// int Shader::_GetShaderStorageIndex(const char *ssbo_name)
|
|
||||||
// {
|
|
||||||
// if(!program)
|
|
||||||
// {
|
|
||||||
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") program=0");
|
|
||||||
// return(-1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// const int index=glGetProgramResourceIndex(program,GL_SHADER_STORAGE_BLOCK,ssbo_name);
|
|
||||||
//
|
|
||||||
// if(index<0)
|
|
||||||
// {
|
|
||||||
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") block_index error");
|
|
||||||
// return(-1);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return index;
|
|
||||||
// }
|
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -1,250 +1,253 @@
|
|||||||
#include<hgl/graph/Shader.h>
|
#include<hgl/graph/Shader.h>
|
||||||
//#include<hgl/graph/UBO.h>
|
//#include<hgl/graph/UBO.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
/**
|
namespace graph
|
||||||
* 取得属性索引地址
|
|
||||||
* @param name 属性名称
|
|
||||||
* @return 索引地址
|
|
||||||
* @return -1 出错
|
|
||||||
*/
|
|
||||||
int Shader::GetAttribLocation(const char *name)
|
|
||||||
{
|
{
|
||||||
if(!name||!(*name))return(-1);
|
/**
|
||||||
|
* 取得属性索引地址
|
||||||
int result;
|
* @param name 属性名称
|
||||||
|
* @return 索引地址
|
||||||
if(!attrib_location.Get(name,result))
|
* @return -1 出错
|
||||||
|
*/
|
||||||
|
int Shader::GetAttribLocation(const char *name)
|
||||||
{
|
{
|
||||||
result=_GetAttribLocation(name);
|
if(!name||!(*name))return(-1);
|
||||||
|
|
||||||
attrib_location.Add(name,result);
|
int result;
|
||||||
|
|
||||||
|
if(!attrib_location.Get(name,result))
|
||||||
|
{
|
||||||
|
result=_GetAttribLocation(name);
|
||||||
|
|
||||||
|
attrib_location.Add(name,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
/**
|
||||||
}
|
* 取得一个变量的地址
|
||||||
|
* @param name 变量名称
|
||||||
/**
|
* @return 地址
|
||||||
* 取得一个变量的地址
|
* @return -1 出错
|
||||||
* @param name 变量名称
|
*/
|
||||||
* @return 地址
|
int Shader::GetUniformLocation(const char *name) ///<取得一个变量的地址
|
||||||
* @return -1 出错
|
|
||||||
*/
|
|
||||||
int Shader::GetUniformLocation(const char *name) ///<取得一个变量的地址
|
|
||||||
{
|
|
||||||
if(!name||!(*name))return(-1);
|
|
||||||
|
|
||||||
int result;
|
|
||||||
|
|
||||||
if(!uniform_location.Get(name,result))
|
|
||||||
{
|
{
|
||||||
result=_GetUniformLocation(name);
|
if(!name||!(*name))return(-1);
|
||||||
|
|
||||||
uniform_location.Add(name,result);
|
int result;
|
||||||
|
|
||||||
|
if(!uniform_location.Get(name,result))
|
||||||
|
{
|
||||||
|
result=_GetUniformLocation(name);
|
||||||
|
|
||||||
|
uniform_location.Add(name,result);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
// /**
|
||||||
}
|
// * 取得一个Shader只读数据区索引
|
||||||
|
// * @param name 数据区名称
|
||||||
|
// * @return 数据区索引
|
||||||
|
// * @return -1 出错
|
||||||
|
// */
|
||||||
|
// int Shader::GetUniformBlockIndex(const char *name)
|
||||||
|
// {
|
||||||
|
// if(!name||!(*name))return(-1);
|
||||||
|
//
|
||||||
|
// int result;
|
||||||
|
//
|
||||||
|
// if(!uniform_block_index.Get(name,result))
|
||||||
|
// {
|
||||||
|
// result=_GetUniformBlockIndex(name);
|
||||||
|
//
|
||||||
|
// uniform_block_index.Add(name,result);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 取得一个Shader数据存储区索引
|
||||||
|
// * @param name 数据存储区名称
|
||||||
|
// * @return 数据存储区索引
|
||||||
|
// * @return -1 出错
|
||||||
|
// */
|
||||||
|
// int Shader::GetShaderStorageIndex(const char *name)
|
||||||
|
// {
|
||||||
|
// if(!name||!(*name))return(-1);
|
||||||
|
//
|
||||||
|
// int result;
|
||||||
|
//
|
||||||
|
// if(!ssbo_index.Get(name,result))
|
||||||
|
// {
|
||||||
|
// result=_GetShaderStorageIndex(name);
|
||||||
|
//
|
||||||
|
// ssbo_index.Add(name,result);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return result;
|
||||||
|
// }
|
||||||
|
|
||||||
// /**
|
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(const char *uniform_name,type v0) \
|
||||||
// * 取得一个Shader只读数据区索引
|
|
||||||
// * @param name 数据区名称
|
|
||||||
// * @return 数据区索引
|
|
||||||
// * @return -1 出错
|
|
||||||
// */
|
|
||||||
// int Shader::GetUniformBlockIndex(const char *name)
|
|
||||||
// {
|
|
||||||
// if(!name||!(*name))return(-1);
|
|
||||||
//
|
|
||||||
// int result;
|
|
||||||
//
|
|
||||||
// if(!uniform_block_index.Get(name,result))
|
|
||||||
// {
|
|
||||||
// result=_GetUniformBlockIndex(name);
|
|
||||||
//
|
|
||||||
// uniform_block_index.Add(name,result);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 取得一个Shader数据存储区索引
|
|
||||||
// * @param name 数据存储区名称
|
|
||||||
// * @return 数据存储区索引
|
|
||||||
// * @return -1 出错
|
|
||||||
// */
|
|
||||||
// int Shader::GetShaderStorageIndex(const char *name)
|
|
||||||
// {
|
|
||||||
// if(!name||!(*name))return(-1);
|
|
||||||
//
|
|
||||||
// int result;
|
|
||||||
//
|
|
||||||
// if(!ssbo_index.Get(name,result))
|
|
||||||
// {
|
|
||||||
// result=_GetShaderStorageIndex(name);
|
|
||||||
//
|
|
||||||
// ssbo_index.Add(name,result);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(const char *uniform_name,type v0) \
|
|
||||||
{ \
|
|
||||||
const int location=GetUniformLocation(uniform_name); \
|
|
||||||
\
|
|
||||||
if(location==-1)return(false); \
|
|
||||||
\
|
|
||||||
return SetUniform1##func(location,v0); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool Shader::SetUniform2##func(const char *uniform_name,type v0,type v1) \
|
|
||||||
{ \
|
|
||||||
const int location=GetUniformLocation(uniform_name); \
|
|
||||||
\
|
|
||||||
if(location==-1)return(false); \
|
|
||||||
\
|
|
||||||
return SetUniform2##func(location,v0,v1); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool Shader::SetUniform3##func(const char *uniform_name,type v0,type v1,type v2) \
|
|
||||||
{ \
|
|
||||||
const int location=GetUniformLocation(uniform_name); \
|
|
||||||
\
|
|
||||||
if(location==-1)return(false); \
|
|
||||||
\
|
|
||||||
return SetUniform3##func(location,v0,v1,v2); \
|
|
||||||
} \
|
|
||||||
\
|
|
||||||
bool Shader::SetUniform4##func(const char *uniform_name,type v0,type v1,type v2,type v3) \
|
|
||||||
{ \
|
|
||||||
const int location=GetUniformLocation(uniform_name); \
|
|
||||||
\
|
|
||||||
if(location==-1)return(false); \
|
|
||||||
\
|
|
||||||
return SetUniform4##func(location,v0,v1,v2,v3); \
|
|
||||||
}
|
|
||||||
HGL_GLSL_SetUniform1234(f,float);
|
|
||||||
HGL_GLSL_SetUniform1234(i,int);
|
|
||||||
HGL_GLSL_SetUniform1234(ui,unsigned int);
|
|
||||||
|
|
||||||
#undef HGL_GLSL_SetUniform1234
|
|
||||||
|
|
||||||
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(const char *uniform_name,const type *value) \
|
|
||||||
{ \
|
{ \
|
||||||
const int location=GetUniformLocation(uniform_name); \
|
const int location=GetUniformLocation(uniform_name); \
|
||||||
\
|
\
|
||||||
if(location==-1)return(false); \
|
if(location==-1)return(false); \
|
||||||
\
|
\
|
||||||
return SetUniform##func(location,value); \
|
return SetUniform1##func(location,v0); \
|
||||||
}
|
} \
|
||||||
|
\
|
||||||
HGL_GLSL_SetUniformPointer(1fv,float);
|
bool Shader::SetUniform2##func(const char *uniform_name,type v0,type v1) \
|
||||||
HGL_GLSL_SetUniformPointer(2fv,float);
|
|
||||||
HGL_GLSL_SetUniformPointer(3fv,float);
|
|
||||||
HGL_GLSL_SetUniformPointer(4fv,float);
|
|
||||||
|
|
||||||
HGL_GLSL_SetUniformPointer(1iv,int);
|
|
||||||
HGL_GLSL_SetUniformPointer(2iv,int);
|
|
||||||
HGL_GLSL_SetUniformPointer(3iv,int);
|
|
||||||
HGL_GLSL_SetUniformPointer(4iv,int);
|
|
||||||
|
|
||||||
HGL_GLSL_SetUniformPointer(1uiv,unsigned int);
|
|
||||||
HGL_GLSL_SetUniformPointer(2uiv,unsigned int);
|
|
||||||
HGL_GLSL_SetUniformPointer(3uiv,unsigned int);
|
|
||||||
HGL_GLSL_SetUniformPointer(4uiv,unsigned int);
|
|
||||||
|
|
||||||
#undef HGL_GLSL_SetUniformPointer
|
|
||||||
|
|
||||||
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(const char *uniform_name,const float *mat) \
|
|
||||||
{ \
|
{ \
|
||||||
const int location=GetUniformLocation(uniform_name); \
|
const int location=GetUniformLocation(uniform_name); \
|
||||||
\
|
\
|
||||||
if(location==-1)return(false); \
|
if(location==-1)return(false); \
|
||||||
\
|
\
|
||||||
return SetUniformMatrix##func(location,mat); \
|
return SetUniform2##func(location,v0,v1); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
bool Shader::SetUniform3##func(const char *uniform_name,type v0,type v1,type v2) \
|
||||||
|
{ \
|
||||||
|
const int location=GetUniformLocation(uniform_name); \
|
||||||
|
\
|
||||||
|
if(location==-1)return(false); \
|
||||||
|
\
|
||||||
|
return SetUniform3##func(location,v0,v1,v2); \
|
||||||
|
} \
|
||||||
|
\
|
||||||
|
bool Shader::SetUniform4##func(const char *uniform_name,type v0,type v1,type v2,type v3) \
|
||||||
|
{ \
|
||||||
|
const int location=GetUniformLocation(uniform_name); \
|
||||||
|
\
|
||||||
|
if(location==-1)return(false); \
|
||||||
|
\
|
||||||
|
return SetUniform4##func(location,v0,v1,v2,v3); \
|
||||||
}
|
}
|
||||||
|
HGL_GLSL_SetUniform1234(f,float);
|
||||||
|
HGL_GLSL_SetUniform1234(i,int);
|
||||||
|
HGL_GLSL_SetUniform1234(ui,unsigned int);
|
||||||
|
|
||||||
HGL_GLSL_SetUniformMatrixPointer(2fv);
|
#undef HGL_GLSL_SetUniform1234
|
||||||
HGL_GLSL_SetUniformMatrixPointer(3fv);
|
|
||||||
HGL_GLSL_SetUniformMatrixPointer(4fv);
|
|
||||||
|
|
||||||
HGL_GLSL_SetUniformMatrixPointer(2x3fv);
|
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(const char *uniform_name,const type *value) \
|
||||||
HGL_GLSL_SetUniformMatrixPointer(3x2fv);
|
{ \
|
||||||
HGL_GLSL_SetUniformMatrixPointer(2x4fv);
|
const int location=GetUniformLocation(uniform_name); \
|
||||||
HGL_GLSL_SetUniformMatrixPointer(4x2fv);
|
\
|
||||||
HGL_GLSL_SetUniformMatrixPointer(3x4fv);
|
if(location==-1)return(false); \
|
||||||
HGL_GLSL_SetUniformMatrixPointer(4x3fv);
|
\
|
||||||
|
return SetUniform##func(location,value); \
|
||||||
|
}
|
||||||
|
|
||||||
#undef HGL_GLSL_SetUniformMatrixPointer
|
HGL_GLSL_SetUniformPointer(1fv,float);
|
||||||
|
HGL_GLSL_SetUniformPointer(2fv,float);
|
||||||
|
HGL_GLSL_SetUniformPointer(3fv,float);
|
||||||
|
HGL_GLSL_SetUniformPointer(4fv,float);
|
||||||
|
|
||||||
// /**
|
HGL_GLSL_SetUniformPointer(1iv,int);
|
||||||
// * 取得一个Shader只读数据区的访问对象
|
HGL_GLSL_SetUniformPointer(2iv,int);
|
||||||
// * @param name 对象名称
|
HGL_GLSL_SetUniformPointer(3iv,int);
|
||||||
// * @param level 访问级别
|
HGL_GLSL_SetUniformPointer(4iv,int);
|
||||||
// * @return 对象指针
|
|
||||||
// */
|
HGL_GLSL_SetUniformPointer(1uiv,unsigned int);
|
||||||
// UBO *Shader::GetUniformBlock(const char *name,uint level)
|
HGL_GLSL_SetUniformPointer(2uiv,unsigned int);
|
||||||
// {
|
HGL_GLSL_SetUniformPointer(3uiv,unsigned int);
|
||||||
// if(!name||!(*name))
|
HGL_GLSL_SetUniformPointer(4uiv,unsigned int);
|
||||||
// {
|
|
||||||
// LOG_ERROR(U8_TEXT("UBO name error:"));
|
#undef HGL_GLSL_SetUniformPointer
|
||||||
// return(nullptr);
|
|
||||||
// }
|
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(const char *uniform_name,const float *mat) \
|
||||||
//
|
{ \
|
||||||
// UBO *ubo=uniform_block_object[name];
|
const int location=GetUniformLocation(uniform_name); \
|
||||||
//
|
\
|
||||||
// if(ubo)
|
if(location==-1)return(false); \
|
||||||
// return ubo;
|
\
|
||||||
//
|
return SetUniformMatrix##func(location,mat); \
|
||||||
// const int index=GetUniformBlockIndex(name);
|
}
|
||||||
//
|
|
||||||
// if(index<0)
|
HGL_GLSL_SetUniformMatrixPointer(2fv);
|
||||||
// {
|
HGL_GLSL_SetUniformMatrixPointer(3fv);
|
||||||
// LOG_ERROR(U8_TEXT("UBO name error:")+UTF8String(name));
|
HGL_GLSL_SetUniformMatrixPointer(4fv);
|
||||||
// return(nullptr);
|
|
||||||
// }
|
HGL_GLSL_SetUniformMatrixPointer(2x3fv);
|
||||||
//
|
HGL_GLSL_SetUniformMatrixPointer(3x2fv);
|
||||||
// ubo=new UBO(name,program,index,level);
|
HGL_GLSL_SetUniformMatrixPointer(2x4fv);
|
||||||
//
|
HGL_GLSL_SetUniformMatrixPointer(4x2fv);
|
||||||
// uniform_block_object.Add(name,ubo);
|
HGL_GLSL_SetUniformMatrixPointer(3x4fv);
|
||||||
//
|
HGL_GLSL_SetUniformMatrixPointer(4x3fv);
|
||||||
// return ubo;
|
|
||||||
// }
|
#undef HGL_GLSL_SetUniformMatrixPointer
|
||||||
//
|
|
||||||
// /**
|
// /**
|
||||||
// * 取得一个Shader数据存储区的访问对象
|
// * 取得一个Shader只读数据区的访问对象
|
||||||
// * @param name 对象名称
|
// * @param name 对象名称
|
||||||
// * @param level 访问级别
|
// * @param level 访问级别
|
||||||
// * @return 对象指针
|
// * @return 对象指针
|
||||||
// */
|
// */
|
||||||
// SSBO *Shader::GetShaderStorage(const char *name,uint level)
|
// UBO *Shader::GetUniformBlock(const char *name,uint level)
|
||||||
// {
|
// {
|
||||||
// if(!name||!(*name))
|
// if(!name||!(*name))
|
||||||
// {
|
// {
|
||||||
// LOG_ERROR(U8_TEXT("SSBO name error:"));
|
// LOG_ERROR(U8_TEXT("UBO name error:"));
|
||||||
// return(nullptr);
|
// return(nullptr);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// SSBO *ssbo=ssbo_object[name];
|
// UBO *ubo=uniform_block_object[name];
|
||||||
//
|
//
|
||||||
// if(ssbo)
|
// if(ubo)
|
||||||
// return ssbo;
|
// return ubo;
|
||||||
//
|
//
|
||||||
// const int index=GetShaderStorageIndex(name);
|
// const int index=GetUniformBlockIndex(name);
|
||||||
//
|
//
|
||||||
// if(index<0)
|
// if(index<0)
|
||||||
// {
|
// {
|
||||||
// LOG_ERROR(U8_TEXT("SSBO name error:")+UTF8String(name));
|
// LOG_ERROR(U8_TEXT("UBO name error:")+UTF8String(name));
|
||||||
// return(nullptr);
|
// return(nullptr);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ssbo=new SSBO(name,program,index,level);
|
// ubo=new UBO(name,program,index,level);
|
||||||
//
|
//
|
||||||
// ssbo_object.Add(name,ssbo);
|
// uniform_block_object.Add(name,ubo);
|
||||||
//
|
//
|
||||||
// return ssbo;
|
// return ubo;
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 取得一个Shader数据存储区的访问对象
|
||||||
|
// * @param name 对象名称
|
||||||
|
// * @param level 访问级别
|
||||||
|
// * @return 对象指针
|
||||||
|
// */
|
||||||
|
// SSBO *Shader::GetShaderStorage(const char *name,uint level)
|
||||||
|
// {
|
||||||
|
// if(!name||!(*name))
|
||||||
|
// {
|
||||||
|
// LOG_ERROR(U8_TEXT("SSBO name error:"));
|
||||||
|
// return(nullptr);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// SSBO *ssbo=ssbo_object[name];
|
||||||
|
//
|
||||||
|
// if(ssbo)
|
||||||
|
// return ssbo;
|
||||||
|
//
|
||||||
|
// const int index=GetShaderStorageIndex(name);
|
||||||
|
//
|
||||||
|
// if(index<0)
|
||||||
|
// {
|
||||||
|
// LOG_ERROR(U8_TEXT("SSBO name error:")+UTF8String(name));
|
||||||
|
// return(nullptr);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ssbo=new SSBO(name,program,index,level);
|
||||||
|
//
|
||||||
|
// ssbo_object.Add(name,ssbo);
|
||||||
|
//
|
||||||
|
// return ssbo;
|
||||||
|
// }
|
||||||
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user