1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
2 | /* |
---|
3 | * ---------------------------------------------------------------------- |
---|
4 | * PlaneRenderer.h : PlaneRenderer class for 2D visualization |
---|
5 | * |
---|
6 | * ====================================================================== |
---|
7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
9 | * |
---|
10 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
11 | * |
---|
12 | * See the file "license.terms" for information on usage and |
---|
13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
14 | * ====================================================================== |
---|
15 | */ |
---|
16 | #ifndef PLANE_RENDERER_H |
---|
17 | #define PLANE_RENDERER_H |
---|
18 | |
---|
19 | #include <math.h> |
---|
20 | #include <stdio.h> |
---|
21 | #include <assert.h> |
---|
22 | #include <float.h> |
---|
23 | |
---|
24 | #include <vector> |
---|
25 | |
---|
26 | #include <GL/glew.h> |
---|
27 | #include <Cg/cgGL.h> |
---|
28 | |
---|
29 | #include "global.h" |
---|
30 | #include "TransferFunction.h" |
---|
31 | #include "Texture2D.h" |
---|
32 | |
---|
33 | class PlaneRenderer |
---|
34 | { |
---|
35 | public: |
---|
36 | PlaneRenderer(CGcontext _context, int width, int height); |
---|
37 | |
---|
38 | ~PlaneRenderer(); |
---|
39 | |
---|
40 | int add_plane(Texture2D* _p, TransferFunction* _tf); |
---|
41 | |
---|
42 | // Add a plane and its transfer function. We require a transfer function |
---|
43 | // when a plane is added. |
---|
44 | void remove_plane(int index); |
---|
45 | |
---|
46 | void set_active_plane(int index); //set the active plane to be rendered |
---|
47 | |
---|
48 | void set_screen_size(int w, int h); //change the rendering size |
---|
49 | |
---|
50 | void render(); |
---|
51 | |
---|
52 | private: |
---|
53 | void init_shaders(); |
---|
54 | |
---|
55 | void activate_shader(int plane_index); |
---|
56 | |
---|
57 | void deactivate_shader(); |
---|
58 | |
---|
59 | std::vector<Texture2D *> _plane; // Array of volumes |
---|
60 | std::vector<TransferFunction *> _tf; // Array of corresponding transfer functions |
---|
61 | int _active_plane; // The active plane, only one is rendered |
---|
62 | int _n_planes; |
---|
63 | |
---|
64 | int _render_width; //render size |
---|
65 | int _render_height; |
---|
66 | |
---|
67 | //cg related |
---|
68 | CGcontext _g_context; // The Nvidia cg context |
---|
69 | CGprogram _fprog; |
---|
70 | CGparameter _data_param; |
---|
71 | CGparameter _tf_param; |
---|
72 | CGparameter _render_param; |
---|
73 | }; |
---|
74 | |
---|
75 | #endif |
---|