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:
gnash::renderer::opengl::oglVertex::oglVertex
oglVertex(double x, double y, double z=0.0)
Definition: Renderer_ogl.h:68
path
VGPath path
Definition: testr_gtk.cpp:84
gnash::key::R
@ R
Definition: GnashKey.h:130
gnash::key::l
@ l
Definition: GnashKey.h:158
GnashVaapiTexture.h
gnash::GradientFill::RADIAL
@ RADIAL
Definition: FillStyle.h:162
gnash::renderer::opengl::Tesselator::error
static void error(GLenum error)
Definition: Renderer_ogl.cpp:513
gnash::SolidFill
A SolidFill containing one color.
Definition: FillStyle.h:247
gnash::renderer::opengl::WholeShape::addPath
void addPath(const Path &add_path)
Definition: Renderer_ogl.h:126
height
@ height
Definition: klash_part.cpp:329
gnash::log_swferror
void log_swferror(StringType msg, Args... args)
Definition: log.h:325
ShapeRecord.h
gnash::PathVec
std::vector< Path > PathVec
Definition: Renderer_cairo.h:35
gnash::renderer::gles1::bitmap_info_ogl::apply
void apply(const gnash::SWFMatrix &bitmap_matrix, bitmap_wrap_mode wrap_mode) const
Definition: Renderer_ogl.cpp:634
gnash::image::ImageRGB
24-bit RGB bitmap
Definition: GnashImage.h:217
gnash::key::T
@ T
Definition: GnashKey.h:132
GLUCALLBACKTYPE
#define GLUCALLBACKTYPE
Definition: Renderer_ogl.h:36
gnash::renderer::opengl::WholeShape::get
const std::vector< PathRefs > & get() const
Definition: Renderer_ogl.h:141
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
y
std::int32_t y
Definition: BitmapData_as.cpp:435
gnash::renderer::opengl::WholeShape::newPath
void newPath(const Path &new_path)
Definition: Renderer_ogl.h:118
gnash::key::i
@ i
Definition: GnashKey.h:155
LOG_ONCE
#define LOG_ONCE(x)
Definition: log.h:49
gnash::rgba
A basic RGBA type.
Definition: RGBA.h:36
gnash::image::GnashImage::iterator
value_type * iterator
Definition: GnashImage.h:83
gnash::renderer::gles1::bitmap_info_ogl::bitmap_wrap_mode
bitmap_wrap_mode
Set line and fill styles for mesh & line_strip rendering.
Definition: Renderer_gles1.h:107
gnash::pixelsToTwips
std::int32_t pixelsToTwips(double a)
Definition: GnashNumeric.h:144
_
#define _(String)
Definition: log.h:44
Renderer.h
Geometry.h
Transform.h
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::renderer::opengl::Tesselator::feed
void feed(std::vector< oglVertex > &vertices)
Definition: Renderer_ogl.cpp:478
gnash::renderer::opengl::Tesselator::endContour
void endContour()
Definition: Renderer_ogl.cpp:488
gnash::image::GnashImage
Base class for different types of bitmaps.
Definition: GnashImage.h:78
gnash::renderer::opengl::Tesselator::rememberVertex
void rememberVertex(GLdouble *v)
Definition: Renderer_ogl.cpp:506
GNASH_REPORT_FUNCTION
#define GNASH_REPORT_FUNCTION
Definition: log.h:452
gnash::Renderer
Base class for render handlers.
Definition: Renderer.h:189
gnash::key::m
@ m
Definition: GnashKey.h:159
utility.h
second
std::int32_t second
Definition: Date_as.cpp:93
gnash::key::n
@ n
Definition: GnashKey.h:160
gnash::SWFCxForm
Color transformation record.
Definition: SWFCxForm.h:35
gnash::BitmapFill::TILED
@ TILED
Definition: FillStyle.h:87
GnashImage.h
gnash::twipsToPixels
double twipsToPixels(int i)
Definition: GnashNumeric.h:97
GnashEnums.h
SWFCxForm.h
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::renderer::opengl::oglVertex
Definition: Renderer_ogl.h:67
gnash::renderer::opengl::WholeShape::addPathRefs
void addPathRefs(const PathRefs &pathrefs)
Definition: Renderer_ogl.h:132
CachedBitmap.h
gnash::GNASH_TEXTURE_VAAPI
@ GNASH_TEXTURE_VAAPI
Definition: GnashTexture.h:30
gnash::renderer::opengl::Tesselator::tesselate
void tesselate()
Definition: Renderer_ogl.cpp:494
IF_VERBOSE_MALFORMED_SWF
#define IF_VERBOSE_MALFORMED_SWF(x)
Definition: log.h:404
color
const VGfloat color[4]
Definition: testr_gtk.cpp:82
gnash::key::r
@ r
Definition: GnashKey.h:164
gnash::lerp
T lerp(T a, T b, T f)
Definition: GnashNumeric.h:85
fill
VGPaint fill
Definition: testr_gtk.cpp:86
gnash::renderer::opengl::for_each
void for_each(C &container, R(T::*pmf)(const A &), const A &arg)
Definition: Renderer_ogl.cpp:690
gnash::key::a
@ a
Definition: GnashKey.h:147
gnash::InvalidatedRanges
geometry::SnappingRanges2d< std::int32_t > InvalidatedRanges
Standard snapping 2d ranges type for invalidated bounds calculation
Definition: snappingrange.h:655
gnash::GradientFill
A GradientFill.
Definition: FillStyle.h:154
GnashVaapiImage.h
gnash::Path
A subset of a shape, a series of edges sharing a single set of styles.
Definition: Geometry.h:167
gnash::key::h
@ h
Definition: GnashKey.h:154
RGBA.h
gnash::key::z
@ z
Definition: GnashKey.h:172
gnash::key::p
@ p
Definition: GnashKey.h:162
gnash::renderer::opengl::Tesselator::Tesselator
Tesselator()
Definition: Renderer_ogl.cpp:435
test.w
w
Definition: test.py:8
gnash::key::C
@ C
Definition: GnashKey.h:115
gnash::key::q
@ q
Definition: GnashKey.h:163
gnash::point
geometry::Point2d point
Definition: Point2d.h:143
gnash::key::_1
@ _1
Definition: GnashKey.h:95
GnashNumeric.h
gnash::renderer::opengl::oglVertex::_x
GLdouble _x
Definition: Renderer_ogl.h:78
gnash::renderer::gles1::bitmap_info_ogl::~bitmap_info_ogl
~bitmap_info_ogl()
Definition: Renderer_ogl.cpp:560
gnash::SWFMatrix
Definition: SWFMatrix.h:54
gnash::geometry::Point2d
2D Point class
Definition: Point2d.h:39
gnash::renderer::opengl::Tesselator
Definition: Renderer_ogl.h:86
gnash::renderer::opengl::oglVertex::oglVertex
oglVertex(const point &p)
Definition: Renderer_ogl.h:73
gnash::renderer::opengl::oglVertex::_y
GLdouble _y
Definition: Renderer_ogl.h:79
gnash::key::j
@ j
Definition: GnashKey.h:156
gnash::renderer::opengl::PathVec
std::vector< Path > PathVec
Definition: Renderer_ogl.cpp:290
gnash::image::GNASH_IMAGE_CPU
@ GNASH_IMAGE_CPU
Definition: GnashImage.h:56
log.h
gnash::renderer::opengl::Tesselator::~Tesselator
~Tesselator()
Definition: Renderer_ogl.cpp:461
gnash::renderer::opengl::WholeShape
Definition: Renderer_ogl.h:116
gnash::key::f
@ f
Definition: GnashKey.h:152
gnashconfig.h
gnash::image::end
pixel_iterator< T > end(GnashImage &im)
Definition: ImageIterators.h:198
gnash::GradientFill::LINEAR
@ LINEAR
Definition: FillStyle.h:161
GnashTexture.h
gnash::BitmapFill
A BitmapFill.
Definition: FillStyle.h:71
gnash::key::c
@ c
Definition: GnashKey.h:149
gnash::image::TYPE_RGB
@ TYPE_RGB
Definition: GnashImage.h:49
GL_LINE_WIDTH_RANGE
#define GL_LINE_WIDTH_RANGE
Definition: render_handler_gles.h:55
gnash::renderer::gles1::PathPointMap
std::map< const Path *, std::vector< oglVertex > > PathPointMap
Definition: Renderer_gles1.h:69
gnash::geometry::Point2d::distance
std::int32_t distance(const Point2d &p) const
Return distance between this and the given point.
Definition: Point2d.h:118
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::renderer::gles1::create_handler
Renderer * create_handler(const char *)
Definition: Renderer_gles1.cpp:315
gnash::renderer::opengl::middle
point middle(const point &a, const point &b)
Definition: Renderer_ogl.cpp:350
FillStyle.h
gnash::renderer::opengl::create_handler
Renderer * create_handler(bool init)
Definition: Renderer_ogl.cpp:1836
gnash::image::GNASH_IMAGE_GPU
@ GNASH_IMAGE_GPU
Definition: GnashImage.h:57
gnash::renderer::opengl::interpolate
std::vector< oglVertex > interpolate(const std::vector< Edge > &edges, const float &anchor_x, const float &anchor_y)
Definition: Renderer_ogl.cpp:409
gnash::Edge
Defines an edge with a control point and an anchor point.
Definition: Geometry.h:45
gnash::Path::transform
void transform(const SWFMatrix &mat)
Transform all path coordinates according to the given SWFMatrix.
Definition: Geometry.h:443
width
@ width
Definition: klash_part.cpp:329
Renderer_ogl.h
gnash::log_unimpl
void log_unimpl(StringType msg, Args... args)
Definition: log.h:289
gnash::key::u
@ u
Definition: GnashKey.h:167
gnash::renderer::opengl::PathPointMap
std::map< const Path *, std::vector< oglVertex > > PathPointMap
Definition: Renderer_ogl.h:83
gnash::CachedBitmap
A CachedBitmap is created by the renderer in a format of its choosing.
Definition: CachedBitmap.h:38
x
std::int32_t x
Definition: BitmapData_as.cpp:434
gnash::renderer::opengl::oglVertex::_z
GLdouble _z
Definition: Renderer_ogl.h:80
gnash::key::b
@ b
Definition: GnashKey.h:148
test.v
v
Definition: test.py:11
data
SimpleBuffer data
Definition: LocalConnection_as.cpp:151
gnash::renderer::opengl::Tesselator::beginContour
void beginContour()
Definition: Renderer_ogl.cpp:472
gnash::renderer::opengl::Tesselator::combine
static void combine(GLdouble coords[3], void *vertex_data[4], GLfloat weight[4], void **outData, void *userdata)
Definition: Renderer_ogl.cpp:520
gnash::image::TYPE_RGBA
@ TYPE_RGBA
Definition: GnashImage.h:50
Range2d.h
gnash::renderer::opengl::Tesselator::beginPolygon
void beginPolygon()
Definition: Renderer_ogl.cpp:467
gnash::PathPtrVec
std::vector< const Path * > PathPtrVec
Definition: Renderer_cairo.h:36
gnash::renderer::opengl::PathRefs
std::vector< const Path * > PathRefs
Definition: Renderer_ogl.h:65
gnash::renderer::opengl::isEven
bool isEven(const size_t &n)
Definition: Renderer_ogl.cpp:536
gnash::image::ImageRGBA
32-bit RGBA bitmap
Definition: GnashImage.h:236
gnash::key::A
@ A
Definition: GnashKey.h:113
gnash::renderer::gles1::bitmap_info_ogl::WRAP_CLAMP
@ WRAP_CLAMP
Definition: Renderer_gles1.h:109
gnash::renderer::opengl::trace_curve
void trace_curve(const point &startP, const point &controlP, const point &endP, std::vector< oglVertex > &coords)
Definition: Renderer_ogl.cpp:390