Refactor contexts slightly - use a null context when running on Direct3D. Clean up DrawTextArgs slightly, start work on a brand new launcher that is free of WinForms.

This commit is contained in:
UnknownShadow200 2015-10-16 19:50:51 +11:00
parent 8a63da7e02
commit 6e3a926fab
17 changed files with 322 additions and 93 deletions

View File

@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTK", "OpenTK\OpenTK.csp
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteropPatcher", "InteropPatcher\InteropPatcher.csproj", "{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher2", "Launcher2\Launcher2.csproj", "{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -24,18 +26,24 @@ Global
{23B9BDA8-4330-46AB-9012-08D87430391A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23B9BDA8-4330-46AB-9012-08D87430391A}.Debug_DX|Any CPU.Build.0 = Debug|Any CPU
{23B9BDA8-4330-46AB-9012-08D87430391A}.Debug_DX|Any CPU.ActiveCfg = Debug|Any CPU
{23B9BDA8-4330-46AB-9012-08D87430391A}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{23B9BDA8-4330-46AB-9012-08D87430391A}.Release_DX|Any CPU.ActiveCfg = Release|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Release|Any CPU.Build.0 = Release|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Debug_DX|Any CPU.Build.0 = Debug_D3D|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Debug_DX|Any CPU.ActiveCfg = Debug_D3D|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Release_DX|Any CPU.ActiveCfg = Release_D3D|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Release|Any CPU.Build.0 = Release|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Debug_DX|Any CPU.Build.0 = Debug|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Debug_DX|Any CPU.ActiveCfg = Debug_D3D|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Debug_DX|Any CPU.ActiveCfg = Debug|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Release_DX|Any CPU.ActiveCfg = Release|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Release|Any CPU.Build.0 = Release|Any CPU
@ -43,13 +51,15 @@ Global
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Debug_DX|Any CPU.Build.0 = Debug|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Debug_DX|Any CPU.ActiveCfg = Debug|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Release_DX|Any CPU.ActiveCfg = Release|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{35FEE071-2DE6-48A1-9343-B5C1F202A12B}.Release_DX|Any CPU.ActiveCfg = Release_D3D|Any CPU
{23B9BDA8-4330-46AB-9012-08D87430391A}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{23B9BDA8-4330-46AB-9012-08D87430391A}.Release_DX|Any CPU.ActiveCfg = Release|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Release_DX|Any CPU.Build.0 = Release|Any CPU
{BEB1C785-5CAD-48FF-A886-876BF0A318D4}.Release_DX|Any CPU.ActiveCfg = Release_D3D|Any CPU
{4A4110EE-21CA-4715-AF67-0C8B7CE0642F}.Release_DX|Any CPU.ActiveCfg = Release|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Release|Any CPU.Build.0 = Release|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Debug_DX|Any CPU.Build.0 = Debug|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Debug_DX|Any CPU.ActiveCfg = Debug|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Release_DX|Any CPU.Build.0 = Debug|Any CPU
{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}.Release_DX|Any CPU.ActiveCfg = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -5,18 +5,13 @@ namespace ClassicalSharp {
public struct DrawTextArgs {
public Color TextColour;
public string Text;
public bool UseShadow;
internal bool SkipPartsCheck;
public bool SkipPartsCheck;
public DrawTextArgs( string text, bool useShadow ) :
this( text, Color.White, useShadow ) { }
public DrawTextArgs( string text, Color col, bool useShadow ) {
public DrawTextArgs( string text, bool useShadow ) {
Text = text;
TextColour = col;
UseShadow = useShadow;
SkipPartsCheck = false;
}

View File

@ -48,7 +48,7 @@ namespace ClassicalSharp {
TextPart part = parts[i];
Brush textBrush = GetOrCreateBrush( part.TextColour );
if( args.UseShadow )
g.DrawString( part.Text, font, shadowBrush, x + shadowOffset, y + shadowOffset, format );
g.DrawString( part.Text, font, shadowBrush, x + Offset, y + Offset, format );
g.DrawString( part.Text, font, textBrush, x, y, format );
x += g.MeasureString( part.Text, font, Int32.MaxValue, format ).Width;
@ -115,8 +115,8 @@ namespace ClassicalSharp {
}
if( shadow && parts.Count > 0 ) {
total.Width += shadowOffset;
total.Height += shadowOffset;
total.Width += Offset;
total.Height += Offset;
}
return Size.Ceiling( total );
}

View File

@ -11,7 +11,7 @@ namespace ClassicalSharp {
public abstract class IDrawer2D : IDisposable {
protected IGraphicsApi graphics;
protected const float shadowOffset = 1.3f;
public const float Offset = 1.3f;
/// <summary> Sets the underlying bitmap that drawing operations will be performed on. </summary>
public abstract void SetBitmap( Bitmap bmp );

View File

@ -93,7 +93,8 @@ namespace ClassicalSharp {
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) {
using( IDrawer2D drawer = game.Drawer2D ) {
drawer.SetBitmap( bmp );
drawer.DrawRoundedRect( shadowCol, 3, 1.3f, 1.3f, baseSize.Width, baseSize.Height );
drawer.DrawRoundedRect( shadowCol, 3, IDrawer2D.Offset, IDrawer2D.Offset,
baseSize.Width, baseSize.Height );
drawer.DrawRoundedRect( boxCol, 3, 0, 0, baseSize.Width, baseSize.Height );
DrawTextArgs args = new DrawTextArgs( text, true );

View File

@ -48,7 +48,7 @@ namespace ClassicalSharp {
}
public override void Init() {
DrawTextArgs caretArgs = new DrawTextArgs( "_", Color.White, false );
DrawTextArgs caretArgs = new DrawTextArgs( "_", false );
chatCaretTexture = game.Drawer2D.MakeTextTexture( boldFont, 0, 0, ref caretArgs );
SetText( chatInputText.GetString() );
}
@ -63,13 +63,13 @@ namespace ClassicalSharp {
using( IDrawer2D drawer = game.Drawer2D ) {
drawer.SetBitmap( bmp );
drawer.DrawRect( backColour, 0, 0, size.Width, size.Height );
DrawTextArgs args = new DrawTextArgs( value, Color.White, false );
DrawTextArgs args = new DrawTextArgs( value, false );
args.SkipPartsCheck = true;
drawer.DrawText( font, ref args, 0, 0 );
string range = Validator.Range;
Size hintSize = drawer.MeasureSize( range, hintFont, true );
args = new DrawTextArgs( range, Color.White, false );
args = new DrawTextArgs( range, false );
args.SkipPartsCheck = true;
drawer.DrawText( hintFont, ref args, size.Width - hintSize.Width, 0 );
chatInputTexture = drawer.Make2DTexture( bmp, size, 0, 0 );

View File

@ -31,7 +31,7 @@ namespace ClassicalSharp {
public override void Init() {
X = 10;
DrawTextArgs caretArgs = new DrawTextArgs( "_", Color.White, false );
DrawTextArgs caretArgs = new DrawTextArgs( "_", false );
chatCaretTexture = game.Drawer2D.MakeTextTexture( boldFont, 0, 0, ref caretArgs );
string value = chatInputText.GetString();
if( chatInputText.Empty || caretPos >= value.Length )
@ -61,7 +61,7 @@ namespace ClassicalSharp {
using( IDrawer2D drawer = game.Drawer2D ) {
drawer.SetBitmap( bmp );
drawer.DrawRect( backColour, 0, 0, bmp.Width, bmp.Height );
DrawTextArgs args = new DrawTextArgs( value, Color.White, false );
DrawTextArgs args = new DrawTextArgs( value, false );
args.SkipPartsCheck = skipCheck;
drawer.DrawText( font, ref args, 0, 0 );
chatInputTexture = drawer.Make2DTexture( bmp, size, 10, y );

View File

@ -12,6 +12,7 @@ using ClassicalSharp.Selections;
using ClassicalSharp.TexturePack;
using OpenTK;
using OpenTK.Input;
using OpenTK.Graphics;
namespace ClassicalSharp {
@ -84,7 +85,12 @@ namespace ClassicalSharp {
Events.RaiseTerrainAtlasChanged();
}
public Game( string username, string mppass, string skinServer, string defaultTexPack ) : base() {
public Game( string username, string mppass, string skinServer, string defaultTexPack )
#if USE_DX
: base( 640, 480, GraphicsMode.Default, Utils.AppName, true, 0, DisplayDevice.Default ) {
#else
: base( 640, 480, GraphicsMode.Default, Utils.AppName, false, 0, DisplayDevice.Default ) {
#endif
Username = username;
Mppass = mppass;
this.skinServer = skinServer;
@ -161,7 +167,6 @@ namespace ClassicalSharp {
//Graphics.DepthWrite = true;
Graphics.AlphaBlendFunc( BlendFunc.SourceAlpha, BlendFunc.InvSourceAlpha );
Graphics.AlphaTestFunc( CompareFunc.Greater, 0.5f );
Title = Utils.AppName;
fpsScreen = new FpsScreen( this );
fpsScreen.Init();
Culling = new FrustumCulling();

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>WinExe</OutputType>
<RootNamespace>Launcher2</RootNamespace>
<AssemblyName>Launcher2</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<NoWin32Manifest>False</NoWin32Manifest>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<BaseAddress>4194304</BaseAddress>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainScreen.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClassicalSharp\ClassicalSharp.csproj">
<Project>{BEB1C785-5CAD-48FF-A886-876BF0A318D4}</Project>
<Name>ClassicalSharp</Name>
</ProjectReference>
<ProjectReference Include="..\OpenTK\OpenTK.csproj">
<Project>{35FEE071-2DE6-48A1-9343-B5C1F202A12B}</Project>
<Name>OpenTK</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

143
Launcher2/MainScreen.cs Normal file
View File

@ -0,0 +1,143 @@
using System;
using System.Drawing;
using ClassicalSharp;
using OpenTK;
using OpenTK.Graphics;
using OpenTK.Platform.Windows;
using OpenTK.Platform;
using OpenTK.Input;
namespace Launcher2 {
public sealed class MainScreen {
public IDrawer2D Drawer;
public NativeWindow Window;
public void Init() {
Window.Resize += HandleResize;
Window.Mouse.Move += new EventHandler<MouseMoveEventArgs>(Window_Mouse_Move);
}
void Window_Mouse_Move(object sender, MouseMoveEventArgs e) {
//System.Diagnostics.Debug.Print( "moved" );
}
public void Display() {
WinWindowInfo info = ((WinWindowInfo)Window.WindowInfo);
IntPtr dc = info.DeviceContext;
using( Graphics g = Graphics.FromHdc( dc ) ) {
g.DrawImage( background, 0, 0, background.Width, background.Height );
}
}
Bitmap background;
public void RecreateBackground() {
System.Diagnostics.Debug.Print( "DISPLAY" );
if( background != null )
background.Dispose();
background = new Bitmap( Window.Width, Window.Height );
Font logoFont = new Font( "Times New Roman", 28, FontStyle.Bold );
Font logoItalicFont = new Font( "Times New Roman", 28, FontStyle.Italic );
using( IDrawer2D drawer = Drawer ) {
drawer.SetBitmap( background );
drawer.Clear( Color.FromArgb( 30, 30, 30 ) );
Size size1 = drawer.MeasureSize( "&eClassical", logoItalicFont, true );
Size size2 = drawer.MeasureSize( "&eSharp", logoFont, true );
int xStart = Window.Width / 2 - (size1.Width + size2.Width ) / 2;
DrawTextArgs args = new DrawTextArgs( "&eClassical", true );
drawer.DrawText( logoItalicFont, ref args, xStart, 20 );
args.Text = "&eSharp";
drawer.DrawText( logoFont, ref args, xStart + size1.Width, 20 );
DrawButtons( drawer );
}
logoFont.Dispose();
logoItalicFont.Dispose();
}
static FastColour boxCol = new FastColour( 169, 143, 192 ), shadowCol = new FastColour( 97, 81, 110 );
void DrawButtons( IDrawer2D drawer ) {
widgetIndex = 0;
using( Font font = new Font( "Arial", 16, FontStyle.Bold ) ) {
DrawText( drawer, "Direct connect", font, Anchor.Centre, Anchor.Centre,
buttonWidth, buttonHeight, 0, -100 );
DrawText( drawer, "ClassiCube.net", font, Anchor.Centre, Anchor.Centre,
buttonWidth, buttonHeight, 0, -50 );
DrawText( drawer, "Default texture pack", font, Anchor.Centre, Anchor.Centre,
buttonWidth, buttonHeight, 0, 50 );
DrawText( drawer, "Singleplayer", font, Anchor.LeftOrTop, Anchor.BottomOrRight,
sideButtonWidth, buttonHeight, 10, -10 );
DrawText( drawer, "Resume", font, Anchor.BottomOrRight, Anchor.BottomOrRight,
sideButtonWidth, buttonHeight, -10, -10 );
}
}
Widget[] widgets = new Widget[5];
int widgetIndex = 0;
const int buttonWidth = 220, buttonHeight = 35, sideButtonWidth = 150;
void DrawText( IDrawer2D drawer, string text, Font font, Anchor horAnchor,
Anchor verAnchor, int width, int height, int x, int y ) {
Size textSize = drawer.MeasureSize( text, font, true );
int xOffset = width - textSize.Width;
int yOffset = height - textSize.Height;
if( horAnchor == Anchor.Centre ) x = x + Window.Width / 2 - width / 2;
else if( horAnchor == Anchor.BottomOrRight ) x = x + Window.Width - width;
if( verAnchor == Anchor.Centre ) y = y + Window.Height / 2 - height / 2;
else if( verAnchor == Anchor.BottomOrRight ) y = y + Window.Height - height;
drawer.DrawRoundedRect( shadowCol, 3, x + IDrawer2D.Offset, y + IDrawer2D.Offset,
width, height );
drawer.DrawRoundedRect( boxCol, 3, x, y, width, height );
DrawTextArgs args = new DrawTextArgs( text, true );
args.SkipPartsCheck = true;
drawer.DrawText( font, ref args,
x + 1 + xOffset / 2, y + 1 + yOffset / 2 );
Widget widget = new Widget();
// adjust for border size of 2
widget.X = x; widget.Y = y;
widget.Width = width + 2; widget.Height = height + 2;
//FilterButton( widget.X, widget.Y, widget.Width, widget.Height, 150 );
widgets[widgetIndex++] = widget;
}
class Widget {
public int X, Y;
public int Width, Height;
public bool Active;
}
void HandleResize( object sender, EventArgs e ) {
RecreateBackground();
}
unsafe void FilterButton( int x, int y, int width, int height, byte scale ) {
using( FastBitmap bmp = new FastBitmap( background, true ) ) {
for( int yy = y; yy < y + height; yy++ ) {
int* row = bmp.GetRowPtr( yy ) + x;
for( int xx = 0; xx < width; xx++ ) {
uint pixel = (uint)row[xx];
uint a = pixel & 0xFF000000;
uint r = (pixel >> 16) & 0xFF;
uint g = (pixel >> 8) & 0xFF;
uint b = pixel & 0xFF;
r = (r * scale) / 255;
g = (g * scale) / 255;
b = (b * scale) / 255;
row[xx] = (int)(a | (r << 16) | (g << 8) | b);
}
}
}
}
}
}

32
Launcher2/Program.cs Normal file
View File

@ -0,0 +1,32 @@
using System;
using ClassicalSharp;
using OpenTK;
using OpenTK.Graphics;
namespace Launcher2 {
internal sealed class Program {
public const string AppName = "ClassicalSharp Launcher 0.95";
[STAThread]
private static void Main( string[] args ) {
NativeWindow window = new NativeWindow( 480, 480, AppName, 0,
GraphicsMode.Default, DisplayDevice.Default );
window.Visible = true;
MainScreen screen = new MainScreen();
screen.Drawer = new GdiPlusDrawer2D( null );
screen.Window = window;
screen.RecreateBackground();
screen.Init();
while( true ) {
window.ProcessEvents();
if( !window.Exists ) break;
screen.Display();
System.Threading.Thread.Sleep( 10 );
}
}
}
}

View File

@ -0,0 +1,31 @@
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Launcher2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Launcher2")]
[assembly: AssemblyCopyright("Copyright 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]

View File

@ -34,6 +34,7 @@ using System.Threading;
using OpenTK.Graphics;
using OpenTK.Input;
using OpenTK.Platform;
using OpenTK.Graphics;
namespace OpenTK
{
@ -82,40 +83,6 @@ namespace OpenTK
double next_render = 0.0;
FrameEventArgs render_args = new FrameEventArgs();
/// <summary>Constructs a new GameWindow with sensible default attributes.</summary>
public GameWindow()
: this(640, 480, GraphicsMode.Default, "OpenTK Game Window", 0, DisplayDevice.Default) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
/// <param name="width">The width of the GameWindow in pixels.</param>
/// <param name="height">The height of the GameWindow in pixels.</param>
public GameWindow(int width, int height)
: this(width, height, GraphicsMode.Default, "OpenTK Game Window", 0, DisplayDevice.Default) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
/// <param name="width">The width of the GameWindow in pixels.</param>
/// <param name="height">The height of the GameWindow in pixels.</param>
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
public GameWindow(int width, int height, GraphicsMode mode)
: this(width, height, mode, "OpenTK Game Window", 0, DisplayDevice.Default) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
/// <param name="width">The width of the GameWindow in pixels.</param>
/// <param name="height">The height of the GameWindow in pixels.</param>
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
/// <param name="title">The title of the GameWindow.</param>
public GameWindow(int width, int height, GraphicsMode mode, string title)
: this(width, height, mode, title, 0, DisplayDevice.Default) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
/// <param name="width">The width of the GameWindow in pixels.</param>
/// <param name="height">The height of the GameWindow in pixels.</param>
/// <param name="mode">The OpenTK.Graphics.GraphicsMode of the GameWindow.</param>
/// <param name="title">The title of the GameWindow.</param>
/// <param name="options">GameWindow options regarding window appearance and behavior.</param>
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options)
: this(width, height, mode, title, options, DisplayDevice.Default) { }
/// <summary>Constructs a new GameWindow with the specified attributes.</summary>
/// <param name="width">The width of the GameWindow in pixels.</param>
/// <param name="height">The height of the GameWindow in pixels.</param>
@ -123,10 +90,12 @@ namespace OpenTK
/// <param name="title">The title of the GameWindow.</param>
/// <param name="options">GameWindow options regarding window appearance and behavior.</param>
/// <param name="device">The OpenTK.Graphics.DisplayDevice to construct the GameWindow in.</param>
public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options, DisplayDevice device)
: base(width, height, title, options, mode == null ? GraphicsMode.Default : mode, device == null ? DisplayDevice.Default : device) {
public GameWindow(int width, int height, GraphicsMode mode, string title, bool nullContext,
GameWindowFlags options, DisplayDevice device)
: base(width, height, title, options, mode, device) {
try {
glContext = Factory.Default.CreateGLContext(mode == null ? GraphicsMode.Default : mode, WindowInfo);
glContext = nullContext ? new NullContext() :
Factory.Default.CreateGLContext(mode, WindowInfo);
glContext.MakeCurrent(WindowInfo);
glContext.LoadAll();
VSync = true;

View File

@ -44,25 +44,6 @@
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<StartAction>Project</StartAction>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug_D3D' ">
<OutputPath>..\output\debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE;USE_DX</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release_D3D' ">
<OutputPath>..\output\release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE;USE_DX</DefineConstants>
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
<StartAction>Project</StartAction>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Drawing" />
@ -121,11 +102,11 @@
<Compile Include="Platform\Windows\API.cs" />
<Compile Include="Platform\Windows\Wgl.cs" />
<Compile Include="Platform\Windows\WinDisplayDevice.cs" />
<Compile Include="Platform\Windows\WinDXContext.cs" />
<Compile Include="Platform\Windows\WinGLContext.cs" />
<Compile Include="Platform\Windows\WinGLNative.cs" />
<Compile Include="Platform\Windows\WinKeyMap.cs" />
<Compile Include="Platform\Windows\WinWindowInfo.cs" />
<Compile Include="Platform\NullContext.cs" />
<Compile Include="Platform\X11\API.cs" />
<Compile Include="Platform\X11\Functions.cs" />
<Compile Include="Platform\X11\Glx.cs" />

View File

@ -79,11 +79,7 @@ namespace OpenTK.Platform.Windows {
}
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window) {
#if USE_DX
return new WinDXContext( mode, (WinWindowInfo)window );
#else
return new WinGLContext(mode, (WinWindowInfo)window);
#endif
}
}
}

View File

@ -1,18 +1,18 @@
using System;
using OpenTK.Graphics;
namespace OpenTK.Platform.Windows {
namespace OpenTK.Platform {
internal sealed class WinDXContext : GraphicsContextBase {
internal sealed class NullContext : GraphicsContextBase {
public WinDXContext(GraphicsMode format, WinWindowInfo window) {
public NullContext() {
Debug.Print( "doing nothing" );
}
public override void SwapBuffers() {
}
public override void MakeCurrent(IWindowInfo window) {
public override void MakeCurrent( IWindowInfo window ) {
}
public override bool IsCurrent {

View File

@ -126,7 +126,6 @@ namespace OpenTK.Platform.Windows
API.SetWindowPos(child_window.WindowHandle, IntPtr.Zero, 0, 0, ClientRectangle.Width, ClientRectangle.Height,
SetWindowPosFlags.NOZORDER | SetWindowPosFlags.NOOWNERZORDER |
SetWindowPosFlags.NOACTIVATE | SetWindowPosFlags.NOSENDCHANGING);
if (suppress_resize <= 0 && Resize != null)
Resize(this, EventArgs.Empty);
}