From 3eddc87704dbdcf031a00504b24d88e17f71affb Mon Sep 17 00:00:00 2001 From: unodgs Date: Thu, 14 Jul 2011 10:22:39 +0000 Subject: [PATCH] Rainbow: WinGL.. git-svn-id: svn://ultimatepp.org/upp/trunk@3658 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- rainbow/WinGl/DrawOp.cpp | 5 +-- rainbow/WinGl/FontGl.h | 48 ++++++++++++++++++++++++++++ rainbow/WinGl/ResGl.h | 24 ++++++++++++++ rainbow/WinGl/WinGl.h | 67 ++-------------------------------------- rainbow/WinGl/WinGl.upp | 2 ++ 5 files changed, 79 insertions(+), 67 deletions(-) create mode 100644 rainbow/WinGl/FontGl.h create mode 100644 rainbow/WinGl/ResGl.h diff --git a/rainbow/WinGl/DrawOp.cpp b/rainbow/WinGl/DrawOp.cpp index b856e517b..8d28c1664 100644 --- a/rainbow/WinGl/DrawOp.cpp +++ b/rainbow/WinGl/DrawOp.cpp @@ -147,7 +147,7 @@ void SystemDraw::SetClip(const Rect& r, int mode) void SystemDraw::BeginOp() { Cloff& w = cloff[ci++]; - w.clipping = true; + w.clipping = false; w.org = drawing_offset; w.drawing_clip = drawing_clip; } @@ -171,13 +171,13 @@ void SystemDraw::EndOp() void SystemDraw::OffsetOp(Point p) { BeginOp(); - cloff[ci - 1].clipping = false; drawing_offset += p; } bool SystemDraw::ClipOp(const Rect& r) { BeginOp(); + cloff[ci - 1].clipping = true; drawing_clip = r + drawing_offset; SetClip(drawing_clip); return true; @@ -186,6 +186,7 @@ bool SystemDraw::ClipOp(const Rect& r) bool SystemDraw::ClipoffOp(const Rect& r) { BeginOp(); + cloff[ci - 1].clipping = true; drawing_clip = r + drawing_offset; drawing_offset += r.TopLeft(); SetClip(drawing_clip); diff --git a/rainbow/WinGl/FontGl.h b/rainbow/WinGl/FontGl.h new file mode 100644 index 000000000..c5dd85249 --- /dev/null +++ b/rainbow/WinGl/FontGl.h @@ -0,0 +1,48 @@ +#ifndef _WinGl_FontGl_h_ +#define _WinGl_FontGl_h_ + +struct OpenGLFont : Moveable +{ + float scaleW; + float scaleH; + float lineHeight; + float base; + + bool texturesUpdated; + + float vtx[1024 * 4 * 2]; + float crd[1024 * 4 * 2]; + + struct CharInfo : Moveable + { + int id; + float x; + float y; + float width; + float height; + float xoffset; + float yoffset; + float xadvance; + int page; + }; + + Vector chars; + VectorMap > kerns; + Vector files; + Array compiledFiles; + Vector pages; + + OpenGLFont() : texturesUpdated(false) + {} + + ~OpenGLFont() + {} + + void LoadBrc(const byte* xml, const byte* image); + void Load(const String& fileName); + void Parse(const char* xml, bool parsePages); + void UpdateTextures(); + void BuildVertices(); +}; + +#endif diff --git a/rainbow/WinGl/ResGl.h b/rainbow/WinGl/ResGl.h new file mode 100644 index 000000000..93c18fcb2 --- /dev/null +++ b/rainbow/WinGl/ResGl.h @@ -0,0 +1,24 @@ +#ifndef _WinGl_ResGl_h_ +#define _WinGl_ResGl_h_ + +struct Texture : Moveable +{ + Size sz; + Point curpos; + VectorMap parts; + void AddPart(int64 serialId, const Image& img); +}; + +struct Resources +{ + static int64 currentSerialId; + static ArrayMap textures; + static VectorMap fonts; + static int64 Bind(const Image& img, bool linear = false); + static bool Bind(int64 serialId, bool force = false); + static OpenGLFont& GetFont(const char* fontName); + static OpenGLFont& GetFontBrc(const char* fontName, const byte* fontDef, const byte* fontImage); + static OpenGLFont& StdFont(bool bold = false); +}; + +#endif diff --git a/rainbow/WinGl/WinGl.h b/rainbow/WinGl/WinGl.h index 336ef35b7..5cf7ba6ed 100644 --- a/rainbow/WinGl/WinGl.h +++ b/rainbow/WinGl/WinGl.h @@ -14,7 +14,6 @@ #include - NAMESPACE_UPP #define IMAGECLASS WinGlImg @@ -45,70 +44,8 @@ float GetFps(); 3 - Manual clip */ -struct OpenGLFont : Moveable -{ - float scaleW; - float scaleH; - float lineHeight; - float base; - - bool texturesUpdated; - - float vtx[1024 * 4 * 2]; - float crd[1024 * 4 * 2]; - - struct CharInfo : Moveable - { - int id; - float x; - float y; - float width; - float height; - float xoffset; - float yoffset; - float xadvance; - int page; - }; - - Vector chars; - VectorMap > kerns; - Vector files; - Array compiledFiles; - Vector pages; - - OpenGLFont() : texturesUpdated(false) - {} - - ~OpenGLFont() - {} - - void LoadBrc(const byte* xml, const byte* image); - void Load(const String& fileName); - void Parse(const char* xml, bool parsePages); - void UpdateTextures(); - void BuildVertices(); - -}; - -struct Texture : Moveable -{ - Size sz; - Point curpos; - VectorMap parts; - void AddPart(int64 serialId, const Image& img); -}; - -struct Resources -{ - static int64 currentSerialId; - static ArrayMap textures; - static VectorMap fonts; - static int64 Bind(const Image& img, bool linear = false); - static bool Bind(int64 serialId, bool force = false); - static OpenGLFont& GetFont(const char* fontName); - static OpenGLFont& GetFontBrc(const char* fontName, const byte* fontDef, const byte* fontImage); - static OpenGLFont& StdFont(bool bold = false); -}; +#include +#include class SystemDraw : public Draw { public: diff --git a/rainbow/WinGl/WinGl.upp b/rainbow/WinGl/WinGl.upp index 1a93fc265..c26fd3ba9 100644 --- a/rainbow/WinGl/WinGl.upp +++ b/rainbow/WinGl/WinGl.upp @@ -10,6 +10,8 @@ options file WinGl.h, + ResGl.h, + FontGl.h, Keys.h, Draw.cpp, DrawOp.cpp,