Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

toxic::Framebuffer Class Reference

#include <framebuffer.h>

List of all members.

Public Types

enum  Format { RGB_FLOAT_32 }

Public Member Functions

 Framebuffer (int width, int height, Format format)
 ~Framebuffer ()
int GetWidth () const
int GetHeight () const
int GetPixels () const
int GetSizeInMemory () const
 Returns the size (in bytes) of the framebuffer in memory.

sheep::Real GetPixelWidth () const
 Returns the dimensions of a pixel.

sheep::Real GetPixelHeight () const
sheep::Point2 ConvertToNDC (int x, int y) const
void ConvertFromNDC (const sheep::Point2 &p, int *x, int *y) const
 Converts from NDC to pixel coordinates.

void Clear (Color3 color=Color3(0.0))
 Clears the framebuffer with a given color.

Color3 GetPixel (int x, int y) const
void SetPixel (int x, int y, const Color3 &color)
void PlotLine (int x1, int y1, int x2, int y2, const Color3 &color)
void Normalize ()
 Maps pixel values to the [0..1] interval.

void CorrectGamma (sheep::Real target_gamma)
bool WriteToDisk (const std::string &filename) const
 Returns true if success, false otherwise.


Private Attributes

int m_width
int m_height
 Dimensions of the framebuffer, in pixels.

int m_pixels
 Total number of pixels, which is equal to m_width * m_height.

Format m_format
 Format of the framebuffer.

union {
   pixel_rgb_float_32 *   m_rgb_float_32
m_bits
sheep::Real m_inv_width
 m_inv_width = 1.0 / m_width.

sheep::Real m_inv_height
 m_inv_height = 1.0 / m_height.

sheep::Real m_half_inv_width
 m_half_inv_width = 1.0 / (2.0 * m_width).

sheep::Real m_half_inv_height
 m_half_inv_height = 1.0 / (2.0 * m_height).


Member Enumeration Documentation

enum toxic::Framebuffer::Format
 

Enumeration values:
RGB_FLOAT_32  RGB format, each channel is coded as 32-bit float.

Definition at line 40 of file framebuffer.h.


Constructor & Destructor Documentation

Framebuffer::Framebuffer int  width,
int  height,
Format  format
 

Definition at line 34 of file framebuffer.cpp.

References m_bits, m_format, m_half_inv_height, m_half_inv_width, m_inv_height, m_inv_width, m_pixels, and RGB_FLOAT_32.

Framebuffer::~Framebuffer  ) 
 

Definition at line 58 of file framebuffer.cpp.

References m_bits, m_format, and RGB_FLOAT_32.


Member Function Documentation

void Framebuffer::Clear Color3  color = Color3(0.0)  ) 
 

Clears the framebuffer with a given color.

Definition at line 82 of file framebuffer.cpp.

References toxic::Color3::m_b, toxic::Framebuffer::pixel_rgb_float_32::m_b, m_bits, m_format, toxic::Color3::m_g, toxic::Framebuffer::pixel_rgb_float_32::m_g, m_pixels, toxic::Color3::m_r, toxic::Framebuffer::pixel_rgb_float_32::m_r, and RGB_FLOAT_32.

Referenced by main().

void Framebuffer::ConvertFromNDC const sheep::Point2 p,
int *  x,
int *  y
const [inline]
 

Converts from NDC to pixel coordinates.

Definition at line 159 of file framebuffer.h.

Referenced by line().

sheep::Point2 Framebuffer::ConvertToNDC int  x,
int  y
const [inline]
 

Converts from pixel coordinates to NDC (see file renderer/camera.h). Returns NDC of the center of the pixel located at (x, y).

Definition at line 149 of file framebuffer.h.

Referenced by toxic::Renderer::render_pixel_supersampling(), and toxic::Renderer::render_pixel_whitted().

void Framebuffer::CorrectGamma sheep::Real  target_gamma  ) 
 

Todo:
Implement a complete tone mapping architecture.

Definition at line 200 of file framebuffer.cpp.

References toxic::Framebuffer::pixel_rgb_float_32::m_b, m_bits, m_format, toxic::Framebuffer::pixel_rgb_float_32::m_g, m_pixels, toxic::Framebuffer::pixel_rgb_float_32::m_r, and RGB_FLOAT_32.

Referenced by main().

int Framebuffer::GetHeight  )  const [inline]
 

Definition at line 129 of file framebuffer.h.

Referenced by toxic::SceneBuilder::pinholecamera_builder(), toxic::Renderer::ResetRenderArea(), toxic::Renderer::SetRenderArea(), and toxic::SceneBuilder::thinlenscamera_builder().

Color3 Framebuffer::GetPixel int  x,
int  y
const [inline]
 

Definition at line 170 of file framebuffer.h.

sheep::Real Framebuffer::GetPixelHeight  )  const [inline]
 

Definition at line 144 of file framebuffer.h.

Referenced by toxic::Renderer::render_pixel_supersampling(), and toxic::Renderer::render_pixel_whitted().

int Framebuffer::GetPixels  )  const [inline]
 

Definition at line 134 of file framebuffer.h.

sheep::Real Framebuffer::GetPixelWidth  )  const [inline]
 

Returns the dimensions of a pixel.

Definition at line 139 of file framebuffer.h.

Referenced by toxic::Renderer::render_pixel_supersampling(), and toxic::Renderer::render_pixel_whitted().

int Framebuffer::GetSizeInMemory  )  const
 

Returns the size (in bytes) of the framebuffer in memory.

Definition at line 68 of file framebuffer.cpp.

References m_format, m_pixels, and RGB_FLOAT_32.

Referenced by main().

int Framebuffer::GetWidth  )  const [inline]
 

Definition at line 124 of file framebuffer.h.

Referenced by toxic::SceneBuilder::pinholecamera_builder(), toxic::Renderer::ResetRenderArea(), toxic::Renderer::Restart(), toxic::Renderer::SetRenderArea(), and toxic::SceneBuilder::thinlenscamera_builder().

void Framebuffer::Normalize  ) 
 

Maps pixel values to the [0..1] interval.

Definition at line 145 of file framebuffer.cpp.

References toxic::Framebuffer::pixel_rgb_float_32::m_b, m_bits, m_format, toxic::Framebuffer::pixel_rgb_float_32::m_g, m_pixels, toxic::Framebuffer::pixel_rgb_float_32::m_r, max(), and RGB_FLOAT_32.

void Framebuffer::PlotLine int  x1,
int  y1,
int  x2,
int  y2,
const Color3 color
 

Definition at line 99 of file framebuffer.cpp.

References SetPixel().

Referenced by line().

void Framebuffer::SetPixel int  x,
int  y,
const Color3 color
[inline]
 

Definition at line 188 of file framebuffer.h.

Referenced by PlotLine(), toxic::Renderer::render_pixel_supersampling(), and toxic::Renderer::render_pixel_whitted().

bool Framebuffer::WriteToDisk const std::string &  filename  )  const
 

Returns true if success, false otherwise.

Todo:
Use ilEnable(IL_ORIGIN_SET) followed by ilOriginFunc(IL_ORIGIN_UPPER_LEFT) to place the origin at the upper left corner.

Definition at line 233 of file framebuffer.cpp.

References convert_float32_to_uint8(), toxic::Framebuffer::pixel_rgb_float_32::m_b, m_bits, m_format, toxic::Framebuffer::pixel_rgb_float_32::m_g, m_pixels, toxic::Framebuffer::pixel_rgb_float_32::m_r, and RGB_FLOAT_32.

Referenced by main().


Member Data Documentation

union { ... } toxic::Framebuffer::m_bits [private]
 

Referenced by Clear(), CorrectGamma(), Framebuffer(), Normalize(), WriteToDisk(), and ~Framebuffer().

Format toxic::Framebuffer::m_format [private]
 

Format of the framebuffer.

Definition at line 85 of file framebuffer.h.

Referenced by Clear(), CorrectGamma(), Framebuffer(), GetSizeInMemory(), Normalize(), WriteToDisk(), and ~Framebuffer().

sheep::Real toxic::Framebuffer::m_half_inv_height [private]
 

m_half_inv_height = 1.0 / (2.0 * m_height).

Definition at line 98 of file framebuffer.h.

Referenced by Framebuffer().

sheep::Real toxic::Framebuffer::m_half_inv_width [private]
 

m_half_inv_width = 1.0 / (2.0 * m_width).

Definition at line 97 of file framebuffer.h.

Referenced by Framebuffer().

int toxic::Framebuffer::m_height [private]
 

Dimensions of the framebuffer, in pixels.

Definition at line 83 of file framebuffer.h.

sheep::Real toxic::Framebuffer::m_inv_height [private]
 

m_inv_height = 1.0 / m_height.

Definition at line 96 of file framebuffer.h.

Referenced by Framebuffer().

sheep::Real toxic::Framebuffer::m_inv_width [private]
 

m_inv_width = 1.0 / m_width.

Definition at line 95 of file framebuffer.h.

Referenced by Framebuffer().

int toxic::Framebuffer::m_pixels [private]
 

Total number of pixels, which is equal to m_width * m_height.

Definition at line 84 of file framebuffer.h.

Referenced by Clear(), CorrectGamma(), Framebuffer(), GetSizeInMemory(), Normalize(), and WriteToDisk().

pixel_rgb_float_32* toxic::Framebuffer::m_rgb_float_32 [private]
 

Definition at line 92 of file framebuffer.h.

int toxic::Framebuffer::m_width [private]
 

Definition at line 83 of file framebuffer.h.


The documentation for this class was generated from the following files:
Generated on Tue May 11 01:31:57 2004 for toxic by doxygen 1.3.6