Hi Guys,
I am making a 2D minecraft sort of game and all has gone well so far, but I’m stumped on something and am unable to find an answer online.
I first draw night sky image and then a day sky image on top of the night image. I then have a Sun class that returns a light level as a float which I then use to control the opacity of the night image so that it fades to night time which works fine.
The problem is that the rest of my world, ie the trees, grass, player etc still looks the same even at night. Blending is enabled in my Game class and below is what I tried but I just get a black screen. I have tried multiple blending modes to try to achieve a sort of multiply effect but nothing is working.
// Draw the overlay after everything else is drawn
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glBegin(GL_QUADS);
glColor3f(1.0f * light, 1.0f * light, 1.0f * light);
glVertex2f(0,0);
glVertex2f(Game.getWidth(),0);
glVertex2f(Game.getWidth(),Game.getHeight());
glVertex2f(0,Game.getHeight());
glEnd();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
I should mention that my default blend function is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and I would be grateful for some direction. I have tried reading about blend modes and I understand the concept but I can’t seem to get what I am looking for. I simply want to slowly darken what is already on the screen.