Gnash  0.8.10
Renderer_ogl.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00018 
00019 #ifndef GNASH_RENDER_HANDLER_OGL_H
00020 #define GNASH_RENDER_HANDLER_OGL_H
00021 
00022 #if defined(NOT_SGI_GL) || defined(__APPLE_CC__)
00023 # ifdef __APPLE_CC__
00024 # include <AGL/agl.h>
00025 # endif
00026 #include <vector>
00027 #include <OpenGL/gl.h>
00028 #include <OpenGL/glu.h>
00029 #include <OpenGL/glext.h>
00030 # if defined(__APPLE_CC__) && (__APPLE_CC__ >= 5465)
00031 # define GLUCALLBACKTYPE GLvoid (*)()
00032 # else
00033 # define GLUCALLBACKTYPE GLvoid (*)(...)
00034 # endif
00035 #else
00036 # define GLUCALLBACKTYPE void (*)()
00037 # include <GL/gl.h>
00038 # ifdef WIN32
00039 #  define GL_CLAMP_TO_EDGE 0x812F
00040 # else
00041 # include <GL/glx.h>
00042 # ifdef OSMESA_TESTING
00043 #  include <GL/osmesa.h>
00044 # endif // OSMESA_TESTING
00045 # endif
00046 # include <GL/glu.h>
00047 # ifndef APIENTRY
00048 #  define APIENTRY
00049 # endif
00050 #endif
00051 
00052 #include "Renderer.h"
00053 #include "Geometry.h"
00054 #include "CachedBitmap.h"
00055 
00056 #include <map>
00057 
00058 
00059 namespace gnash {
00060 
00061 namespace renderer {
00062 
00063 namespace opengl {
00064 
00065 typedef std::vector<const Path*> PathRefs;
00066  
00067 struct oglVertex {
00068   oglVertex(double x, double y, double z = 0.0)
00069     : _x(x), _y(y), _z(z)
00070   {
00071   }
00072   
00073   oglVertex(const point& p)
00074     : _x(p.x), _y(p.y), _z(0.0)
00075   {
00076   }
00077 
00078   GLdouble _x;
00079   GLdouble _y;
00080   GLdouble _z;
00081 };
00082 
00083 typedef std::map<const Path*, std::vector<oglVertex> > PathPointMap;
00084 
00085 class Tesselator
00086 {
00087 public:
00088   Tesselator();  
00089   ~Tesselator();
00090   
00091   void beginPolygon();
00092   
00093   void feed(std::vector<oglVertex>& vertices);
00094   
00095   void tesselate();
00096   
00097   void beginContour();
00098   void endContour();
00099   
00100   void rememberVertex(GLdouble* v);
00101   
00102   static void
00103   error(GLenum error);
00104 
00105   static void combine(GLdouble coords [3], void *vertex_data[4],
00106                       GLfloat weight[4], void **outData, void* userdata);
00107   
00108 
00109   
00110 private:
00111   std::vector<GLdouble*> _vertices;
00112   GLUtesselator* _tessobj;
00113 };
00114 
00115 class WholeShape
00116 {
00117 public:
00118   void newPath(const Path& new_path)
00119   {
00120     PathRefs refs;
00121     refs.push_back(&new_path);
00122     
00123     shape.push_back(refs);
00124   }
00125   
00126   void addPath(const Path& add_path)
00127   {
00128     PathRefs& refs = shape.back();
00129     refs.push_back(&add_path);
00130   }
00131   
00132   void addPathRefs(const PathRefs& pathrefs)
00133   {
00134   
00135     PathRefs new_refs(pathrefs.begin(), pathrefs.end());
00136     
00137     shape.push_back(new_refs);
00138   }
00139   
00140   
00141   const std::vector<PathRefs>& get() const
00142   {
00143     return shape;
00144   }
00145   
00146 private:
00147   std::vector<PathRefs> shape;
00148 
00149 };
00150 
00151 DSOEXPORT Renderer* create_handler(bool init = true);
00152 
00153 } // namespace gnash::renderer::opengl
00154 } // namespace gnash::renderer
00155 } // namespace gnash
00156 
00157 #endif
00158 
00159 // local Variables:
00160 // mode: C++
00161 // indent-tabs-mode: nil
00162 // End: