$40 off Craftsman 5 Drawer Homeowner Tool Center with Riser and Parts Bins $99.99 on sale 10/2-10/8
Sears Deal of the Day: Thule Car Top Carrier, Quest

Figure 13
Note: The square figure keeps blinking (appearing and disappearing) in rotation
======================
/*
//Author: Cheikh Drame
//To support, please do one of the following
//- Visit irap123.com many times a day
//- Join irap123.com
//- Buy my app irap123 (rhyming dictionary) available for android, and iphone. On windows phone, it is called iLyrics. If you not you can get the desktop version at www.irap123.com/apps/webstore/
//- Include irap123.com in your blogs, forums, facebook walls, email footers, comments
//- send a donation at my paypal address at cbdsigned.vevo@gmail.com
//- Buy a story at http://shop.pparzygnat.com
*/
// 3Dexample.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
GLfloat x,y,z=-2.0, dz=0.02, theta=0, dt=0.2, p=3.141593/180;
void display()
{
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glColor3f(1,0,0);//red
// glEnable(GL_CULL_FACE);
// glCullFace(GL_FRONT);
glBegin(GL_POLYGON);
glVertex3f(-1, 0, 2);
glVertex3f(1, -0.5, -4);
glVertex3f(0.8, 1.25, -6);
glEnd();
x=cos(theta*p);
y=sin(theta*p);
glColor3f(0,1,0);
glBegin(GL_POLYGON);
glVertex3f(x,y,z);
glVertex3f(-y,x,z);
glVertex3f(-x,-y,z);
glVertex3f(y,-x,z);
glEnd();
glutSwapBuffers();
glFlush();
}
void idle()
{
if(dz<0 && z<=-5.5 || dz>0 && z>=-0.6) dz=-dz;//chage direction at ends
z+=dz;
theta=(theta<360)?theta+dt:dt;
glutPostRedisplay();
}
void main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB|GLUT_DEPTH|GLUT_DOUBLE);
glutInitWindowSize(512,512);
glutInitWindowPosition(250,200);
glutCreateWindow("Double buffer animation");
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-2,2,-2,2); //0.5,6);
glEnable(GL_DEPTH_TEST);
glutDisplayFunc(display);
glutIdleFunc(idle);
glutMainLoop();
}
No comments:
Post a Comment