zenilib: zenilib/jni/external/zenilib/zeni_graphics/Zeni/Quadrilateral.hxx Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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>
39 Quadrilateral<VERTEX>::Quadrilateral()
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>
57 Quadrilateral<VERTEX>::Quadrilateral(const Quadrilateral<VERTEX> &rhs)
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>
67 Quadrilateral<VERTEX> & Quadrilateral<VERTEX>::operator=(const Quadrilateral<VERTEX> &rhs) {
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>
79 bool Quadrilateral<VERTEX>::is_3d() const {
80 return a.is_3d();
81 }
82
83 #if !defined(DISABLE_GL) && !defined(REQUIRE_GL_ES)
84 template <typename VERTEX>
85 void Quadrilateral<VERTEX>::render_to(Video_GL_Fixed &screen) const {
86 glBegin(GL_TRIANGLE_FAN);
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>
97 void Quadrilateral<VERTEX>::render_to(Video_DX9 &screen) const {
98 screen.get_d3d_device()->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, a.get_address(), sizeof(VERTEX));
99 }
100 #endif
101
102 template <typename VERTEX>
103 Quadrilateral<VERTEX> * Quadrilateral<VERTEX>::get_duplicate() const {
104 return new Quadrilateral<VERTEX>(*this);
105 }
106
107 template <typename VERTEX>
108 Triangle<VERTEX> * Quadrilateral<VERTEX>::get_duplicate_t0() const {
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>
115 Triangle<VERTEX> * Quadrilateral<VERTEX>::get_duplicate_t1() const {
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>
129 VERTEX & Quadrilateral<VERTEX>::operator[](const int &index) {
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
Triangle.hxx
Vertex3f.h
Zeni::Quadrilateral::Quadrilateral
Quadrilateral()
Definition: Quadrilateral.hxx:39
t0
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
Definition: glew.h:11582
Zeni::Video_DX9
The Direct3D9 Rendering System.
Definition: Video_DX9.h:62
Zeni::Quadrilateral::b
VERTEX b
Definition: Quadrilateral.h:73
Zeni::Video_DX9::get_d3d_device
LPDIRECT3DDEVICE9 & get_d3d_device()
See DirectX Documentation for details.
Definition: Video_DX9.hxx:48
a
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
Zeni::Quadrilateral::a
VERTEX a
Definition: Quadrilateral.h:72
Zeni::Quadrilateral
An Abstraction of a Quadrilateral.
Definition: Quadrilateral.h:37
d
return Display return Display Bool Bool int d
Definition: SDL_x11sym.h:30
assert
#define assert(x)
Definition: SDL_malloc.c:1234
Zeni::Renderable
A Renderable Interface.
Definition: Renderable.h:47
GL_TRIANGLE_FAN
#define GL_TRIANGLE_FAN
Definition: gl2.h:60
Vertex3f.hxx
Zeni::Quadrilateral::get_duplicate_t1
Triangle< VERTEX > * get_duplicate_t1() const
Get the second half of the Quadrilateral.
Definition: Quadrilateral.hxx:115
D3DPT_TRIANGLEFAN
Definition: d3d9types.h:309
t1
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t1
Definition: glew.h:11582
Zeni::Video_GL_Fixed
The OpenGL Rendering System.
Definition: Video_GL_Fixed.h:70
Quadrilateral.h
Triangle.h
Zeni::Quadrilateral::render_to
virtual void render_to(Video_GL_Fixed &screen) const
Overridden for OpenGL rendering.
Definition: Quadrilateral.hxx:85
c
const GLfloat * c
Definition: glew.h:14913
Zeni::Quadrilateral::operator=
Quadrilateral< VERTEX > & operator=(const Quadrilateral< VERTEX > &rhs)
Definition: Quadrilateral.hxx:67
Zeni::Quadrilateral::get_duplicate
Quadrilateral< VERTEX > * get_duplicate() const
Get a duplicate of the Quadrilateral.
Definition: Quadrilateral.hxx:103
index
GLuint index
Definition: glew.h:1800
Zeni::Quadrilateral::d
VERTEX d
Definition: Quadrilateral.h:75
Zeni::Quadrilateral::is_3d
virtual bool is_3d() const
Tell the rendering system if we&#39;re using 3D coordinates.
Definition: Quadrilateral.hxx:79
Zeni::Quadrilateral::get_duplicate_t0
Triangle< VERTEX > * get_duplicate_t0() const
Get the first half of the Quadrilateral.
Definition: Quadrilateral.hxx:108
Zeni::Renderable::fax_Material
void fax_Material(const Material *const &material)
Set the Material, giving the Renderable a copy.
Definition: Renderable.cpp:50
b
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
Zeni::Triangle
An Abstraction of a Triangle.
Definition: Triangle.h:36
glBegin
#define glBegin
Definition: gl_mangle.h:56
glEnd
#define glEnd
Definition: gl_mangle.h:450
Zeni::Quadrilateral::operator[]
const VERTEX & operator[](const int &index) const
Get &#39;index&#39;.
Definition: Quadrilateral.hxx:122
Zeni::Quadrilateral::c
VERTEX c
Definition: Quadrilateral.h:74