-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyMatrix.cpp
More file actions
65 lines (56 loc) · 1.47 KB
/
Copy pathmyMatrix.cpp
File metadata and controls
65 lines (56 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "myMatrix.h"
MyMatrix::MyMatrix(void)
{
this->loadIdentity();
}
MyMatrix::MyMatrix(float coeffs[])
{
this->loadIdentity();
GLfloat newMatrix[16];
for (int i = 0; i < 16; i++) {
newMatrix[i] = coeffs[i];
}
memcpy(this->myMatrix, newMatrix, sizeof(myMatrix));
}
void MyMatrix::loadIdentity(void)
{
static GLfloat identityMatrix[16] =
{
1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,1.0,0.0,
0.0,0.0,0.0,1.0
};
memcpy(this->myMatrix, identityMatrix, sizeof(identityMatrix));
}
void MyMatrix::getGLMatrix(GLenum pname)
// Returns any matrix (used by other functions: do use directly)
{
//remember, you should have a GLfloat myMatrix[16]; defined
//as a member of your class (see above)
glGetFloatv(pname,this->myMatrix);
}
void MyMatrix::getGLModelviewMatrix(void)
// Returns the current modelview matrix
{
getGLMatrix(GL_MODELVIEW_MATRIX);
}
void MyMatrix::getGLProjectionMatrix(void)
// Returns the current projection matrix
{
getGLMatrix(GL_PROJECTION_MATRIX);
}
void MyMatrix::multiplyGLMatrix(void)
// Multiply our matrix by the current OpenGL one
//Remember to first set the current GL matrix by using the command:
// glMatrixMode()!!!
{
glMultMatrixf(this->myMatrix);
}
void MyMatrix::setGLMatrix(void)
// Set the OpenGL matrix to that currently specified in myMatrix
//Remember to first set the current GL matrix by using the command:
// glMatrixMode()!!!
{
glLoadMatrixf(this->myMatrix);
}