00001 00002 #ifndef __rendering_cache_hpp__ 00003 #define __rendering_cache_hpp__ 00004 00005 #include <crbn/basic/ray.hpp> 00006 #include <crbn/basic/vec3.hpp> 00007 00008 typedef struct _cache_entry { 00009 uint x, y; 00010 uint size; 00011 vec2* uvs; 00012 ray* rays; 00013 vec3 color; 00014 } cache_entry; 00015 00016 class RenderingCache 00017 { 00018 public: 00019 RenderingCache( int size, int samples ) : _size( size ), _samples( samples ) { 00020 _entries = new cache_entry [ size ]; 00021 for( int i = 0; i < size; ++i ) { 00022 _entries[ i ].size = samples; 00023 _entries[ i ].uvs = new vec2 [ samples ]; 00024 _entries[ i ].rays = new ray [ samples ]; 00025 } 00026 } 00027 ~RenderingCache() { 00028 for( int i = 0; i < _size; ++i ) { 00029 delete [] _entries[ i ].rays; 00030 _entries[ i ].rays = 0; 00031 delete [] _entries[ i ].uvs; 00032 _entries[ i ].uvs = 0; 00033 } 00034 delete [] _entries; 00035 _entries = 0; 00036 } 00037 00038 int samples() { return _samples; } 00039 00040 cache_entry* get_entry( int i ) { 00041 return &(_entries[ i ]); 00042 } 00043 private: 00044 int _size, _samples; 00045 cache_entry* _entries; 00046 }; 00047 00048 #endif // __rendering_cache_hpp__