1 /***************************************************************************** 2 * $LastChangedDate: 2009-12-26 00:05:41 -0500 (Sat, 26 Dec 2009) $ 3 * @file 4 * @author Jim E. Brooks http://www.palomino3d.org 5 * @brief OpenGL abstraction. 6 *//* 7 * LEGAL: COPYRIGHT (C) 2008 JIM E. BROOKS 8 * THIS SOURCE CODE IS RELEASED UNDER THE TERMS 9 * OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2). 10 *****************************************************************************/ 11 12 #ifndef GFX_GFX_HH 13 #define GFX_GFX_HH 1 14 15 #include "gfx/opengl.hh" 16 #include "gfx/graphics.hh" 17 #include "gfx/rgba.hh" 18 19 namespace gfx { 20 21 //////////////////////////////////////////////////////////////////////////////// 22 /// @brief OpenGL abstraction. 23 /// 24 /// The GFX class is intended for when low-level OpenGL functions 25 /// are called by an osg::Operation functor. OSG allows changes to OpenGL state 26 /// in that situation and GFX makes no attempt to save/restore OpenGL state. 27 /// 28 class GFX 29 { 30 PREVENT_COPYING(GFX) 31 public: 32 CLASS_METHOD void Begin2D( const Rect<int>& rect ); 33 CLASS_METHOD void Begin2D( void ); // current window 34 CLASS_METHOD void End2D( void ); 35 CLASS_METHOD void DrawBox( const Rect<int>& rect, const RGBA color, const bool drawX = false ); 36 37 /***************************************************************************** 38 * Send 2D vertex. 39 *****************************************************************************/ 40 CLASS_METHOD 41 void Vertex2D(fp x,fp y)42 Vertex2D( fp x, fp y ) 43 { 44 // glVertex3f() with Z=1.0 is actually used for a 2D vertex 45 // in order to draw 2D vertexs over a 3D scene. 46 // A particular problem is drawing 2D fonts when a 3D land polygon 47 // at low altitude becomes so close that it would obscure the 2D fonts. 48 glVertex3f( x, y, 1.0f ); 49 } 50 }; 51 52 } // namespace gfx 53 54 #endif // GFX_GFX_HH 55