修正Shader/GLSL类的一些设计错误
This commit is contained in:
parent
269615b206
commit
7f68b4b420
@ -108,24 +108,24 @@ namespace hgl
|
||||
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 *);
|
||||
bool SetUniform2fv(int,const float *);
|
||||
bool SetUniform3fv(int,const float *);
|
||||
bool SetUniform4fv(int,const float *);
|
||||
bool SetUniform1fv(int,int count,const float *);
|
||||
bool SetUniform2fv(int,int count,const float *);
|
||||
bool SetUniform3fv(int,int count,const float *);
|
||||
bool SetUniform4fv(int,int count,const float *);
|
||||
|
||||
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);}
|
||||
bool SetUniform4fv(int index,const Vector4f &v){return SetUniform4fv(index,(const float *)&v);}
|
||||
bool SetUniform2fv(int index,const Vector2f &v){return SetUniform2fv(index,1,(const float *)&v);}
|
||||
bool SetUniform3fv(int index,const Vector3f &v){return SetUniform3fv(index,1,(const float *)&v);}
|
||||
bool SetUniform4fv(int index,const Vector4f &v){return SetUniform4fv(index,1,(const float *)&v);}
|
||||
|
||||
bool SetUniform1iv(int,const int *);
|
||||
bool SetUniform2iv(int,const int *);
|
||||
bool SetUniform3iv(int,const int *);
|
||||
bool SetUniform4iv(int,const int *);
|
||||
bool SetUniform1iv(int,int count,const int *);
|
||||
bool SetUniform2iv(int,int count,const int *);
|
||||
bool SetUniform3iv(int,int count,const int *);
|
||||
bool SetUniform4iv(int,int count,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 SetUniform1uiv(int,int count,const unsigned int *);
|
||||
bool SetUniform2uiv(int,int count,const unsigned int *);
|
||||
bool SetUniform3uiv(int,int count,const unsigned int *);
|
||||
bool SetUniform4uiv(int,int count,const unsigned int *);
|
||||
|
||||
bool SetUniformMatrix2fv(int,const float *);
|
||||
bool SetUniformMatrix3fv(int,const float *);
|
||||
@ -155,24 +155,24 @@ namespace hgl
|
||||
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 SetUniform1fv(const char *,int count,const float *);
|
||||
bool SetUniform2fv(const char *,int count,const float *);
|
||||
bool SetUniform3fv(const char *,int count,const float *);
|
||||
bool SetUniform4fv(const char *,int count,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 SetUniform2fv(const char *name,const Vector2f &v){return SetUniform2fv(name,1,(const float *)&v);}
|
||||
bool SetUniform3fv(const char *name,const Vector3f &v){return SetUniform3fv(name,1,(const float *)&v);}
|
||||
bool SetUniform4fv(const char *name,const Vector4f &v){return SetUniform4fv(name,1,(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 SetUniform1iv(const char *,int count,const int *);
|
||||
bool SetUniform2iv(const char *,int count,const int *);
|
||||
bool SetUniform3iv(const char *,int count,const int *);
|
||||
bool SetUniform4iv(const char *,int count,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 SetUniform1uiv(const char *,int count,const unsigned int *);
|
||||
bool SetUniform2uiv(const char *,int count,const unsigned int *);
|
||||
bool SetUniform3uiv(const char *,int count,const unsigned int *);
|
||||
bool SetUniform4uiv(const char *,int count,const unsigned int *);
|
||||
|
||||
bool SetUniformMatrix2fv(const char *,const float *);
|
||||
bool SetUniformMatrix3fv(const char *,const float *);
|
||||
|
@ -148,7 +148,7 @@ namespace hgl
|
||||
|
||||
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;
|
||||
|
||||
@ -228,7 +228,7 @@ namespace hgl
|
||||
return(result);
|
||||
}
|
||||
|
||||
#define HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(func) if(!program) \
|
||||
#define HGL_GLSL_CHECK_PROGRAM_AND_LOCATION(func) if(!program) \
|
||||
{ \
|
||||
LOG_ERROR(u8"Shader::SetUniform" #func ",program=0"); \
|
||||
return(false); \
|
||||
@ -240,45 +240,46 @@ namespace hgl
|
||||
return(false); \
|
||||
}
|
||||
|
||||
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(int location,type v0) \
|
||||
{ \
|
||||
#define HGL_GLSL_SetUniform1234(func,type) bool Shader::SetUniform1##func(int location,type v0) \
|
||||
{ \
|
||||
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);
|
||||
|
||||
#undef HGL_GLSL_SetUniform1234
|
||||
|
||||
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(int location,const type *value) \
|
||||
{ \
|
||||
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(int location,int count,const type *value) \
|
||||
{ \
|
||||
if(!program) \
|
||||
{ \
|
||||
/*LOG_ERROR(u8"Shader::SetUniform" #func ",program=0");*/ \
|
||||
@ -297,7 +298,7 @@ namespace hgl
|
||||
return(false); \
|
||||
} \
|
||||
\
|
||||
glProgramUniform##func(program,location,1,value); \
|
||||
glProgramUniform##func(program,location,count,value); \
|
||||
return(true); \
|
||||
}
|
||||
|
||||
@ -318,8 +319,8 @@ namespace hgl
|
||||
|
||||
#undef HGL_GLSL_SetUniformPointer
|
||||
|
||||
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(int location,const float *mat) \
|
||||
{ \
|
||||
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(int location,const float *mat) \
|
||||
{ \
|
||||
if(!program) \
|
||||
{ \
|
||||
LOG_ERROR(u8"Shader::SetUniformMatrix" #func ",program=0"); \
|
||||
|
@ -93,8 +93,10 @@ namespace hgl
|
||||
// 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) \
|
||||
{ \
|
||||
if(!uniform_name||!*uniform_name)return(false); \
|
||||
\
|
||||
const int location=GetUniformLocation(uniform_name); \
|
||||
\
|
||||
if(location==-1)return(false); \
|
||||
@ -103,7 +105,9 @@ namespace hgl
|
||||
} \
|
||||
\
|
||||
bool Shader::SetUniform2##func(const char *uniform_name,type v0,type v1) \
|
||||
{ \
|
||||
{ \
|
||||
if(!uniform_name||!*uniform_name)return(false); \
|
||||
\
|
||||
const int location=GetUniformLocation(uniform_name); \
|
||||
\
|
||||
if(location==-1)return(false); \
|
||||
@ -112,7 +116,9 @@ namespace hgl
|
||||
} \
|
||||
\
|
||||
bool Shader::SetUniform3##func(const char *uniform_name,type v0,type v1,type v2) \
|
||||
{ \
|
||||
{ \
|
||||
if(!uniform_name||!*uniform_name)return(false); \
|
||||
\
|
||||
const int location=GetUniformLocation(uniform_name); \
|
||||
\
|
||||
if(location==-1)return(false); \
|
||||
@ -121,7 +127,9 @@ namespace hgl
|
||||
} \
|
||||
\
|
||||
bool Shader::SetUniform4##func(const char *uniform_name,type v0,type v1,type v2,type v3) \
|
||||
{ \
|
||||
{ \
|
||||
if(!uniform_name||!*uniform_name)return(false); \
|
||||
\
|
||||
const int location=GetUniformLocation(uniform_name); \
|
||||
\
|
||||
if(location==-1)return(false); \
|
||||
@ -134,13 +142,15 @@ namespace hgl
|
||||
|
||||
#undef HGL_GLSL_SetUniform1234
|
||||
|
||||
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(const char *uniform_name,const type *value) \
|
||||
{ \
|
||||
#define HGL_GLSL_SetUniformPointer(func,type) bool Shader::SetUniform##func(const char *uniform_name,int count,const type *value) \
|
||||
{ \
|
||||
if(!uniform_name||!*uniform_name||count<=0||!value)return(false); \
|
||||
\
|
||||
const int location=GetUniformLocation(uniform_name); \
|
||||
\
|
||||
if(location==-1)return(false); \
|
||||
\
|
||||
return SetUniform##func(location,value); \
|
||||
return SetUniform##func(location,count,value); \
|
||||
}
|
||||
|
||||
HGL_GLSL_SetUniformPointer(1fv,float);
|
||||
@ -160,8 +170,10 @@ namespace hgl
|
||||
|
||||
#undef HGL_GLSL_SetUniformPointer
|
||||
|
||||
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(const char *uniform_name,const float *mat) \
|
||||
{ \
|
||||
#define HGL_GLSL_SetUniformMatrixPointer(func) bool Shader::SetUniformMatrix##func(const char *uniform_name,const float *mat) \
|
||||
{ \
|
||||
if(!uniform_name||!*uniform_name||*mat)return(false); \
|
||||
\
|
||||
const int location=GetUniformLocation(uniform_name); \
|
||||
\
|
||||
if(location==-1)return(false); \
|
||||
|
Loading…
x
Reference in New Issue
Block a user