CrystalSpace

Public API Reference

Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

pen.h

00001 /*
00002   Copyright (C) 2005 by Christopher Nelson
00003 
00004   This library is free software; you can redistribute it and/or
00005   modify it under the terms of the GNU Library General Public
00006   License as published by the Free Software Foundation; either
00007   version 2 of the License, or (at your option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012   Library General Public License for more details.
00013 
00014   You should have received a copy of the GNU Library General Public
00015   License along with this library; if not, write to the Free
00016   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_CSTOOL_PEN_H__
00020 #define __CS_CSTOOL_PEN_H__
00021 
00022 #include "csgeom/poly3d.h"
00023 #include "csgeom/polyidx.h"
00024 #include "csgeom/vector4.h"
00025 #include "csutil/dirtyaccessarray.h"
00026 #include "csutil/ref.h"
00027 
00028 #include "ivideo/graph3d.h"
00029 
00030 struct iFont;
00031 struct iGraphics2D;
00032 struct iGraphics3D;
00033 
00034 enum CS_PEN_TEXT_ALIGN { CS_PEN_TA_TOP, CS_PEN_TA_BOT, CS_PEN_TA_LEFT, CS_PEN_TA_RIGHT, CS_PEN_TA_CENTER };
00035 
00039 struct iPen
00040 {
00044   virtual void SetColor (float r, float g, float b, float a) = 0;
00045 
00049   virtual void ClearTransform()=0;
00050 
00054   virtual void PushTransform()=0;
00055 
00059   virtual void PopTransform()=0;
00060 
00064   virtual void SetOrigin(const csVector3 &o)=0;
00065 
00069   virtual void Translate(const csVector3 &t)=0;
00070 
00074   virtual void Rotate(const float &a)=0;
00075 
00079   virtual void DrawLine (uint x1, uint y1, uint x2, uint y2) = 0;
00080 
00084   virtual void DrawPoint (uint x1, uint y2) = 0;
00085 
00089   virtual void DrawRect (uint x1, uint y1, uint x2, uint y2, bool fill = false) = 0;
00090   
00095   virtual void DrawMiteredRect (uint x1, uint y1, uint x2, uint y2, 
00096     float miter, bool fill = false) = 0;
00097 
00102   virtual void DrawRoundedRect (uint x1, uint y1, uint x2, uint y2, 
00103     float roundness, bool fill = false) = 0; 
00104 
00111   virtual void DrawArc(uint x1, uint y1, uint x2, uint y2, float start_angle, float end_angle, bool fill=false) = 0;
00112 
00116   virtual void Write(iFont *font, uint x1, uint y1, char *text)=0;
00117 
00122   virtual void WriteBoxed(iFont *font, uint x1, uint y1, uint x2, uint y2, 
00123     uint h_align, uint v_align, char *text)=0;
00124 };
00125 
00127 class csPen : public iPen
00128 {
00130   csRef<iGraphics3D> g3d;
00131 
00133   csRef<iGraphics2D> g2d;
00134 
00136   csSimpleRenderMesh mesh;
00137   
00139   csPolyIndexed poly_idx;
00140   
00142   csPoly3D poly;
00143 
00145   csVector4 color;
00146 
00148   csVector3 tt;
00149 
00151   csDirtyAccessArray<csVector4> colors;
00152 
00154   csArray<csReversibleTransform> transforms;
00155 
00156 protected:
00160   void Start();
00161 
00165   void AddVertex(float x, float y);
00166 
00170   void SetupMesh();
00171 
00175   void DrawMesh(csRenderMeshType mesh_type);
00176 
00177 public:
00178   csPen(iGraphics2D *_g2d, iGraphics3D *_g3d);
00179   virtual ~csPen();
00180 
00184   virtual void SetColor (float r, float g, float b, float a);
00185 
00189   virtual void ClearTransform();
00190 
00194   virtual void PushTransform();
00195 
00199   virtual void PopTransform();
00200 
00204   virtual void SetOrigin(const csVector3 &o);
00205 
00209   virtual void Translate(const csVector3 &t);
00210 
00214   virtual void Rotate(const float &a);
00215 
00219   virtual void DrawLine (uint x1, uint y1, uint x2, uint y2);
00220 
00224   virtual void DrawPoint (uint x1, uint y2);
00225 
00229   virtual void DrawRect (uint x1, uint y1, uint x2, uint y2, bool fill = false);
00230 
00235   virtual void DrawMiteredRect (uint x1, uint y1, uint x2, uint y2, 
00236     float miter, bool fill = false);
00237 
00242   virtual void DrawRoundedRect (uint x1, uint y1, uint x2, uint y2, 
00243     float roundness, bool fill = false);
00244 
00251   virtual void DrawArc(uint x1, uint y1, uint x2, uint y2, float start_angle, float end_angle, bool fill=false);
00252 
00256   virtual void Write(iFont *font, uint x1, uint y1, char *text);
00257 
00262   virtual void WriteBoxed(iFont *font, uint x1, uint y1, uint x2, uint y2, 
00263     uint h_align, uint v_align, char *text);
00264 };
00265 
00266 
00267 #endif

Generated for Crystal Space by doxygen 1.4.4