Sunday, September 25, 2011

Figure 14


$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
Wholesale Fleece Blankets
400950_BuddhaGroove.com-Culture Infused Living: Home Accents, Jewelry, Accessories from around the world!
400948_Culture Infused Living: Home Accents, Jewelry, and accessories from around the world. CulturalElemen
504427_Save up to 75% on batteries and accessories at Brooklyn Battery Works!
504080_10% OFF Orders of $75 or More from Journelle.com! Use Promo Code: NOV11 (Valid 11/1 - 11/30/11)
502239_Brand names, bargain prices at shoezoo.com. If you don't love your new shoes, return them for free!

400949_GaneshMall.com-Culture Infused Living: Home Accents, Jewelry, and accessories from around the world!



Figure 14
============

/*
//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
*/
// CafeWallIllusion.cpp : Defines the entry point for the console application.
//author: Cheikh Drame
//class: Research
//focus: Computer Graphics using openGL

#include "stdafx.h"
#include
#include

const int WIDTH=400, HEIGHT=400;


//this function draws 5 squares, with equal spacing specified by W
void drawSquares(int x1, int y1, int W)
{
glColor3f(0,0,0);
int x2=x1+W, y2=y1, x3=x2, y3=y2+W, x4=x1, y4=y1+W;
for(int i=0; i<5; ++i){
glVertex2i(x1, y1); glVertex2i(x2,y2); glVertex2i(x3, y3); glVertex2i(x4,y4);

x1=x2+W; x2=x1+W; x3=x2; x4=x3-W;
}
}
//this function draws an horizontal line
void drawLine(int y1)
{
glColor3ub(100,100,110);
glVertex2i(0,y1); glVertex2i(WIDTH,y1);
glVertex2i(0,y1+3); glVertex2i(WIDTH,y1+3);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0,0,0);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

glBegin(GL_QUADS);
const int W=40;
int x1=0, y1=30, x2=x1+W, y2=y1, x3=x2, y3=y2+W, x4=x1, y4=y1+W; //specification of the first square line

for(int i=0; i<3; ++i){//the loop goes for 3 times
drawSquares(x1,y1, W); drawLine(y1); //draws the first square line

x1=W/2; y1=y3; x2=x1+W; y2=y1; x3=x2; y3=y2+W; x4=x1; y4=y1+W;//specification of the second square line
drawSquares(x1,y1,W); drawLine(y1);

x1=2*(W/2); y1=y3; x2=x1+W; y2=y1; x3=x2; y3=y2+W; x4=x1; y4=y1+W;//specification of the third square line
drawSquares(x1,y1,W); drawLine(y1);

x1=W/2; y1=y3; x2=x1+W; y2=y1; x3=x2; y3=y2+W; x4=x1; y4=y1+W;//specification of the fourth square line
drawSquares(x1,y1,W); drawLine(y1);

x1=0; y1=y3; x2=x1+W; y2=y1; x3=x2; y3=y2+W; x4=x1; y4=y1+W;//this line is for the next iteration
}
glEnd();

glFlush();
}

void main(int argc, char**argv)
{
glutInit(&argc, argv);
// glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(WIDTH, HEIGHT);
glutInitWindowPosition(200,100);
glutCreateWindow("sample Prog: Points");
glClearColor(1.0,1.0,1.0,0.0);
gluOrtho2D(0.0, WIDTH, HEIGHT, 0.0);

glutDisplayFunc(display);
glutMainLoop();
}

No comments:

Post a Comment