Comp Graph-4
Comp Graph-4
h>
#include <math.h>
#define PI 3.14159265358979323846
#define ROWS 4
#define COLS 5
#define VIEWPORT_SIZE 150
void drawPattern() {
float size = 0.03;
float step = 0.02;
int numHexagons = 20;
glPushMatrix();
for (int i = 0; i < numHexagons; i++) {
drawHexagon(size);
size += step;
glRotatef(10, 0, 0, 1);
}
glPopMatrix();
}
void drawGrid() {
for (int row = 0; row < ROWS; row++) {
for (int col = 0; col < COLS; col++) {
// Viewport-ийг тохируулах
glViewport(col * VIEWPORT_SIZE, row * VIEWPORT_SIZE, VIEWPORT_SIZE,
VIEWPORT_SIZE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-0.25, 0.25, -0.25, 0.25);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix();
void display() {
glClear(GL_COLOR_BUFFER_BIT);
drawGrid(); // Only draw the grid
glutSwapBuffers();
}
void init() {
glClearColor(0.2, 0.5, 0.8, 1.0);
}