Skip to content

Instantly share code, notes, and snippets.

@BrunoAlmeidaKotesky
Last active September 6, 2022 19:37
Show Gist options
  • Save BrunoAlmeidaKotesky/533f07aae4302494c73017bc99700d44 to your computer and use it in GitHub Desktop.
Save BrunoAlmeidaKotesky/533f07aae4302494c73017bc99700d44 to your computer and use it in GitHub Desktop.
//use OpenGL library for drawing a simple red house.
#include <GL/glut.h> // GLUT, includes glu.h and gl.h
#include <stdlib.h>
#include <stdio.h>
// Initialize OpenGL Graphics
void init()
{
// Define a cor de fundo da janela
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Limpa a janeja
glClear(GL_COLOR_BUFFER_BIT);
}
void drawHouse() {
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 0.0f, -1.0f);
glVertex3f(1.0f, 0.0f, -1.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
glEnd();
glBegin(GL_TRIANGLES);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 0.0f, 0.0f);
glVertex3f(0.0f, 1.0f, 0.0f);
glEnd();
glFlush();
}
// Draw a house using the current transformation
int main(int argc, char *argv[]) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowPosition(800, 600);
glutInitWindowSize(800, 600);
glutCreateWindow("Casa");
init();
// Definição da função de callback
glutDisplayFunc(drawHouse);
glutMainLoop();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment