這是蓋莫游戲引擎2.1.2中GUI之2-GUI刷子
該對象提供對2d基本圖元的繪制和操作
提供以下功能
1.點繪制
2.線段繪制
3.矩形繪制
4.三角形繪制
5.紋理渲染
以后還會加入更多的功能
其功能大致相當于UI lib中的Graphics,
Glooery中的Renderer
以及GUI Chart中的Graphics!
其接口如下:
////////////////////////////////////////////////////////////
/// 定義引擎GUI刷子(提供簡單的幾何體繪制操作)
////////////////////////////////////////////////////////////
class G_DLL_API GuiBrush : public Object
{
public:
////////////////////////////////////////////////////////
/// GUI刷子構造,析構
////////////////////////////////////////////////////////
GuiBrush();
virtual ~GuiBrush();
public:
////////////////////////////////////////////////////////
/// 設置GUI刷子顏色
////////////////////////////////////////////////////////
virtual void SetBrushColor(const Color& color) = 0;
//////////////////////////////////////////////////////////
/// 設置刷子線寬
//////////////////////////////////////////////////////////
virtual void SetLineWidth(float width) = 0;
virtual float GetMaxLineWidth()const = 0;
virtual float GetLineWidth()const = 0;
//////////////////////////////////////////////////////////
/// 繪制一個點
//////////////////////////////////////////////////////////
virtual void RenderPoint(const Point& point) = 0;
virtual void RenderPoint(const Vector2f& point) = 0;
virtual void RenderPoint(int x,int y) = 0;
virtual void RenderPoint(float x,float y) = 0;
////////////////////////////////////////////////////////
/// 繪制一個線段
////////////////////////////////////////////////////////
virtual void RenderLine(const Vector2f& from, const Vector2f& to) = 0;
virtual void RenderLine(const Point& from, const Point& to) = 0;
////////////////////////////////////////////////////////
/// 繪制一個矩陣框(填充與否)
////////////////////////////////////////////////////////
virtual void RenderRect(const Recti& rect, bool fill = true) = 0;
virtual void RenderRect(const Rectf& rect, bool fill = true) = 0;
////////////////////////////////////////////////////////
/// 繪制一個三角形
////////////////////////////////////////////////////////
virtual void RenderTriangle(const Vector2f& p1,const Vector2f& p2,const Vector2f& p3, bool fill = true) = 0;
virtual void RenderTriangle(const Point& p1,const Point& p2,const Point& p3, bool fill = true) = 0;
//////////////////////////////////////////////////////////
/// 繪制一個園,園扇(segments為邊數(shù))
//////////////////////////////////////////////////////////
virtual void RenderCircle(const Vector2f& center,float radius,int segments = 32) = 0;
virtual void RenderCircleSegment(const Vector2f& center,float radius,float angle1,float angle2,int segments = 32,bool filled = true) = 0;
////////////////////////////////////////////////////////
/// 渲染紋理
////////////////////////////////////////////////////////
virtual void RenderTexture(float x,float y,float w,float h) = 0;
virtual void RenderTexture(const Rectf& rect) = 0;
DECLARE_OBJECT(GuiBrush)
};
可以看出比較簡單 沒有什么復雜的東西!
在GUI部分
引擎還會陸續(xù)加入以下對象
1.Widget 基本控件單元
2.Border 控件裝飾器
3.Layout 控件布局管理器
4.UIManager UI管理器
5.UIEvent UI消息事件
6.WidgetSort 提供對控件的深度排序
可能還會加入UISurface以提供對控件表面的裝飾效果
引擎UI需要達到的高度
1.控件組動態(tài)生成(要求源于xml config file)
2.控件自布局
3.靈活簡單易用
4.UI引擎和引擎的低聚合
.....