本文整理汇总了C++中mat4::ToViewMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ mat4::ToViewMatrix方法的具体用法?C++ mat4::ToViewMatrix怎么用?C++ mat4::ToViewMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat4
的用法示例。
在下文中一共展示了mat4::ToViewMatrix方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void Draw()
{
// clear the backbuffer to our clear colour and clear the depth
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set active shader
glUseProgram(g_ShaderID);
// convert camera's world matrix to a view matrix
g_ViewMatrix = g_CameraMatrix.ToViewMatrix();
// set current transforms in the shader
GLuint ViewID = glGetUniformLocation(g_ShaderID,"View");
glUniformMatrix4fv(ViewID, 1, false, g_ViewMatrix);
GLuint ModelID = glGetUniformLocation(g_ShaderID,"Model");
glUniformMatrix4fv(ModelID, 1, false, g_ModelMatrix);
// set active texture, bind the crate quad's buffers and draw it
glActiveTexture(GL_TEXTURE0);
glBindTexture( GL_TEXTURE_2D, g_TextureID );
glBindVertexArray(g_VAO);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
// draw the quad again at a different position
g_ModelMatrix.row3 = vec4(4,0,0,1);
glUniformMatrix4fv(ModelID, 1, false, g_ModelMatrix);
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
g_ModelMatrix.row3 = vec4(0,0,0,1);
// draw the visualiser shapes
Visualiser::Get()->Draw(&g_ViewMatrix,&g_ProjectionMatrix);
}
示例2: Init
void Init()
{
// create a visualiser
Visualiser::Create();
// setup matrices
g_CameraMatrix.SetFrame( vec4(0,10,-10,1), vec4(0,-1,1,0), vec4(0,1,0,0));
g_ProjectionMatrix.Perspective(PI/6, 1200/720.0f, 0.1f, 100);
// g_ProjectionMatrix.Orthographic(1280,720,0.1f,100);
g_ViewMatrix = g_CameraMatrix.ToViewMatrix();
g_ModelMatrix = mat4(1,0,0,0,
0,1,0,0,
0,0,1,0,
0,0,0,1);
glEnable(GL_DEPTH_TEST);
// load shader
const char* aszInputs[] = { "Position", "UV" };
const char* aszOutputs[] = { "outColour" };
g_ShaderID = LoadShader( 2, aszInputs, 1, aszOutputs,
"./shaders/vertex.glsl",
"./shaders/pixel.glsl");
// build 2-triangle plane
float fPlaneSize = 2.0f;
Build3DPlane(fPlaneSize,g_VAO,g_VBO,g_IBO);
// load texture
g_TextureID = LoadTexture("./images/crate_sideup.png", GL_BGRA);
// set matrix uniforms within the shaders
GLuint ProjectionID = glGetUniformLocation(g_ShaderID,"Projection");
GLuint ViewID = glGetUniformLocation(g_ShaderID,"View");
GLuint ModelID = glGetUniformLocation(g_ShaderID,"Model");
glUniformMatrix4fv(ProjectionID, 1, false, g_ProjectionMatrix);
glUniformMatrix4fv(ViewID, 1, false, g_ViewMatrix);
glUniformMatrix4fv(ModelID, 1, false, g_ModelMatrix);
// set the texture to use slot 0 in the shader
GLuint texUniformID = glGetUniformLocation(g_ShaderID,"diffuseTexture");
glUniform1i(texUniformID,0);
// set clear colour
glClearColor(0.25f,0.25f,0.25f,1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
// start our timer
AIE::ResetTimer();
}