diff --git a/ClassicalSharp.sln b/ClassicalSharp.sln index c01c225a7..229e42ed7 100644 --- a/ClassicalSharp.sln +++ b/ClassicalSharp.sln @@ -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 diff --git a/ClassicalSharp/2D/Drawing/DrawTextArgs.cs b/ClassicalSharp/2D/Drawing/DrawTextArgs.cs index e83003a83..3243cb11e 100644 --- a/ClassicalSharp/2D/Drawing/DrawTextArgs.cs +++ b/ClassicalSharp/2D/Drawing/DrawTextArgs.cs @@ -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; } diff --git a/ClassicalSharp/2D/Drawing/GdiPlusDrawer2D.cs b/ClassicalSharp/2D/Drawing/GdiPlusDrawer2D.cs index 56fbf89aa..855c30801 100644 --- a/ClassicalSharp/2D/Drawing/GdiPlusDrawer2D.cs +++ b/ClassicalSharp/2D/Drawing/GdiPlusDrawer2D.cs @@ -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 ); } diff --git a/ClassicalSharp/2D/Drawing/IDrawer2D.cs b/ClassicalSharp/2D/Drawing/IDrawer2D.cs index b3b05dff1..52e674712 100644 --- a/ClassicalSharp/2D/Drawing/IDrawer2D.cs +++ b/ClassicalSharp/2D/Drawing/IDrawer2D.cs @@ -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; /// Sets the underlying bitmap that drawing operations will be performed on. public abstract void SetBitmap( Bitmap bmp ); diff --git a/ClassicalSharp/2D/Widgets/ButtonWidget.cs b/ClassicalSharp/2D/Widgets/ButtonWidget.cs index fe5b8ce41..90ce13d6e 100644 --- a/ClassicalSharp/2D/Widgets/ButtonWidget.cs +++ b/ClassicalSharp/2D/Widgets/ButtonWidget.cs @@ -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 ); diff --git a/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs b/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs index 282fd0999..72a857157 100644 --- a/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs +++ b/ClassicalSharp/2D/Widgets/Menu/MenuInputWidget.cs @@ -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 ); diff --git a/ClassicalSharp/2D/Widgets/TextInputWidget.cs b/ClassicalSharp/2D/Widgets/TextInputWidget.cs index d43b4e22e..3df2e842f 100644 --- a/ClassicalSharp/2D/Widgets/TextInputWidget.cs +++ b/ClassicalSharp/2D/Widgets/TextInputWidget.cs @@ -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 ); diff --git a/ClassicalSharp/Game/Game.cs b/ClassicalSharp/Game/Game.cs index 1f22b23fe..c3989c445 100644 --- a/ClassicalSharp/Game/Game.cs +++ b/ClassicalSharp/Game/Game.cs @@ -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(); diff --git a/Launcher2/Launcher2.csproj b/Launcher2/Launcher2.csproj new file mode 100644 index 000000000..98b34a036 --- /dev/null +++ b/Launcher2/Launcher2.csproj @@ -0,0 +1,67 @@ + + + + {3E84ACC1-27B4-401B-A359-6AAE4DF6C9B5} + Debug + AnyCPU + WinExe + Launcher2 + Launcher2 + v4.0 + Client + Properties + False + True + False + False + obj\$(Configuration)\ + 4 + + + x86 + 4194304 + False + Auto + 4096 + + + bin\Debug\ + True + Full + False + False + DEBUG;TRACE + obj\ + + + bin\Release\ + False + None + True + False + TRACE + + + + + 3.5 + + + + + + + + + + + {BEB1C785-5CAD-48FF-A886-876BF0A318D4} + ClassicalSharp + + + {35FEE071-2DE6-48A1-9343-B5C1F202A12B} + OpenTK + + + + \ No newline at end of file diff --git a/Launcher2/MainScreen.cs b/Launcher2/MainScreen.cs new file mode 100644 index 000000000..656dc31a8 --- /dev/null +++ b/Launcher2/MainScreen.cs @@ -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(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); + } + } + } + } + + } +} diff --git a/Launcher2/Program.cs b/Launcher2/Program.cs new file mode 100644 index 000000000..938c95fad --- /dev/null +++ b/Launcher2/Program.cs @@ -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 ); + } + } + } +} diff --git a/Launcher2/Properties/AssemblyInfo.cs b/Launcher2/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9ea91a1b5 --- /dev/null +++ b/Launcher2/Properties/AssemblyInfo.cs @@ -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.*")] diff --git a/OpenTK/GameWindow.cs b/OpenTK/GameWindow.cs index 134c1faf2..fddb22149 100644 --- a/OpenTK/GameWindow.cs +++ b/OpenTK/GameWindow.cs @@ -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(); - /// Constructs a new GameWindow with sensible default attributes. - public GameWindow() - : this(640, 480, GraphicsMode.Default, "OpenTK Game Window", 0, DisplayDevice.Default) { } - - /// Constructs a new GameWindow with the specified attributes. - /// The width of the GameWindow in pixels. - /// The height of the GameWindow in pixels. - public GameWindow(int width, int height) - : this(width, height, GraphicsMode.Default, "OpenTK Game Window", 0, DisplayDevice.Default) { } - - /// Constructs a new GameWindow with the specified attributes. - /// The width of the GameWindow in pixels. - /// The height of the GameWindow in pixels. - /// The OpenTK.Graphics.GraphicsMode of the GameWindow. - public GameWindow(int width, int height, GraphicsMode mode) - : this(width, height, mode, "OpenTK Game Window", 0, DisplayDevice.Default) { } - - /// Constructs a new GameWindow with the specified attributes. - /// The width of the GameWindow in pixels. - /// The height of the GameWindow in pixels. - /// The OpenTK.Graphics.GraphicsMode of the GameWindow. - /// The title of the GameWindow. - public GameWindow(int width, int height, GraphicsMode mode, string title) - : this(width, height, mode, title, 0, DisplayDevice.Default) { } - - /// Constructs a new GameWindow with the specified attributes. - /// The width of the GameWindow in pixels. - /// The height of the GameWindow in pixels. - /// The OpenTK.Graphics.GraphicsMode of the GameWindow. - /// The title of the GameWindow. - /// GameWindow options regarding window appearance and behavior. - public GameWindow(int width, int height, GraphicsMode mode, string title, GameWindowFlags options) - : this(width, height, mode, title, options, DisplayDevice.Default) { } - /// Constructs a new GameWindow with the specified attributes. /// The width of the GameWindow in pixels. /// The height of the GameWindow in pixels. @@ -123,10 +90,12 @@ namespace OpenTK /// The title of the GameWindow. /// GameWindow options regarding window appearance and behavior. /// The OpenTK.Graphics.DisplayDevice to construct the GameWindow in. - 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; diff --git a/OpenTK/OpenTK.csproj b/OpenTK/OpenTK.csproj index 3ce80058f..bf0ad9b84 100644 --- a/OpenTK/OpenTK.csproj +++ b/OpenTK/OpenTK.csproj @@ -44,25 +44,6 @@ obj\ Project - - ..\output\debug\ - True - None - True - False - DEBUG;TRACE;USE_DX - obj\ - - - ..\output\release\ - False - None - True - False - TRACE;USE_DX - obj\ - Project - @@ -121,11 +102,11 @@ - + diff --git a/OpenTK/Platform/IPlatformFactory.cs b/OpenTK/Platform/IPlatformFactory.cs index 33809de6e..551bbc285 100644 --- a/OpenTK/Platform/IPlatformFactory.cs +++ b/OpenTK/Platform/IPlatformFactory.cs @@ -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 } } } diff --git a/OpenTK/Platform/Windows/WinDXContext.cs b/OpenTK/Platform/NullContext.cs similarity index 66% rename from OpenTK/Platform/Windows/WinDXContext.cs rename to OpenTK/Platform/NullContext.cs index dd0a92f16..03e151029 100644 --- a/OpenTK/Platform/Windows/WinDXContext.cs +++ b/OpenTK/Platform/NullContext.cs @@ -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 { diff --git a/OpenTK/Platform/Windows/WinGLNative.cs b/OpenTK/Platform/Windows/WinGLNative.cs index a8eb8f963..4dd4680d0 100644 --- a/OpenTK/Platform/Windows/WinGLNative.cs +++ b/OpenTK/Platform/Windows/WinGLNative.cs @@ -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); }