source: trunk/vizservers/nanovis/NvColorTableRenderer.cpp @ 854

Last change on this file since 854 was 854, checked in by vrinside, 17 years ago

Fixed glPushMatrix/glPopMatrix calls

File size: 1.7 KB
Line 
1#include <R2/R2Fonts.h>
2#include "NvColorTableRenderer.h"
3#include <stdlib.h>
4
5NvColorTableRenderer::NvColorTableRenderer()
6: _fonts(NULL)
7{
8    _shader = new NvColorTableShader();   
9}
10
11NvColorTableRenderer::~NvColorTableRenderer()
12{
13    delete _shader;
14}
15
16void NvColorTableRenderer::render(int width, int height, Texture2D* texture, TransferFunction* tf, double rangeMin, double rangeMax)
17{
18    glEnable(GL_TEXTURE_2D);
19    glEnable(GL_BLEND);
20
21    glViewport(0, 0, width, height);
22
23    glMatrixMode(GL_PROJECTION);
24    glPushMatrix();
25    glLoadIdentity();
26    gluOrtho2D(0, width, 0, height);
27
28    glMatrixMode(GL_MODELVIEW);
29    glPushMatrix();
30    glLoadIdentity();
31
32    //glColor3f(1.,1.,1.);         //MUST HAVE THIS LINE!!!
33    _shader->bind(texture, tf);
34
35    glBegin(GL_QUADS);
36    glTexCoord2f(0, 0); glVertex2f(30, 30);
37    glTexCoord2f(1, 0); glVertex2f(width - 30, 30);
38    glTexCoord2f(1, 1); glVertex2f(width - 30, 60);
39    glTexCoord2f(0, 1); glVertex2f(30, 60);
40    glEnd();
41
42    _shader->unbind();
43
44    if (_fonts)
45    {
46        _fonts->resize(width, height);
47        _fonts->begin();
48
49        glPushMatrix();
50            glTranslatef(width - 110, 5, 0.0f);
51            _fonts->draw("Quantum dot lab - www.nanohub.org");
52        glPopMatrix();
53
54        glPushMatrix();
55            glTranslatef(30, height - 25, 0.0f);
56            _fonts->draw("%.08lf", rangeMin);
57        glPopMatrix();
58
59        glPushMatrix();
60            glTranslatef(width - 110, height - 25, 0.0f);
61            _fonts->draw("%.08lf", rangeMax);
62        glPopMatrix();
63
64        _fonts->end();
65    }
66
67    glMatrixMode(GL_PROJECTION);
68    glPopMatrix();
69    glMatrixMode(GL_MODELVIEW);
70    glPopMatrix();
71}
Note: See TracBrowser for help on using the repository browser.