Merge branch 'freetype'
This commit is contained in:
BIN
FreeSans.ttf
Executable file
BIN
FreeSans.ttf
Executable file
Binary file not shown.
BIN
FreeSansBold.ttf
Normal file
BIN
FreeSansBold.ttf
Normal file
Binary file not shown.
6
Makefile
6
Makefile
@@ -8,7 +8,7 @@ COMMON_LIBS = System.dll System.Core.dll System.Drawing.dll System.Xml.dll
|
||||
fileformats_SRCS = $(shell find OpenRa.FileFormats/ -iname '*.cs')
|
||||
fileformats_TARGET = OpenRa.FileFormats.dll
|
||||
fileformats_KIND = library
|
||||
fileformats_LIBS = $(COMMON_LIBS)
|
||||
fileformats_LIBS = $(COMMON_LIBS) thirdparty/Tao/Tao.Glfw.dll
|
||||
|
||||
gl_SRCS = $(shell find OpenRa.Gl/ -iname '*.cs')
|
||||
gl_TARGET = OpenRa.Gl.dll
|
||||
@@ -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')
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
@@ -24,6 +25,8 @@
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
@@ -33,6 +36,7 @@
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@@ -42,6 +46,10 @@
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Tao.Glfw, Version=2.6.0.0, Culture=neutral, PublicKeyToken=2bb092b6587e4402">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\thirdparty\Tao\Tao.Glfw.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AudLoader.cs" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#region Copyright & License Information
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||
* This file is part of OpenRA.
|
||||
@@ -19,35 +19,26 @@
|
||||
#endregion
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using Tao.Glfw;
|
||||
|
||||
namespace OpenRa.Support
|
||||
{
|
||||
public class Stopwatch
|
||||
{
|
||||
//[DllImport("kernel32.dll")]
|
||||
static bool QueryPerformanceCounter(out long value) { value = 1; return true; }
|
||||
//[DllImport("kernel32.dll")]
|
||||
static bool QueryPerformanceFrequency(out long frequency) { frequency = 1; return true; }
|
||||
|
||||
long freq, start;
|
||||
|
||||
double start;
|
||||
public Stopwatch()
|
||||
{
|
||||
QueryPerformanceFrequency(out freq);
|
||||
QueryPerformanceCounter(out start);
|
||||
Reset();
|
||||
}
|
||||
|
||||
public double ElapsedTime()
|
||||
{
|
||||
long current;
|
||||
QueryPerformanceCounter(out current);
|
||||
|
||||
return (current - start) / (double)freq;
|
||||
return (Glfw.glfwGetTime() - start);
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
QueryPerformanceCounter(out start);
|
||||
start = Glfw.glfwGetTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -43,11 +45,8 @@ namespace OpenRa.Graphics
|
||||
|
||||
public ITexture PaletteTexture;
|
||||
|
||||
readonly Font fDebug, fTitle;
|
||||
|
||||
Sheet textSheet;
|
||||
SpriteRenderer rgbaRenderer;
|
||||
Sprite textSprite;
|
||||
readonly FTFontGL regularFont, boldFont;
|
||||
const int RenderedFontSize = 48;
|
||||
|
||||
public Size Resolution { get { return device.WindowSize; } }
|
||||
|
||||
@@ -60,11 +59,21 @@ namespace OpenRa.Graphics
|
||||
RgbaSpriteShader = device.CreateShader(FileSystem.Open("shaders/chrome-rgba.fx"));
|
||||
WorldSpriteShader = device.CreateShader(FileSystem.Open("shaders/chrome-shp.fx"));
|
||||
|
||||
//fDebug = new Font("Tahoma", 10, FontStyle.Regular);
|
||||
//fTitle = new Font("Tahoma", 10, FontStyle.Bold);
|
||||
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);
|
||||
int Errors;
|
||||
regularFont = new FTFontGL("FreeSans.ttf", out Errors);
|
||||
|
||||
if (Errors > 0)
|
||||
throw new InvalidOperationException("Error(s) loading font");
|
||||
|
||||
regularFont.ftRenderToTexture(RenderedFontSize, 192);
|
||||
regularFont.FT_ALIGN = FTFontAlign.FT_ALIGN_LEFT;
|
||||
|
||||
boldFont = new FTFontGL("FreeSansBold.ttf", out Errors);
|
||||
if (Errors > 0)
|
||||
throw new InvalidOperationException("Error(s) loading font");
|
||||
|
||||
boldFont.ftRenderToTexture(RenderedFontSize, 192);
|
||||
boldFont.FT_ALIGN = FTFontAlign.FT_ALIGN_LEFT;
|
||||
}
|
||||
|
||||
IGraphicsDevice CreateDevice( Assembly rendererDll, int width, int height, bool fullscreen, bool vsync )
|
||||
@@ -77,25 +86,6 @@ namespace OpenRa.Graphics
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
Bitmap RenderTextToBitmap(string s, Font f, Color c)
|
||||
{
|
||||
Bitmap b = new Bitmap(256, 256);
|
||||
using (var g = System.Drawing.Graphics.FromImage(b))
|
||||
{
|
||||
g.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
g.DrawString(s, f, new SolidBrush(c), 0, 0);
|
||||
g.Flush();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
int2 GetTextSize(string s, Font f)
|
||||
{
|
||||
Bitmap b = new Bitmap(1,1);
|
||||
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(b);
|
||||
return new int2(g.MeasureString(s, f).ToSize());
|
||||
}
|
||||
|
||||
public IGraphicsDevice Device { get { return device; } }
|
||||
|
||||
public void BeginFrame(float2 r1, float2 r2, float2 scroll)
|
||||
@@ -154,38 +144,61 @@ namespace OpenRa.Graphics
|
||||
PerfHistory.Increment("batches", 1);
|
||||
}
|
||||
|
||||
public void DrawText(string text, int2 pos, Color c)
|
||||
{
|
||||
return;
|
||||
using (new PerfSample("text"))
|
||||
static void CheckError()
|
||||
{
|
||||
var e = Gl.glGetError();
|
||||
if (e != Gl.GL_NO_ERROR)
|
||||
throw new InvalidOperationException("GL Error: " + Gl.glGetString(e));
|
||||
}
|
||||
|
||||
const float emHeight = 14f; /* px */
|
||||
|
||||
void DrawTextInner(FTFontGL f, string text, int2 pos, Color c)
|
||||
{
|
||||
using (new PerfSample("text"))
|
||||
{
|
||||
Bitmap b = RenderTextToBitmap(text, fDebug, c);
|
||||
textSheet.Texture.SetData(b);
|
||||
rgbaRenderer.DrawSprite(textSprite, pos.ToFloat2(), "chrome");
|
||||
rgbaRenderer.Flush();
|
||||
pos.Y += (int)(emHeight);
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glPushMatrix();
|
||||
Gl.glLoadIdentity();
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_PROJECTION);
|
||||
Gl.glPushMatrix();
|
||||
Gl.glLoadIdentity();
|
||||
|
||||
Gl.glOrtho(0, Resolution.Width, 0, Resolution.Height, 0, 1);
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glTranslatef(pos.X, Resolution.Height - pos.Y, 0);
|
||||
Gl.glScalef(emHeight / RenderedFontSize, emHeight / RenderedFontSize, 1);
|
||||
|
||||
f.ftBeginFont(false);
|
||||
Gl.glColor4f(c.R / 255f, c.G / 255f, c.B / 255f, c.A / 255f);
|
||||
f.ftWrite(text);
|
||||
f.ftEndFont();
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_PROJECTION);
|
||||
Gl.glPopMatrix();
|
||||
|
||||
Gl.glMatrixMode(Gl.GL_MODELVIEW);
|
||||
Gl.glPopMatrix();
|
||||
|
||||
CheckError();
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawText2(string text, int2 pos, Color c)
|
||||
{
|
||||
return;
|
||||
using (new PerfSample("text"))
|
||||
{
|
||||
Bitmap b = RenderTextToBitmap(text, fTitle, c);
|
||||
textSheet.Texture.SetData(b);
|
||||
rgbaRenderer.DrawSprite(textSprite, pos.ToFloat2(), "chrome");
|
||||
rgbaRenderer.Flush();
|
||||
}
|
||||
}
|
||||
public void DrawText(string text, int2 pos, Color c) { DrawTextInner(regularFont, text, pos, c); }
|
||||
public void DrawText2(string text, int2 pos, Color c) { DrawTextInner(boldFont, text, pos, c); }
|
||||
|
||||
public int2 MeasureText(string text)
|
||||
{
|
||||
return new int2(0,0); //GetTextSize(text, fDebug);
|
||||
return new int2((int)(regularFont.ftExtent(ref text) / 3), (int)emHeight);
|
||||
}
|
||||
|
||||
public int2 MeasureText2(string text)
|
||||
{
|
||||
return new int2(0,0);// GetTextSize(text, fTitle);
|
||||
return new int2((int)(boldFont.ftExtent(ref text) / 3), (int)emHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</ProjectGuid>
|
||||
@@ -30,8 +31,6 @@
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<ApplicationIcon>OpenRA.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
@@ -43,6 +42,8 @@
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Optimize>false</Optimize>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
@@ -53,6 +54,7 @@
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
@@ -64,6 +66,14 @@
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311, processorArchitecture=MSIL" />
|
||||
<Reference Include="Tao.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\thirdparty\Tao\Tao.OpenGl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ISE.FreeType, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1b34ab585684d5ea">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\thirdparty\ISE.FreeType.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Chat.cs" />
|
||||
|
||||
BIN
thirdparty/ISE.FreeType.dll
vendored
Executable file
BIN
thirdparty/ISE.FreeType.dll
vendored
Executable file
Binary file not shown.
7
thirdparty/ISE.FreeType.dll.config
vendored
Normal file
7
thirdparty/ISE.FreeType.dll.config
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<configuration>
|
||||
<dllmap dll="freetype6.dll">
|
||||
<dllentry os="linux" dll="libfreetype.so.6" />
|
||||
<dllentry os="windows" dll="freetype6.dll" />
|
||||
<dllentry os="osx" dll="/sw/lib/libfreetype.dylib" />
|
||||
</dllmap>
|
||||
</configuration>
|
||||
BIN
thirdparty/Tao.Externals.dll
vendored
Executable file
BIN
thirdparty/Tao.Externals.dll
vendored
Executable file
Binary file not shown.
12
thirdparty/Tao.Externals.dll.config
vendored
Normal file
12
thirdparty/Tao.Externals.dll.config
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
<configuration>
|
||||
<dllmap dll="freetype6.dll">
|
||||
<dllentry os="linux" dll="libfreetype.so.6" />
|
||||
<dllentry os="windows" dll="freetype6.dll" />
|
||||
<dllentry os="osx" dll="/sw/lib/libfreetype.dylib" />
|
||||
</dllmap>
|
||||
</configuration>
|
||||
<dllmap dll="OpenAL32.dll">
|
||||
<dllentry os="linux" dll="libopenal.so.1" />
|
||||
<dllentry os="windows" dll="OpenAL32.dll" />
|
||||
<dllentry os="osx" dll="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
</dllmap>
|
||||
BIN
thirdparty/Tao/Tao.FreeType.dll
vendored
Executable file
BIN
thirdparty/Tao/Tao.FreeType.dll
vendored
Executable file
Binary file not shown.
7
thirdparty/Tao/Tao.FreeType.dll.config
vendored
Normal file
7
thirdparty/Tao/Tao.FreeType.dll.config
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<configuration>
|
||||
<dllmap dll="freetype6.dll">
|
||||
<dllentry os="linux" dll="libfreetype.so.6" />
|
||||
<dllentry os="windows" dll="freetype6.dll" />
|
||||
<dllentry os="osx" dll="/sw/lib/libfreetype.dylib" />
|
||||
</dllmap>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user