zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Quadrilateral.hxx
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef ZENI_QUADRILATERAL_HXX
19 #define ZENI_QUADRILATERAL_HXX
20 
21 // HXXed below
22 #include <Zeni/Triangle.h>
23 #include <Zeni/Vertex3f.h>
24 
25 #include <Zeni/Quadrilateral.h>
26 
27 // Not HXXed
28 #if defined(REQUIRE_GL_ES)
29 #include <GLES/gl.h>
30 #else
31 #include <GL/glew.h>
32 #endif
33 
34 #include <cassert>
35 
36 namespace Zeni {
37 
38  template <typename VERTEX>
40  : a(VERTEX()),
41  b(VERTEX()),
42  c(VERTEX()),
43  d(VERTEX())
44  {
45  }
46 
47  template <typename VERTEX>
48  Quadrilateral<VERTEX>::Quadrilateral(const VERTEX &vertex0, const VERTEX &vertex1, const VERTEX &vertex2, const VERTEX &vertex3)
49  : a(vertex0),
50  b(vertex1),
51  c(vertex2),
52  d(vertex3)
53  {
54  }
55 
56  template <typename VERTEX>
58  : Renderable(rhs),
59  a(rhs.a),
60  b(rhs.b),
61  c(rhs.c),
62  d(rhs.d)
63  {
64  }
65 
66  template <typename VERTEX>
68  static_cast<Renderable &>(*this) = rhs;
69 
70  a = rhs.a;
71  b = rhs.b;
72  c = rhs.c;
73  d = rhs.d;
74 
75  return *this;
76  }
77 
78  template <typename VERTEX>
80  return a.is_3d();
81  }
82 
83 #if !defined(DISABLE_GL) && !defined(REQUIRE_GL_ES)
84  template <typename VERTEX>
87  a.subrender_to(screen);
88  b.subrender_to(screen);
89  c.subrender_to(screen);
90  d.subrender_to(screen);
91  glEnd();
92  }
93 #endif
94 
95 #ifndef DISABLE_DX9
96  template <typename VERTEX>
98  screen.get_d3d_device()->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, a.get_address(), sizeof(VERTEX));
99  }
100 #endif
101 
102  template <typename VERTEX>
104  return new Quadrilateral<VERTEX>(*this);
105  }
106 
107  template <typename VERTEX>
109  Triangle<VERTEX> * const t0 = new Triangle<VERTEX>(a, b, c);
110  t0->fax_Material(get_Material());
111  return t0;
112  }
113 
114  template <typename VERTEX>
116  Triangle<VERTEX> * const t1 = new Triangle<VERTEX>(a, c, d);
117  t1->fax_Material(get_Material());
118  return t1;
119  }
120 
121  template <typename VERTEX>
122  const VERTEX & Quadrilateral<VERTEX>::operator[](const int &index) const {
123  assert(-1 < index && index < 4);
124  const VERTEX * const ptr = &a;
125  return ptr[index];
126  }
127 
128  template <typename VERTEX>
130  assert(-1 < index && index < 4);
131  VERTEX * const ptr = &a;
132  return ptr[index];
133  }
134 
135 }
136 
137 #include <Zeni/Triangle.hxx>
138 #include <Zeni/Vertex3f.hxx>
139 
140 #endif
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition: glew.h:11582
The Direct3D9 Rendering System.
Definition: Video_DX9.h:62
LPDIRECT3DDEVICE9 & get_d3d_device()
See DirectX Documentation for details.
Definition: Video_DX9.hxx:48
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
An Abstraction of a Quadrilateral.
Definition: Quadrilateral.h:37
return Display return Display Bool Bool int d
Definition: SDL_x11sym.h:30
#define assert(x)
Definition: SDL_malloc.c:1234
A Renderable Interface.
Definition: Renderable.h:47
#define GL_TRIANGLE_FAN
Definition: gl2.h:60
Triangle< VERTEX > * get_duplicate_t1() const
Get the second half of the Quadrilateral.
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:11582
The OpenGL Rendering System.
virtual void render_to(Video_GL_Fixed &screen) const
Overridden for OpenGL rendering.
const GLfloat * c
Definition: glew.h:14913
Quadrilateral< VERTEX > & operator=(const Quadrilateral< VERTEX > &rhs)
Quadrilateral< VERTEX > * get_duplicate() const
Get a duplicate of the Quadrilateral.
GLuint index
Definition: glew.h:1800
virtual bool is_3d() const
Tell the rendering system if we&#39;re using 3D coordinates.
Triangle< VERTEX > * get_duplicate_t0() const
Get the first half of the Quadrilateral.
void fax_Material(const Material *const &material)
Set the Material, giving the Renderable a copy.
Definition: Renderable.cpp:50
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
An Abstraction of a Triangle.
Definition: Triangle.h:36
#define glBegin
Definition: gl_mangle.h:56
#define glEnd
Definition: gl_mangle.h:450
const VERTEX & operator[](const int &index) const
Get &#39;index&#39;.