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

Last change on this file since 2822 was 2822, checked in by ldelgass, 8 years ago

Const correctness fixes, pass vector/matrix objects by reference, various
formatting and style cleanups, don't spam syslog and uncomment openlog() call.
Still needs to be compiled with -DWANT_TRACE to get tracing, but now trace
output will be output to file in /tmp.

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