source: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/GlobalLinesRenderer.cpp @ 1940

Revision 1940, 2.0 KB checked in by mattausch, 18 years ago (diff)
Line 
1#include "glInterface.h"
2#include "GlobalLinesRenderer.h"
3#include "common.h"
4
5#include <Cg/cg.h>
6#include <Cg/cgGL.h>
7
8#include <QtOpenGL>
9
10namespace GtpVisibilityPreprocessor {
11
12static CGcontext sCgContext = NULL;
13static CGprogram sCgDepthPeelingProgram = NULL;
14static CGprofile sCgFragmentProfile;
15
16
17static void handleCgError()
18{
19    cerr << "Cg error: " << cgGetErrorString(cgGetError()) << endl;
20    exit(1);
21}
22
23
24GlobalLinesRenderer::GlobalLinesRenderer(QGLPixelBuffer *buffer1, QGLPixelBuffer *buffer2):
25mNewBuffer(buffer1), mOldBuffer(buffer2)
26{
27}
28
29
30GlobalLinesRenderer::~GlobalLinesRenderer()
31{
32        if (sCgDepthPeelingProgram)
33                cgDestroyProgram(sCgDepthPeelingProgram);
34        if (sCgContext)
35                cgDestroyContext(sCgContext);
36}
37
38 
39void GlobalLinesRenderer::CastGlobalLines(Beam &beam, const int samples)
40{
41        // bind pixel shader implementing the front depth buffer functionality
42        cgGLBindProgram(sCgDepthPeelingProgram);
43        cgGLEnableProfile(sCgFragmentProfile);
44
45        ApplyDepthPeeling(beam, samples);
46}
47
48
49void GlobalLinesRenderer::DrawGeometry()
50{
51}
52
53void GlobalLinesRenderer::ApplyDepthPeeling(Beam &beam, const int samples)
54{
55/*      if (rtNew->IsDoubleBuffered())
56                glDrawBuffer(GL_BACK);
57       
58        rtNew->BeginCapture();
59        {
60                cgGLBindProgram(passthru);
61                glColor3f(0,0.0,0.0);
62                DrawGeometry();   //just random geomerty   
63        }
64        rtNew->EndCapture();
65
66        for(int l = 0; l < mCurrentDepth; l++)
67        {
68                // Peel another layer
69                pingpong(); // switch pointer between rendertextures
70     
71                rtNew->BeginCapture();
72                {
73                        if (rtNew->IsDoubleBuffered())
74                                glDrawBuffer(GL_BACK);
75       
76                        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);         
77                       
78                        cgGLBindProgram(fragmentProgram);
79                        cgGLSetTextureParameter(input1, rtOld->GetDepthTextureID());
80                        cgGLEnableTextureParameter(input1);
81
82            glColor3f(0,0.0,0.0);
83                        DrawGeometry();
84                        cgGLDisableTextureParameter(input1);
85                }
86                rtNew->EndCapture();
87   }*/
88}
89
90
91}
Note: See TracBrowser for help on using the repository browser.