Fix perf counter

This commit is contained in:
pchote
2010-02-20 19:46:02 +13:00
parent 37084f4014
commit a88d0b7be1
4 changed files with 20 additions and 21 deletions

View File

@@ -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_SRCS = $(shell find OpenRa.FileFormats/ -iname '*.cs')
fileformats_TARGET = OpenRa.FileFormats.dll fileformats_TARGET = OpenRa.FileFormats.dll
fileformats_KIND = library 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_SRCS = $(shell find OpenRa.Gl/ -iname '*.cs')
gl_TARGET = OpenRa.Gl.dll gl_TARGET = OpenRa.Gl.dll

View File

@@ -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> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -24,6 +25,8 @@
<DebugType>full</DebugType> <DebugType>full</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Optimize>false</Optimize>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
@@ -33,6 +36,7 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
@@ -42,6 +46,10 @@
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.Xml" /> <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>
<ItemGroup> <ItemGroup>
<Compile Include="AudLoader.cs" /> <Compile Include="AudLoader.cs" />

View File

@@ -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. * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
* This file is part of OpenRA. * This file is part of OpenRA.
@@ -19,35 +19,26 @@
#endregion #endregion
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Tao.Glfw;
namespace OpenRa.Support namespace OpenRa.Support
{ {
public class Stopwatch public class Stopwatch
{ {
//[DllImport("kernel32.dll")] double start;
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;
public Stopwatch() public Stopwatch()
{ {
QueryPerformanceFrequency(out freq); Reset();
QueryPerformanceCounter(out start);
} }
public double ElapsedTime() public double ElapsedTime()
{ {
long current; return (Glfw.glfwGetTime() - start);
QueryPerformanceCounter(out current);
return (current - start) / (double)freq;
} }
public void Reset() public void Reset()
{ {
QueryPerformanceCounter(out start); start = Glfw.glfwGetTime();
} }
} }
} }

View File

@@ -66,14 +66,14 @@
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311, processorArchitecture=MSIL" /> <Reference Include="Tao.OpenAl, Version=1.1.0.1, Culture=neutral, PublicKeyToken=a7579dda88828311, processorArchitecture=MSIL" />
<Reference Include="ISE.FreeType, Version=1.0.2885.37773, Culture=neutral, PublicKeyToken=null">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\thirdparty\ISE.FreeType.dll</HintPath>
</Reference>
<Reference Include="Tao.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef"> <Reference Include="Tao.OpenGl, Version=2.1.0.12, Culture=neutral, PublicKeyToken=1ca010269a4501ef">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\thirdparty\Tao\Tao.OpenGl.dll</HintPath> <HintPath>..\thirdparty\Tao\Tao.OpenGl.dll</HintPath>
</Reference> </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>
<ItemGroup> <ItemGroup>
<Compile Include="Chat.cs" /> <Compile Include="Chat.cs" />