All pastes #613140 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-10 20:41 UTC
rendered paste body
#include <iostream>
#include <windows.h>
#include <GL/gl.h>
#include <glut.h>

using std::cin;
using std::cout;
using std::endl;
void init (void) {
	glClearColor(0,0,0,0);
	gluPerspective(60,1,.1,1000);
	gluLookAt(2.0,2.0,2.0
		,0,0,0,
		-1,1,0);//up vector
}
void myDisplay(void){
	cout<<"Hello";
	
	glClear(GL_COLOR_BUFFER_BIT);
	glBegin(GL_LINES);
	//first box
		glColor3f(1.0,0,0);
		glVertex3f(0,0,0);
		glVertex3f(0.5,0,0);

		glColor3f(1,0,0);
		glVertex3f(0,0,0);
		glVertex3f(0,0.5,0);

		glColor3f(1,0,0);
		glVertex3f(0.5,0,0);
		glVertex3f(0.5,0.5,0);

		glColor3f(1,0,0);
		glVertex3f(0,0.5,0);
		glVertex3f(0.5,0.5,0);



	glEnd();
	const double box2off = 0.2;
	glBegin(GL_LINES);
		//connecting lines

		glColor3f(1,0,0);
		glVertex3f(0,0.5,0);
		glVertex3f(box2off,box2off+0.5,0);

		glColor3f(1,0,0);
		glVertex3f(0.5,0,0);
		glVertex3f(box2off+0.5,box2off,0);

		glColor3f(1,0,0);
		glVertex3f(0,0,0);
		glVertex3f(box2off,box2off,0);

		glColor3f(1,0,0);
		glVertex3f(0.5,0.5,0);
		glVertex3f(box2off+0.5, box2off+0.5,0);

	glEnd;
	glBegin(GL_LINES);



	//second box
		glColor3f(1.0,0,0);
		glVertex3f(box2off,box2off,0);
		glVertex3f(box2off + 0.5,box2off,0);

		glColor3f(1,0,0);
		glVertex3f(box2off,box2off,0);
		glVertex3f(box2off,box2off+0.5,0);

		glColor3f(1,0,0);
		glVertex3f(box2off+0.5,box2off,0);
		glVertex3f(box2off+0.5,box2off+0.5,0);

		glColor3f(1,0,0);
		glVertex3f(box2off, box2off+0.5,0);
		glVertex3f(box2off+0.5,box2off+0.5,0);

	glEnd();
	glutSwapBuffers();
}
void key(unsigned char k, int x, int y) {
cout<<"key pressed "<<k<<" "<<x<<" "<<y<<endl;
}
void mouse (int button, int state, int x, int y) {
cout <<"Mouse "<<state<<" "<<x<<" "<<y;
}
int main (int argc, char* argv[]) {
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
	glutInitWindowSize(500,500);
	glutInitWindowPosition(100,100);
	glutCreateWindow("My First Glut Application");
	init();
	glutDisplayFunc(myDisplay);
	glutKeyboardFunc(key);
	glutMouseFunc(mouse);
	glutMainLoop();
	cin.ignore();
	return 0;
}