All pastes #567132 Raw Edit

OpenGL coo

public text v1 · immutable
·published 2007-06-14 19:59 UTC
rendered paste body
#define WINDOW_HEIGHT 600
#define WINDOW_LENGTH 700

#include <iostream>
#include <string>
#include <cmath>
#include <glut.h>
using namespace std;

void init();
void drawboard();
void drawCircle(float x, float y);
void keyb(unsigned char key, int x, int y);

int main(int argc, char** argv)
{
	glutInit(&argc, argv);
	glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
	glutInitWindowSize(WINDOW_LENGTH, WINDOW_HEIGHT);
	glutCreateWindow("SUPER AWESOME CONNECT 4 GAME");
	glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
	glutDisplayFunc(drawboard);
	glutKeyboardFunc(keyb);

	glutMainLoop();

	return 0;
}

void drawboard() {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glColor3f(1.0f, 1.0f, 0.0f);
glRectf(-1.0f, 1.0f, 1.0f, -1.0f);
	
	glColor3f(0.0f, 0.0f, 0.0f);
	drawCircle(0,0);

	glutSwapBuffers();
}

void drawCircle(float x, float y)
{
	int i;
	int sections = 50; //number of triangles to use to estimate a circle
                      // (a higher number yields a more perfect circle)
	GLfloat radius = 0.07142f; //radius
	GLfloat twoPi = 2.0f * 3.14159f;

	glBegin(GL_TRIANGLE_FAN);
		glVertex2f(x, y); // origin
		for(i = 0; i <= sections;i++) { // make $section number of circles
			glVertex2f(radius * cos(i *  twoPi / sections), radius* sin(i * twoPi / sections));
		}
   glEnd();
}

void keyb(unsigned char key, int x, int y){
  cout << "Pressed key " << key << " on coordinates (" << x << "," << y << ")";
  cout << endl;
}