Basically I am trying to draw a screen that has the same star but in different sizes. I am trying to use different sized viewports to accomplish this, but it is only drawing the star once. With the code I have now I am just trying to tile stars all the same size just as a test…
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <windows.h>
#include <GL/glut.h>
#include <GL/gl.h>
#include <fstream>
using namespace std;
void myInit(void)
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glPointSize(4.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 400, 0.0, 400);
glViewport(400,400, 800, 800);
}
void setWindow(float left, float right, float bottom, float top)
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(left, right, bottom, top);
}
void drawStar(void)
{
float x1 = 100;
float y1 = 100;
float x2 = 200;
float y2 = 400;
float x3 = 300;
float y3 = 100;
float x4 = 75;
float y4 = 300;
float x5 = 325;
float y5 = 300;
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINE_LOOP);
glVertex2i(x1,y1);
glVertex2i(x2,y2);
glVertex2i(x3,y3);
glVertex2i(x4,y4);
glVertex2i(x5,y5);
glEnd();
glFlush();
}
void myDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
setWindow(0, 400.0, 0, 500.0);
for(int i = 0; i < 9; i++) // for each column
for(int j = 0; j < 9; j++) // for each row
{
glViewport(i * 64, j * 44, 64, 44); // set the next viewport
drawStar(); // draw it again
}
glEnd();
glFlush();
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(600, 400);
glutInitWindowPosition(200, 200);
glutCreateWindow("Swag");
glutDisplayFunc(myDisplay);
myInit();
glutMainLoop();
}