GL Studio C++ Runtime API
glpolygon.h
Go to the documentation of this file.
1 /*! \file
2  \brief The disti::GLPolygon class. Implements Polygons.
3 
4  \par Copyright Information
5 
6  Copyright (c) 2017 by The DiSTI Corporation.<br>
7  11301 Corporate Blvd; Suite 100<br>
8  Orlando, Florida 32817<br>
9  USA<br>
10  <br>
11  All rights reserved.<br>
12 
13  This Software contains proprietary trade secrets of DiSTI and may not be
14 reproduced, in whole or part, in any form, or by any means of electronic,
15 mechanical, or otherwise, without the written permission of DiSTI. Said
16 permission may be derived through the purchase of applicable DiSTI product
17 licenses which detail the distribution rights of this content and any
18 Derivative Works based on this or other copyrighted DiSTI Software.
19 
20  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
21 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
22 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
23 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
24 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
25 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
26 
27  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
28 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
29 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
30 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
31 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
32 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBILITY
33 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
34 EXCEED FIVE DOLLARS (US$5.00).
35 
36  The aforementioned terms and restrictions are governed by the laws of the
37 State of Florida and the United States of America.
38 
39 */
40 #ifndef _GLPOLYGON_H
41 #define _GLPOLYGON_H
42 
43 #include "gls_include.h"
44 #ifdef GLES
45 # include "gls_vertex_array.h"
46 #endif
47 #include "display.h"
48 #include "gls_cpp_lang_support.h"
49 
50 namespace disti
51 {
52 /**
53  \brief The Polygon class. Implements Polygons
54 */
55 class GLPolygon : public DisplayObject
56 {
57 private:
58  /** Assignment operator not implemented. Use CloneObject() or the copy constructor instead. */
59  GLPolygon& operator=( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
60  GLPolygon( const GLPolygon& that ) DISTI_SPECIAL_MEM_FUN_DELETE;
61 
62 public:
63  DISTI_DEPRECATED( "This identifier is forbidden by the C++ standard. Use BaseClass instead." )
64  typedef DisplayObject _BaseClass;
65  typedef DisplayObject BaseClass;
66  friend class GLPolygonEditor;
67 
68  static GLS_EXPORT DisplayObject* CreateInstance();
69 
70  /** Creates a polygon with the vertices specified
71  * \param nPoints The number of vertices in the new polygon
72  * \param vertices The array of vertices for the polygon
73  */
74  GLS_EXPORT GLPolygon( unsigned int nPoints, const Vertex* vertices );
75 
76  /** Creates a polygon with the vertices specified
77  * \param nPoints The number of vertices in the new polygon
78  * \param vertices The array of vertices for the polygon
79  * \param location The location point of the object
80  */
81  GLS_EXPORT GLPolygon( unsigned int nPoints, const Vertex* vertices, const Vertex& location );
82 
83  /** Allocate a (blank) polygon object */
84  GLS_EXPORT GLPolygon( void );
85 
86  /** Copy construct a new GLPolygon object
87  * \param polygon The polygon to be cloned
88  * \param generateNames Whether or not to generate a new instance name
89  */
90  GLS_EXPORT GLPolygon( const GLPolygon& polygon, const bool generateNames );
91 
92  /** Destroy a polygon object */
93  virtual GLS_EXPORT ~GLPolygon( void );
94 
95  /** Configures MetaData */
96  GLS_EXPORT void ConfigureMetaData( void );
97 
98  /* Copy+Create operation in one method. In derived classes, this
99  * method will create a new instance of the derived class and then
100  * copy the object into the new instance. The cut,copy,paste and undo
101  * operations use this method.
102  * \param generateNames Whether or not to generate new names for cloned objects
103  * \return A new object, identical to the original, except for the instance name
104  */
105  virtual GLS_EXPORT DisplayObject* CloneObject( bool generateNames = false );
106 
107 #ifdef GLES
108  virtual GLS_EXPORT void PreDraw( const OpenGLMatrices& current, Culler& culler );
109 #endif
110 
111  /** Draws this object on the current display frame (_parent member). */
112  virtual GLS_EXPORT void Draw( void );
113 
114  /** Recalculates the texture coordinates for the object based on the TexturePoints.
115  */
116  virtual GLS_EXPORT void CalculateTextureCoordinates( void );
117 
118  /** Calculates normals based on the vertices and the specified winding order */
119  virtual GLS_EXPORT void CalcNormals( int windingOrder = 1 );
120 
121 #ifdef GLES
122  /** Sets the RGBA color for filling the object
123  * \param r The new Red fill color (0-255 range) for the object
124  * \param g The new Green fill color (0-255 range) for the object
125  * \param b The new Blue fill color (0-255 range) for the object
126  * \param a The new Alpha fill color (0-255 range) for the object
127  */
128  virtual GLS_EXPORT void SetFillColor( unsigned char r, unsigned char g, unsigned char b, unsigned char a );
129 
130  /** Sets the RGBA color for filling the object
131  * \param color The new RGBA fill color (0-255 range) for the object
132  */
133  virtual GLS_EXPORT void SetFillColor( const GlsColor& color );
134 #endif
135 
136  /** DeleteVertexAt is overloaded in polygon to prevent having a poly with less than 2 verts. This
137  * prevents incorrect GL calls when polygon is set to POLY_MODE_FILLED
138  */
139  virtual GLS_EXPORT void DeleteVertexAt( unsigned int index );
140 
141  virtual GLS_EXPORT DisplayObject* Pick3D( const Vector& winLoc,
142  const Vector& logicalCoords,
143  float scale,
144  const Vector& directionVector,
145  Vector& collisionWinLoc, /*Returned*/
146  const OpenGLMatrices& parentDrawn );
147 
148 #ifdef GLES
149 protected:
150  void DrawSolidGeometry( bool textureObject, bool color, bool normal );
151  void DrawOutlineGeometry();
152  void DrawPoints();
153  void BakeVBO( bool hasT, bool hasC, bool hasN );
154 
155  GlsVertexArray _vertArray;
156  bool _pendingFillColor;
157 #endif
158 };
159 
160 } // namespace disti
161 
162 #endif
Definition: cull.h:49
Definition: vertex.h:409
virtual void DeleteVertexAt(unsigned int index)
#define DISTI_DEPRECATED(msg)
Defines whether this compiler supports the C++14 deprecated attribute.
Definition: gls_cpp_lang_support.h:436
Class to contain current OpenGL view, projection and draw matrices.
Definition: util.h:471
virtual void PreDraw(const OpenGLMatrices &current, Culler &culler)
The Polygon class. Implements Polygons.
Definition: glpolygon.h:55
Definition: display.h:98
A file for all GL Studio files to include.
The disti::DisplayObject class and global enumerations.
virtual void Draw(void)
virtual DisplayObject * Pick3D(const Vector &winLoc, const Vector &logicalCoords, float scale, const Vector &directionVector, Vector &collisionWinLoc, const OpenGLMatrices &parentDrawn)
virtual void CalcNormals(int windingOrder=1)
Definition: gls_vertex_array.h:58
Definition: gls_color.h:53
void ConfigureMetaData(void)
virtual void CalculateTextureCoordinates(void)
An object for managing vertices, texture coordinates, colors and normals for GLPolygon and other disp...
Definition: vertex.h:84
virtual ~GLPolygon(void)
Macros and helper code to determine what subset of C++11/14/17 is available.
Definition: bmpimage.h:46
void SetFillColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
Definition: display.h:675
virtual DisplayObject * CloneObject(bool generateNames=false)