The next step in my project at the moment is getting smooth transitions between screens. I have watched Oscar’s video about it and I liked the idea. The only thing I want to do differently is to not fade in the actual components, but fade out an overlay of black. I have the theory down:
Call for state change
Fade out screen
Change State
Fade in screen
I have been trying to implement it but I am having trouble with glColor4f(); At the moment, I am drawing the overlay like this.
package src.longarmx.work;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
public class Overlay {
private float fade = 50;
private boolean fadein = true;
public Overlay(){
}
public void init(){
}
public void update(){
if(fadein){
if(fade < 90){
fade += 1;
}else{
fadein = false;
}
}else{
if(fade > 0){
fade -= 1;
}else{
fadein = true;
}
}
}
public void render(){
GL11.glColor4f(.5f, .75f, .75f, (float) Math.sin(Math.toRadians(fade)));
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(0, 0);
GL11.glVertex2f(Display.getWidth(), 0);
GL11.glVertex2f(Display.getWidth(), Display.getHeight());
GL11.glVertex2f(0, Display.getHeight());
GL11.glEnd();
}
}
The problem is with glColor4f(); Whenever I make the RGB all zeros, there is just a black screen. Also, whenever I make them 1.0f, The screen has transparency, but there is a hue of whatever color is drawn on the screen right before it. I have tried with glClear(GL11.GL_COLOR_BUFFER_BIT); but that just removes the transparency. I have also tried glClearColor() but I don’t know how to work it. If anyone has any idea how to do this, I would greatly appreciate it!
Thanks,
Longarmx