tumvispainter.cpp 1.42 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include "tumvispainter.h"
#include "tgt/camera.h"
#include "tgt/quadric.h"

namespace TUMVis {
    const std::string TumVisPainter::loggerCat_ = "TUMVis.core.TumVisPainter";

    TumVisPainter::TumVisPainter(tgt::GLCanvas* canvas)
        : tgt::Painter(canvas) {
    }

    void TumVisPainter::paint() {
        // Put TUMVis rendering pipeline evaluation inside

        // Some Dummy rendering:
        glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);  
        getCamera()->look();  
        glColor3f(1.f, 0.f, 0.f);  
schultezub's avatar
schultezub committed
19
        tgt::Sphere sphere(_size, 64, 32);  
schultezub's avatar
schultezub committed
20
21
22
23
24
25
26
27
        sphere.render();  
    }

    void TumVisPainter::sizeChanged(const tgt::ivec2& size) {
        if (getCanvas()) {
            getCanvas()->getGLFocus();
        }
        glViewport(0, 0, size.x, size.y);
schultezub's avatar
schultezub committed
28
        getCamera()->setRatio((float) size.x/size.y);
schultezub's avatar
schultezub committed
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
    }

    void TumVisPainter::init() {
        if (getCanvas()) {
            getCanvas()->getGLFocus();
        }
        else {
            LWARNING("initialize(): No canvas");
        }

        glEnable(GL_DEPTH_TEST);  
        glShadeModel(GL_SMOOTH);  
        glEnable(GL_COLOR_MATERIAL);  
        glEnable(GL_LIGHTING);  
        glEnable(GL_LIGHT0);  

        getCamera()->setPosition(tgt::vec3(0.f,0.f,2.f)); 

/*


        glEnable(GL_DEPTH_TEST);
        glDepthFunc(GL_LESS);
        glDisable(GL_CULL_FACE);
        glCullFace(GL_BACK);*/
    }
}