#include <stdio.h> #include <conio.h> #include <iostream.h> #include <stdlib.h> #include <glut.h> #define WINW 800 #define WINL 600 float xmap(int x) { float halfw,fx; halfw = (float)WINW/2; fx = (x)/halfw; return fx; } float ymap(int y) { float halfy,fy; halfy = (float)WINL/2; fy = (y)/halfy; return fy; } void setup() { glClearColor(0.0f,0.0f,0.0f,0.0f); glClear(GL_COLOR_BUFFER_BIT); glutSwapBuffers(); } void display() { int i; for(i=1;i<=3;i++) { glBegin(GL_LINE_STRIP); glColor3f(1.0f,1.0f,1.0f); glVertex3f(xmap(0),ymap(0),0.0f); glVertex3f(xmap(0),ymap(100),0.0f); glVertex3f(xmap(50),ymap(100),0.0f); glVertex3f(xmap(50),ymap(0),0.0f); glVertex3f(xmap(150),ymap(0),0.0f); glEnd(); glutSwapBuffers(); glTranslatef(xmap(150),0.0f,0.0f); } } int main(int argc,char * argv[]) { glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutInitWindowSize(WINW,WINL); glutCreateWindow("123techguide.blogspot.com"); setup(); glutDisplayFunc(display); glutMainLoop(); getch(); return 0; }