Loading...
Searching...
No Matches
cudaVolumeRenderer.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_VIEW_RENDERING_RENDERERS_CUDARAYTRACINGRENDERER_H
#define BALL_VIEW_RENDERING_RENDERERS_CUDARAYTRACINGRENDERER_H
#define BALLVIEW_CUDAVOLUMERENDERER_THROW(exceptionName, message) (throw BALL::Exception::##exceptionName##(__FILE__, __LINE__, message))
#include <BALL/VIEW/RENDERING/RENDERERS/raytracingRenderer.h>
#include <cudamm/cuda.hpp>
namespace BALL
{
namespace VIEW
{
class BALL_DEPRECATED CudaVolumeRenderer
: public RaytracingRenderer
{
public:
/* RT renderer methods */
virtual bool init(const Scene& scene)
{
try
{
cuda::Cuda cudaCtx(0);
cuda::Module mod("../libVIEW/GeneratedFiles/Debug/raytracer_debug.cubin");
}
catch(cuda::Exception const &e)
{
BALL::Log.error() << "Initialization of CudaVolumeRenderer failed" << std::endl;
BALLVIEW_CUDAVOLUMERENDERER_THROW(CUDAError, e.what());
}
return true;
}
virtual String getRenderer()
throw()
{
return "CUDA Volume Renderer v1";
}
virtual void formatUpdated()
{
}
virtual void prepareBufferedRendering(const Stage& stage)
{
}
virtual void renderToBufferImpl(FrameBufferPtr buffer)
{
FrameBufferFormat fmt = buffer->getFormat();
if(fmt.getPixelFormat() == PixelFormat::RGBA_32)
{
renderImpl<int>(reinterpret_cast<int*>(buffer->getData()), fmt.getWidth(), fmt.getHeight());
}
if(fmt.getPixelFormat() == PixelFormat::RGBF_96)
{
renderImpl<float>(reinterpret_cast<float*>(buffer->getData()), fmt.getWidth(), fmt.getHeight());
}
}
private:
template<typename taPixelType>
void renderImpl(taPixelType* buffer, const unsigned int width, const unsigned int height);
template<>
void renderImpl(int* buffer, const unsigned int width, const unsigned int height)
{
for (unsigned int j = 0; j < height; j++)
{
for (unsigned int i = 0; i < width; i++)
{
if ( (((i / 64) % 2) == 0) && (((j / 64) % 2) == 0))
{
buffer[j*width + i] = (0 << 24) | (255 << 16) | (0 << 8) | (0);
}
else
{
buffer[j*width + i] = (0 << 24) | (0 << 16) | (0 << 8) | (255);
}
}
}
}
template<>
void renderImpl(float* buffer, const unsigned int width, const unsigned int height)
{
for (unsigned int j = 0; j < height; j++)
{
for (unsigned int i = 0; i < width; i++)
{
if ( (((i / 64) % 2) == 0) && (((j / 64) % 2) == 0))
{
buffer[3 * (j*width + i) + 0] = 1;
buffer[3 * (j*width + i) + 1] = 0;
buffer[3 * (j*width + i) + 2] = 0;
}
else
{
buffer[3 * (j*width + i) + 0] = 0;
buffer[3 * (j*width + i) + 1] = 1;
buffer[3 * (j*width + i) + 2] = 0;
}
}
}
}
};
} // namespace VIEW
} // namespace BALL
#endif // BALL_VIEW_RENDERING_CUDARAYTRACINGRENDERER_H
BALL_DEPRECATED
#define BALL_DEPRECATED
Definition COMMON/global.h:64
BALL::String
Definition string.h:57
BALL::VIEW::CudaVolumeRenderer
Definition cudaVolumeRenderer.h:18
BALL::VIEW::CudaVolumeRenderer::formatUpdated
virtual void formatUpdated()
Definition cudaVolumeRenderer.h:45
BALL::VIEW::CudaVolumeRenderer::init
virtual bool init(const Scene &scene)
Definition cudaVolumeRenderer.h:23
BALL::VIEW::CudaVolumeRenderer::renderToBufferImpl
virtual void renderToBufferImpl(FrameBufferPtr buffer)
Definition cudaVolumeRenderer.h:55
BALL::VIEW::CudaVolumeRenderer::getRenderer
virtual String getRenderer()
Definition cudaVolumeRenderer.h:39
BALL::VIEW::CudaVolumeRenderer::prepareBufferedRendering
virtual void prepareBufferedRendering(const Stage &stage)
Definition cudaVolumeRenderer.h:50
BALL::VIEW::FrameBufferFormat
Definition renderTarget.h:45
BALL::VIEW::FrameBufferFormat::getWidth
unsigned int getWidth() const
Definition renderTarget.h:92
BALL::VIEW::FrameBufferFormat::getHeight
unsigned int getHeight() const
Definition renderTarget.h:100
BALL::VIEW::FrameBufferFormat::getPixelFormat
const PixelFormat & getPixelFormat() const
Definition renderTarget.h:112
BALL::VIEW::PixelFormat::RGBA_32
static const PixelFormat RGBA_32
Definition pixelFormat.h:193
BALL::VIEW::PixelFormat::RGBF_96
static const PixelFormat RGBF_96
Definition pixelFormat.h:201
BALL::VIEW::RaytracingRenderer
Definition raytracingRenderer.h:34
BALL::VIEW::Scene
Definition scene.h:141
BALL::VIEW::Stage
Definition stage.h:239
BALLVIEW_CUDAVOLUMERENDERER_THROW
#define BALLVIEW_CUDAVOLUMERENDERER_THROW(exceptionName, message)
Definition cudaVolumeRenderer.h:8
BALL::VIEW::FrameBufferPtr
boost::shared_ptr< FrameBuffer > FrameBufferPtr
Definition renderTarget.h:222
BALL
Definition constants.h:13
BALL::Log
BALL_EXPORT LogStream Log
raytracingRenderer.h