Rainbow: WinGL..

git-svn-id: svn://ultimatepp.org/upp/trunk@3658 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
unodgs 2011-07-14 10:22:39 +00:00
parent 8163e72248
commit 3eddc87704
5 changed files with 79 additions and 67 deletions

View file

@ -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);

48
rainbow/WinGl/FontGl.h Normal file
View file

@ -0,0 +1,48 @@
#ifndef _WinGl_FontGl_h_
#define _WinGl_FontGl_h_
struct OpenGLFont : Moveable<OpenGLFont>
{
float scaleW;
float scaleH;
float lineHeight;
float base;
bool texturesUpdated;
float vtx[1024 * 4 * 2];
float crd[1024 * 4 * 2];
struct CharInfo : Moveable<CharInfo>
{
int id;
float x;
float y;
float width;
float height;
float xoffset;
float yoffset;
float xadvance;
int page;
};
Vector<CharInfo> chars;
VectorMap<int, VectorMap<int, float> > kerns;
Vector<String> files;
Array<const byte> compiledFiles;
Vector<int64> 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

24
rainbow/WinGl/ResGl.h Normal file
View file

@ -0,0 +1,24 @@
#ifndef _WinGl_ResGl_h_
#define _WinGl_ResGl_h_
struct Texture : Moveable<Texture>
{
Size sz;
Point curpos;
VectorMap<int64, Rect> parts;
void AddPart(int64 serialId, const Image& img);
};
struct Resources
{
static int64 currentSerialId;
static ArrayMap<int64, Texture> textures;
static VectorMap<String, OpenGLFont> 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

View file

@ -14,7 +14,6 @@
#include <Painter/Painter.h>
NAMESPACE_UPP
#define IMAGECLASS WinGlImg
@ -45,70 +44,8 @@ float GetFps();
3 - Manual clip
*/
struct OpenGLFont : Moveable<OpenGLFont>
{
float scaleW;
float scaleH;
float lineHeight;
float base;
bool texturesUpdated;
float vtx[1024 * 4 * 2];
float crd[1024 * 4 * 2];
struct CharInfo : Moveable<CharInfo>
{
int id;
float x;
float y;
float width;
float height;
float xoffset;
float yoffset;
float xadvance;
int page;
};
Vector<CharInfo> chars;
VectorMap<int, VectorMap<int, float> > kerns;
Vector<String> files;
Array<const byte> compiledFiles;
Vector<int64> 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<Texture>
{
Size sz;
Point curpos;
VectorMap<int64, Rect> parts;
void AddPart(int64 serialId, const Image& img);
};
struct Resources
{
static int64 currentSerialId;
static ArrayMap<int64, Texture> textures;
static VectorMap<String, OpenGLFont> 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 <WinGl/FontGl.h>
#include <WinGl/ResGl.h>
class SystemDraw : public Draw {
public:

View file

@ -10,6 +10,8 @@ options
file
WinGl.h,
ResGl.h,
FontGl.h,
Keys.h,
Draw.cpp,
DrawOp.cpp,