Lines 1-178
Link Here
|
1 |
diff -ruN backend/render_handler_ogl.h.orig backend/render_handler_ogl.h |
|
|
2 |
--- backend/render_handler_ogl.h.orig 1970-01-01 03:00:00.000000000 +0300 |
3 |
+++ backend/render_handler_ogl.h 2008-05-15 06:18:41.725653935 +0400 |
4 |
@@ -0,0 +1,174 @@ |
5 |
+// |
6 |
+// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
7 |
+// |
8 |
+// This program is free software; you can redistribute it and/or modify |
9 |
+// it under the terms of the GNU General Public License as published by |
10 |
+// the Free Software Foundation; either version 3 of the License, or |
11 |
+// (at your option) any later version. |
12 |
+// |
13 |
+// This program is distributed in the hope that it will be useful, |
14 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
+// GNU General Public License for more details. |
17 |
+// |
18 |
+// You should have received a copy of the GNU General Public License |
19 |
+// along with this program; if not, write to the Free Software |
20 |
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 |
+ |
22 |
+#ifndef __RENDER_HANDLER_OGL_H__ |
23 |
+#define __RENDER_HANDLER_OGL_H__ |
24 |
+ |
25 |
+ |
26 |
+#if defined(NOT_SGI_GL) || defined(__APPLE_CC__) |
27 |
+#include <AGL/agl.h> |
28 |
+#include <OpenGL/gl.h> |
29 |
+#include <OpenGL/glu.h> |
30 |
+#include <OpenGL/glext.h> |
31 |
+#define GLUCALLBACKTYPE GLvoid (*)(...) |
32 |
+#else |
33 |
+# define GLUCALLBACKTYPE void (*)() |
34 |
+# include <GL/gl.h> |
35 |
+# ifdef WIN32 |
36 |
+# define GL_CLAMP_TO_EDGE 0x812F |
37 |
+# else |
38 |
+# include <GL/glx.h> |
39 |
+# ifdef OSMESA_TESTING |
40 |
+# include <GL/osmesa.h> |
41 |
+# endif // OSMESA_TESTING |
42 |
+# endif |
43 |
+# include <GL/glu.h> |
44 |
+# ifndef APIENTRY |
45 |
+# define APIENTRY |
46 |
+# endif |
47 |
+#endif |
48 |
+ |
49 |
+ |
50 |
+ |
51 |
+ |
52 |
+namespace gnash { |
53 |
+ |
54 |
+ |
55 |
+ |
56 |
+ |
57 |
+typedef std::vector<const path*> PathRefs; |
58 |
+ |
59 |
+ |
60 |
+ |
61 |
+struct oglVertex { |
62 |
+ oglVertex(double x, double y, double z = 0.0) |
63 |
+ : _x(x), _y(y), _z(z) |
64 |
+ { |
65 |
+ } |
66 |
+ |
67 |
+ oglVertex(const point& p) |
68 |
+ : _x(p.x), _y(p.y), _z(0.0) |
69 |
+ { |
70 |
+ } |
71 |
+ |
72 |
+ GLdouble _x; |
73 |
+ GLdouble _y; |
74 |
+ GLdouble _z; |
75 |
+}; |
76 |
+ |
77 |
+typedef std::map< const path*, std::vector<oglVertex> > PathPointMap; |
78 |
+ |
79 |
+class Tesselator |
80 |
+{ |
81 |
+public: |
82 |
+ Tesselator(); |
83 |
+ ~Tesselator(); |
84 |
+ |
85 |
+ void beginPolygon(); |
86 |
+ |
87 |
+ void feed(std::vector<oglVertex>& vertices); |
88 |
+ |
89 |
+ void tesselate(); |
90 |
+ |
91 |
+ void beginContour(); |
92 |
+ void endContour(); |
93 |
+ |
94 |
+ void rememberVertex(GLdouble* v); |
95 |
+ |
96 |
+ static void |
97 |
+ error(GLenum error); |
98 |
+ |
99 |
+ static void combine(GLdouble coords [3], void *vertex_data[4], |
100 |
+ GLfloat weight[4], void **outData, void* userdata); |
101 |
+ |
102 |
+ |
103 |
+ |
104 |
+private: |
105 |
+ std::vector<GLdouble*> _vertices; |
106 |
+ GLUtesselator* _tessobj; |
107 |
+}; |
108 |
+ |
109 |
+class WholeShape |
110 |
+{ |
111 |
+public: |
112 |
+ void newPath(const path& new_path) |
113 |
+ { |
114 |
+ PathRefs refs; |
115 |
+ refs.push_back(&new_path); |
116 |
+ |
117 |
+ shape.push_back(refs); |
118 |
+ } |
119 |
+ |
120 |
+ void addPath(const path& add_path) |
121 |
+ { |
122 |
+ PathRefs& refs = shape.back(); |
123 |
+ refs.push_back(&add_path); |
124 |
+ } |
125 |
+ |
126 |
+ void addPathRefs(const PathRefs& pathrefs) |
127 |
+ { |
128 |
+ |
129 |
+ PathRefs new_refs(pathrefs.begin(), pathrefs.end()); |
130 |
+ |
131 |
+ shape.push_back(new_refs); |
132 |
+ } |
133 |
+ |
134 |
+ |
135 |
+ const std::vector<PathRefs>& get() const |
136 |
+ { |
137 |
+ return shape; |
138 |
+ } |
139 |
+ |
140 |
+private: |
141 |
+ std::vector<PathRefs> shape; |
142 |
+ |
143 |
+}; |
144 |
+ |
145 |
+ |
146 |
+class bitmap_info_ogl : public bitmap_info |
147 |
+{ |
148 |
+ public: |
149 |
+ bitmap_info_ogl(image::image_base* image, GLenum pixelformat, |
150 |
+ bool ogl_accessible); |
151 |
+ ~bitmap_info_ogl(); |
152 |
+ |
153 |
+ void apply(const gnash::matrix& bitmap_matrix, |
154 |
+ render_handler::bitmap_wrap_mode wrap_mode); |
155 |
+ private: |
156 |
+ inline bool ogl_accessible() const; |
157 |
+ void setup(); |
158 |
+ void upload(boost::uint8_t* data, size_t width, size_t height); |
159 |
+ |
160 |
+ std::auto_ptr<image::image_base> _img; |
161 |
+ GLenum _pixel_format; |
162 |
+ GLenum _ogl_img_type; |
163 |
+ bool _ogl_accessible; |
164 |
+ GLuint _texture_id; |
165 |
+ size_t _orig_width; |
166 |
+ size_t _orig_height; |
167 |
+}; |
168 |
+ |
169 |
+ |
170 |
+ |
171 |
+ |
172 |
+ |
173 |
+ |
174 |
+} // namespace gnash |
175 |
+ |
176 |
+ |
177 |
+#endif // __RENDER_HANDLER_OGL_H__ |
178 |
+ |