Thursday, September 29, 2011

Figure 25


$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 25
====================

/*
//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 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
*/
// Figures.cpp : Defines the entry point for the console application.
//


#include
#include

int WIDTH=400, HEIGHT=400;

void rectangle1()
{
glColor3f(1.0,0.0,0.0);

glBegin(GL_POINTS);
glRecti(10,10,100,50);
glEnd();

glFlush();
}
void rectangle2()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);

glBegin(GL_POLYGON);
glVertex2i(10,10); glVertex2i(100,10); glVertex2i(100,30); glVertex2i(10,30);
glEnd();
glFlush();
}
void rectangle3()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_QUADS);
glVertex2i(10,200); glVertex2i(110,200); glVertex2i(110,100); glVertex2i(10,100);
glEnd();

glFlush();
}
void cube()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_QUADS);
int i=20, w=WIDTH/2, j=i+w/2;
glVertex2i(i,i); glVertex2i(i+w,i); glVertex2i(i+w,i+w); glVertex2i(i,i+w);
glVertex2i(i,i); glVertex2i(i+w,i); glVertex2i(j+w,j); glVertex2i(j,j);

glVertex2i(j,j); glVertex2i(j+w,j); glVertex2i(j+w,j+w); glVertex2i(j,j+w);
glVertex2i(i,i+w); glVertex2i(i+w,i+w); glVertex2i(j+w,j+w); glVertex2i(j,j+w);
glEnd();

glFlush();
}
void cubeFill()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT, GL_FILL);


glEnable(GL_BLEND);
glBlendFunc(0x0002,0x0003);
glEnable(GL_LINE_SMOOTH);
glBegin(GL_QUADS);
int i=20, w=WIDTH/2, j=i+w/2;
glVertex2i(i,i); glVertex2i(i+w,i); glVertex2i(i+w,i+w); glVertex2i(i,i+w);
glVertex2i(i,i+w); glVertex2i(i+w,i+w); glVertex2i(j+w,j+w); glVertex2i(j,j+w);

glVertex2i(i,i); glVertex2i(i+w,i); glVertex2i(j+w,j); glVertex2i(j,j);
glVertex2i(j,j); glVertex2i(j+w,j); glVertex2i(j+w,j+w); glVertex2i(j,j+w);
//glDisable(GL_BLEND);
glEnd();

glFlush();
}
void strange1()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3ub(100,110,100);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_QUADS);
int x1=0, y1=HEIGHT, x2=WIDTH, y2=HEIGHT, x3=WIDTH, y3=0, x4=0, y4=0;
const int CONSTANT=10;
while( (x3-x4)>=20 ){
glVertex2i(x1,y1); glVertex2i(x2,y2); glVertex2i(x3,y3); glVertex2i(x4,y4);

x1+=CONSTANT; y1-=CONSTANT;
x2-=CONSTANT; y2-=CONSTANT;
x3-=CONSTANT; y3+=CONSTANT;
x4+=CONSTANT; y3+=CONSTANT;
}
glEnd();

glEnd();
glFlush();
}
void strange2()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_QUADS);
int i=20, w=WIDTH/2, j=i+w/2;
glVertex2i(i,i); glVertex2i(i+w,i); glVertex2i(i+w,i+w); glVertex2i(i,i+w);
glVertex2i(i,i); glVertex2i(i+w,i); glVertex2i(j,j); glVertex2i(j+w,j);

glVertex2i(j,j); glVertex2i(j+w,j); glVertex2i(j+w,j+w); glVertex2i(j,j+w);
glVertex2i(i,i+w); glVertex2i(i+w,i+w); glVertex2i(j,j+w); glVertex2i(j+w,j+w);
glEnd();

glFlush();
}
void triangle()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_TRIANGLES);
glVertex2i(100,HEIGHT/2); glVertex2i(50,HEIGHT/2); glVertex2i(50,10);
glEnd();

glFlush();
}
void triangle2()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_TRIANGLES);
glNormal3i(200,50,0);
glNormal3i(300,200,0);
glNormal3i(100,200,0);
glEnd();

glFlush();
}
void polygon1()
{
int v0[]={200,200}, v1[]={100,300}, v2[]={100,390}, v3[]={300,390}, v4[]={200,350};
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_POLYGON);
glVertex2iv(v0); glVertex2iv(v1); glVertex2iv(v2); glVertex2iv(v3); glVertex2iv(v4); glVertex2iv(v0);
glEnd();

glFlush();
}
void multipleFigures()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0.0, 1.0, 0.0);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glBegin(GL_QUADS);
glVertex2i(10,200); glVertex2i(110,200); glVertex2i(110,100); glVertex2i(10,100);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2i(100,HEIGHT/2); glVertex2i(50,HEIGHT/2); glVertex2i(50,10);
glEnd();

glFlush();
}

void main(int argc, char**argv)
{
glutInit(&argc, argv);
// glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGBA);
glutInitWindowSize(WIDTH,HEIGHT);
glutInitWindowPosition(200,100);
glutCreateWindow("sample Prog: Figures by irap123.com");
glClearColor(0.0,0.0,0.0,0.0);
gluOrtho2D(0, WIDTH, HEIGHT, 0);
glutDisplayFunc(strange2);
glutMainLoop();
}

No comments:

Post a Comment