PDA

View Full Version : Oblique Projection



MburKe
09-18-2003, 06:54 PM
How can i perform an oblique projection on a WireCube. here is what i have done and i am now brain dead, can anyone help please

#include <GL/glut.h>
#include <stdlib.h>
#include<math.h>
void init(void)
{
glClearColor (0.0, 0.0, 0.0, 0.0);
glShadeModel (GL_FLAT);
}

void display(void)
{
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 1.0, 1.0);
glLoadIdentity (); // clear the matrix

gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glScalef (0.5, 0.5, 1.0); // modeling transformation
glutWireCube (0.5);
glFlush ();
}

void reshape (int w, int h)
{
//{1,0,-cot20,0, 0,1,-cot10,0, 0,0,1,0, 0,0,0,0};
float shear[16]={1,0,87.14,0, 0,1,84.29,0, 0,0,1,0, 0,0,0,0};

glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glMultMatrixf(shear);
glOrtho (-1.0, 1.0, -1.0, 1.0, 1.5, 20.0);
glMatrixMode (GL_MODELVIEW);
}


void keyboard(unsigned char key, int x, int y)
{
switch (key) {
case 27:
exit(0);
break;
}
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize (500, 500);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);
init ();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
glutMainLoop();
return 0;
}

I will really appreciate it if anyone could point out my mistake or in the right direction

zeckensack
09-19-2003, 12:19 AM
Post-transform w should never be zero.
The last element of your matrix should be 1.0f.