OGforever
11-29-2005, 07:18 AM
Hello,
I am trying to create perspective projection
I started with drawing a line with help from
the gluPerspective-command, but then I found out
that that is forbidden in this assignment
It's like this:
*load a file with coords
*draw the figure with perspective projection
*use flat shading, painter's algorithm etc
I am not sure whether or not to use gluOrtho2D
as replacement for gluPerspective or what to do.
Everything is to be made "by hand" ..
For example how can make this line in display
visible ->
OG Regards
/********* GLUT callbacks ***********/
void display()
{
/* Draw a grid on the screen */
int x, y, w, h;
w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);
/* Clear the screen */
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// glClear(GL_COLOR_BUFFER_BIT);
/* Set color to light grey */
glColor3f(0, 1.0, 0);
glBegin(GL_LINES);
glVertex3f(-2.0f, 2.0f, 0.0f);
glVertex3f(2.0f, -2.0f, 0.0f);
glEnd();
/* Force the commands to complete */
glFlush();
}
void idle()
{
/* Update the GUI */
if(!tickGUI())
{
/* The GUI window has been closed */
exit(EXIT_SUCCESS);
}
}
void reshape(int width, int height)
{
/* Setup the viewport and transformations that must be used for
the project */
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, width, height, 0);
//gluPerspective(44.0f, width/height, 0.2f, 255.0f);
// gluOrth
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -128.0f);
}
I am trying to create perspective projection
I started with drawing a line with help from
the gluPerspective-command, but then I found out
that that is forbidden in this assignment
It's like this:
*load a file with coords
*draw the figure with perspective projection
*use flat shading, painter's algorithm etc
I am not sure whether or not to use gluOrtho2D
as replacement for gluPerspective or what to do.
Everything is to be made "by hand" ..
For example how can make this line in display
visible ->
OG Regards
/********* GLUT callbacks ***********/
void display()
{
/* Draw a grid on the screen */
int x, y, w, h;
w = glutGet(GLUT_WINDOW_WIDTH);
h = glutGet(GLUT_WINDOW_HEIGHT);
/* Clear the screen */
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
// glClear(GL_COLOR_BUFFER_BIT);
/* Set color to light grey */
glColor3f(0, 1.0, 0);
glBegin(GL_LINES);
glVertex3f(-2.0f, 2.0f, 0.0f);
glVertex3f(2.0f, -2.0f, 0.0f);
glEnd();
/* Force the commands to complete */
glFlush();
}
void idle()
{
/* Update the GUI */
if(!tickGUI())
{
/* The GUI window has been closed */
exit(EXIT_SUCCESS);
}
}
void reshape(int width, int height)
{
/* Setup the viewport and transformations that must be used for
the project */
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, width, height, 0);
//gluPerspective(44.0f, width/height, 0.2f, 255.0f);
// gluOrth
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -128.0f);
}