tumvispainter.cpp 1.52 KB
Newer Older
schultezub's avatar
schultezub committed
1
#include "tumvispainter.h"
2
#include "tgt/assert.h"
schultezub's avatar
schultezub committed
3
4
5
6
7
8
9
#include "tgt/camera.h"
#include "tgt/quadric.h"

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

    TumVisPainter::TumVisPainter(tgt::GLCanvas* canvas)
10
11
12
        : tgt::Painter(canvas)
    {
        tgtAssert(getCanvas() != 0, "The given canvas must not be 0!");
schultezub's avatar
schultezub committed
13
14
15
16
17
18
19
20
21
    }

    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);  
22
        tgt::Sphere sphere(.5f, 64, 32);  
schultezub's avatar
schultezub committed
23
24
25
26
27
28
29
30
        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
31
        getCamera()->setRatio((float) size.x/size.y);
schultezub's avatar
schultezub committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
    }

    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);*/
    }
}