图形部分增加名字空间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,6 +8,8 @@
|
|||||||
// #include<hgl/graph/SSBO.h>
|
// #include<hgl/graph/SSBO.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
constexpr uint HGL_MAX_SHADER_NAME_LENGTH=128; ///<最大Shader名称长度
|
constexpr uint HGL_MAX_SHADER_NAME_LENGTH=128; ///<最大Shader名称长度
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,16 +47,16 @@ namespace hgl
|
|||||||
Map<UTF8String,int> attrib_location;
|
Map<UTF8String,int> attrib_location;
|
||||||
Map<UTF8String,int> uniform_location;
|
Map<UTF8String,int> uniform_location;
|
||||||
|
|
||||||
// Map<UTF8String,int> uniform_block_index;
|
// Map<UTF8String,int> uniform_block_index;
|
||||||
// MapObject<UTF8String,UBO> uniform_block_object;
|
// MapObject<UTF8String,UBO> uniform_block_object;
|
||||||
//
|
//
|
||||||
// Map<UTF8String,int> ssbo_index;
|
// Map<UTF8String,int> ssbo_index;
|
||||||
// MapObject<UTF8String,SSBO> ssbo_object;
|
// MapObject<UTF8String,SSBO> ssbo_object;
|
||||||
|
|
||||||
int _GetAttribLocation(const char *); ///<取得指定属性地址
|
int _GetAttribLocation(const char *); ///<取得指定属性地址
|
||||||
int _GetUniformLocation(const char *); ///<取得一个变量的地址
|
int _GetUniformLocation(const char *); ///<取得一个变量的地址
|
||||||
// int _GetUniformBlockIndex(const char *); ///<取得一个只读数据块的地址索引
|
// int _GetUniformBlockIndex(const char *); ///<取得一个只读数据块的地址索引
|
||||||
// int _GetShaderStorageIndex(const char *); ///<取得一个数据存储区的地址索引
|
// int _GetShaderStorageIndex(const char *); ///<取得一个数据存储区的地址索引
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -83,8 +85,8 @@ namespace hgl
|
|||||||
|
|
||||||
int GetAttribLocation(const char *); ///<取得指定属性地址
|
int GetAttribLocation(const char *); ///<取得指定属性地址
|
||||||
int GetUniformLocation(const char *); ///<取得一个变量的地址
|
int GetUniformLocation(const char *); ///<取得一个变量的地址
|
||||||
// int GetUniformBlockIndex(const char *); ///<取得一个只读数据块索引
|
// int GetUniformBlockIndex(const char *); ///<取得一个只读数据块索引
|
||||||
// int GetShaderStorageIndex(const char *); ///<取得一个数据存储区索引
|
// int GetShaderStorageIndex(const char *); ///<取得一个数据存储区索引
|
||||||
|
|
||||||
//bool SetAttrib1f(int,float);
|
//bool SetAttrib1f(int,float);
|
||||||
//bool GetAttrib1f(int,float &);
|
//bool GetAttrib1f(int,float &);
|
||||||
@ -191,5 +193,6 @@ namespace hgl
|
|||||||
// UBO *GetUniformBlock(const char *,uint=HGL_DYNAMIC_DRAW);
|
// UBO *GetUniformBlock(const char *,uint=HGL_DYNAMIC_DRAW);
|
||||||
// SSBO *GetShaderStorage(const char *,uint=HGL_DYNAMIC_DRAW);
|
// SSBO *GetShaderStorage(const char *,uint=HGL_DYNAMIC_DRAW);
|
||||||
};//class Shader
|
};//class Shader
|
||||||
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_SHADER_INCLUDE
|
#endif//HGL_SHADER_INCLUDE
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#include<hgl/graph/RenderDriver.h>
|
#include<hgl/graph/RenderDriver.h>
|
||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
class RenderDriverGLCore:public RenderDriver
|
class RenderDriverGLCore:public RenderDriver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -18,4 +20,5 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
};//class RenderDriverGLCore:public RenderDriver
|
};//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,6 +6,8 @@
|
|||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
|
namespace graph
|
||||||
|
{
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
constexpr uint OpenGLShaderType[ShaderType::stEnd]=
|
constexpr uint OpenGLShaderType[ShaderType::stEnd]=
|
||||||
@ -63,7 +65,7 @@ namespace hgl
|
|||||||
|
|
||||||
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;
|
delete[] log;
|
||||||
|
|
||||||
@ -146,7 +148,7 @@ namespace hgl
|
|||||||
|
|
||||||
glGetProgramInfoLog(program,log_length,&char_written,log);
|
glGetProgramInfoLog(program,log_length,&char_written,log);
|
||||||
|
|
||||||
// LOG_ERROR(u8"Shader program link error\n\n"+UTF8String(log));
|
// LOG_ERROR(u8"Shader program link error\n\n"+UTF8String(log));
|
||||||
|
|
||||||
delete[] log;
|
delete[] log;
|
||||||
|
|
||||||
@ -173,7 +175,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
if(!program)
|
if(!program)
|
||||||
{
|
{
|
||||||
// LOG_ERROR(u8"GetAttribLocation("+UTF8String(name)+u8"),program=0");
|
// LOG_ERROR(u8"GetAttribLocation("+UTF8String(name)+u8"),program=0");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +212,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
if(!program)
|
if(!program)
|
||||||
{
|
{
|
||||||
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program=0");
|
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program=0");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +222,7 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
const int gl_error=glGetError();
|
const int gl_error=glGetError();
|
||||||
|
|
||||||
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program="+UTF8String(program)+u8",result=-1,gl_error="+UTF8String(gl_error));
|
// LOG_ERROR(u8"GetUniformLocation("+UTF8String(name)+u8"),program="+UTF8String(program)+u8",result=-1,gl_error="+UTF8String(gl_error));
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
@ -353,41 +355,42 @@ namespace hgl
|
|||||||
|
|
||||||
#undef HGL_GLSL_SetUniformMatrixPointer
|
#undef HGL_GLSL_SetUniformMatrixPointer
|
||||||
|
|
||||||
// int Shader::_GetUniformBlockIndex(const char *uniform_block_name)
|
// int Shader::_GetUniformBlockIndex(const char *uniform_block_name)
|
||||||
// {
|
// {
|
||||||
// if(!program)
|
// if(!program)
|
||||||
// {
|
// {
|
||||||
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") program=0");
|
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") program=0");
|
||||||
// return(-1);
|
// return(-1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// const int index=glGetUniformBlockIndex(program,uniform_block_name);
|
// const int index=glGetUniformBlockIndex(program,uniform_block_name);
|
||||||
//
|
//
|
||||||
// if(index<0)
|
// if(index<0)
|
||||||
// {
|
// {
|
||||||
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") block_index error");
|
// // LOG_ERROR(u8"Shader::_GetUniformBlockIndex("+UTF8String(uniform_block_name)+") block_index error");
|
||||||
// return(-1);
|
// return(-1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return index;
|
// return index;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// int Shader::_GetShaderStorageIndex(const char *ssbo_name)
|
// int Shader::_GetShaderStorageIndex(const char *ssbo_name)
|
||||||
// {
|
// {
|
||||||
// if(!program)
|
// if(!program)
|
||||||
// {
|
// {
|
||||||
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") program=0");
|
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") program=0");
|
||||||
// return(-1);
|
// return(-1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// const int index=glGetProgramResourceIndex(program,GL_SHADER_STORAGE_BLOCK,ssbo_name);
|
// const int index=glGetProgramResourceIndex(program,GL_SHADER_STORAGE_BLOCK,ssbo_name);
|
||||||
//
|
//
|
||||||
// if(index<0)
|
// if(index<0)
|
||||||
// {
|
// {
|
||||||
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") block_index error");
|
// // LOG_ERROR(u8"Shader::_GetShaderStorageIndex("+UTF8String(ssbo_name)+") block_index error");
|
||||||
// return(-1);
|
// return(-1);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return index;
|
// return index;
|
||||||
// }
|
// }
|
||||||
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#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 属性名称
|
* @param name 属性名称
|
||||||
@ -47,49 +49,49 @@ namespace hgl
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 取得一个Shader只读数据区索引
|
// * 取得一个Shader只读数据区索引
|
||||||
// * @param name 数据区名称
|
// * @param name 数据区名称
|
||||||
// * @return 数据区索引
|
// * @return 数据区索引
|
||||||
// * @return -1 出错
|
// * @return -1 出错
|
||||||
// */
|
// */
|
||||||
// int Shader::GetUniformBlockIndex(const char *name)
|
// int Shader::GetUniformBlockIndex(const char *name)
|
||||||
// {
|
// {
|
||||||
// if(!name||!(*name))return(-1);
|
// if(!name||!(*name))return(-1);
|
||||||
//
|
//
|
||||||
// int result;
|
// int result;
|
||||||
//
|
//
|
||||||
// if(!uniform_block_index.Get(name,result))
|
// if(!uniform_block_index.Get(name,result))
|
||||||
// {
|
// {
|
||||||
// result=_GetUniformBlockIndex(name);
|
// result=_GetUniformBlockIndex(name);
|
||||||
//
|
//
|
||||||
// uniform_block_index.Add(name,result);
|
// uniform_block_index.Add(name,result);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return result;
|
// return result;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * 取得一个Shader数据存储区索引
|
// * 取得一个Shader数据存储区索引
|
||||||
// * @param name 数据存储区名称
|
// * @param name 数据存储区名称
|
||||||
// * @return 数据存储区索引
|
// * @return 数据存储区索引
|
||||||
// * @return -1 出错
|
// * @return -1 出错
|
||||||
// */
|
// */
|
||||||
// int Shader::GetShaderStorageIndex(const char *name)
|
// int Shader::GetShaderStorageIndex(const char *name)
|
||||||
// {
|
// {
|
||||||
// if(!name||!(*name))return(-1);
|
// if(!name||!(*name))return(-1);
|
||||||
//
|
//
|
||||||
// int result;
|
// int result;
|
||||||
//
|
//
|
||||||
// if(!ssbo_index.Get(name,result))
|
// if(!ssbo_index.Get(name,result))
|
||||||
// {
|
// {
|
||||||
// result=_GetShaderStorageIndex(name);
|
// result=_GetShaderStorageIndex(name);
|
||||||
//
|
//
|
||||||
// ssbo_index.Add(name,result);
|
// ssbo_index.Add(name,result);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return result;
|
// return result;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(const char *uniform_name,type v0) \
|
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(const char *uniform_name,type v0) \
|
||||||
{ \
|
{ \
|
||||||
@ -180,71 +182,72 @@ namespace hgl
|
|||||||
|
|
||||||
#undef HGL_GLSL_SetUniformMatrixPointer
|
#undef HGL_GLSL_SetUniformMatrixPointer
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 取得一个Shader只读数据区的访问对象
|
// * 取得一个Shader只读数据区的访问对象
|
||||||
// * @param name 对象名称
|
// * @param name 对象名称
|
||||||
// * @param level 访问级别
|
// * @param level 访问级别
|
||||||
// * @return 对象指针
|
// * @return 对象指针
|
||||||
// */
|
// */
|
||||||
// UBO *Shader::GetUniformBlock(const char *name,uint level)
|
// UBO *Shader::GetUniformBlock(const char *name,uint level)
|
||||||
// {
|
// {
|
||||||
// if(!name||!(*name))
|
// if(!name||!(*name))
|
||||||
// {
|
// {
|
||||||
// LOG_ERROR(U8_TEXT("UBO name error:"));
|
// LOG_ERROR(U8_TEXT("UBO name error:"));
|
||||||
// return(nullptr);
|
// return(nullptr);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// UBO *ubo=uniform_block_object[name];
|
// UBO *ubo=uniform_block_object[name];
|
||||||
//
|
//
|
||||||
// if(ubo)
|
// if(ubo)
|
||||||
// return ubo;
|
// return ubo;
|
||||||
//
|
//
|
||||||
// const int index=GetUniformBlockIndex(name);
|
// const int index=GetUniformBlockIndex(name);
|
||||||
//
|
//
|
||||||
// if(index<0)
|
// if(index<0)
|
||||||
// {
|
// {
|
||||||
// LOG_ERROR(U8_TEXT("UBO name error:")+UTF8String(name));
|
// LOG_ERROR(U8_TEXT("UBO name error:")+UTF8String(name));
|
||||||
// return(nullptr);
|
// return(nullptr);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ubo=new UBO(name,program,index,level);
|
// ubo=new UBO(name,program,index,level);
|
||||||
//
|
//
|
||||||
// uniform_block_object.Add(name,ubo);
|
// uniform_block_object.Add(name,ubo);
|
||||||
//
|
//
|
||||||
// return ubo;
|
// return ubo;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// /**
|
// /**
|
||||||
// * 取得一个Shader数据存储区的访问对象
|
// * 取得一个Shader数据存储区的访问对象
|
||||||
// * @param name 对象名称
|
// * @param name 对象名称
|
||||||
// * @param level 访问级别
|
// * @param level 访问级别
|
||||||
// * @return 对象指针
|
// * @return 对象指针
|
||||||
// */
|
// */
|
||||||
// SSBO *Shader::GetShaderStorage(const char *name,uint level)
|
// SSBO *Shader::GetShaderStorage(const char *name,uint level)
|
||||||
// {
|
// {
|
||||||
// if(!name||!(*name))
|
// if(!name||!(*name))
|
||||||
// {
|
// {
|
||||||
// LOG_ERROR(U8_TEXT("SSBO name error:"));
|
// LOG_ERROR(U8_TEXT("SSBO name error:"));
|
||||||
// return(nullptr);
|
// return(nullptr);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// SSBO *ssbo=ssbo_object[name];
|
// SSBO *ssbo=ssbo_object[name];
|
||||||
//
|
//
|
||||||
// if(ssbo)
|
// if(ssbo)
|
||||||
// return ssbo;
|
// return ssbo;
|
||||||
//
|
//
|
||||||
// const int index=GetShaderStorageIndex(name);
|
// const int index=GetShaderStorageIndex(name);
|
||||||
//
|
//
|
||||||
// if(index<0)
|
// if(index<0)
|
||||||
// {
|
// {
|
||||||
// LOG_ERROR(U8_TEXT("SSBO name error:")+UTF8String(name));
|
// LOG_ERROR(U8_TEXT("SSBO name error:")+UTF8String(name));
|
||||||
// return(nullptr);
|
// return(nullptr);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ssbo=new SSBO(name,program,index,level);
|
// ssbo=new SSBO(name,program,index,level);
|
||||||
//
|
//
|
||||||
// ssbo_object.Add(name,ssbo);
|
// ssbo_object.Add(name,ssbo);
|
||||||
//
|
//
|
||||||
// return ssbo;
|
// return ssbo;
|
||||||
// }
|
// }
|
||||||
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user