本文整理汇总了C++中mat4::Perspective方法的典型用法代码示例。如果您正苦于以下问题:C++ mat4::Perspective方法的具体用法?C++ mat4::Perspective怎么用?C++ mat4::Perspective使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mat4
的用法示例。
在下文中一共展示了mat4::Perspective方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}