00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (gl_render_h)
00024 #define gl_render_h 1
00025
00026 #ifdef HAVE_WINDOWS_H
00027 #include <windows.h>
00028 #endif
00029
00030 #ifdef HAVE_GL_GL_H
00031 #include <GL/gl.h>
00032 #elif defined HAVE_OPENGL_GL_H || defined HAVE_FRAMEWORK_OPENGL
00033 #include <OpenGL/gl.h>
00034 #endif
00035
00036 #ifdef HAVE_GL_GLU_H
00037 #include <GL/glu.h>
00038 #elif defined HAVE_OPENGL_GLU_H || defined HAVE_FRAMEWORK_OPENGL
00039 #include <OpenGL/glu.h>
00040 #endif
00041
00042 #include "graphics.h"
00043 #include "txt-eng-ft.h"
00044
00045 class
00046 OCTINTERP_API
00047 opengl_renderer
00048 {
00049 public:
00050 opengl_renderer (void) { }
00051
00052 virtual ~opengl_renderer (void) { }
00053
00054 virtual void draw (const graphics_handle& h)
00055 { draw (gh_manager::get_object (h)); }
00056
00057 virtual void draw (const graphics_object& go);
00058
00059 virtual void draw (const Matrix& hlist)
00060 {
00061 int len = hlist.length ();
00062
00063 for (int i = 0; i < len; i++)
00064 {
00065 graphics_handle h = gh_manager::lookup (hlist(i));
00066
00067 if (h.ok ())
00068 draw (h);
00069 }
00070 }
00071
00072 virtual void set_viewport (int w, int h);
00073
00074 protected:
00075 virtual void draw (const figure::properties& props);
00076 virtual void draw (const axes::properties& props);
00077 virtual void draw (const line::properties& props);
00078 virtual void draw (const surface::properties& props);
00079 virtual void draw (const patch::properties& props);
00080 virtual void draw (const hggroup::properties& props);
00081 virtual void draw (const text::properties& props);
00082 virtual void draw (const image::properties& props);
00083
00084 virtual void set_color (const Matrix& c);
00085 virtual void set_polygon_offset (bool on, double offset = 0.0);
00086 virtual void set_linewidth (float w);
00087 virtual void set_linestyle (const std::string& s, bool stipple = false);
00088 virtual void set_clipbox (double x1, double x2, double y1, double y2,
00089 double z1, double z2);
00090 virtual void set_clipping (bool on);
00091 virtual void set_font (const base_properties& props);
00092
00093 virtual void init_marker (const std::string& m, double size, float width);
00094 virtual void end_marker (void);
00095 virtual void draw_marker (double x, double y, double z,
00096 const Matrix& lc, const Matrix& fc);
00097
00098 virtual Matrix draw_text (const std::string& txt,
00099 double x, double y, double z,
00100 int halign, int valign, double rotation = 0.0);
00101
00102 private:
00103 opengl_renderer (const opengl_renderer&) { }
00104
00105 opengl_renderer& operator = (const opengl_renderer&)
00106 { return *this; }
00107
00108 bool is_nan_or_inf (double x, double y, double z) const
00109 {
00110 return (xisnan (x) || xisnan (y) || xisnan (z)
00111 || xisinf (x) || xisinf (y) || xisinf (z));
00112 }
00113
00114 octave_uint8 clip_code (double x, double y, double z) const
00115 {
00116 return ((x < xmin ? 1 : 0)
00117 | (x > xmax ? 1 : 0) << 1
00118 | (y < ymin ? 1 : 0) << 2
00119 | (y > ymax ? 1 : 0) << 3
00120 | (z < zmin ? 1 : 0) << 4
00121 | (z > zmax ? 1 : 0) << 5
00122 | (is_nan_or_inf (x, y, z) ? 0 : 1) << 6);
00123 }
00124
00125 unsigned int make_marker_list (const std::string& m, double size,
00126 bool filled) const;
00127
00128 private:
00129
00130 graphics_backend backend;
00131
00132
00133 graphics_xform xform;
00134
00135
00136 double xmin, xmax;
00137 double ymin, ymax;
00138 double zmin, zmax;
00139
00140
00141 double xZ1, xZ2;
00142
00143
00144 unsigned int marker_id, filled_marker_id;
00145
00146
00147 ColumnVector camera_pos, camera_dir;
00148
00149 #if HAVE_FREETYPE
00150
00151 ft_render text_renderer;
00152 #endif
00153
00154 private:
00155 class patch_tesselator;
00156 };
00157
00158 #endif