Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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
00043
00059
00060 class VLGRAPHICS_EXPORT DrawPixels: public Renderable
00061 {
00062 VL_INSTRUMENT_CLASS(vl::DrawPixels, Renderable)
00063
00064 public:
00065
00066
00067
00071 class VLGRAPHICS_EXPORT Pixels: public Object
00072 {
00073 VL_INSTRUMENT_CLASS(vl::DrawPixels::Pixels, Object)
00074
00075 friend class DrawPixels;
00076
00077 public:
00078 Pixels();
00084 Pixels(ImagePBO* img, int scrx, int scry, int startx=0, int starty=0, int width=-1, int height=-1, int alignment = AlignBottom | AlignLeft);
00085
00086 Pixels(const Pixels& other);
00087
00088 Pixels& operator=(const Pixels& other);
00089
00090 ~Pixels();
00091
00092 const ivec2& position() const { return mPosition; }
00093
00094 const ivec2& start() const { return mStart; }
00095
00096 const ivec2& size() const { return mSize; }
00097
00098 void setPosition( const ivec2& position) { mPosition = position; }
00099
00100 void setStart( const ivec2& start) { mStart = start; }
00101
00102 void setSize( const ivec2& size) { mSize = size; }
00103
00104 ImagePBO* image() { return mImage.get(); }
00105
00106 const ImagePBO* image() const { return mImage.get(); }
00107
00108 int align() const { return mAlign; }
00109
00110 void setAlign(int align) { mAlign = align; }
00111
00117 bool generatePixelBufferObject(EBufferObjectUsage usage, bool discard_local_storage);
00118
00119 void deletePixelBufferObject();
00120
00121 bool hasPixelBufferObject() const;
00122
00123 protected:
00124 ref<ImagePBO> mImage;
00125 ivec2 mPosition;
00126 ivec2 mStart;
00127 ivec2 mSize;
00128 int mAlign;
00129 };
00130 public:
00131
00132 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(EBufferObjectUsage usage, bool discard_local_storage);
00154
00155 void setUsePixelBufferObject(bool use_pbo);
00156
00157 bool usePixelBufferObject() const { return mUsePixelBufferObject; }
00158
00159
00160
00161 virtual void updateDirtyBufferObject(EBufferObjectUpdateMode) {}
00162
00163 virtual void deleteBufferObject() {}
00164
00165 protected:
00166 Collection<Pixels> mDraws;
00167 bool mUsePixelBufferObject;
00168 };
00169
00170 }
00171
00172 #endif