foo
[laserbrain_demo] / src / ui_exhibit.cc
index dd09678..9b42c45 100644 (file)
@@ -50,7 +50,7 @@ bool exui_init()
        ui_width = ui_height * aspect;
 
        rtarg = new RenderTarget;
-       if(!rtarg->create(ui_width, ui_height, GL_RGB)) {
+       if(!rtarg->create(ui_width, ui_height, GL_RGBA)) {
                error_log("failed to create exui render target\n");
                return false;
        }
@@ -116,7 +116,8 @@ static void draw_2d_ui()
        glMatrixMode(GL_PROJECTION);
        glPushMatrix();
        glLoadIdentity();
-       glOrtho(0, ui_width, 0, ui_height, -1, 1);
+       glTranslatef(-1, 1, 0);
+       glScalef(2.0 / ui_width, -2.0 / ui_height, 1);
 
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
@@ -161,10 +162,25 @@ void exui_draw()
        // place UI image into the scene
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
+
+       Mat4 mvmat;
+       glGetFloatv(GL_MODELVIEW_MATRIX, mvmat[0]);
+
+       /*
        if(parent) {
                glMultMatrixf(parent->get_matrix()[0]);
        }
        glTranslatef(pos.x, pos.y, pos.z);
+       */
+       if(parent) {
+               mvmat = parent->get_matrix() * mvmat;
+       }
+       mvmat.translate(pos.x, pos.y, pos.z);
+
+       mvmat[0][0] = mvmat[1][1] = mvmat[2][2] = 1.0f;
+       mvmat[0][1] = mvmat[0][2] = mvmat[1][0] = mvmat[2][0] = mvmat[1][2] = mvmat[2][1] = 0.0f;
+
+       glLoadMatrixf(mvmat[0]);
 
        glPushAttrib(GL_ENABLE_BIT);
        glEnable(GL_BLEND);