TINYGL: Added a few utility methods and operators.
This commit is contained in:
parent
b7853b48f8
commit
b1b498d336
3 changed files with 48 additions and 43 deletions
|
@ -69,7 +69,7 @@ void glopMultMatrix(GLContext *c, GLParam *p) {
|
|||
q += 4;
|
||||
}
|
||||
|
||||
*c->matrix_stack_ptr[c->matrix_mode] = (*c->matrix_stack_ptr[c->matrix_mode]) * m;
|
||||
*c->matrix_stack_ptr[c->matrix_mode] *= m;
|
||||
|
||||
gl_matrix_update(c);
|
||||
}
|
||||
|
@ -126,8 +126,7 @@ void glopRotate(GLContext *c, GLParam *p) {
|
|||
if (u[2] < 0) angle = -angle;
|
||||
m = Matrix4::rotation(angle,2);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
float cost, sint;
|
||||
|
||||
// normalize vector
|
||||
|
@ -165,7 +164,7 @@ void glopRotate(GLContext *c, GLParam *p) {
|
|||
}
|
||||
}
|
||||
|
||||
*c->matrix_stack_ptr[c->matrix_mode] = (*c->matrix_stack_ptr[c->matrix_mode]) * m;
|
||||
*c->matrix_stack_ptr[c->matrix_mode] *= m;
|
||||
|
||||
gl_matrix_update(c);
|
||||
}
|
||||
|
@ -179,7 +178,7 @@ void glopScale(GLContext *c, GLParam *p) {
|
|||
m.set(1,1,y);
|
||||
m.set(2,2,z);
|
||||
|
||||
*c->matrix_stack_ptr[c->matrix_mode] = (*c->matrix_stack_ptr[c->matrix_mode]) * m;
|
||||
*c->matrix_stack_ptr[c->matrix_mode] *= m;
|
||||
|
||||
gl_matrix_update(c);
|
||||
}
|
||||
|
@ -192,7 +191,7 @@ void glopTranslate(GLContext *c, GLParam *p) {
|
|||
m.set(3,1,y);
|
||||
m.set(3,2,z);
|
||||
|
||||
*c->matrix_stack_ptr[c->matrix_mode] = (*c->matrix_stack_ptr[c->matrix_mode]) * m;
|
||||
*c->matrix_stack_ptr[c->matrix_mode] *= m;
|
||||
|
||||
gl_matrix_update(c);
|
||||
}
|
||||
|
@ -219,7 +218,7 @@ void glopFrustum(GLContext *c, GLParam *p) {
|
|||
m.set(0,2, 0); m.set(1,2, 0); m.set(2,2, C); m.set(3,2, D);
|
||||
m.set(0,3, 0); m.set(1,3, 0); m.set(2,3, -1); m.set(3,3, 0);
|
||||
|
||||
*c->matrix_stack_ptr[c->matrix_mode] = (*c->matrix_stack_ptr[c->matrix_mode]) * m;
|
||||
*c->matrix_stack_ptr[c->matrix_mode] *= m;
|
||||
|
||||
gl_matrix_update(c);
|
||||
}
|
||||
|
|
|
@ -172,7 +172,6 @@ Vector4::Vector4() {
|
|||
// Empty constructor, no overhead
|
||||
}
|
||||
|
||||
|
||||
Vector4::Vector4(float x, float y, float z, float w) {
|
||||
_v[0] = x;
|
||||
_v[1] = y;
|
||||
|
|
|
@ -214,6 +214,13 @@ public:
|
|||
return result;
|
||||
}
|
||||
|
||||
Matrix4& operator*=(const Matrix4 &b)
|
||||
{
|
||||
Matrix4 result = *this * b;
|
||||
*this = result;
|
||||
return *this;
|
||||
}
|
||||
|
||||
static Matrix4 identity();
|
||||
static Matrix4 rotation(float t, int u);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue