zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Line_Segment.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_LINE_SEGMENT_HXX
19 #define ZENI_LINE_SEGMENT_HXX
20 
21 // HXXed below
22 #include <Zeni/Video_DX9.h>
23 
24 #include <Zeni/Line_Segment.h>
25 
26 // Not HXXed
27 #include <Zeni/Vector3f.h>
28 
29 #if defined(REQUIRE_GL_ES)
30 #include <GLES/gl.h>
31 #else
32 #include <GL/glew.h>
33 #endif
34 
35 namespace Zeni {
36 
37  template <typename VERTEX>
39  : a(VERTEX()),
40  b(VERTEX())
41  {
42  }
43 
44  template <typename VERTEX>
45  Line_Segment<VERTEX>::Line_Segment(const VERTEX &vertex0, const VERTEX &vertex1)
46  : a(vertex0),
47  b(vertex1)
48  {
49  }
50 
51  template <typename VERTEX>
53  : Renderable(rhs),
54  a(rhs.a),
55  b(rhs.b)
56  {
57  }
58 
59  template <typename VERTEX>
61  static_cast<Renderable &>(*this) = rhs;
62 
63  a = rhs.a;
64  b = rhs.b;
65 
66  return *this;
67  }
68 
69  template <typename VERTEX>
71  return a.is_3d();
72  }
73 
74 #if !defined(DISABLE_GL) && !defined(REQUIRE_GL_ES)
75  template <typename VERTEX>
78  a.subrender_to(screen);
79  b.subrender_to(screen);
80  glEnd();
81  }
82 #endif
83 
84 #ifndef DISABLE_DX9
85  template <typename VERTEX>
87  screen.get_d3d_device()->DrawPrimitiveUP(D3DPT_LINELIST, 1, a.get_address(), sizeof(VERTEX));
88  }
89 #endif
90 
91  template <typename VERTEX>
93  return new Line_Segment<VERTEX>(*this);
94  }
95 
96  template <typename VERTEX>
97  const VERTEX & Line_Segment<VERTEX>::operator[](const int &index) const {
98  assert(-1 < index && index < 2);
99  const VERTEX * const ptr = &a;
100  return ptr[index];
101  }
102 
103  template <typename VERTEX>
105  assert(-1 < index && index < 2);
106  VERTEX * const ptr = &a;
107  return ptr[index];
108  }
109 
110 }
111 
112 #include <Zeni/Video_DX9.hxx>
113 
114 #endif
The Direct3D9 Rendering System.
Definition: Video_DX9.h:62
LPDIRECT3DDEVICE9 & get_d3d_device()
See DirectX Documentation for details.
Definition: Video_DX9.hxx:48
#define GL_LINES
Definition: gl2.h:55
An Abstraction of a Line.
Definition: Line_Segment.h:36
const VERTEX & operator[](const int &index) const
Get &#39;index&#39;.
virtual void render_to(Video_GL_Fixed &screen) const
Overridden for OpenGL rendering.
GLboolean GLboolean GLboolean GLboolean a
Definition: glew.h:8736
#define assert(x)
Definition: SDL_malloc.c:1234
A Renderable Interface.
Definition: Renderable.h:47
The OpenGL Rendering System.
virtual bool is_3d() const
Tell the rendering system if we&#39;re using 3D coordinates.
GLuint index
Definition: glew.h:1800
Line_Segment< VERTEX > * get_duplicate() const
Get a duplicate of the Line.
GLdouble GLdouble GLdouble b
Definition: glew.h:8383
#define glBegin
Definition: gl_mangle.h:56
#define glEnd
Definition: gl_mangle.h:450
Line_Segment< VERTEX > & operator=(const Line_Segment< VERTEX > &rhs)