I have a 3d model rendered in opengl, navigated with a camera, viewed with an orthogonal perspective. I can't find a way to draw UI elements on top without having them distorted.
I made this simple sketch to isolate the problem:
Code:
import processing.opengl.*;
void setup() {
size(400, 400, OPENGL);
}
void draw() {
background(0);
lights();
ortho(-width, width, -height, height, -1000, 1000);
camera(30.0, mouseY, 220.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
fill(150);
box(100);
camera();
//perspective();
noLights();
hint(DISABLE_DEPTH_TEST);
fill(255,0,0);
rect(0,0,200,200);
unhint(DISABLE_DEPTH_TEST);
}
If the line 'perspective()' is uncommented, the default perspective overwrites the orthogonal, placing the red square where and how it should be, on the top left corner with a size of 200. But the orthogonal view of the model is lost.
Isn't there some simple way to maintain the orthogonal perspective and then draw on top under a different perspective?
I need to use opengl, so drawing the 3d to an out of screen buffer is not an option. I could modify pixels[], but I'd rather use a faster and simpler solution, if there is one..