glviewvol

view src/renderer.cc @ 15:2a67ea257ac0

makefile fixes for macosx
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 06 Feb 2015 23:47:28 +0200
parents 89efc666105c
children
line source
1 /*
2 glviewvol is an OpenGL 3D volume data viewer
3 Copyright (C) 2014 John Tsiombikas <nuclear@member.fsf.org>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #include <math.h>
19 #include "renderer.h"
21 Renderer::Renderer()
22 {
23 vol = 0;
24 view_width = 512;
25 view_height = 512;
27 for(int i=0; i<MAX_CLIP_PLANES; i++) {
28 disable_clipping_plane(i);
29 }
31 zscale = 1.0;
32 }
34 Renderer::~Renderer()
35 {
36 destroy();
37 }
39 bool Renderer::init()
40 {
41 return true;
42 }
44 void Renderer::destroy()
45 {
46 }
48 void Renderer::set_volume(Volume *vol)
49 {
50 this->vol = vol;
51 }
53 Volume *Renderer::get_volume() const
54 {
55 return vol;
56 }
58 void Renderer::set_zscale(float zs)
59 {
60 zscale = zs;
61 }
63 float Renderer::get_zscale() const
64 {
65 return zscale;
66 }
68 void Renderer::set_transfer_function(TransferFunc *xfer)
69 {
70 this->xfer = xfer;
71 }
73 TransferFunc *Renderer::get_transfer_function() const
74 {
75 return xfer;
76 }
78 void Renderer::set_clipping_plane(int idx, float nx, float ny, float nz, float dist)
79 {
80 float len = sqrt(nx * nx + ny * ny + nz * nz);
81 if(len != 0.0) {
82 nx /= len;
83 ny /= len;
84 nz /= len;
85 }
86 clip_plane[idx][0] = nx;
87 clip_plane[idx][1] = ny;
88 clip_plane[idx][2] = nz;
89 clip_plane[idx][3] = dist;
90 }
92 void Renderer::disable_clipping_plane(int idx)
93 {
94 clip_plane[idx][0] = clip_plane[idx][2] = 0;
95 clip_plane[idx][1] = 1;
96 clip_plane[idx][3] = -1;
97 }
99 void Renderer::reshape(int x, int y)
100 {
101 view_width = x;
102 view_height = y;
103 }
105 void Renderer::update(unsigned int msec)
106 {
107 }