source: trunk/packages/vizservers/nanovis/NvZincBlendeVolumeShader.h @ 2849

Last change on this file since 2849 was 2844, checked in by ldelgass, 12 years ago

Cleanups, no functional changes

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2#ifndef NV_ZINCBLENDE_SHADER_H
3#define NV_ZINCBLENDE_SHADER_H
4
5#include "ZincBlendeVolume.h"
6#include "NvVolumeShader.h"
7
8class NvZincBlendeVolumeShader : public NvVolumeShader
9{
10public :
11    NvZincBlendeVolumeShader();
12
13    ~NvZincBlendeVolumeShader();
14
15    void bind(unsigned int tfID, Volume *volume, int sliceMode);
16
17    void unbind();
18
19private :
20    void init();
21
22    CGparameter _tfParam;
23    CGparameter _volumeAParam;
24    CGparameter _volumeBParam;
25    CGparameter _cellSizeParam;
26    CGparameter _mviParam;
27    CGparameter _renderParam;
28    CGparameter _option_one_volume_param;
29};
30
31inline void NvZincBlendeVolumeShader::bind(unsigned int tfID, Volume *volume, int sliceMode)
32{
33    ZincBlendeVolume *vol = (ZincBlendeVolume *)volume;
34    cgGLSetStateMatrixParameter(_mviParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
35    cgGLSetTextureParameter(_tfParam, tfID);
36    cgGLSetParameter4f(_cellSizeParam, vol->cell_size.x, vol->cell_size.y, vol->cell_size.z, 0.);
37
38    if (!sliceMode) {
39        cgGLSetParameter4f(_renderParam,
40                           vol->n_slices(),
41                           vol->opacity_scale(),
42                           vol->diffuse(),
43                           vol->specular());
44    } else {
45        cgGLSetParameter4f(_renderParam,
46                           0.,
47                           vol->opacity_scale(),
48                           vol->diffuse(),
49                           vol->specular());
50    }
51
52    cgGLSetParameter4f(_option_one_volume_param,
53                       0.0f,
54                       volume->isosurface(),
55                       0.0f,
56                       0.0f);
57
58    cgGLSetTextureParameter(_volumeAParam, vol->zincblende_tex[0]->id);
59    cgGLSetTextureParameter(_volumeBParam, vol->zincblende_tex[1]->id);
60    cgGLEnableTextureParameter(_volumeAParam);
61    cgGLEnableTextureParameter(_volumeBParam);
62
63    cgGLBindProgram(_cgFP);
64    cgGLEnableProfile(CG_PROFILE_FP30);
65}
66
67inline void NvZincBlendeVolumeShader::unbind()
68{
69    cgGLDisableTextureParameter(_volumeAParam);
70    cgGLDisableTextureParameter(_volumeBParam);
71    cgGLDisableTextureParameter(_tfParam);
72
73    cgGLDisableProfile(CG_PROFILE_FP30);
74}
75
76#endif
Note: See TracBrowser for help on using the repository browser.