Gnash  0.8.11dev
Renderer_ogl.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_RENDER_HANDLER_OGL_H
20 #define GNASH_RENDER_HANDLER_OGL_H
21 
22 #if defined(NOT_SGI_GL) || defined(__APPLE_CC__)
23 # ifdef __APPLE_CC__
24 # include <AGL/agl.h>
25 # endif
26 #include <vector>
27 #include <OpenGL/gl.h>
28 #include <OpenGL/glu.h>
29 #include <OpenGL/glext.h>
30 # if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
31 # define GLUCALLBACKTYPE GLvoid (*)()
32 # else
33 # define GLUCALLBACKTYPE GLvoid (*)(...)
34 # endif
35 #else
36 # define GLUCALLBACKTYPE void (*)()
37 # include <GL/gl.h>
38 # ifdef WIN32
39 # define GL_CLAMP_TO_EDGE 0x812F
40 # else
41 # include <GL/glx.h>
42 # ifdef OSMESA_TESTING
43 # include <GL/osmesa.h>
44 # endif // OSMESA_TESTING
45 # endif
46 # include <GL/glu.h>
47 # ifndef APIENTRY
48 # define APIENTRY
49 # endif
50 #endif
51 
52 #include "Renderer.h"
53 #include "Geometry.h"
54 #include "CachedBitmap.h"
55 
56 #include <map>
57 
58 
59 namespace gnash {
60 
61 namespace renderer {
62 
63 namespace opengl {
64 
65 typedef std::vector<const Path*> PathRefs;
66 
67 struct oglVertex {
68  oglVertex(double x, double y, double z = 0.0)
69  : _x(x), _y(y), _z(z)
70  {
71  }
72 
73  oglVertex(const point& p)
74  : _x(p.x), _y(p.y), _z(0.0)
75  {
76  }
77 
78  GLdouble _x;
79  GLdouble _y;
80  GLdouble _z;
81 };
82 
83 typedef std::map<const Path*, std::vector<oglVertex> > PathPointMap;
84 
86 {
87 public:
88  Tesselator();
89  ~Tesselator();
90 
91  void beginPolygon();
92 
93  void feed(std::vector<oglVertex>& vertices);
94 
95  void tesselate();
96 
97  void beginContour();
98  void endContour();
99 
100  void rememberVertex(GLdouble* v);
101 
102  static void
103  error(GLenum error);
104 
105  static void combine(GLdouble coords [3], void *vertex_data[4],
106  GLfloat weight[4], void **outData, void* userdata);
107 
108 
109 
110 private:
111  std::vector<GLdouble*> _vertices;
112  GLUtesselator* _tessobj;
113 };
114 
116 {
117 public:
118  void newPath(const Path& new_path)
119  {
120  PathRefs refs;
121  refs.push_back(&new_path);
122 
123  shape.push_back(refs);
124  }
125 
126  void addPath(const Path& add_path)
127  {
128  PathRefs& refs = shape.back();
129  refs.push_back(&add_path);
130  }
131 
132  void addPathRefs(const PathRefs& pathrefs)
133  {
134 
135  PathRefs new_refs(pathrefs.begin(), pathrefs.end());
136 
137  shape.push_back(new_refs);
138  }
139 
140 
141  const std::vector<PathRefs>& get() const
142  {
143  return shape;
144  }
145 
146 private:
147  std::vector<PathRefs> shape;
148 
149 };
150 
151 DSOEXPORT Renderer* create_handler(bool init = true);
152 
153 } // namespace gnash::renderer::opengl
154 } // namespace gnash::renderer
155 } // namespace gnash
156 
157 #endif
158 
159 // local Variables:
160 // mode: C++
161 // indent-tabs-mode: nil
162 // End: