本文整理汇总了C++中Mat4::makeIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4::makeIdentity方法的具体用法?C++ Mat4::makeIdentity怎么用?C++ Mat4::makeIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4
的用法示例。
在下文中一共展示了Mat4::makeIdentity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
void
PhysicsRendererer::initShader()
{
//--------------------------------------------------------------------------
// setup the shader
//--------------------------------------------------------------------------
const GLchar * vertexShaderSrc =
"attribute vec3 positionAttr;"
""
"uniform mat4 projectionTransform;"
"uniform mat4 viewTransform;"
"uniform mat4 modelTransform;"
""
"void main() {"
" gl_Position = projectionTransform * viewTransform * modelTransform * vec4(positionAttr.xyz, 1.0);"
"}";
const GLchar * fragShaderSrc =
""
"uniform " HIGHP " vec3 color;"
""
"void main() {"
" gl_FragColor = vec4(color,1.0);"
"}";
_shader.setVertexShaderSrc(vertexShaderSrc);
_shader.setFragmentShaderSrc(fragShaderSrc);
_shader.declareAttrib("positionAttr", _positionAttrib);
_shader.initGL();
//--------------------------------------------------------------------------
// setup the shader matrices
//--------------------------------------------------------------------------
_proj.makeOrtho(0, 1, 0, 1, 1, 10);
_view.makeLookAt(0, 0, 4, 0, 0, 0, 0, 1, 0);
_model.makeIdentity();
_shader.bind();
_shader.setUniformMat4fv("projectionTransform", _proj.get());
_shader.setUniformMat4fv("viewTransform", _view.get());
_shader.setUniformMat4fv("modelTransform", _model.get());
_shader.unbind();
}
示例2: TestMat4
void TestMat4()
{
// -------- Basics
{
Mat4 A;
for (int i = 0; i < 16; i++)
failIf(A[i] != 0,
"Mat4() constructor or array style reading (partial test)");
}
{
Mat4 A(1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16);
for (int i = 0; i < 16; i++)
failIf(A[i] != (i + 1),
"Mat4(double, ...) constructor or array style reading "
"(partial test)");
}
{
Mat4 A(1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16);
failIf(!(A == A) || (A != A), "Mat4 self-equality");
}
{
Mat4 A(1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16);
Mat4 B(20, 21, 22, 23,
24, 25, 26, 27,
28, 29, 30, 31,
32, 33, 34, 35);
failIf(A == B, "Not-equal Mat4's");
}
{
Mat4 A(1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16);
Mat4 B(A);
failIf(A != B, "Mat4 copy constructor");
}
{
Mat4 A;
A.makeIdentity();
Mat4 B(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1);
failIf(A != B, "Mat4.makeIdentity()");
}
{
Mat4 A;
A.makeFullOne();
Mat4 B(1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1,
1, 1, 1, 1);
failIf(A != B, "Mat4.makeFullOne()");
}
{
Mat4 A(8, 8, 8, 8,
1, 0, 0, 0,
8, 8, 8, 8,
8, 8, 8, 8);
Vec3 r = A.column(1);
Vec3 result(1, 0, 0);
failIf(r != result, "Mat4.column()");
}
{
Mat4 A(8, 1, 8, 8,
8, 0, 8, 8,
8, 0, 8, 8,
8, 0, 8, 8);
Vec3 r = A.row(1);
Vec3 result(1, 0, 0);
failIf(r != result, "Mat4.row()");
}
// -------- Addition, Subtraction
{
Mat4 A(1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16);
Mat4 B(16, 12, 8, 4,
15, 11, 7, 3,
14, 10, 6, 2,
13, 9, 5, 1);
//.........这里部分代码省略.........