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 public:
00063
00064
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
00160
00161 void updateVBOs(bool,bool) {}
00162
00163 protected:
00164 Collection<Pixels> mDraws;
00165 bool mUsePixelBufferObject;
00166 };
00167
00168 }
00169
00170 #endif