1 | |
---|
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 | |
---|
17 | #ifndef _PLANE_RENDERER_H_ |
---|
18 | #define _PLANE_RENDERER_H_ |
---|
19 | |
---|
20 | #include <GL/glew.h> |
---|
21 | #include <Cg/cgGL.h> |
---|
22 | #include <GL/glut.h> |
---|
23 | #include <math.h> |
---|
24 | #include <stdio.h> |
---|
25 | #include <assert.h> |
---|
26 | #include <float.h> |
---|
27 | #include <vector> |
---|
28 | |
---|
29 | #include "define.h" |
---|
30 | #include "global.h" |
---|
31 | #include "TransferFunction.h" |
---|
32 | #include "Texture2D.h" |
---|
33 | |
---|
34 | using namespace std; |
---|
35 | |
---|
36 | class PlaneRenderer{ |
---|
37 | |
---|
38 | private: |
---|
39 | vector <Texture2D*> plane; // Array of volumes |
---|
40 | vector <TransferFunction*> tf; // Array of corresponding transfer functions |
---|
41 | int active_plane; // The active plane, only one is rendered |
---|
42 | int n_planes; |
---|
43 | |
---|
44 | int render_width; //render size |
---|
45 | int render_height; |
---|
46 | |
---|
47 | //cg related |
---|
48 | CGcontext g_context; // The Nvidia cg context |
---|
49 | CGprogram m_fprog; |
---|
50 | CGparameter m_data_param; |
---|
51 | CGparameter m_tf_param; |
---|
52 | CGparameter m_render_param; |
---|
53 | |
---|
54 | void init_shaders(); |
---|
55 | void activate_shader(int plane_index); |
---|
56 | void deactivate_shader(); |
---|
57 | |
---|
58 | public: |
---|
59 | PlaneRenderer(CGcontext _context, int width, int height); |
---|
60 | ~PlaneRenderer(); |
---|
61 | |
---|
62 | int add_plane(Texture2D* _p, TransferFunction* _tf); |
---|
63 | // Add a plane and its transfer function. We require a transfer function |
---|
64 | // when a plane is added. |
---|
65 | void remove_plane(int index); |
---|
66 | void set_active_plane(int index); //set the active plane to be rendered |
---|
67 | void set_screen_size(int w, int h); //change the rendering size |
---|
68 | void render(); |
---|
69 | }; |
---|
70 | |
---|
71 | #endif |
---|