# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/DrawPixels.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.com                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #ifndef DrawPixels_INCLUDE_ONCE
    00033 #define DrawPixels_INCLUDE_ONCE
    00034
    00035 #include <vlGraphics/Renderable.hpp>
    00036 #include <vlGraphics/ImagePBO.hpp>
    00037 #include <vlCore/Collection.hpp>
    00038
    00039 namespace vl
    00040 {
    00041   //-----------------------------------------------------------------------------
    00042   // DrawPixels
    00043   //-----------------------------------------------------------------------------
    00059   //-----------------------------------------------------------------------------
    00060   class VLGRAPHICS_EXPORT DrawPixels: public Renderable
    00061   {
    00062   public:
    00063   //-----------------------------------------------------------------------------
    00064   // Pixels
    00065   //-----------------------------------------------------------------------------
    00069     class VLGRAPHICS_EXPORT Pixels: public Object
    00070     {
    00071       friend class DrawPixels;
    00072
    00073     public:
    00074       virtual const char* className() { return "vl::Pixels"; }
    00075
    00076       Pixels();
    00082       Pixels(ImagePBO* img, int scrx, int scry, int startx=0, int starty=0, int width=-1, int height=-1, int alignment = AlignBottom | AlignLeft);
    00083
    00084       Pixels(const Pixels& other);
    00085
    00086       Pixels& operator=(const Pixels& other);
    00087
    00088       ~Pixels();
    00089
    00090       const ivec2& position() const { return mPosition; }
    00091
    00092       const ivec2& start() const { return mStart; }
    00093
    00094       const ivec2& size() const { return mSize; }
    00095
    00096       void setPosition( const ivec2& position) { mPosition = position; }
    00097
    00098       void setStart( const ivec2& start) { mStart = start; }
    00099
    00100       void setSize( const ivec2& size) { mSize = size; }
    00101
    00102       ImagePBO* image() { return mImage.get(); }
    00103
    00104       const ImagePBO* image() const { return mImage.get(); }
    00105
    00106       int align() const { return mAlign; }
    00107
    00108       void setAlign(int align) { mAlign = align; }
    00109
    00115       bool generatePixelBufferObject(EGLBufferUsage usage, bool discard_local_storage);
    00116
    00117       void deletePixelBufferObject();
    00118
    00119       bool hasPixelBufferObject() const;
    00120
    00121     protected:
    00122       ref<ImagePBO> mImage;
    00123       ivec2 mPosition;
    00124       ivec2 mStart;
    00125       ivec2 mSize;
    00126       int mAlign;
    00127     };
    00128   public:
    00129
    00130     DrawPixels();
    00131
    00132     virtual const char* className() { return "vl::DrawPixels"; }
    00133
    00134     void computeBounds_Implementation() { setBoundingBox(AABB()); setBoundingSphere(Sphere()); }
    00135
    00140     void render_Implementation(const Actor* actor, const Shader* shader, const Camera* camera, OpenGLContext* gl_context) const;
    00141
    00142     const Collection<Pixels>* draws() const { return &mDraws; }
    00143
    00144     Collection<Pixels>* draws() { return &mDraws; }
    00145
    00147     void deletePixelBufferObjects();
    00148
    00150     void releaseImages();
    00151
    00153     bool generatePixelBufferObjects(EGLBufferUsage usage, bool discard_local_storage);
    00154
    00155     void setUsePixelBufferObject(bool use_pbo);
    00156
    00157     bool usePixelBufferObject() const { return mUsePixelBufferObject; }
    00158
    00159     // Renderable interface implementation.
    00160
    00161     void updateVBOs(bool,bool) {}
    00162
    00163   protected:
    00164     Collection<Pixels> mDraws;
    00165     bool mUsePixelBufferObject;
    00166   };
    00167   //-----------------------------------------------------------------------------
    00168 }
    00169
    00170 #endif

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:23.
Permission is granted to use this page to write and publish articles regarding Visualization Library.