I'm in a graphics coding class and as a beginner, I am having an issue with the loops and other things needed in order to split the screen four ways and put the images inside. The prompt is as follows :
"Write a program in C++ that will display the image subdivided into four colored sections as seen on the right. Teal on the top left, yellow on the top right, white on the bottom left and purple on the bottom right.
In the white square draw a filled yellow circle.
In the teal square draw a Lissajou curve with parameters ωx=5, ωy=6 or ratio=5/6.
In the yellow square draw a Lissajou curve with parameters ωx=3, ωy=5 or ratio=3/5.
In the purple square draw a Lissajou curve with parameters ωx=7, ωy=4 or ratio=7/4.
Select some contrasting colors so that the curves are visible.
Implement the background coloring and Lissajous curves using parameterized functions FillRectangle(); and DrawLissajou(); (so that each of the squares will be calling the same FillRectangle(); using a different set of parameters);"
I think I only have to edit after CalcImage(); but I am still unsure!
/*********************************
Some OpenGL-related functions
**********************************/
//called when a window is reshaped
void Reshape(int w, int h)
{
glViewport(0,0,w, h);
glEnable(GL_DEPTH_TEST);
//remember the settings for the camera
wWindow=w;
hWindow=h;
}
void Kbd(unsigned char a, int x, int y)//keyboard callback
{
switch(a)
{
case 27 : exit(0);break;
}
glutPostRedisplay();
}
void SetPixel(int x, int y, unsigned char red, unsigned char green, unsigned char blue) {
if ((x < 0) || (x > MAX) || (y < 0) || (y > MAX))
{
cout << "Pixel coordinates are out of range for the image size!" << x << " " << y << endl;
return;
}
image[x][y][0] = red;
image[x][y][1] = green;
image[x][y][2] = blue;
}
//this is the function you need to edit
void CalcImage() {
cerr << "tst";
for (int i = 0; i < MAX; i++) {
//white line
SetPixel(i,i,255,255,255);
//red line
SetPixel(i, MAX - i - 1, 255, 0, 0);
//blue line
SetPixel(i, MAX / 2, 0, 0, 255);
//yellow line
SetPixel(MAX / 2, i, 255, 255, 0);
}
for (float t = 0; t < 2 * 3.14; t += 0.01)
SetPixel(MAX / 2 + MAX / 2 * sin(t), MAX / 2 + MAX / 2 * cos(t), 255, 255, 255);
}