im trying to change the color of the sky after the sunset behind the hill
this is the view of the compiled code:
#include<stdio.h>
#include<windows.h>
#include<GL/glut.h>
#include <GL/gl.h>
#include <stdlib.h>
#define SPEED 50.0
float i=0.0,m=0.0,n=0.0,o=0.0,c=0.0,b=0.0,xm=900;
//float p=0.75,q=0.47,r=0.14;
//float e=0.90,f=0.91,g=0.98;
//int day;
void draw_pixel(GLint x, GLint y)
{
glBegin(GL_POINTS);
glVertex2i(x,y);
glEnd();
}
void plotpixels(GLint h,GLint k, GLint x,GLint y)
{
draw_pixel(x+h,y+k);
draw_pixel(-x+h,y+k);
draw_pixel(x+h,-y+k);
draw_pixel(-x+h,-y+k);
draw_pixel(y+h,x+k);
draw_pixel(-y+h,x+k);
draw_pixel(y+h,-x+k);
draw_pixel(-y+h,-x+k);
}
void draw_circle(GLint h, GLint k, GLint r)
{
int d=1-r, x=0, y=r;
while(x<=y)
{
plotpixels(h,k,x,y);
if(d<0) d+=2*x+3;
else
{
d+=2*(x-y)+5;
y--;
}
x++;
}
plotpixels(h,k,x,y);
}
void draw_object()
{
int l;
glColor3f(0.30,0.0,0 );
//glColor3f(0.0,0.0,0.0);
glBegin(GL_POLYGON);
//glColor3f(0.0,0.0,0.0);
glVertex2f(0,160);
//glColor3f(0.5,0,0);
glColor3f(0.0,0.0,0.0);
glVertex2f(0,700+m);
glColor3f(0.0,0.0,0.0);
glVertex2f(1100,700);
glColor3f(0.0,0.0,0.0);
glVertex2f(1100,160);
glEnd();
//sun
for(l=0;l<=85;l++)
{
glColor3f(0.6,0,0.1);
draw_circle(570,625-m,l);
}
/*
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 0.0f);
glutWireSphere(0.5f, 50, 60);
glutSwapBuffers();
*/
//Ground
glColor3f(0.0,0.3,0.0);
glBegin(GL_POLYGON);
glVertex2f(0,0);
glVertex2f(0,165);
glVertex2f(250,250);
glColor3f(0,0,0);
glVertex2f(450,220);
glVertex2f(650,225);
glVertex2f(850,250);
glVertex2f(1100,165);
glVertex2f(1100,0);
glEnd();
//Hill
glColor3f(0.59,0.29,0.0);
glBegin(GL_POLYGON);
glVertex2f(450,220);
glVertex2f(470,285);
//glColor3f(0.0,0.0,0.0);
glVertex2f(500,350);
glColor3f(0.7,0.3,0);
glColor3f(0.0,0.0,0.0);
glVertex2f(570,415);
glColor3f(0.0,0.0,0.0);
glVertex2f(620,370);
glColor3f(0.0,0.0,0.0);
glVertex2f(645,295);
glVertex2f(700,225);
glEnd();
//star
//cloud2
glFlush();
}
void idle()
{
if(i>=0 && i<=1150)
{
i+=SPEED/50;
m+=SPEED/80;
b+=SPEED/150;
n+=SPEED/200;
}
glutPostRedisplay(); //glutPostRedisplay marks the current window as needing to be redisplayed.
}
void myinit()
{
glClearColor(0.9,0.5,0,0);
glColor3f(176,58,46);
glPointSize(2.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0,1100.0,0.0,700.0);
}
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
draw_object();
glutSwapBuffers( );
}
int main(int argc,char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB);
glutInitWindowSize(1100,700);
glutInitWindowPosition(0,0);
glutCreateWindow("Simple Village");
glutDisplayFunc(display);
glutIdleFunc(idle); //glutIdleFunc sets the global idle callback to be func so a GLUT program can perform background processing tasks or continuous animation when window system events are not being received.
myinit();
glutMainLoop();
return 0;
}