Skip to content

Instantly share code, notes, and snippets.

@georgelima
Created May 15, 2018 18:53
Show Gist options
  • Save georgelima/8e75e461df703823994e124371b2d397 to your computer and use it in GitHub Desktop.
Save georgelima/8e75e461df703823994e124371b2d397 to your computer and use it in GitHub Desktop.
casa
#include <stdio.h>
#include <GL/glut.h>
#include <stdlib.h>
#include <math.h>
#define t 640
#define sz 4
#define l 20
void init(void) {
glClearColor(0.0, 0.8, 0.8, 1.0);
glOrtho(0, 256, 0, 256, -1, 1);
}
void drawFilledCircle(GLfloat x, GLfloat y, GLfloat radius){
int i;
int triangleAmount = 20;
GLfloat twicePi = 2.0f * 3.1415f;
glBegin(GL_TRIANGLE_FAN);
glVertex2f(x, y); // center of circle
for(i = 0; i <= triangleAmount;i++) {
glVertex2f(
x + (radius * cos(i * twicePi / triangleAmount)),
y + (radius * sin(i * twicePi / triangleAmount))
);
}
glEnd();
}
void display(void) {
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(10, 10);
glVertex2i(10, 100);
glVertex2i(80, 100);
glVertex2i(80, 10);
glEnd();
glColor3f(0.0,1.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(30, 10);
glVertex2i(30, 60);
glVertex2i(60, 60);
glVertex2i(60, 10);
glEnd();
glColor3f(0.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2i(10, 100);
glVertex2i(45, 160);
glVertex2i(80, 100);
glEnd();
glColor3f(1.0,0.0,1.0);
glBegin(GL_POLYGON);
glVertex2i(80, 100);
glVertex2i(45, 160);
glVertex2i(170, 160);
glVertex2i(200, 100);
glEnd();
glColor3f(0.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex2i(80, 10);
glVertex2i(200, 10);
glVertex2i(200, 100);
glVertex2i(80, 100);
glEnd();
glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
glVertex2i(120, 40);
glVertex2i(120, 80);
glVertex2i(170, 80);
glVertex2i(170, 40);
glEnd();
glColor3f(1.0,1.0,0.0);
drawFilledCircle(200.0, 200.0, 25.0);
glutSwapBuffers();
}
int main(int argc, char** argv){
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(t, t);
glutInitWindowPosition(100,100);
glutCreateWindow("House");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment