arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

VolShaderStd.cpp

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     6-17-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 /// VolShaderStd.cpp
00019 ///  Classes for Standard Simian Volume Shaders
00020 
00021 #include "VolShaderStd.h"
00022 #include <sstream>
00023 using namespace glift;
00024 using namespace std;
00025 ////////////////////////////////////////////////////////////////////////////
00026 /// Construction
00027 ////////////////////////////////////////////////////////////////////////////
00028 VolShaderStd::VolShaderStd()
00029 {
00030    char fp[] = 
00031       "!!ARBfp1.0 \n"
00032       "TEMP data0; \n"
00033       "PARAM red   = {.01, 0, 0, 0.01}; \n "
00034       "TEX data0, fragment.texcoord[0], texture[0], 3D;   #Read texture \n"
00035       "MOV data0, data0.xxxx;                             #replicate value one \n"
00036       "MUL data0.xyz, data0, data0.w;                     #Always muliply color by alpha \n"
00037       "MOV result.color, data0;                           #output color \n"
00038       "END \n";
00039    setPixelShader(new FragProgARB(fp,false));
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////////////
00043 /// Bind
00044 ////////////////////////////////////////////////////////////////////////////
00045 void VolShaderStd::bindDef()
00046 {
00047    glDepthMask(GL_FALSE);
00048    glColor4f(1,1,1,1);
00049    glDisable(GL_LIGHTING);
00050    bindShaders();
00051    bindBlend();
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////////////
00055 /// Release
00056 ////////////////////////////////////////////////////////////////////////////
00057 void VolShaderStd::releaseDef()
00058 {
00059    glDepthMask(GL_TRUE);
00060    glEnable(GL_LIGHTING);
00061    releaseShaders();
00062    releaseBlend();
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////////////
00066 ////////////////////////////////////////////////////////////////////////////
00067 ////////////////////////////////////////////////////////////////////////////
00068 /// VolShaderTexCoord
00069 ////////////////////////////////////////////////////////////////////////////
00070 ////////////////////////////////////////////////////////////////////////////
00071 ////////////////////////////////////////////////////////////////////////////
00072 VolShaderTexCoord::VolShaderTexCoord(unsigned int tcNum)
00073 {
00074    //std::stringstream ss;
00075    string fp;
00076    fp = "!!ARBfp1.0 \n"
00077       "TEMP data0; \n" 
00078       "PARAM alpha   = {0, 0, 0, 0.1}; \n"
00079       "MOV data0, fragment.texcoord[0];\n"  ///<< tcNum << "]; \n"
00080       "MUL data0.rgb, data0, alpha.a; \n"
00081       "MOV result.color, data0; \n"
00082       "MOV result.color.a, alpha.a; \n"
00083       "END \n";
00084    setPixelShader(new FragProgARB(fp.c_str(),false));
00085 }

Send questions, comments, and bug reports to:
jmk