diff --git a/FreeSans.ttf b/FreeSans.ttf new file mode 100755 index 0000000000..6de62ebf67 Binary files /dev/null and b/FreeSans.ttf differ diff --git a/Makefile b/Makefile index e5f4ea4848..9a25627cfe 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ gl_KIND = library gl_DEPS = $(fileformats_TARGET) $(game_TARGET) \ thirdparty/Tao/Tao.Glfw.dll gl_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll \ - thirdparty/Tao/Tao.Cg.dll thirdparty/Tao/Tao.OpenGl.dll \ + thirdparty/Tao/Tao.Cg.dll thirdparty/Tao.Externals.dll \ $(gl_DEPS) $(game_TARGET) game_SRCS = $(shell find OpenRa.Game/ -iname '*.cs') @@ -24,7 +24,7 @@ game_TARGET = OpenRa.Game.exe game_KIND = winexe game_DEPS = $(fileformats_TARGET) game_LIBS = $(COMMON_LIBS) System.Windows.Forms.dll $(game_DEPS) \ - thirdparty/Tao/Tao.OpenAl.dll + thirdparty/Tao.Externals.dll thirdparty/ISE.FreeType.dll game_FLAGS = -win32icon:OpenRa.Game/OpenRa.ico ra_SRCS = $(shell find OpenRa.Mods.RA/ -iname '*.cs') diff --git a/OpenRa.Game/Graphics/Renderer.cs b/OpenRa.Game/Graphics/Renderer.cs index 0b3ca88962..ae25b0bc14 100644 --- a/OpenRa.Game/Graphics/Renderer.cs +++ b/OpenRa.Game/Graphics/Renderer.cs @@ -27,6 +27,8 @@ using OpenRa.FileFormats; using OpenRa.FileFormats.Graphics; using OpenRa.Support; using System.IO; +using ISE; +using Tao.OpenGl; namespace OpenRa.Graphics { @@ -44,7 +46,8 @@ namespace OpenRa.Graphics public ITexture PaletteTexture; readonly Font fDebug, fTitle; - + readonly FTFontBitmap testFont; + Sheet textSheet; SpriteRenderer rgbaRenderer; Sprite textSprite; @@ -60,8 +63,13 @@ namespace OpenRa.Graphics RgbaSpriteShader = device.CreateShader(FileSystem.Open("chrome-rgba.fx")); WorldSpriteShader = device.CreateShader(FileSystem.Open("chrome-shp.fx")); - //fDebug = new Font("Tahoma", 10, FontStyle.Regular); + //fDebug = new Font("Tahoma", 10.0f, FontStyle.Regular); //fTitle = new Font("Tahoma", 10, FontStyle.Bold); + int Errors; + testFont = new FTFontBitmap("FreeSans.ttf", out Errors); + testFont.ftRenderToTexture(2, 48); + testFont.FT_ALIGN = FTFontAlign.FT_ALIGN_CENTERED; + textSheet = new Sheet(this, new Size(256, 256)); rgbaRenderer = new SpriteRenderer(this, true, RgbaSpriteShader); textSprite = new Sprite(textSheet, new Rectangle(0, 0, 256, 256), TextureChannel.Alpha); @@ -80,6 +88,10 @@ namespace OpenRa.Graphics Bitmap RenderTextToBitmap(string s, Font f, Color c) { Bitmap b = new Bitmap(256, 256); + testFont.ftBeginFont(0.9f,0.0f,0.0f,0.5f); + testFont.ftWrite("Test",b); + testFont.ftEndFont(); + /*using (var g = System.Drawing.Graphics.FromImage(b)) { g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit; @@ -91,7 +103,7 @@ namespace OpenRa.Graphics int2 GetTextSize(string s, Font f) { - return new int2(0,0); + return new int2(50,100); /*Bitmap b = new Bitmap(1,1); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b); return new int2(g.MeasureString(s, f).ToSize());*/ @@ -157,9 +169,8 @@ namespace OpenRa.Graphics public void DrawText(string text, int2 pos, Color c) { - return; using (new PerfSample("text")) - { + { Bitmap b = RenderTextToBitmap(text, fDebug, c); textSheet.Texture.SetData(b); rgbaRenderer.DrawSprite(textSprite, pos.ToFloat2(), "chrome"); @@ -169,7 +180,6 @@ namespace OpenRa.Graphics public void DrawText2(string text, int2 pos, Color c) { - return; using (new PerfSample("text")) { Bitmap b = RenderTextToBitmap(text, fTitle, c); @@ -181,12 +191,12 @@ namespace OpenRa.Graphics public int2 MeasureText(string text) { - return new int2(0,0); //GetTextSize(text, fDebug); + return GetTextSize(text, fDebug); } public int2 MeasureText2(string text) { - return new int2(0,0);// GetTextSize(text, fTitle); + return GetTextSize(text, fTitle); } } } diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index f2f2ab62d5..a1c49da2c3 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -1,7 +1,8 @@ - + + Debug - AnyCPU + x86 9.0.30729 2.0 {0DFB103F-2962-400F-8C6D-E2C28CCBA633} @@ -30,8 +31,6 @@ false true v3.5 - - OpenRA.ico @@ -43,6 +42,8 @@ x86 false prompt + 4 + false bin\Release\ @@ -53,6 +54,7 @@ x86 false prompt + 4 @@ -64,6 +66,14 @@ + + False + ..\thirdparty\ISE.FreeType.dll + + + False + ..\thirdparty\Tao\Tao.OpenGl.dll + diff --git a/thirdparty/ISE.FreeType.dll b/thirdparty/ISE.FreeType.dll new file mode 100755 index 0000000000..7a7b7a7587 Binary files /dev/null and b/thirdparty/ISE.FreeType.dll differ diff --git a/thirdparty/Tao.Externals.dll b/thirdparty/Tao.Externals.dll new file mode 100755 index 0000000000..81ecf2e1aa Binary files /dev/null and b/thirdparty/Tao.Externals.dll differ diff --git a/thirdparty/Tao.Externals.dll.config b/thirdparty/Tao.Externals.dll.config new file mode 100644 index 0000000000..b6745059fe --- /dev/null +++ b/thirdparty/Tao.Externals.dll.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/thirdparty/Tao/Tao.FreeType.dll b/thirdparty/Tao/Tao.FreeType.dll new file mode 100755 index 0000000000..15ccb306d2 Binary files /dev/null and b/thirdparty/Tao/Tao.FreeType.dll differ diff --git a/thirdparty/Tao/Tao.FreeType.dll.config b/thirdparty/Tao/Tao.FreeType.dll.config new file mode 100644 index 0000000000..f16cbf2616 --- /dev/null +++ b/thirdparty/Tao/Tao.FreeType.dll.config @@ -0,0 +1,7 @@ + + + + + + +