32 #ifndef CameraReadPixels_INCLUDE_ONCE 33 #define CameraReadPixels_INCLUDE_ONCE 59 #if defined(VL_OPENGL) 60 glPushClientAttrib(GL_CLIENT_PIXEL_STORE_BIT);
63 glPixelStorei( GL_PACK_ALIGNMENT, 1);
64 #if defined(VL_OPENGL) 65 glPixelStorei( GL_PACK_ROW_LENGTH, w);
66 glPixelStorei( GL_PACK_SKIP_PIXELS, 0);
67 glPixelStorei( GL_PACK_SKIP_ROWS, 0);
68 glPixelStorei( GL_PACK_SWAP_BYTES, 0);
69 glPixelStorei( GL_PACK_LSB_FIRST, 0);
72 glPixelStorei( GL_PACK_IMAGE_HEIGHT, 0 );
73 glPixelStorei( GL_PACK_SKIP_IMAGES, 0 );
78 glReadBuffer( read_buffer );
82 if (glGetError() != GL_NO_ERROR)
85 "You seem to have specified a wrong read buffer for the bound render target,\n" 86 "for example you might have specified a RDB_BACK_LEFT but the active camera\n" 87 "is bound to a FBO (Framebuffer Object) render target or the selected\n" 88 "read buffer is FBO-specific (like RDB_COLOR_ATTACHMENT0_EXT) but the active\n" 89 "camera is not bound to a FBO render target. \n") << __FILE__ << __LINE__
95 bool supports_pbo = Has_GL_ARB_pixel_buffer_object||Has_GL_EXT_pixel_buffer_object||
Has_GL_Version_2_1;
97 if (store_in_pixel_buffer_object && supports_pbo)
106 VL_glBindBuffer( GL_PIXEL_PACK_BUFFER, glbuf->
handle() );
108 glReadPixels( x, y, w, h, image->
format(), image->
type(), 0);
110 VL_glBindBuffer( GL_PIXEL_PACK_BUFFER, 0 );
124 glReadPixels( x, y, w, h, image->
format(), image->
type(), image->
pixels() );
127 #if defined(VL_OPENGL) 129 glReadBuffer( prev );
165 VL_DEBUG_SET_OBJECT_NAME()
177 VL_DEBUG_SET_OBJECT_NAME()
222 int x()
const {
return mX; }
223 int y()
const {
return mY; }
virtual bool onRenderingFinished(const RenderingAbstract *)
Reimplement to react to this event.
const String & savePath() const
void setSavePath(const String &path)
EReadDrawBuffer mReadBuffer
A simple String formatting class.
const unsigned char * pixels() const
Raw pointer to pixels.
The RenderingAbstract class is the base of all the rendering related sub-classes. ...
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
void reset(int x, int y, int z, int bytealign, EImageFormat format, EImageType type, bool is_cubemap)
Sets up the image configuration & clears the local storage.
bool mStoreInPixelBufferObject
void setStoreInPixelBufferObject(bool use_pbo)
static void error(const String &message)
Use this function to provide information about run-time errors: file not found, out of memory...
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Visualization Library main namespace.
virtual bool onRendererFinished(const RendererAbstract *)
Reimplement to react to this event.
int length() const
Returns the length of the string.
An abstract class used to react to rendering events.
virtual bool onRendererStarted(const RendererAbstract *)
Reimplement to react to this event.
EBufferObjectUsage usage() const
BufferObject usage flag as specified by setBufferData().
VLCORE_EXPORT bool saveImage(Image *img, VirtualFile *file)
Writes an image on the specified file.
virtual bool onRenderingStarted(const RenderingAbstract *)
Reimplement to react to this event.
EImageDimension dimension() const
A RenderEventCallback that copyes a rectangular pixel area from a source buffer to an Image at the en...
static void print(const String &message)
Application message for the user.
Buffer * imageBuffer()
The buffer used to store the image pixels.
EReadDrawBuffer readBuffer() const
Base class providing all the basic funtionalities of a Renderer.
void setReadBuffer(EReadDrawBuffer buffer)
void setImage(Image *image)
void setup(int x, int y, int width, int height, EReadDrawBuffer read_buffer, bool store_in_pbo)
The BufferObject class is a Buffer that can upload its data on the GPU memory.
unsigned int handle() const
void setBufferData(EBufferObjectUsage usage, bool discard_local_storage=false)
void readPixels(Image *image, int x, int y, int w, int h, EReadDrawBuffer read_buffer, bool store_in_pixel_buffer_object)
Reads a rectangular pixel area from the specified read buffer and stores it in an Image...
Implements a generic 1d, 2d, 3d and cubemap image that can have mipmaps.
The ref<> class is used to reference-count an Object.
void allocate2D(int x, int y, int bytealign, EImageFormat format, EImageType type)
ReadPixels(int x, int y, int width, int height, EReadDrawBuffer read_buffer, Image *image, bool store_in_pbo)
const Image * image() const
void setHeight(int height)
bool storeInPixelBufferObject() const
static int requiredMemory2D(int x, int y, int bytealign, EImageFormat format, EImageType type)
EImageFormat format() const