Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <GL/glut.h>
- #include <math.h>
- #define WINDOW_HEIGHT 400
- #define WINDOW_WIDTH 400
- void keyboard(unsigned char key, int x, int y);
- void resize(GLsizei w, GLsizei h);
- void display(void);
- void house(void);
- void door(void);
- void roof(void);
- void floor(void);
- void window(void);
- void point(void);
- int main(int argc, char** argv) {
- // controla se o sistema operacional tem suporte a janelas
- glutInit(&argc, argv);
- // quantidade de buffer de cores e que padrão de cores é RGB ou RGBA
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- // tamanho da janela
- glutInitWindowSize(400, 400);
- // posicao inicial da janela
- glutInitWindowPosition(WINDOW_HEIGHT, WINDOW_WIDTH);
- // cria janela
- glutCreateWindow("GLUT Test Vinicius ---- exercicio glut");
- glutKeyboardFunc(&keyboard);
- glutReshapeFunc(&resize);
- glutDisplayFunc(display);
- glutMainLoop();
- return EXIT_SUCCESS;
- }
- void keyboard(unsigned char key, int x, int y) {
- switch (key) {
- case '\x1b':
- exit(EXIT_SUCCESS);
- break;
- }
- }
- void resize(GLsizei w, GLsizei h) {
- // evite divisao por zero
- if (h == 0)
- h = 1;
- // Especifica as dimensões do Viewport
- glViewport(0, 0, w, h);
- // inicializa os sistemas de cordernadas
- glMatrixMode(GL_PROJECTION);
- // limpa memoria
- glLoadIdentity();
- if (w <= h) {
- gluOrtho2D(0.0f, WINDOW_HEIGHT, 0.0f, WINDOW_WIDTH * h / w);
- } else {
- gluOrtho2D(0.0f, WINDOW_HEIGHT * w / h, 0.0f, WINDOW_WIDTH);
- }
- glMatrixMode(GL_MODELVIEW);
- }
- void display() {
- glMatrixMode(GL_MODELVIEW);
- // LIMPAR toda a matriz
- glLoadIdentity();
- // cor de fundo
- glClearColor(0, 0, 1, 1);
- // limpa a tela com a cor de fundo
- glClear(GL_COLOR_BUFFER_BIT);
- //centralizar plano cartesiano
- glTranslatef(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, 0);
- glBegin(GL_QUADS);
- glColor3f(255.0, 255.0, 0.0);
- glVertex2f(-100, -100);
- glVertex2f(-100, 100);
- glVertex2f(100, 100);
- glVertex2f(100, -100);
- glEnd();
- glFlush();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement