When i try to call gluPerspective using g++ (MinGW) i get the error undefined reference to gluPerspective@32'`. I see that the function was removed in a previous version of GLU and found a workaround which should fix it https://stackoverflow.com/a/14793491/14709794
He wrote to write your own version and pass the matrix direct to OpenGL but how to do that? When i implement the 2 functions from the answer how do i call them instead of calling gluPerspective?
void reshape(int w,int h){
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, 1, 2, 50);
glMatrixMode(GL_MODELVIEW);
}
I tried
float *matrix;
glhPerspectivef2(matrix, 60, 1, 2, 50);
glPushMatrix();
As @rafix07 wrote i changed float *matrix to float *matrix = new float[w * h] and instead of glPushMatrix(matrix) i called glLoadMatrixf(matrix).
float *matrix = new float[w * h];
glhPerspectivef2(matrix, 60, 1, 1, 500);
glLoadMatrixf(matrix);