/**
* This program renders 2 dimensional boxes that iterate
* over x and y
*/
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>
#include <iostream>
using namespace std;
#define LIMIT 20.0 // limit
#define CENTER (LIMIT - LIMIT - 1)
// prototype
void setup(); // initialization of the program
void display(); // drawing method
void createCoordinate(); // certasian coordinate
void draw(); // draw the object
void setup(){
glClearColor(1.0, 1.0, 1.0, 1.0);
gluOrtho2D(CENTER, LIMIT, CENTER, LIMIT); // -x1, x2, -y1, y2
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
draw();
createCoordinate();
glFlush();
}
void draw(){
int i = 1, k = 1;
#include <GL/glu.h>
#include <GL/glut.h>
#include <iostream>
using namespace std;
#define LIMIT 20.0 // limit
#define CENTER (LIMIT - LIMIT - 1)
// prototype
void setup(); // initialization of the program
void display(); // drawing method
void createCoordinate(); // certasian coordinate
void draw(); // draw the object
void setup(){
glClearColor(1.0, 1.0, 1.0, 1.0);
gluOrtho2D(CENTER, LIMIT, CENTER, LIMIT); // -x1, x2, -y1, y2
}
void display(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0.0, 0.0);
draw();
createCoordinate();
glFlush();
}
void draw(){
int i = 1, k = 1;
// vertical multiplier
for(k=1;k<=12;k++){
float y = k * 2;
for(k=1;k<=12;k++){
float y = k * 2;
// horizontal multiplier
for(i=1; i<= 15; i++){
float x = i * 2;
float width = 1, height = 1;
glBegin(GL_POLYGON);
glVertex2f(x-1, y); // bottom left
glVertex2f(x-1, y+height); // top left
glVertex2f(x, y+height); // top right
glVertex2f(x, y); // bottom right
glEnd();
}
}
}
void createCoordinate(){
glBegin(GL_LINES);
// horizontal lines
glVertex2f(-LIMIT, 0.0);
glVertex2f(LIMIT, 0.0);
// vertical lines
glVertex2f(0.0, -LIMIT);
glVertex2f(0.0, LIMIT);
glEnd();
}
int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(200, 100);
glutInitWindowSize(400, 300);
glutCreateWindow("Hello World");
glutDisplayFunc(display);
setup();
glutMainLoop();
return 0;
}
for(i=1; i<= 15; i++){
float x = i * 2;
float width = 1, height = 1;
glBegin(GL_POLYGON);
glVertex2f(x-1, y); // bottom left
glVertex2f(x-1, y+height); // top left
glVertex2f(x, y+height); // top right
glVertex2f(x, y); // bottom right
glEnd();
}
}
}
void createCoordinate(){
glBegin(GL_LINES);
// horizontal lines
glVertex2f(-LIMIT, 0.0);
glVertex2f(LIMIT, 0.0);
// vertical lines
glVertex2f(0.0, -LIMIT);
glVertex2f(0.0, LIMIT);
glEnd();
}
int main(int argc, char *argv[]){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(200, 100);
glutInitWindowSize(400, 300);
glutCreateWindow("Hello World");
glutDisplayFunc(display);
setup();
glutMainLoop();
return 0;
}
No comments:
Post a Comment