Fresco/Berlin/modules/Drawing/openGL DrawingKit.cc,1.106,1.107 DrawingKit.hh,1.64,1.65 FTFont.cc,1.6,1.7 FTFont.hh,1.3,1.4 Font.hh,1.11,1.12 FontServer.cc,1.3,1.4 FontServer.hh,1.2,1.3 Quadric.cc,1.7,1.8 Quadric.hh,1.5,1.6 Raster.cc,1.16,1.17 Raster.hh,1.10,1.11
Tobias Hunger <[email protected]> Tue, 30 Dec 2003 06:10:08 +0100
| Newsgroups | gmane.comp.video.fresco.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL
In directory purcel:/tmp/cvs-serv30213/modules/Drawing/openGL
Modified Files:
DrawingKit.cc DrawingKit.hh FTFont.cc FTFont.hh Font.hh
FontServer.cc FontServer.hh Quadric.cc Quadric.hh Raster.cc
Raster.hh
Log Message:
* Styleguidify Berlin
* Add namespace Berlin
Both patches are mixed into one since I did not want to commit two such
large and disruptive patches.
Index: DrawingKit.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/DrawingKit.cc,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- DrawingKit.cc 3 Nov 2003 20:45:41 -0000 1.106
+++ DrawingKit.cc 29 Dec 2003 08:03:24 -0000 1.107
@@ -33,13 +33,13 @@
using namespace Prague;
using namespace Fresco;
+using namespace Berlin::Console_Extension;
using namespace Berlin::DrawingKit;
class openGL::DrawingKit::Light::Init : public virtual GLContext::Callback
{
public:
- Init::Init(int *max)
- : my_max(max) {}
[...1209 lines suppressed...]
void openGL::DrawingKit::draw_mesh(const Fresco::Mesh &mesh)
{
- my_glcontext->add_to_queue(new DrawMesh(mesh));
+ my_glcontext->add_to_queue(new DrawMesh(mesh));
}
-void openGL::DrawingKit::copy_drawable(Drawable_ptr d, PixelCoord x, PixelCoord y, PixelCoord w, PixelCoord h) {}
+void openGL::DrawingKit::copy_drawable(Drawable_ptr d,
+ PixelCoord x, PixelCoord y,
+ PixelCoord w, PixelCoord h) { }
-extern "C" KitImpl *load()
+extern "C" Berlin::KitImpl *load()
{
- static std::string properties[] = {"implementation", "GLDrawingKit"};
- return create_prototype<openGL::DrawingKit> ("IDL:fresco.org/Fresco/DrawingKit3D:1.0", properties, 2);
+ static std::string properties[] = {"implementation", "GLDrawingKit"};
+ return Berlin::create_prototype<openGL::DrawingKit> ("IDL:fresco.org/Fresco/DrawingKit3D:1.0", properties, 2);
}
Index: DrawingKit.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/DrawingKit.hh,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- DrawingKit.hh 27 May 2003 23:12:46 -0000 1.64
+++ DrawingKit.hh 29 Dec 2003 08:03:25 -0000 1.65
@@ -20,8 +20,8 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*/
-#ifndef _DrawingKit_hh
-#define _DrawingKit_hh
+#ifndef _openGL_DrawingKit_hh
+#define _openGL_DrawingKit_hh
#include <Prague/Sys/Thread.hh>
#include <Fresco/config.hh>
@@ -43,177 +43,225 @@
namespace Berlin
{
-namespace DrawingKit
-{
-namespace openGL
-{
-
-class DrawingKit : public virtual POA_Fresco::DrawingKit3D,
- public DrawingKitBase, public KitImpl
-{
- class Restore;
- friend class Texture;
- friend class Image;
-
- class Light
- {
- friend class openGL::DrawingKit::Restore;
- public:
- Light(GLContext *);
- int push();
- int top() const;
- void pop();
- private:
- class Init;
- GLContext *my_glcontext;
- int _max;
- int _number;
- };
- struct DrawState
+ namespace DrawingKit
{
- enum { st_lights, st_last};
- DrawState() {}
- std::bitset<st_last> flags;
- size_t lights;
- };
-public:
- DrawingKit(const std::string &,
- const Fresco::Kit::PropertySeq &,
- ServerContextImpl *);
- virtual ~DrawingKit();
- virtual KitImpl *clone(const Fresco::Kit::PropertySeq &, ServerContextImpl *);
-
- virtual void save();
- virtual void restore();
-
- virtual void transformation(Fresco::Transform_ptr t) { DrawingKitBase::transformation(t);}
- virtual Fresco::Transform_ptr transformation() { return Fresco::Transform::_duplicate(_tr);}
- virtual void clipping(Fresco::Region_ptr r) { DrawingKitBase::clipping(r);}
- virtual Fresco::Region_ptr clipping() { return Fresco::Region::_duplicate(_cl);}
-// using DrawingKitBase::foreground;
- virtual void foreground(const Fresco::Color &c) { DrawingKitBase::foreground(c);}
- virtual Fresco::Color foreground() { return _fg;}
- virtual void lighting(const Fresco::Color &c) { DrawingKitBase::lighting(c);}
- virtual Fresco::Color lighting() { return _lt;}
- virtual void point_size(Fresco::Coord c) { DrawingKitBase::point_size(c);}
- virtual Fresco::Coord point_size() { return _ps;}
- virtual void line_width(Fresco::Coord c) { DrawingKitBase::line_width(c);}
- virtual Fresco::Coord line_width() { return _lw;}
- virtual void line_endstyle(Fresco::DrawingKit::Endstyle e) { DrawingKitBase::line_endstyle(e);}
- virtual Fresco::DrawingKit::Endstyle line_endstyle() { return _es;}
- virtual void surface_fillstyle(Fresco::DrawingKit::Fillstyle f) { DrawingKitBase::surface_fillstyle(f);}
- virtual Fresco::DrawingKit::Fillstyle surface_fillstyle() { return _fs;}
- virtual void texture(Fresco::Raster_ptr r) { DrawingKitBase::texture(r);}
- virtual Fresco::Raster_ptr texture() { return _tx ? Fresco::Raster::_duplicate(_tx->remote) : Fresco::Raster::_nil();}
+ namespace openGL
+ {
- virtual CORBA::ULong font_size() { return _font->size();}
- virtual CORBA::ULong font_weight() { return _font->weight();}
- virtual Fresco::Unistring *font_family() { return _font->family();}
- virtual Fresco::Unistring *font_subfamily() { return _font->subfamily();}
- virtual Fresco::Unistring *font_fullname() { return _font->fullname();}
- virtual Fresco::Unistring *font_style() { return _font->style();}
- virtual Fresco::DrawingKit::FontMetrics font_metrics() { return _font->metrics();}
- virtual Fresco::DrawingKit::GlyphMetrics glyph_metrics(Fresco::Unichar uc) { return _font->metrics(uc);}
- virtual CORBA::Any *get_font_attribute(const Fresco::Unistring & name) { return new CORBA::Any();}
+ class DrawingKit : public virtual POA_Fresco::DrawingKit3D,
+ public DrawingKitBase, public KitImpl
+ {
+ class Restore;
+ friend class Texture;
+ friend class Image;
- virtual void material(const Fresco::MaterialAttr &) {}
- virtual Fresco::MaterialAttr material() { return Fresco::MaterialAttr();}
- virtual void textures(const Fresco::Rasters &) {}
- virtual Fresco::Rasters *textures() { return new Fresco::Rasters();}
- virtual void tex_mode(Fresco::DrawingKit3D::TextureMode) {}
- virtual Fresco::DrawingKit3D::TextureMode tex_mode() { return Fresco::DrawingKit3D::TextureOff;}
- virtual void directional_light(const Fresco::Color &, CORBA::Float, const Fresco::Vertex &);
- virtual void point_light(const Fresco::Color &, CORBA::Float, const Fresco::Vertex &);
- virtual void spot_light(const Fresco::Color &, CORBA::Float, const Fresco::Vertex &, const Fresco::Vertex &, CORBA::Float, CORBA::Float);
- virtual void fog_mode(Fresco::DrawingKit3D::FoggingMode) {}
- virtual Fresco::DrawingKit3D::FoggingMode fog_mode() { return Fresco::DrawingKit3D::FogOff;}
+ class Light
+ {
+ friend class openGL::DrawingKit::Restore;
+ public:
+ Light(Console_Extension::GLContext *);
+ int push();
+ int top() const;
+ void pop();
+ private:
+ class Init;
+ Console_Extension::GLContext *my_glcontext;
+ int my_max;
+ int my_number;
+ };
+ struct DrawState
+ {
+ enum { st_lights, st_last};
+ DrawState() { }
+ std::bitset<st_last> flags;
+ size_t lights;
+ };
+ public:
+ DrawingKit(const std::string &,
+ const Fresco::Kit::PropertySeq &,
+ ServerContextImpl *);
+ virtual ~DrawingKit();
+ virtual KitImpl *clone(const Fresco::Kit::PropertySeq &,
+ ServerContextImpl *);
- virtual void set_transformation(Fresco::Transform_ptr);
- virtual void set_clipping(Fresco::Region_ptr);
- virtual void set_foreground(const Fresco::Color &);
- virtual void set_lighting(const Fresco::Color &);
- virtual void set_point_size(Fresco::Coord);
- virtual void set_line_width(Fresco::Coord);
- virtual void set_line_endstyle(Fresco::DrawingKit::Endstyle);
- virtual void set_surface_fillstyle(Fresco::DrawingKit::Fillstyle);
- virtual void set_texture(Fresco::Raster_ptr);
+ virtual void save();
+ virtual void restore();
+
+ virtual void transformation(Fresco::Transform_ptr t)
+ { DrawingKitBase::transformation(t); }
+ virtual Fresco::Transform_ptr transformation()
+ { return Fresco::Transform::_duplicate(my_tr); }
+ virtual void clipping(Fresco::Region_ptr r)
+ { DrawingKitBase::clipping(r); }
+ virtual Fresco::Region_ptr clipping()
+ { return Fresco::Region::_duplicate(my_cl); }
+ virtual void foreground(const Fresco::Color &c)
+ { DrawingKitBase::foreground(c); }
+ virtual Fresco::Color foreground() { return my_fg; }
+ virtual void lighting(const Fresco::Color &c)
+ { DrawingKitBase::lighting(c); }
+ virtual Fresco::Color lighting() { return my_lt; }
+ virtual void point_size(Fresco::Coord c)
+ { DrawingKitBase::point_size(c); }
+ virtual Fresco::Coord point_size() { return my_ps; }
+ virtual void line_width(Fresco::Coord c)
+ { DrawingKitBase::line_width(c); }
+ virtual Fresco::Coord line_width() { return my_lw; }
+ virtual void line_endstyle(Fresco::DrawingKit::Endstyle e)
+ { DrawingKitBase::line_endstyle(e); }
+ virtual Fresco::DrawingKit::Endstyle line_endstyle()
+ { return my_es; }
+ virtual void surface_fillstyle(Fresco::DrawingKit::Fillstyle f)
+ { DrawingKitBase::surface_fillstyle(f); }
+ virtual Fresco::DrawingKit::Fillstyle surface_fillstyle()
+ { return my_fs; }
+ virtual void texture(Fresco::Raster_ptr r)
+ { DrawingKitBase::texture(r); }
+ virtual Fresco::Raster_ptr texture()
+ {
+ return my_tx ? Fresco::Raster::_duplicate(my_tx->remote) :
+ Fresco::Raster::_nil();
+ }
- virtual void set_font_size(CORBA::ULong);
- virtual void set_font_weight(CORBA::ULong);
- virtual void set_font_family(const Fresco::Unistring &);
- virtual void set_font_subfamily(const Fresco::Unistring &);
- virtual void set_font_fullname(const Fresco::Unistring &);
- virtual void set_font_style(const Fresco::Unistring &);
- virtual void set_font_attribute(const Fresco::NVPair &);
+ virtual CORBA::ULong font_size() { return my_font->size(); }
+ virtual CORBA::ULong font_weight() { return my_font->weight(); }
+ virtual Fresco::Unistring *font_family()
+ { return my_font->family(); }
+ virtual Fresco::Unistring *font_subfamily()
+ { return my_font->subfamily(); }
+ virtual Fresco::Unistring *font_fullname()
+ { return my_font->fullname(); }
+ virtual Fresco::Unistring *font_style()
+ { return my_font->style(); }
+ virtual Fresco::DrawingKit::FontMetrics font_metrics()
+ { return my_font->metrics(); }
+ virtual Fresco::DrawingKit::GlyphMetrics
+ glyph_metrics(Fresco::Unichar uc)
+ { return my_font->metrics(uc); }
+ virtual CORBA::Any *
+ get_font_attribute(const Fresco::Unistring & name)
+ { return new CORBA::Any(); }
-// virtual void set_lighting(bool);
+ virtual void material(const Fresco::MaterialAttr &) { }
+ virtual Fresco::MaterialAttr material()
+ { return Fresco::MaterialAttr(); }
+ virtual void textures(const Fresco::Rasters &) { }
+ virtual Fresco::Rasters *textures()
+ { return new Fresco::Rasters(); }
+ virtual void tex_mode(Fresco::DrawingKit3D::TextureMode) { }
+ virtual Fresco::DrawingKit3D::TextureMode tex_mode()
+ { return Fresco::DrawingKit3D::TextureOff; }
+ virtual void directional_light(const Fresco::Color &,
+ CORBA::Float,
+ const Fresco::Vertex &);
+ virtual void point_light(const Fresco::Color &, CORBA::Float,
+ const Fresco::Vertex &);
+ virtual void spot_light(const Fresco::Color &, CORBA::Float,
+ const Fresco::Vertex &,
+ const Fresco::Vertex &,
+ CORBA::Float, CORBA::Float);
+ virtual void fog_mode(Fresco::DrawingKit3D::FoggingMode) { }
+ virtual Fresco::DrawingKit3D::FoggingMode fog_mode()
+ { return Fresco::DrawingKit3D::FogOff; }
- virtual Fresco::Coord resolution(Fresco::Axis a) { return _drawable->resolution(a);}
- virtual void draw_path(const Fresco::Path &);
- virtual void draw_new_path(const Fresco::NewPath &);
-// virtual void drawPatch(const Fresco::Patch &);
- virtual void draw_rectangle(const Fresco::Vertex &, const Fresco::Vertex &);
- virtual void draw_quadric(const Fresco::DrawingKit::Quadric, Fresco::Coord, Fresco::Coord);
- virtual void draw_ellipse(const Fresco::Vertex &, const Fresco::Vertex &);
- virtual void draw_image(Fresco::Raster_ptr);
- virtual void allocate_char(Fresco::Unichar, Fresco::Graphic::Requisition &);
- virtual void draw_char(Fresco::Unichar);
- virtual void allocate_text(const Fresco::Unistring &, Fresco::Graphic::Requisition &);
- virtual void draw_text(const Fresco::Unistring &);
+ virtual void set_transformation(Fresco::Transform_ptr);
+ virtual void set_clipping(Fresco::Region_ptr);
+ virtual void set_foreground(const Fresco::Color &);
+ virtual void set_lighting(const Fresco::Color &);
+ virtual void set_point_size(Fresco::Coord);
+ virtual void set_line_width(Fresco::Coord);
+ virtual void set_line_endstyle(Fresco::DrawingKit::Endstyle);
+ virtual void
+ set_surface_fillstyle(Fresco::DrawingKit::Fillstyle);
+ virtual void set_texture(Fresco::Raster_ptr);
- virtual void draw_mesh(const Fresco::Mesh &);
-// virtual void draw_lines(const Fresco::Vertices &coords, const Fresco::TexCoords &tcs);
-// virtual void draw_points(const Fresco::Vertices &coords);
+ virtual void set_font_size(CORBA::ULong);
+ virtual void set_font_weight(CORBA::ULong);
+ virtual void set_font_family(const Fresco::Unistring &);
+ virtual void set_font_subfamily(const Fresco::Unistring &);
+ virtual void set_font_fullname(const Fresco::Unistring &);
+ virtual void set_font_style(const Fresco::Unistring &);
+ virtual void set_font_attribute(const Fresco::NVPair &);
- virtual void copy_drawable(Fresco::Drawable_ptr, Fresco::PixelCoord, Fresco::PixelCoord, Fresco::PixelCoord, Fresco::PixelCoord);
+ // virtual void set_lighting(bool);
- virtual void start_traversal(Fresco::Traversal_ptr) { }
- virtual void finish_traversal() { }
+ virtual Fresco::Coord resolution(Fresco::Axis a)
+ { return my_drawable->resolution(a); }
+ virtual void draw_path(const Fresco::Path &);
+ virtual void draw_new_path(const Fresco::NewPath &);
+ // virtual void drawPatch(const Fresco::Patch &);
+ virtual void draw_rectangle(const Fresco::Vertex &,
+ const Fresco::Vertex &);
+ virtual void draw_quadric(const Fresco::DrawingKit::Quadric,
+ Fresco::Coord, Fresco::Coord);
+ virtual void draw_ellipse(const Fresco::Vertex &,
+ const Fresco::Vertex &);
+ virtual void draw_image(Fresco::Raster_ptr);
+ virtual void allocate_char(Fresco::Unichar,
+ Fresco::Graphic::Requisition &);
+ virtual void draw_char(Fresco::Unichar);
+ virtual void allocate_text(const Fresco::Unistring &,
+ Fresco::Graphic::Requisition &);
+ virtual void draw_text(const Fresco::Unistring &);
+
+ virtual void draw_mesh(const Fresco::Mesh &);
+ // virtual void draw_lines(const Fresco::Vertices &coords,
+ // const Fresco::TexCoords &tcs);
+ // virtual void draw_points(const Fresco::Vertices &coords);
- virtual void flush() { my_glcontext->flush(); }
+ virtual void copy_drawable(Fresco::Drawable_ptr,
+ Fresco::PixelCoord,
+ Fresco::PixelCoord,
+ Fresco::PixelCoord,
+ Fresco::PixelCoord);
-// void clear(Coord, Coord, Coord, Coord);
-// Coord width() { return drawable->width();}
-// Coord height() { return drawable->height();}
-private:
- class ResetTrafo;
- class SetTrafo;
- class SetColor;
- class SetClipping;
- class SetPointSize;
- class SetLineWidth;
- class SetTexture;
- class SetOutline;
+ virtual void start_traversal(Fresco::Traversal_ptr) { }
+ virtual void finish_traversal() { }
- class DrawPath;
- class DrawMesh;
+ virtual void flush() { my_glcontext->flush(); }
- class PointLight;
- class SpotLight;
- class DirectionalLight;
+ // void clear(Coord, Coord, Coord, Coord);
+ // Coord width() { return drawable->width();}
+ // Coord height() { return drawable->height();}
+ private:
+ class ResetTrafo;
+ class SetTrafo;
+ class SetColor;
+ class SetClipping;
+ class SetPointSize;
+ class SetLineWidth;
+ class SetTexture;
+ class SetOutline;
+
+ class DrawPath;
+ class DrawMesh;
+
+ class PointLight;
+ class SpotLight;
+ class DirectionalLight;
- void init();
- std::stack<DrawState> _states;
- Console::Drawable *_drawable;
- GLContext *my_glcontext;
- Prague::Mutex _mutex;
- Fresco::Transform_var _tr;
- Fresco::Region_var _cl;
- Fresco::Color _fg;
- Fresco::Color _lt;
- Fresco::Coord _ps;
- Fresco::Coord _lw;
- Fresco::DrawingKit::Endstyle _es;
- Fresco::DrawingKit::Fillstyle _fs;
- Texture *_tx;
- FTFont *_font;
- Light *_light;
- ObjectCache<Fresco::Raster_var, Texture> _textures;
- ObjectCache<Fresco::Raster_var, Image> _images;
-};
+ void init();
+ std::stack<DrawState> my_states;
+ Console::Drawable *my_drawable;
+ Console_Extension::GLContext *my_glcontext;
+ Prague::Mutex my_mutex;
+ Fresco::Transform_var my_tr;
+ Fresco::Region_var my_cl;
+ Fresco::Color my_fg;
+ Fresco::Color my_lt;
+ Fresco::Coord my_ps;
+ Fresco::Coord my_lw;
+ Fresco::DrawingKit::Endstyle my_es;
+ Fresco::DrawingKit::Fillstyle my_fs;
+ Texture *my_tx;
+ FTFont *my_font;
+ Light *my_light;
+ ObjectCache<Fresco::Raster_var, Texture> my_textures;
+ ObjectCache<Fresco::Raster_var, Image> my_images;
+ };
-} // namespace
-} // namespace
+ } // namespace
+ } // namespace
} // namespace
#endif
Index: FTFont.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/FTFont.cc,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- FTFont.cc 19 Feb 2003 22:36:59 -0000 1.6
+++ FTFont.cc 29 Dec 2003 08:03:25 -0000 1.7
@@ -45,281 +45,309 @@
using namespace Prague;
using namespace Fresco;
+using namespace Berlin::Console_Extension;
using namespace Berlin::DrawingKit;
-openGL::FTFont::FTFont(GLContext *glcontext)
- : _family(Unicode::to_CORBA(Babylon::String("GNU Unifont"))),
- _subfamily(),
- _fullname(),
- _style(Unicode::to_CORBA(Babylon::String("monospace"))),
+openGL::FTFont::FTFont(GLContext *glcontext) :
+ my_family(Unicode::to_CORBA(Babylon::String("GNU Unifont"))),
+ my_subfamily(),
+ my_fullname(),
+ my_style(Unicode::to_CORBA(Babylon::String("monospace"))),
my_size(14),
my_glcontext(glcontext)
{
- Prague::Path path = RCManager::get_path("unifontpath");
- std::string font_file = path.lookup_file("unifont.bdf");
- FT_Init_FreeType(&my_library);
- if (FT_New_Face(my_library, font_file.c_str(), 0, &my_face) != 0)
- throw std::runtime_error("unifont.bdf not found. Please check your font path!");
- FT_Set_Char_Size(my_face, 0, my_size*64, 72, 72);
+ Prague::Path path = RCManager::get_path("unifontpath");
+ std::string font_file = path.lookup_file("unifont.bdf");
+ FT_Init_FreeType(&my_library);
+ if (FT_New_Face(my_library, font_file.c_str(), 0, &my_face) != 0)
+ throw std::runtime_error("unifont.bdf not found. Please check your font path!");
+ FT_Set_Char_Size(my_face, 0, my_size*64, 72, 72);
}
-openGL::FTFont::~FTFont() {
-}
+openGL::FTFont::~FTFont() { }
-CORBA::ULong openGL::FTFont::weight() { return 100;}
-Unistring *openGL::FTFont::family() { return new Unistring(_family);}
-Unistring *openGL::FTFont::subfamily() { return new Unistring(_subfamily);}
-Unistring *openGL::FTFont::fullname() { return new Unistring(_fullname);}
-Unistring *openGL::FTFont::style() { return new Unistring(_style);}
+CORBA::ULong openGL::FTFont::weight() { return 100; }
+Unistring *openGL::FTFont::family() { return new Unistring(my_family); }
+Unistring *openGL::FTFont::subfamily()
+{ return new Unistring(my_subfamily); }
+Unistring *openGL::FTFont::fullname()
+{ return new Unistring(my_fullname); }
+Unistring *openGL::FTFont::style() { return new Unistring(my_style); }
Fresco::DrawingKit::FontMetrics openGL::FTFont::metrics()
{
- Fresco::DrawingKit::FontMetrics fm;
+ Fresco::DrawingKit::FontMetrics fm;
- if (!FT_IS_SCALABLE(my_face)) { // XXX
- // GNU Unifont . the bdf reader returns all 0s through size->metrics.
- fm.ascender = 16 << 6;
- fm.descender = 0;
- fm.height = 16 << 6;
- fm.max_advance = 16 << 6;
- } else {
- fm.ascender = my_face->size->metrics.ascender;
- fm.descender = my_face->size->metrics.descender;
- fm.height = my_face->size->metrics.height;
- fm.max_advance = my_face->size->metrics.max_advance;
- }
+ if (!FT_IS_SCALABLE(my_face))
+ {
+ // FIXME: the bdf reader returns all 0s through size->metrics.
+ fm.ascender = 16 << 6;
+ fm.descender = 0;
+ fm.height = 16 << 6;
+ fm.max_advance = 16 << 6;
+ }
+ else
+ {
+ fm.ascender = my_face->size->metrics.ascender;
+ fm.descender = my_face->size->metrics.descender;
+ fm.height = my_face->size->metrics.height;
+ fm.max_advance = my_face->size->metrics.max_advance;
+ }
- return fm;
+ return fm;
}
Fresco::DrawingKit::GlyphMetrics openGL::FTFont::metrics(Unichar uc)
{
- Fresco::DrawingKit::GlyphMetrics gm;
+ Fresco::DrawingKit::GlyphMetrics gm;
- FT_Load_Glyph(my_face, FT_Get_Char_Index(my_face, (FT_ULong)uc),
- FT_LOAD_DEFAULT);
+ FT_Load_Glyph(my_face, FT_Get_Char_Index(my_face, (FT_ULong)uc),
+ FT_LOAD_DEFAULT);
- double scale = 1.;
- gm.width = static_cast<CORBA::Long>(my_face->glyph->metrics.width / scale);
- gm.height = static_cast<CORBA::Long>(my_face->glyph->metrics.height / scale);
- gm.horiBearingX = static_cast<CORBA::Long>(my_face->glyph->metrics.horiBearingX / scale);
- gm.horiBearingY = static_cast<CORBA::Long>(my_face->glyph->metrics.horiBearingY /scale);
- gm.horiAdvance = static_cast<CORBA::Long>(my_face->glyph->metrics.horiAdvance / scale);
- gm.vertBearingX = static_cast<CORBA::Long>(my_face->glyph->metrics.vertBearingX / scale);
- gm.vertBearingY = static_cast<CORBA::Long>(my_face->glyph->metrics.vertBearingY / scale);
- gm.vertAdvance = static_cast<CORBA::Long>(my_face->glyph->metrics.vertAdvance / scale);
+ double scale = 1.;
+ gm.width = static_cast<CORBA::Long>(my_face->glyph->metrics.width /
+ scale);
+ gm.height = static_cast<CORBA::Long>(my_face->glyph->metrics.height /
+ scale);
+ gm.horiBearingX =
+ static_cast<CORBA::Long>(my_face->glyph->metrics.horiBearingX /
+ scale);
+ gm.horiBearingY =
+ static_cast<CORBA::Long>(my_face->glyph->metrics.horiBearingY /
+ scale);
+ gm.horiAdvance =
+ static_cast<CORBA::Long>(my_face->glyph->metrics.horiAdvance /
+ scale);
+ gm.vertBearingX =
+ static_cast<CORBA::Long>(my_face->glyph->metrics.vertBearingX /
+ scale);
+ gm.vertBearingY =
+ static_cast<CORBA::Long>(my_face->glyph->metrics.vertBearingY /
+ scale);
+ gm.vertAdvance =
+ static_cast<CORBA::Long>(my_face->glyph->metrics.vertAdvance /
+ scale);
- return gm;
+ return gm;
}
static inline bool is_pow2(unsigned int x)
-{
- return x != 0 && !(x & (x-1));
-}
+{ return x != 0 && !(x & (x-1)); }
// The LSB is 0, the MSB is (e.g.) 31.
static inline unsigned int highest_bit_set(unsigned int x)
{
- assert(x != 0);
+ assert(x != 0);
- unsigned int k;
- for (k = 0; x >>= 1; k++)
- /* nothing */;
- return k;
+ unsigned int k;
+ for (k = 0; x >>= 1; k++)
+ ; // nothing
+ return k;
}
static inline unsigned int next_pow2(unsigned int n)
{
- assert(n <= UINT_MAX / 2);
+ assert(n <= UINT_MAX / 2);
- if (n == 0 || is_pow2(n)) return n;
- else return 1 << (highest_bit_set(n) + 1);
+ if (n == 0 || is_pow2(n)) return n;
+ else return 1 << (highest_bit_set(n) + 1);
}
void openGL::FTFont::set_transform(const Fresco::Transform_var tr)
-{
- _tr = tr;
-}
+{ my_tr = tr; }
// magnitude of a - b.
-inline float delta_magnitude(const Fresco::Vertex &a, const Fresco::Vertex &b)
+inline float delta_magnitude(const Fresco::Vertex &a,
+ const Fresco::Vertex &b)
{
- return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z));
+ return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) +
+ (a.z-b.z)*(a.z-b.z));
}
-class openGL::FTFont::DrawChar : public virtual GLContext::Callback {
-public:
- DrawChar::DrawChar(Unichar uc, FTFont *that)
- {
- ::Console::Drawable *drawable = ::Console::instance()->drawable();
+class openGL::FTFont::DrawChar : public virtual GLContext::Callback
+{
+ public:
+ DrawChar::DrawChar(Unichar uc, FTFont *that)
+ {
+ Berlin::Console::Drawable *drawable =
+ Berlin::Console::instance()->drawable();
- GraphicImpl::init_requisition(r);
- that->allocate_char(uc, r);
-
- Fresco::Vertex o = {0, 0, 0};
- Fresco::Vertex e1 = {1, 0, 0};
- Fresco::Vertex e2 = {0, 1, 0};
+ GraphicImpl::init_requisition(my_r);
+ that->allocate_char(uc, my_r);
- that->_tr->transform_vertex(o);
- that->_tr->transform_vertex(e1);
- that->_tr->transform_vertex(e2);
+ Fresco::Vertex o = {0, 0, 0};
+ Fresco::Vertex e1 = {1, 0, 0};
+ Fresco::Vertex e2 = {0, 1, 0};
+
+ that->my_tr->transform_vertex(o);
+ that->my_tr->transform_vertex(e1);
+ that->my_tr->transform_vertex(e2);
- x_zoom = 1./(drawable->resolution(Fresco::xaxis)*delta_magnitude(e1, o));
- y_zoom = 1./(drawable->resolution(Fresco::xaxis)*delta_magnitude(e2, o));
+ my_x_zoom = 1./(drawable->resolution(Fresco::xaxis)*
+ delta_magnitude(e1, o));
+ my_y_zoom = 1./(drawable->resolution(Fresco::xaxis)*
+ delta_magnitude(e2, o));
- // the other option is better looking but *SLOW*
+ // the other option is better looking but *SLOW*
#if 1
- FT_Matrix matrix = {delta_magnitude(e1, o)*0x10000, 0,
- 0, delta_magnitude(e2, o)*0x10000};
-
- FT_Set_Transform(that->my_face, &matrix, 0);
+ FT_Matrix matrix = {delta_magnitude(e1, o)*0x10000, 0,
+ 0, delta_magnitude(e2, o)*0x10000};
+
+ FT_Set_Transform(that->my_face, &matrix, 0);
#else
-
- FT_Set_Char_Size(that->my_face, 0, that->my_size*64,
- 72*delta_magnitude(e1, o),
- 72*delta_magnitude(e2, o));
+ FT_Set_Char_Size(that->my_face, 0, that->my_size*64,
+ 72*delta_magnitude(e1, o),
+ 72*delta_magnitude(e2, o));
#endif
- FT_Load_Char(that->my_face, uc, FT_LOAD_DEFAULT);
+ FT_Load_Char(that->my_face, uc, FT_LOAD_DEFAULT);
- FT_Vector origin;
- origin.x = 0;//(o.x - floorf(o.x)) * 0x10000;
- origin.y = 0;//(o.y - floorf(o.y)) * 0x10000;
-
- FT_Get_Glyph(that->my_face->glyph, &glyph);
-
- FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, &origin, 1);
- glyph_bitmap = (FT_BitmapGlyph)glyph;
+ FT_Vector origin;
+ origin.x = 0;//(o.x - floorf(o.x)) * 0x10000;
+ origin.y = 0;//(o.y - floorf(o.y)) * 0x10000;
+
+ FT_Get_Glyph(that->my_face->glyph, &my_glyph);
+
+ FT_Glyph_To_Bitmap(&my_glyph, ft_render_mode_normal, &origin, 1);
+ my_glyph_bitmap = (FT_BitmapGlyph)my_glyph;
+
+ FT_Set_Transform(that->my_face, 0, 0);
+ }
- FT_Set_Transform(that->my_face, 0, 0);
- }
- void operator()()
- {
- unsigned char *buffer = glyph_bitmap->bitmap.buffer;
- int width = glyph_bitmap->bitmap.width;
- int height = glyph_bitmap->bitmap.rows;
+ void operator()()
+ {
+ unsigned char *buffer = my_glyph_bitmap->bitmap.buffer;
+ int width = my_glyph_bitmap->bitmap.width;
+ int height = my_glyph_bitmap->bitmap.rows;
- // XXX: We should be breaking oversized characters into pieces of
- // textures and drawing them all.
- GLint maxsize, w, h;
- glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
- w = next_pow2(width);
- h = next_pow2(height);
+ // FIXME: We should be breaking oversized characters into pieces of
+ // textures and drawing them all.
+ GLint maxsize, w, h;
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize);
+ w = next_pow2(width);
+ h = next_pow2(height);
- while (w*h < 64)
- if (w < h) { w = next_pow2(w+1); } else { h = next_pow2(h+1); }
+ while (w*h < 64)
+ if (w < h) w = next_pow2(w+1);
+ else h = next_pow2(h+1);
- if (w > maxsize || h > maxsize) {
- std::cerr << "Character too large to render." << std::endl;
- delete this; return;
- }
+ if (w > maxsize || h > maxsize)
+ {
+ std::cerr << "Character too large to render." << std::endl;
+ delete this; return;
+ }
- std::vector<unsigned char> pixels(w*h, 0);
+ std::vector<unsigned char> pixels(w*h, 0);
- GLint internal_format;
- GLenum format, type;
+ GLint internal_format;
+ GLenum format, type;
- switch (glyph_bitmap->bitmap.pixel_mode)
- {
- case FT_PIXEL_MODE_NONE:
- // should never happen
- std::cout << "WTF;FT_PIXEL_MODE_NONE" << std::endl;
- break;
- case FT_PIXEL_MODE_MONO: // MSB 1 bpp
- internal_format = GL_ALPHA;
- format = GL_ALPHA;
- type = GL_UNSIGNED_BYTE;
+ switch (my_glyph_bitmap->bitmap.pixel_mode)
{
- ::Console::Drawable *drawable = ::Console::instance()->drawable();
- x_zoom = 1./drawable->resolution(Fresco::xaxis);
- y_zoom = 1./drawable->resolution(Fresco::yaxis);
+ case FT_PIXEL_MODE_NONE:
+ // should never happen
+ std::cout << "WTF;FT_PIXEL_MODE_NONE" << std::endl;
+ break;
+ case FT_PIXEL_MODE_MONO: // MSB 1 bpp
+ internal_format = GL_ALPHA;
+ format = GL_ALPHA;
+ type = GL_UNSIGNED_BYTE;
+ {
+ Berlin::Console::Drawable *drawable =
+ Berlin::Console::instance()->drawable();
+ my_x_zoom = 1./drawable->resolution(Fresco::xaxis);
+ my_y_zoom = 1./drawable->resolution(Fresco::yaxis);
+ }
+ // FIXME: Use memcopy?
+ for (int i = 0; i < height; i++)
+ for (int j = 0; j < width; j++)
+ pixels[i*w + j] = (buffer[i*(width/8)+(j/8)] &
+ (0x80 >> j%8)) ? 0xFF : 0;
+ break;
+ case FT_PIXEL_MODE_GRAY: // 8 bpp count of grey levels in num_bytes
+ internal_format = GL_ALPHA;
+ format = GL_ALPHA;
+ type = GL_UNSIGNED_BYTE;
+ // FIXME: Use memcopy?
+ for (int i = 0; i < height; i++)
+ for (int j = 0; j < width; j++)
+ pixels[i*w+j] = buffer[i*width+j];
+ break;
+ case FT_PIXEL_MODE_GRAY2: // 2bpp (no known fonts)
+ std::cout << "NYI;FT_PIXEL_MODE_GRAY2" << std::endl;
+ break;
+ case FT_PIXEL_MODE_GRAY4: // 4bpp (no known fonts)
+ std::cout << "NYI;FT_PIXEL_MODE_GRAY4" << std::endl;
+ break;
+ case FT_PIXEL_MODE_LCD: // 8bpp RGB or BGR, width=3*glyph_width
+ std::cout << "NYI;FT_PIXEL_MODE_LCD" << std::endl;
+ break;
+ case FT_PIXEL_MODE_LCD_V: // 8bpp RGB or BGR, height=3*glyph_rows
+ std::cout << "NYI;FT_PIXEL_MODE_LCD_V" << std::endl;
+ break;
+ default:
+ std::cout << "Unknown: " << my_glyph_bitmap->bitmap.pixel_mode
+ << std::endl;
+ break;
}
- for (int i = 0; i < height; i++)
- for (int j = 0; j < width; j++)
- pixels[i*w + j] = (buffer[i*(width/8)+(j/8)] &
- (0x80 >> j%8)) ? 0xFF : 0;
- break;
- case FT_PIXEL_MODE_GRAY: // 8 bpp count of grey levels in num_bytes
- internal_format = GL_ALPHA;
- format = GL_ALPHA;
- type = GL_UNSIGNED_BYTE;
- for (int i = 0; i < height; i++)
- for (int j = 0; j < width; j++)
- pixels[i*w+j] = buffer[i*width+j];
- break;
- case FT_PIXEL_MODE_GRAY2: // 2bpp (no known fonts)
- std::cout << "NYI;FT_PIXEL_MODE_GRAY2" << std::endl;
- break;
- case FT_PIXEL_MODE_GRAY4: // 4bpp (no known fonts)
- std::cout << "NYI;FT_PIXEL_MODE_GRAY4" << std::endl;
- break;
- case FT_PIXEL_MODE_LCD: // 8bpp RGB or BGR, width=3*glyph_width
- std::cout << "NYI;FT_PIXEL_MODE_LCD" << std::endl;
- break;
- case FT_PIXEL_MODE_LCD_V: // 8bpp RGB or BGR, height=3*glyph_rows
- std::cout << "NYI;FT_PIXEL_MODE_LCD_V" << std::endl;
- break;
- default:
- std::cout << "Unknown: " << glyph_bitmap->bitmap.pixel_mode << std::endl;
- break;
- }
-
- GLuint texture;
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0, format, type, &pixels[0]);
+ GLuint texture;
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, internal_format, w, h, 0,
+ format, type, &pixels[0]);
- glEnable(GL_TEXTURE_2D);
- glBegin(GL_QUADS);
- float top = -height * r.y.align;
- glTexCoord2f(0, 1); glVertex3f(0.0, (top+h)*y_zoom, 0.0);
- glTexCoord2f(1, 1); glVertex3f(w*x_zoom, (top+h)*y_zoom, 0.0);
- glTexCoord2f(1, 0); glVertex3f(w*x_zoom, top*y_zoom, 0.0);
- glTexCoord2f(0, 0); glVertex3f(0.0, top*y_zoom, 0.0);
- glEnd();
- glDisable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, 0);
- glDeleteTextures(1, &texture);
-
- delete this;
- }
-private:
- Fresco::Graphic::Requisition r;
- FT_Glyph glyph;
- FT_BitmapGlyph glyph_bitmap;
- float x_zoom, y_zoom;
+ glEnable(GL_TEXTURE_2D);
+ glBegin(GL_QUADS);
+ float top = -height * my_r.y.align;
+ glTexCoord2f(0, 1); glVertex3f(0.0, (top+h)*my_y_zoom, 0.0);
+ glTexCoord2f(1, 1); glVertex3f(w*my_x_zoom,
+ (top+h)*my_y_zoom,
+ 0.0);
+ glTexCoord2f(1, 0); glVertex3f(w*my_x_zoom,
+ top*my_y_zoom,
+ 0.0);
+ glTexCoord2f(0, 0); glVertex3f(0.0, top*my_y_zoom, 0.0);
+ glEnd();
+ glDisable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glDeleteTextures(1, &texture);
+
+ delete this;
+ }
+ private:
+ Fresco::Graphic::Requisition my_r;
+ FT_Glyph my_glyph;
+ FT_BitmapGlyph my_glyph_bitmap;
+ float my_x_zoom, my_y_zoom;
};
-void openGL::FTFont::draw_char(Unichar uc)
-{
- my_glcontext->add_to_queue(new DrawChar(uc, this));
-}
+void openGL::FTFont::draw_char(Unichar uc)
+{ my_glcontext->add_to_queue(new DrawChar(uc, this)); }
void openGL::FTFont::allocate_char(Unichar uc, Graphic::Requisition &r)
{
- FT_Load_Glyph(my_face, FT_Get_Char_Index(my_face, (FT_ULong)uc), FT_LOAD_DEFAULT);
+ FT_Load_Glyph(my_face,
+ FT_Get_Char_Index(my_face, (FT_ULong)uc),
+ FT_LOAD_DEFAULT);
- Fresco::DrawingKit::GlyphMetrics gm = metrics(uc);
- r.x.natural = r.x.minimum = r.x.maximum = (gm.horiAdvance*10) >> 6;
- r.x.defined = true;
- r.x.align = gm.width == 0 ? 0. : ((double)gm.horiBearingX)/((double)gm.horiAdvance);
- r.y.natural = r.y.minimum = r.y.maximum = (gm.height*10) >> 6;
- r.y.defined = true;
- r.y.align = gm.height == 0 ? 0. : ((double)gm.horiBearingY)/((double)gm.height);
+ Fresco::DrawingKit::GlyphMetrics gm = metrics(uc);
+ r.x.natural = r.x.minimum = r.x.maximum = (gm.horiAdvance*10) >> 6;
+ r.x.defined = true;
+ r.x.align = gm.width == 0 ? 0. :
+ ((double)gm.horiBearingX)/((double)gm.horiAdvance);
+ r.y.natural = r.y.minimum = r.y.maximum = (gm.height*10) >> 6;
+ r.y.defined = true;
+ r.y.align = gm.height == 0 ? 0. :
+ ((double)gm.horiBearingY)/((double)gm.height);
}
// what's this in? points? Fresco::Coord? Fresco::PixelCoord?
-void openGL::FTFont::size(CORBA::ULong s)
-{
- my_size = s;
-}
+void openGL::FTFont::size(CORBA::ULong s) { my_size = s; }
-CORBA::ULong openGL::FTFont::size()
-{
- return my_size;
-}
+CORBA::ULong openGL::FTFont::size() { return my_size; }
Index: FTFont.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/FTFont.hh,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- FTFont.hh 5 Jan 2003 16:21:31 -0000 1.3
+++ FTFont.hh 29 Dec 2003 08:03:25 -0000 1.4
@@ -20,8 +20,8 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*/
-#ifndef _FTFont_hh
-#define _FTFont_hh
+#ifndef _openGL_FTFont_hh
+#define _openGL_FTFont_hh
#include <Prague/Sys/MMap.hh>
#include <Fresco/config.hh>
@@ -37,47 +37,52 @@
#include <ft2build.h>
#include FT_FREETYPE_H
-namespace Berlin {
-namespace DrawingKit {
-namespace openGL {
-
-class FTFont
-//. This is a Freetype font.
+namespace Berlin
{
-public:
- FTFont(GLContext *my_glcontext);
- virtual ~FTFont();
- virtual CORBA::ULong size();
- virtual CORBA::ULong weight();
- virtual Fresco::Unistring *family();
- virtual Fresco::Unistring *subfamily();
- virtual Fresco::Unistring *fullname();
- virtual Fresco::Unistring *style();
- virtual Fresco::DrawingKit::FontMetrics metrics();
- virtual Fresco::DrawingKit::GlyphMetrics metrics(Fresco::Unichar);
+ namespace DrawingKit
+ {
+ namespace openGL
+ {
- virtual void set_transform(const Fresco::Transform_var);
- virtual void size(CORBA::ULong);
+ //. This is a Freetype font.
+ class FTFont
+ {
+ public:
+ FTFont(Console_Extension::GLContext *my_glcontext);
+ virtual ~FTFont();
+ virtual CORBA::ULong size();
+ virtual CORBA::ULong weight();
+ virtual Fresco::Unistring *family();
+ virtual Fresco::Unistring *subfamily();
+ virtual Fresco::Unistring *fullname();
+ virtual Fresco::Unistring *style();
+ virtual Fresco::DrawingKit::FontMetrics metrics();
+ virtual Fresco::DrawingKit::GlyphMetrics
+ metrics(Fresco::Unichar);
- void draw_char(Fresco::Unichar);
- void allocate_char(Fresco::Unichar, Fresco::Graphic::Requisition &);
-private:
- class DrawChar;
- friend class DrawChar;
- FT_Face my_face;
- Fresco::Transform_var _tr;
- CORBA::ULong my_size;
- FT_Library my_library;
- Fresco::Unistring _family;
- Fresco::Unistring _subfamily;
- Fresco::Unistring _fullname;
- Fresco::Unistring _style;
+ virtual void set_transform(const Fresco::Transform_var);
+ virtual void size(CORBA::ULong);
+
+ void draw_char(Fresco::Unichar);
+ void allocate_char(Fresco::Unichar,
+ Fresco::Graphic::Requisition &);
+ private:
+ class DrawChar;
+ friend class DrawChar;
+ FT_Face my_face;
+ Fresco::Transform_var my_tr;
+ CORBA::ULong my_size;
+ FT_Library my_library;
+ Fresco::Unistring my_family;
+ Fresco::Unistring my_subfamily;
+ Fresco::Unistring my_fullname;
+ Fresco::Unistring my_style;
- GLContext *my_glcontext;
-};
+ Console_Extension::GLContext *my_glcontext;
+ };
-} // namespace
-} // namespace
+ } // namespace
+ } // namespace
} // namespace
#endif
Index: Font.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/Font.hh,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Font.hh 5 Jan 2003 16:21:31 -0000 1.11
+++ Font.hh 29 Dec 2003 08:03:25 -0000 1.12
@@ -20,8 +20,8 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*/
-#ifndef _Font_hh
-#define _Font_hh
+#ifndef _openGL_Font_hh
+#define _openGL_Font_hh
#include <Fresco/config.hh>
#include <Fresco/Types.hh>
@@ -30,31 +30,36 @@
#include <string>
#include <GL/gl.h>
-namespace Berlin {
-namespace DrawingKit {
-namespace openGL {
-
-class Font
+namespace Berlin
{
-public:
- Font() {}
- virtual ~Font() {}
- virtual CORBA::ULong size() = 0;
- virtual void size(CORBA::ULong) = 0;
- virtual CORBA::ULong weight() = 0;
- virtual Fresco::Unistring *family() = 0;
- virtual Fresco::Unistring *subfamily() = 0;
- virtual Fresco::Unistring *fullname() = 0;
- virtual Fresco::Unistring *style() = 0;
- virtual Fresco::DrawingKit::FontMetrics metrics() = 0;
- virtual Fresco::DrawingKit::GlyphMetrics metrics(Fresco::Unichar uc) = 0;
+ namespace DrawingKit
+ {
+ namespace openGL
+ {
- virtual void draw_char(Fresco::Unichar) = 0;
- virtual void allocate_char(Fresco::Unichar, Fresco::Graphic::Requisition &) = 0;
-};
+ class Font
+ {
+ public:
+ Font() { }
+ virtual ~Font() { }
+ virtual CORBA::ULong size() = 0;
+ virtual void size(CORBA::ULong) = 0;
+ virtual CORBA::ULong weight() = 0;
+ virtual Fresco::Unistring *family() = 0;
+ virtual Fresco::Unistring *subfamily() = 0;
+ virtual Fresco::Unistring *fullname() = 0;
+ virtual Fresco::Unistring *style() = 0;
+ virtual Fresco::DrawingKit::FontMetrics metrics() = 0;
+ virtual Fresco::DrawingKit::GlyphMetrics
+ metrics(Fresco::Unichar uc) = 0;
-} // namespace
-} // namespace
+ virtual void draw_char(Fresco::Unichar) = 0;
+ virtual void allocate_char(Fresco::Unichar,
+ Fresco::Graphic::Requisition &) = 0;
+ };
+
+ } // namespace
+ } // namespace
} // namespace
#endif
Index: FontServer.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/FontServer.cc,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- FontServer.cc 5 Jan 2003 16:21:31 -0000 1.3
+++ FontServer.cc 29 Dec 2003 08:03:25 -0000 1.4
@@ -29,33 +29,33 @@
openGL::FontServer::FontServer()
{
- _size = 16;
- _weight = 100;
- _font = new GLUnifont;
- fonts[key(16, 100, Unicode::toCORBA(Unicode::String("GNU Unifont")))] = _font;
-// char *env = getenv("BERLIN_ROOT");
-// if (!env)
-// {
-// std::cerr << "Please set environment variable BERLIN_ROOT first"
-// << std::endl;
-// exit(-1);
-// }
-// string ttf = string(env) + "/etc/Fonts/helv.ttf";
-// FT::Face *face = new FT::Face(ttf.c_str());
-// faces[Unicode::toCORBA(Unicode::String("Helvetica"))] = face;
-// _font = new GLPixmapFont(*face, 10);
-// fonts[key(16, 100, Unicode::toCORBA(Unicode::String("Helvetica")))] = _font;
+ my_size = 16;
+ my_weight = 100;
+ my_font = new GLUnifont;
+ my_fonts[key(16, 100,
+ Unicode::toCORBA(Unicode::String("GNU Unifont")))] =
+ my_font;
+// char *env = getenv("BERLIN_ROOT");
+// if (!env)
+// {
+// std::cerr << "Please set environment variable BERLIN_ROOT first"
+// << std::endl;
+// exit(-1);
+// }
+// string ttf = string(env) + "/etc/Fonts/helv.ttf";
+// FT::Face *face = new FT::Face(ttf.c_str());
+// faces[Unicode::toCORBA(Unicode::String("Helvetica"))] = face;
+// my_font = new GLPixmapFont(*face, 10);
+// my_fonts[key(16, 100,
+// Unicode::toCORBA(Unicode::String("Helvetica")))] = my_font;
}
openGL::FontServer::~FontServer()
{
- for (fmap_t::iterator i = fonts.begin(); i != fonts.end(); i++)
+ for (fmap_t::iterator i = my_fonts.begin(); i != my_fonts.end(); ++i)
delete (*i).second;
}
void
openGL::FontServer::lookup(unsigned long, unsigned long, const Unistring &)
-{
-}
-
-};
+{ }
Index: FontServer.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/FontServer.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- FontServer.hh 5 Jan 2003 16:21:31 -0000 1.2
+++ FontServer.hh 29 Dec 2003 08:03:25 -0000 1.3
@@ -19,86 +19,113 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*/
-#ifndef _GL_FontServer_hh
-#define _GL_FontServer_hh
+#ifndef _openGL_FontServer_hh
+#define _openGL_FontServer_hh
#include <Drawing/openGL/GLFont.hh>
#include <Drawing/FT/Face.hh>
#include <map>
-namespace Berlin {
-namespace DrawingKit {
-namespace openGL {
-
-inline bool operator == (const Unistring &us1, const Unistring &us2)
+namespace Berlin
{
- if (us1.length() != us2.length()) return false;
- for (const Unichar *uc1 = us1.get_buffer(), *uc2 = us2.get_buffer(); uc1 != us1.get_buffer() + us1.length(); uc1++, uc2++)
- if (*uc1 != *uc2) return false;
- return true;
-}
+ namespace DrawingKit
+ {
+ namespace openGL
+ {
-inline bool operator < (const Unistring &us1, const Unistring &us2)
-{
- if (us1.length() < us2.length()) return true;
- if (us1.length() > us2.length()) return false;
- for (const Unichar *uc1 = us1.get_buffer(), *uc2 = us2.get_buffer(); uc1 != us1.get_buffer() + us1.length(); uc1++, uc2++)
- if (*uc1 < *uc2) return true;
- else if (*uc1 > *uc2) return false;
- return false;
-}
+ inline bool operator == (const Unistring &us1, const Unistring &us2)
+ {
+ if (us1.length() != us2.length()) return false;
+ for (const Unichar *uc1 = us1.get_buffer(),
+ *uc2 = us2.get_buffer();
+ uc1 != us1.get_buffer() + us1.length();
+ uc1++, uc2++)
+ if (*uc1 != *uc2) return false;
+ return true;
+ }
-struct my_less
-{
- bool operator ()(const Unistring &us1, const Unistring &us2) const { return us1 < us2;}
-};
+ inline bool operator < (const Unistring &us1, const Unistring &us2)
+ {
+ if (us1.length() < us2.length()) return true;
+ if (us1.length() > us2.length()) return false;
+ for (const Unichar *uc1 = us1.get_buffer(),
+ *uc2 = us2.get_buffer();
+ uc1 != us1.get_buffer() + us1.length();
+ uc1++, uc2++)
+ if (*uc1 < *uc2) return true;
+ else if (*uc1 > *uc2) return false;
+ return false;
+ }
-class FontServer
-{
- struct key
- {
- key(unsigned long s, unsigned long w, const Unistring &f) : size(s), weight(w), family(f) {}
- bool operator == (const key &k) const { return size == k.size && weight == k.weight && family == k.family;}
- bool operator < (const key &k) const { return size < k.size && weight < k.weight && family < k.family;}
- unsigned long size;
- unsigned long weight;
- Unistring family;
- };
- typedef map<key, GLFont *> fmap_t;
- typedef map<Unistring, FT::Face *, my_less> faces_t;
-public:
- FontServer();
- ~FontServer();
- unsigned long size() { return _size;}
- void size(unsigned long s) { lookup(s, _weight, _family);}
- unsigned long weight() { return _weight;}
- void weight(unsigned long w) { lookup(_size, w, _family);}
- const Unistring &family() { return _family;}
- void family(const Unistring &f) { lookup(_size, _weight, f);}
- const Unistring &subfamily() { return _subfamily;}
- void subfamily(const Unistring &) {}
- const Unistring &fullname() { return _fullname;}
- void fullname(const Unistring &) {}
- const Unistring &style() { return _style;}
- void style(const Unistring &) {}
-
- void drawText(const Unistring & text) { _font->drawText(text);}
- void allocateText(const Unistring & s, Graphic::Requisition & req) { _font->allocateText(s, req);}
-private:
- void lookup(unsigned long, unsigned long, const Unistring &);
- unsigned long _size;
- unsigned long _weight;
- Unistring _family;
- Unistring _subfamily;
- Unistring _fullname;
- Unistring _style;
- GLFont *_font;
- fmap_t fonts;
- faces_t faces;
-};
+ struct my_less
+ {
+ bool operator ()(const Unistring &us1,
+ const Unistring &us2) const
+ { return us1 < us2; }
+ };
-} // namespace
-} // namespace
+ class FontServer
+ {
+ struct key
+ {
+ key(unsigned long s, unsigned long w, const Unistring &f) :
+ size(s), weight(w), family(f)
+ { }
+ bool operator == (const key &k) const
+ {
+ return size == k.size &&
+ weight == k.weight &&
+ family == k.family;
+ }
+ bool operator < (const key &k) const
+ {
+ return size < k.size &&
+ weight < k.weight &&
+ family < k.family;
+ }
+ unsigned long size;
+ unsigned long weight;
+ Unistring family;
+ };
+ typedef map<key, GLFont *> fmap_t;
+ typedef map<Unistring, FT::Face *, my_less> faces_t;
+ public:
+ FontServer();
+ ~FontServer();
+ unsigned long size() { return _size; }
+ void size(unsigned long s) { lookup(s, my_weight, my_family); }
+ unsigned long weight() { return my_weight; }
+ void weight(unsigned long w) { lookup(my_size, w, my_family); }
+ const Unistring &family() { return my_family; }
+ void family(const Unistring &f)
+ { lookup(my_size, my_weight, f); }
+ const Unistring &subfamily() { return my_subfamily; }
+ void subfamily(const Unistring &) { /* FIXME: NIY */ }
+ const Unistring &fullname() { return my_fullname; }
+ void fullname(const Unistring &) { /* FIXME: NIY */ }
+ const Unistring &style() { return my_style;}
+ void style(const Unistring &) { /* FIXME: NIY */ }
+
+ void drawText(const Unistring & text)
+ { my_font->drawText(text); }
+ void allocateText(const Unistring & s,
+ Graphic::Requisition & req)
+ { _font->allocateText(s, req); }
+ private:
+ void lookup(unsigned long, unsigned long, const Unistring &);
+ unsigned long my_size;
+ unsigned long my_weight;
+ Unistring my_family;
+ Unistring my_subfamily;
+ Unistring my_fullname;
+ Unistring my_style;
+ GLFont *my_font;
+ fmap_t my_fonts;
+ faces_t my_faces;
+ };
+
+ } // namespace
+ } // namespace
} // namespace
-#endif /* _GL_FontServer_hh */
+#endif
Index: Quadric.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/Quadric.cc,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Quadric.cc 5 Jan 2003 16:21:31 -0000 1.7
+++ Quadric.cc 29 Dec 2003 08:03:25 -0000 1.8
@@ -32,588 +32,597 @@
using namespace Fresco;
using namespace Berlin::DrawingKit;
-/*
- * Convert degrees to radians:
- */
-inline double deg_to_rad(double a) { return a * M_PI / 180.0;}
+//, Convert degrees to radians:
+inline double deg_to_rad(double a) { return a * M_PI / 180.0; }
-/*
[...972 lines suppressed...]
- else
+ else
{
- glVertex2d(radius * sin(angle), radius * cos(angle));
- glVertex2d((radius + dr)*sin(angle), (radius + dr)*cos(angle));
+ glVertex2d(radius * sin(angle),
+ radius * cos(angle));
+ glVertex2d((radius + dr)*sin(angle),
+ (radius + dr)*cos(angle));
}
- angle += da;
+ angle += da;
}
- glEnd();
- radius += dr;
+ glEnd();
+ radius += dr;
}
}
}
Index: Quadric.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/Quadric.hh,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Quadric.hh 5 Jan 2003 16:21:31 -0000 1.5
+++ Quadric.hh 29 Dec 2003 08:03:25 -0000 1.6
@@ -25,29 +25,35 @@
#include <Fresco/config.hh>
#include <Fresco/DrawingKit.hh>
-namespace Berlin {
-namespace DrawingKit {
-namespace openGL {
-
-class Quadric
+namespace Berlin
{
-public:
- enum orientation {in, out};
- enum normals {none, flat, smooth};
- Quadric(Fresco::DrawingKit::Fillstyle s, orientation o, normals n = none) : style(s), orient(o), norm(n) {}
- ~Quadric() {}
- void cylinder(double, double, double, int, int);
- void sphere(double, int, int);
- void disk(double, double, int, int);
- void partialDisk(double, double, int, int, double, double);
-private:
- Fresco::DrawingKit::Fillstyle style;
- orientation orient;
- normals norm;
-};
+ namespace DrawingKit
+ {
+ namespace openGL
+ {
-} // namespace
-} // namespace
+ class Quadric
+ {
+ public:
+ enum orientation {in, out};
+ enum normals {none, flat, smooth};
+ Quadric(Fresco::DrawingKit::Fillstyle s,
+ orientation o, normals n = none) :
+ my_style(s), my_orient(o), my_norm(n)
+ { }
+ ~Quadric() { }
+ void cylinder(double, double, double, int, int);
+ void sphere(double, int, int);
+ void disk(double, double, int, int);
+ void partialDisk(double, double, int, int, double, double);
+ private:
+ Fresco::DrawingKit::Fillstyle my_style;
+ orientation my_orient;
+ normals my_norm;
+ };
+
+ } // namespace
+ } // namespace
} // namespace
#endif
Index: Raster.cc
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/Raster.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Raster.cc 5 Jan 2003 16:21:31 -0000 1.16
+++ Raster.cc 29 Dec 2003 08:03:25 -0000 1.17
@@ -30,19 +30,21 @@
using namespace Prague;
using namespace Fresco;
-
+using namespace Berlin::Console_Extension;
using namespace Berlin::DrawingKit;
template <class T>
-T ceiling(T a, T b) { return a % b == 0 ? a/b : a/b + 1;}
+T ceiling(T a, T b) { return a % b == 0 ? a/b : a/b + 1; }
[...1046 lines suppressed...]
{
- if (!is_bound) {
- glcontext->add_to_queue(new Bind(GL_RGBA, GL_RGBA, &data[0], this));
- my_glcontext = glcontext;
- is_bound = true;
- }
- // XXX assert(glcontext == my_glcontext);
- my_glcontext->add_to_queue(new Activate(&texture, &texgen_w, &texgen_h, &height));
+ if (!my_is_bound)
+ {
+ glcontext->add_to_queue(new Bind(GL_RGBA, GL_RGBA, &my_data[0],
+ this));
+ my_glcontext = glcontext;
+ my_is_bound = true;
+ }
+ // assert(glcontext == my_glcontext);
+ my_glcontext->add_to_queue(new Activate(&texture,
+ &texgen_w, &texgen_h,
+ &height));
}
Index: Raster.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Berlin/modules/Drawing/openGL/Raster.hh,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Raster.hh 5 Jan 2003 16:21:31 -0000 1.10
+++ Raster.hh 29 Dec 2003 08:03:25 -0000 1.11
@@ -19,8 +19,8 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
* MA 02139, USA.
*/
-#ifndef _Raster_hh
-#define _Raster_hh
+#ifndef _openGL_Raster_hh
+#define _openGL_Raster_hh
#include <Fresco/config.hh>
#include <Fresco/Raster.hh>
@@ -29,56 +29,59 @@
#include <vector>
#include <GL/gl.h>
-namespace Berlin {
-namespace DrawingKit {
-namespace openGL {
-
-class Texture
+namespace Berlin
{
-public:
- Texture(Fresco::Raster_var);
- ~Texture();
- void activate(GLContext *);
- Fresco::Raster_var remote;
- Fresco::PixelCoord width;
- Fresco::PixelCoord height;
- Fresco::PixelCoord texgen_w;
- Fresco::PixelCoord texgen_h;
- GLuint texture;
-private:
- class Activate;
- class Bind;
- class Delete;
- bool is_bound;
- GLContext *my_glcontext;
- std::vector<unsigned char> data;
-};
+ namespace DrawingKit
+ {
+ namespace openGL
+ {
+ class Texture
+ {
+ public:
+ Texture(Fresco::Raster_var);
+ ~Texture();
+ void activate(Console_Extension::GLContext *);
+ Fresco::Raster_var remote;
+ Fresco::PixelCoord width;
+ Fresco::PixelCoord height;
+ Fresco::PixelCoord texgen_w;
+ Fresco::PixelCoord texgen_h;
+ GLuint texture;
+ private:
+ class Activate;
+ class Bind;
+ class Delete;
+ bool my_is_bound;
+ Console_Extension::GLContext *my_glcontext;
+ std::vector<unsigned char> my_data;
+ };
-class Image
-{
-public:
- Image(Fresco::Raster_var r);
- ~Image();
- void activate(GLContext *);
- GLfloat s, t;
- Fresco::Raster_var remote;
- Fresco::PixelCoord width;
- Fresco::PixelCoord height;
- Fresco::PixelCoord texgen_w;
- Fresco::PixelCoord texgen_h;
- GLuint texture;
-private:
- class Activate;
- class Bind;
- class Delete;
- bool is_bound;
- GLContext *my_glcontext;
- std::vector<unsigned char> data;
-};
-} // namespace
-} // namespace
+ class Image
+ {
+ public:
+ Image(Fresco::Raster_var r);
+ ~Image();
+ void activate(Console_Extension::GLContext *);
+ GLfloat s, t;
+ Fresco::Raster_var remote;
+ Fresco::PixelCoord width;
+ Fresco::PixelCoord height;
+ Fresco::PixelCoord texgen_w;
+ Fresco::PixelCoord texgen_h;
+ GLuint texture;
+ private:
+ class Activate;
+ class Bind;
+ class Delete;
+ bool my_is_bound;
+ Console_Extension::GLContext *my_glcontext;
+ std::vector<unsigned char> my_data;
+ };
+
+ } // namespace
+ } // namespace
} // namespace
#endif