I was looking at examples of being able to represent transformations using a matrix instead of the built in functions. I want to learn more about the low level functions WITHOUT using any of opengl’s matrix or transform functions
Say I have a matrix class:
class Matrix
{
public:
float data [ 3 ] [ 3 ];
Matrix ( void )
{
int i, j;
for ( i = 0; i < 3; i++ )
{
for ( j = 0; j < 3; j++ )
{
data [ i ] [ j ] = 0;
}sa
}
}
};
Example function:
Matrix scale ( Pt p, float alpha )
{
Matrix rvalue;
rvalue.data[0][0] = alpha;
rvalue.data[0][1] = 0;
rvalue.data[0][2] = (1-alpha)*p.x;
rvalue.data[1][0] = 0;
rvalue.data[1][1] = alpha;
rvalue.data[1][2] = (1-alpha)*p.y;
rvalue.data[2][0] = 0;
rvalue.data[2][1] = 0;
rvalue.data[2][2] = 1;
return rvalue;
}
How would I apply those transformations using opengl? I’m not where where to start. Is there a function that cane take a 3×3 matrix and load it in?
You probably want one of
glLoadMatrixorglMultMatrix. They take column-major 4×4 matrices so you’ll want to write a shim like:So I’ve just padded out your data with the relevant parts of the identity matrix.