Visualization Library 2.1.0

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
DrawPixels.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef DrawPixels_INCLUDE_ONCE
33 #define DrawPixels_INCLUDE_ONCE
34 
36 #include <vlGraphics/ImagePBO.hpp>
37 #include <vlCore/Collection.hpp>
38 
39 namespace vl
40 {
41  //-----------------------------------------------------------------------------
42  // DrawPixels
43  //-----------------------------------------------------------------------------
59  //-----------------------------------------------------------------------------
61  {
63 
64  public:
65  //-----------------------------------------------------------------------------
66  // Pixels
67  //-----------------------------------------------------------------------------
72  {
74 
75  friend class DrawPixels;
76 
77  public:
78  Pixels();
84  Pixels(ImagePBO* img, int scrx, int scry, int startx=0, int starty=0, int width=-1, int height=-1, int alignment = AlignBottom | AlignLeft);
85 
86  Pixels(const Pixels& other);
87 
88  Pixels& operator=(const Pixels& other);
89 
90  ~Pixels();
91 
92  const ivec2& position() const { return mPosition; }
93 
94  const ivec2& start() const { return mStart; }
95 
96  const ivec2& size() const { return mSize; }
97 
98  void setPosition( const ivec2& position) { mPosition = position; }
99 
100  void setStart( const ivec2& start) { mStart = start; }
101 
102  void setSize( const ivec2& size) { mSize = size; }
103 
104  ImagePBO* image() { return mImage.get(); }
105 
106  const ImagePBO* image() const { return mImage.get(); }
107 
108  int align() const { return mAlign; }
109 
110  void setAlign(int align) { mAlign = align; }
111 
117  bool generatePixelBufferObject(EBufferObjectUsage usage, bool discard_local_storage);
118 
119  void deletePixelBufferObject();
120 
121  bool hasPixelBufferObject() const;
122 
123  protected:
128  int mAlign;
129  };
130  public:
131 
132  DrawPixels();
133 
134  void computeBounds_Implementation() { setBoundingBox(AABB()); setBoundingSphere(Sphere()); }
135 
140  void render_Implementation(const Actor* actor, const Shader* shader, const Camera* camera, OpenGLContext* gl_context) const;
141 
142  const Collection<Pixels>* draws() const { return &mDraws; }
143 
144  Collection<Pixels>* draws() { return &mDraws; }
145 
147  void deletePixelBufferObjects();
148 
150  void releaseImages();
151 
153  bool generatePixelBufferObjects(EBufferObjectUsage usage, bool discard_local_storage);
154 
155  void setUsePixelBufferObject(bool use_pbo);
156 
157  bool usePixelBufferObject() const { return mUsePixelBufferObject; }
158 
159  // Renderable interface implementation.
160 
162 
163  virtual void deleteBufferObject() {}
164 
165  protected:
168  };
169  //-----------------------------------------------------------------------------
170 }
171 
172 #endif
const Collection< Pixels > * draws() const
Definition: DrawPixels.hpp:142
Associates a Renderable object to an Effect and Transform.
Definition: Actor.hpp:130
const ivec2 & size() const
Definition: DrawPixels.hpp:96
bool usePixelBufferObject() const
Definition: DrawPixels.hpp:157
void computeBounds_Implementation()
Definition: DrawPixels.hpp:134
bool mUsePixelBufferObject
Definition: DrawPixels.hpp:167
Represents an OpenGL context, possibly a widget or a pbuffer, which can also respond to keyboard...
void setStart(const ivec2 &start)
Definition: DrawPixels.hpp:100
Collection< Pixels > * draws()
Definition: DrawPixels.hpp:144
void setAlign(int align)
Definition: DrawPixels.hpp:110
const ivec2 & start() const
Definition: DrawPixels.hpp:94
EBufferObjectUsage
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
virtual void deleteBufferObject()
Destroys the BufferObject (vertex buffer objects) associated to this a Renderable.
Definition: DrawPixels.hpp:163
Visualization Library main namespace.
Represents a bitmap to be drawn on the screen.
Definition: DrawPixels.hpp:71
const ImagePBO * image() const
Definition: DrawPixels.hpp:106
void setPosition(const ivec2 &position)
Definition: DrawPixels.hpp:98
The AABB class implements an axis-aligned bounding box using vl::real precision.
Definition: AABB.hpp:44
void setSize(const ivec2 &size)
Definition: DrawPixels.hpp:102
The base class for all the reference counted objects.
Definition: Object.hpp:158
An abstract class that represents all the objects that can be rendered.
Definition: Renderable.hpp:58
Represents a vl::Image with an associated Pixel Buffer Object.
Definition: ImagePBO.hpp:44
EBufferObjectUpdateMode
Wraps the OpenGL function glDrawPixels().
Definition: DrawPixels.hpp:60
Manages most of the OpenGL rendering states responsible of the final aspect of the rendered objects...
Definition: Shader.hpp:1830
The Sphere class defines a sphere using a center and a radius using vl::real precision.
Definition: Sphere.hpp:43
virtual void updateDirtyBufferObject(EBufferObjectUpdateMode)
Uploads the data stored in the local buffers on the GPU memory.
Definition: DrawPixels.hpp:161
It&#39;s basically an std::vector for Objects that is itself an Object so it can be reference counted and...
Definition: Collection.hpp:49
ref< ImagePBO > mImage
Definition: DrawPixels.hpp:124
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
Represents a virtual camera defining, among other things, the point of view from which scenes can be ...
Definition: Camera.hpp:49
Collection< Pixels > mDraws
Definition: DrawPixels.hpp:166