Debian Codegraph @

include/BALL/VIEW/RENDERING/RENDERERS/cudaVolumeRenderer.h

raw symbols SCIP
1 // -*- Mode: C++; tab-width: 2; -*-
2 // vi: set ts=2:
3 //
4
5 #ifndef BALL_VIEW_RENDERING_RENDERERS_CUDARAYTRACINGRENDERER_H
6 #define BALL_VIEW_RENDERING_RENDERERS_CUDARAYTRACINGRENDERER_H
7
8 #define BALLVIEW_CUDAVOLUMERENDERER_THROW(exceptionName, message) (throw BALL::Exception::##exceptionName##(__FILE__, __LINE__, message))
9 #include <BALL/VIEW/RENDERING/RENDERERS/raytracingRenderer.h>
10 #include <cudamm/cuda.hpp>
11
12 namespace BALL
13 {
14 namespace VIEW
15 {
16 class BALL_DEPRECATED CudaVolumeRenderer
17 : public RaytracingRenderer
18 {
19 public:
20
21 /* RT renderer methods */
22 /// @throws BALL::Exception::CUDAError
23 virtual bool init(const Scene& scene)
24 {
25 try
26 {
27 cuda::Cuda cudaCtx(0);
28 cuda::Module mod("../libVIEW/GeneratedFiles/Debug/raytracer_debug.cubin");
29 }
30 catch(cuda::Exception const &e)
31 {
32 BALL::Log.error() << "Initialization of CudaVolumeRenderer failed" << std::endl;
33 BALLVIEW_CUDAVOLUMERENDERER_THROW(CUDAError, e.what());
34 }
35
36 return true;
37 }
38
39 virtual String getRenderer()
40 throw()
41 {
42 return "CUDA Volume Renderer v1";
43 }
44
45 virtual void formatUpdated()
46 {
47
48 }
49
50 virtual void prepareBufferedRendering(const Stage& stage)
51 {
52
53 }
54
55 virtual void renderToBufferImpl(FrameBufferPtr buffer)
56 {
57 FrameBufferFormat fmt = buffer->getFormat();
58 if(fmt.getPixelFormat() == PixelFormat::RGBA_32)
59 {
60 renderImpl<int>(reinterpret_cast<int*>(buffer->getData()), fmt.getWidth(), fmt.getHeight());
61 }
62 if(fmt.getPixelFormat() == PixelFormat::RGBF_96)
63 {
64 renderImpl<float>(reinterpret_cast<float*>(buffer->getData()), fmt.getWidth(), fmt.getHeight());
65 }
66 }
67
68 private:
69
70 template<typename taPixelType>
71 void renderImpl(taPixelType* buffer, const unsigned int width, const unsigned int height);
72
73 template<>
74 void renderImpl(int* buffer, const unsigned int width, const unsigned int height)
75 {
76 for (unsigned int j = 0; j < height; j++)
77 {
78 for (unsigned int i = 0; i < width; i++)
79 {
80 if ( (((i / 64) % 2) == 0) && (((j / 64) % 2) == 0))
81 {
82 buffer[j*width + i] = (0 << 24) | (255 << 16) | (0 << 8) | (0);
83 }
84 else
85 {
86 buffer[j*width + i] = (0 << 24) | (0 << 16) | (0 << 8) | (255);
87 }
88
89 }
90 }
91 }
92
93 template<>
94 void renderImpl(float* buffer, const unsigned int width, const unsigned int height)
95 {
96 for (unsigned int j = 0; j < height; j++)
97 {
98 for (unsigned int i = 0; i < width; i++)
99 {
100 if ( (((i / 64) % 2) == 0) && (((j / 64) % 2) == 0))
101 {
102 buffer[3 * (j*width + i) + 0] = 1;
103 buffer[3 * (j*width + i) + 1] = 0;
104 buffer[3 * (j*width + i) + 2] = 0;
105 }
106 else
107 {
108 buffer[3 * (j*width + i) + 0] = 0;
109 buffer[3 * (j*width + i) + 1] = 1;
110 buffer[3 * (j*width + i) + 2] = 0;
111 }
112
113 }
114 }
115 }
116
117 };
118
119
120 } // namespace VIEW
121
122 } // namespace BALL
123
124 #endif // BALL_VIEW_RENDERING_CUDARAYTRACINGRENDERER_H