|
MGCL V10
V10
MGCL V10
|
mgGLSLProgramはOpenGL Shader Programをcompile , linkしてそのuniform変数の管理を行います. [詳解]
クラス | |
| union | SELECT_NAME |
公開型 | |
| enum | GLSLShaderType { VERTEX, FRAGMENT, GEOMETRY, TESS_CONTROL, TESS_EVALUATION } |
| CreateShaderのタイプ列挙子 [詳解] | |
| enum | VertexAttribId { vPosition =0, vColor, vNormal, vTextureCoord } |
| enum | UniformName { modelViewProjMatrix =0, modelViewMatrix, projMatrix, normalMatrix, ndcMarix, ndcScaleMatrix, dpiFactor, FuncType, DrawType, ShaderMode, CoordinateType, texture2D, pointSize, anchorPoint, LightTwoSides, ForceLight, ZebraAxis, ZebraSize } |
| enum | LightProps { isEnabled =0, ambientColor, diffuseColor, specularColor, position, spotDirection, spotExponent, spotCutoff, constantAttenuation, linearAttenuation, quadraticAttenuation } |
公開メンバ関数 | |
| mgGLSLProgram () | |
| ~mgGLSLProgram () | |
| bool | compileShaderFromFile (const char *fileName, GLSLShaderType type) |
| compileがうまく行われたときはtrueを、失敗したときはfalseを返します [詳解] | |
| bool | compileShaderFromString (const std::string &source, GLSLShaderType type) |
| compileがうまく行われたときはtrueを、失敗したときはfalseを返します [詳解] | |
| void | freeProgram () |
| Delete this program and initialize this. [詳解] | |
| bool | link () |
| linkがうまく行われたときはtrueを、失敗したときはfalseを返します [詳解] | |
| void | use () |
| このmgGLSLProgramの利用を開始します。 [詳解] | |
| std::string & | log () |
| エラーが起こった時のログ内容を文字で求めます [詳解] | |
| int | getHandle () |
| Programハンドルを返します [詳解] | |
| bool | isLinked () |
| Link済か否かを尋ねる [詳解] | |
| void | bindAttribLocation (GLuint location, const char *name) |
| nameに割り当てるlocationを指定する。locationはこの後のlink()で有効となる。 [詳解] | |
| void | bindFragDataLocation (GLuint location, const char *name) |
| nameに割り当てるlocationを指定する。locationはこの後のlink()で有効となる。 [詳解] | |
| int | getvPositionLocation () const |
| 規定のvetex attrib のlocationを求める。 [詳解] | |
| int | getvColorLocation () const |
| vPosition [詳解] | |
| int | getvNormalLocation () const |
| vColor [詳解] | |
| int | getvTextureCoordLocation () const |
| vNormal [詳解] | |
| GLint | getUniformLocation (const char *name) const |
| vTexture [詳解] | |
| GLint | getUniformLocation (const std::string &name) const |
| void | setUniform (GLint loc, float x, float y, float z) |
| void | setUniform (GLint loc, const glm::vec3 &v) |
| void | setUniform (GLint loc, const glm::vec4 &v) |
| void | setUniform (GLint loc, const glm::mat4 &m) |
| void | setUniform (GLint loc, const glm::mat3 &m) |
| void | setUniform (GLint loc, float val) |
| void | setUniform (GLint loc, int val) |
| void | setUniform (GLint loc, bool val) |
| void | printActiveUniforms () |
| void | printActiveAttribs () |
| void | EnableLights (bool bEnabled=true) |
| bool | LightEnabled () |
| void | setUniform (UniformName name, float x, float y, float z) |
| void | setUniform (UniformName name, const glm::vec3 &v) |
| void | setUniform (UniformName name, const glm::vec4 &v) |
| void | setUniform (UniformName name, const glm::mat4 &m) |
| void | setUniform (UniformName name, const glm::mat3 &m) |
| void | setUniform (UniformName name, float val) |
| void | setUniform (UniformName name, int val) |
| void | setUniform (UniformName name, bool val) |
| void | setUniformLights (GLint lightNo, LightProps name, float x, float y, float z) |
| void | setUniformLights (GLint lightNo, LightProps name, const glm::vec3 &v) |
| void | setUniformLights (GLint lightNo, LightProps name, const glm::vec4 &v) |
| void | setUniformLights (GLint lightNo, LightProps name, const glm::mat4 &m) |
| void | setUniformLights (GLint lightNo, LightProps name, const glm::mat3 &m) |
| void | setUniformLights (GLint lightNo, LightProps name, float val) |
| void | setUniformLights (GLint lightNo, LightProps name, int val) |
| void | setUniformLights (GLint lightNo, LightProps name, bool val) |
| void | setOpenGLVersion () |
| void | getOpenGLVerion (GLint &major, GLint &minor) const |
| in this program. [詳解] | |
| void | printPrjMatrix () |
| void | printLightProps () |
| void | printLightProps (GLint lightNo) |
| void | setFuncType (mgGLSL::FuncType type) |
| int | getFuncType () |
静的公開メンバ関数 | |
| static void | setCurrentGLSLProgram (mgGLSLProgram *glsl) |
| Current mgGLSLProgramを求める。 [詳解] | |
| static mgGLSLProgram * | getCurrentGLSLProgram () |
| Current mgGLSLProgramを求める。 [詳解] | |
静的公開変数類 | |
| static const size_t | MAX_ATTRIB_LOC = 20 |
| static const GLint | LIGHT_NUM = 10 |
| static const GLint | PROP_NUM = 11 |
mgGLSLProgramはOpenGL Shader Programをcompile , linkしてそのuniform変数の管理を行います.
利用方法: 1、mgGLSLProgramオブジェクトの作成 2、compileShaderFromFile、またはcompileShaderFromStringで必要なshaderを コンパイル 3、必要であればbindAttribLocation(), bindFragDataLocation()を呼んだ後、link() 3、use()によりshaderプログラムを選択し、setUniform()によりuniform変数に値をセット
***** MGCLではshaderに対して次のlocationと変数名を予約している: locationに対してこれらの値をは使用してはならない。 また、これらの変数はすべてのvertex shaderに下記のように宣言されなければならない。 uniform int functionID;//Function ID of the shaders: 0: standard(no shading functions); 11: Texture that uses texture1 sampler2D.(MGPlaneImage Texture uses this one.)
uniform mat4 modelViewProjMatrix;//=projMatrix*modelViewMatrix. uniform mat3 normalMatrix; uniform mat4 modelViewMatrix; uniform mat4 projMatrix; uniform sampler2D texture1;
layout(location = 0) in vec3 vPosition; layout(location = 1) in vec4 vColor; layout(location = 2) in vec3 vNormal; layout(location = 3) in vec2 vTextureCoord;
| mgGLSLProgram::mgGLSLProgram | ( | ) |
| mgGLSLProgram::~mgGLSLProgram | ( | ) |
| void mgGLSLProgram::bindAttribLocation | ( | GLuint | location, |
| const char * | name | ||
| ) |
nameに割り当てるlocationを指定する。locationはこの後のlink()で有効となる。
| void mgGLSLProgram::bindFragDataLocation | ( | GLuint | location, |
| const char * | name | ||
| ) |
nameに割り当てるlocationを指定する。locationはこの後のlink()で有効となる。
| bool mgGLSLProgram::compileShaderFromFile | ( | const char * | fileName, |
| GLSLShaderType | type | ||
| ) |
compileがうまく行われたときはtrueを、失敗したときはfalseを返します
| bool mgGLSLProgram::compileShaderFromString | ( | const std::string & | source, |
| GLSLShaderType | type | ||
| ) |
compileがうまく行われたときはtrueを、失敗したときはfalseを返します
| void mgGLSLProgram::EnableLights | ( | bool | bEnabled = true | ) |
| void mgGLSLProgram::freeProgram | ( | ) |
Delete this program and initialize this.
|
static |
Current mgGLSLProgramを求める。
| int mgGLSLProgram::getFuncType | ( | ) |
| int mgGLSLProgram::getHandle | ( | ) |
Programハンドルを返します
| void mgGLSLProgram::getOpenGLVerion | ( | GLint & | major, |
| GLint & | minor | ||
| ) | const |
in this program.
Get version by glGetInteger(), and set the info
| GLint mgGLSLProgram::getUniformLocation | ( | const char * | name | ) | const |
vTexture
|
inline |
| int mgGLSLProgram::getvColorLocation | ( | ) | const |
vPosition
| int mgGLSLProgram::getvNormalLocation | ( | ) | const |
vColor
| int mgGLSLProgram::getvPositionLocation | ( | ) | const |
規定のvetex attrib のlocationを求める。
| int mgGLSLProgram::getvTextureCoordLocation | ( | ) | const |
vNormal
| bool mgGLSLProgram::isLinked | ( | ) |
Link済か否かを尋ねる
| bool mgGLSLProgram::LightEnabled | ( | ) |
| bool mgGLSLProgram::link | ( | ) |
linkがうまく行われたときはtrueを、失敗したときはfalseを返します
| std::string& mgGLSLProgram::log | ( | ) |
エラーが起こった時のログ内容を文字で求めます
| void mgGLSLProgram::printActiveAttribs | ( | ) |
| void mgGLSLProgram::printActiveUniforms | ( | ) |
| void mgGLSLProgram::printLightProps | ( | ) |
| void mgGLSLProgram::printLightProps | ( | GLint | lightNo | ) |
| void mgGLSLProgram::printPrjMatrix | ( | ) |
|
static |
Current mgGLSLProgramを求める。
| void mgGLSLProgram::setFuncType | ( | mgGLSL::FuncType | type | ) |
| void mgGLSLProgram::setOpenGLVersion | ( | ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| float | x, | ||
| float | y, | ||
| float | z | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| const glm::vec3 & | v | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| const glm::vec4 & | v | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| const glm::mat4 & | m | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| const glm::mat3 & | m | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| float | val | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| int | val | ||
| ) |
| void mgGLSLProgram::setUniform | ( | GLint | loc, |
| bool | val | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| float | x, | ||
| float | y, | ||
| float | z | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| const glm::vec3 & | v | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| const glm::vec4 & | v | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| const glm::mat4 & | m | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| const glm::mat3 & | m | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| float | val | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| int | val | ||
| ) |
| void mgGLSLProgram::setUniform | ( | UniformName | name, |
| bool | val | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| float | x, | ||
| float | y, | ||
| float | z | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| const glm::vec3 & | v | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| const glm::vec4 & | v | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| const glm::mat4 & | m | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| const glm::mat3 & | m | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| float | val | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| int | val | ||
| ) |
| void mgGLSLProgram::setUniformLights | ( | GLint | lightNo, |
| LightProps | name, | ||
| bool | val | ||
| ) |
| void mgGLSLProgram::use | ( | ) |
このmgGLSLProgramの利用を開始します。
|
static |
|
static |
|
static |