Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <string.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <iostream>
- #include <freeglut.h>
- float startX = -180.0f;
- float startZ = -100.0f;
- float qtyX = 36;
- float qtyZ = 20;
- float red = 0.0f, green = 0.0f, blue = 0.0f;
- void init(void)
- {
- glClearColor(0.0, 0.0, 0.0, 0.0);
- }
- void display(void)
- {
- glClear(GL_COLOR_BUFFER_BIT);
- //glColor3f(1.0, 1.0, 1.0);
- glLoadIdentity(); /* clear the matrix */
- /* viewing transformation */
- gluLookAt(0.0, 30.0f , 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0);
- for (int i = 0; i <= qtyX; i = i++)
- {
- red = 0.0f;
- for (int j = 0; j <= qtyZ; j++)
- {
- if ((i+j)%2 == 0)
- {
- blue = 0.1f;
- red = 0.1f;
- green = 0.1f;
- }
- else red = green = blue = 0.0f;
- glColor3f(red, green, blue);
- glBegin(GL_QUADS);
- glVertex3f(startX + (i * 10) - 5.0f, 0.0f, startZ + (j * 10) - 5.0f);
- glVertex3f(startX + (i * 10) + 5.0f, 0.0f, startZ + (j * 10) - 5.0f);
- glVertex3f(startX + (i * 10) + 5.0f, 0.0f, startZ + (j * 10) + 5.0f);
- glVertex3f(startX + (i * 10) - 5.0f, 0.0f, startZ + (j * 10) + 5.0f);
- glEnd();
- }
- }
- //glutWireSphere(20.0f, 20.0f, 20.0f);
- glutSwapBuffers();
- glFlush();
- }
- void reshape(int w, int h)
- {
- glViewport(0, 0, (GLsizei)w, (GLsizei)h);
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum(-64.0, 64.0, -36.0, 36.0, 10, 10000.0);
- glMatrixMode(GL_MODELVIEW);
- }
- int main(int argc, char** argv)
- {
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
- glutInitWindowSize(1280, 720);
- glutInitWindowPosition(100, 100);
- glutCreateWindow(argv[0]);
- init();
- glutDisplayFunc(display);
- glutIdleFunc(display);
- glutReshapeFunc(reshape);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement