//cone_perspective.cpp: draws a perspective view of a GLUT wire cone
// w32ogl Project / Properties:
// Must add Linker / Input / Additional Dependencies: opengl32.lib glu32.lib glut32.lib
// Must set Linker / Advanced / Entry Point to: mainCRTStartup
#include "glut.h"
GLint winWidth=500, winHeight=500;
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glFrustum(-1.0,1.0,-1.0,1.0,1.0,5.0);
//glOrtho(-1.0,1.0,-1.0,1.0,1.0,5.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(2.0,2.0,1.0,0.0,0.0,0.0,0.0,0.0,1.0);
}
void mydisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
//*** display the coordinate axes in blue
glColor3f(0.0,0.0,1.0);
glBegin(GL_LINES);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,2.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,2.0,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(2.0,0.0,0.0);
glEnd();
glColor3f(1.0,0.0,0.0); // red wireframe cone
//***display cone rotated by 30 degrees about y-axis
//glRotatef(30.0,0.0,1.0,0.0);
//move cone out y-axis & rotate by 30 degrees about y-axis
//glRotatef(30.0,0.0,1.0,0.0);
//glTranslatef(0.0,1.0,0.0);
//move out y-axis & rotate by 90 degrees about x-axis
//glRotatef(90.0,1.0,0.0,0.0);
//glTranslatef(0.0,1.8,0.0);
//reverse previous
glTranslatef(0.0,1.8,0.0);
glRotatef(90.0,1.0,0.0,0.0);
glutWireCone(0.5,1.0,12,6);
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
//glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowPosition(100,100);
glutInitWindowSize(winWidth,winHeight);
glutCreateWindow("Perspective View of a Wireframe Cone");
init();
glutDisplayFunc(mydisplay);
glutMainLoop();
}