Here's an example for desktop jPCT:
import java.awt.Color;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.GLSLShader;
import com.threed.jpct.IRenderer;
import com.threed.jpct.Loader;
import com.threed.jpct.Texture;
import com.threed.jpct.World;
public class RTT
{
private World world;
private FrameBuffer buffer;
public static void main(String[] args)
throws Exception
{
new RTT().loop();
}
private void loop()
throws Exception
{
buffer = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
world = new World();
Texture t = new Texture("d.png");
Texture t1 = new Texture(512, 512);
Texture t2 = new Texture(512, 512);
GLSLShader shady = new GLSLShader(Loader.loadTextFile("vertex.glsl"), Loader.loadTextFile("fragment.glsl"));
shady.setUniform("colorMap", 0);
while (!org.lwjgl.opengl.Display.isCloseRequested())
{
buffer.setRenderTarget(t1);
buffer.setVirtualDimensions(buffer.getWidth(), buffer.getHeight());
buffer.clear(Color.BLUE);
world.renderScene(buffer);
world.draw(buffer);
buffer.blit(t, 0, 0, 0, 0, t.getWidth(), t.getHeight(), buffer.getWidth(), buffer.getHeight(), -1, false);
display();
buffer.removeRenderTarget();
buffer.setRenderTarget(t2);
buffer.setBlittingShader(shady);
buffer.blit(t1, 0, 0, 0, 0, t1.getWidth(), t1.getHeight(), buffer.getWidth(), buffer.getHeight(), -1, false);
display();
buffer.removeRenderTarget();
buffer.setBlittingShader(null);
buffer.blit(t2, 0, 0, 0, 0, t1.getWidth(), t1.getHeight(), buffer.getWidth(), buffer.getHeight(), -1, false);
display();
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.dispose();
System.exit(0);
}
public void display()
{
buffer.update();
buffer.displayGLOnly();
}
}
Vertex shader
varying vec2 texCoord;
void main(void)
{
gl_Position = ftransform();
texCoord = gl_MultiTexCoord0.xy;
}
Fragment shader
varying vec2 texCoord;
uniform sampler2D colorMap;
void main (void)
{
vec4 base = texture2D(colorMap, texCoord);
gl_FragColor = vec4(base.r*2.0,0.0,base.g,base.a);
}
What this basically does, is to blit a texture into a render target, set a blitting shader that eliminates green and boosts red and blit the first target texture into a second one using that shader. It then displays the result by blitting the second target onto the screen.