mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 11:55:31 +00:00
Merged gw-next2 branch to trunk.
This commit is contained in:
parent
ac21b13246
commit
7df9a448d6
|
@ -5,13 +5,34 @@ OpenTK does not require installation. Simply decompress the archive to a folder
|
|||
|
||||
Usage
|
||||
|
||||
To use OpenTK, you need to reference OpenTK.dll from your project. The way you do this changes from IDE to IDE - refer to http://www.opentk.com/doc for specific instructions.
|
||||
To use OpenTK, you need to reference "OpenTK.dll". Refer to http://www.opentk.com/doc for specific instructions.
|
||||
|
||||
In any case, make sure the OpenTK.dll.config file is copied to the output directory along with OpenTK.dll. This file is *required* for OpenTK to function on Linux and Mac OS X.
|
||||
Regardless of your development environment and operating system, ensure that you copy "OpenTK.dll.config" to the output directory. Without OpenTK.dll.config, your application will not function on Linux or MacOS.
|
||||
|
||||
|
||||
Build instructions
|
||||
|
||||
If you have Visual Studio 2005/2008 or MonoDevelop 2 (post-beta1), simply open OpenTK.sln in the Build/ folder. If you wish build from the commandline, install nant (http://nant.sourceforge.net) and execute Build.exe in the Build/ folder.
|
||||
You can build OpenTK using Visual Studio 2005+, SharpDevelop 2.0+, MonoDevelop 2.0+, msbuild or nant. Instructions:
|
||||
|
||||
The resulting binaries are placed into the Binaries/Release or Binaries/Debug folder.
|
||||
1a. Open the Build/ folder.
|
||||
|
||||
1b. If you are using a fresh SVN checkout, double click "Build.exe", type "vs" and press enter twice to create OpenTK.sln. This step is not necessary if you are using a released version of OpenTK.
|
||||
|
||||
2a. If you are using Visual Studio, SharpDevelop or MonoDevelop, double-click OpenTK.sln, select a build configuration (debug/release) and build the project.
|
||||
|
||||
2b. If you wish to build from the commandline:
|
||||
|
||||
[Windows]
|
||||
Make sure msbuild is in your path and type:
|
||||
|
||||
cd Build
|
||||
Build.exe vs
|
||||
msbuild
|
||||
|
||||
[Linux / MacOS]
|
||||
Make sure nant (http://nant.sourceforge.net) is in your path and type:
|
||||
|
||||
cd Build/
|
||||
mono Build.exe nant release
|
||||
|
||||
4. The resulting binaries are placed into the Binaries/Release or Binaries/Debug folder.
|
|
@ -38,6 +38,7 @@ To visit an issue report, type "http://www.opentk.com/node/{id}", where {id} is
|
|||
[#870]
|
||||
|
||||
|
||||
|
||||
[Known issues]
|
||||
|
||||
Mono 2.2 and 2.4 cannot compile this release (bug report: https://bugzilla.novell.com/show_bug.cgi?id=488960). Please compile with Mono 2.0 or 2.4.2+, or use the precompiled binaries.
|
||||
|
@ -46,13 +47,48 @@ OpenTK.Graphics.TextPrinter fails to render text with newlines or a layout recta
|
|||
|
||||
Example documentation may not show up correctly when running on Mono.
|
||||
|
||||
Joystick input is not supported on MacOS at this time.
|
||||
|
||||
OpenGL 3.0 is not supported on MacOS at this time.
|
||||
|
||||
|
||||
|
||||
[API changes]
|
||||
|
||||
Please note that binary compatibility is not preserved between beta releases.
|
||||
|
||||
OpenTK 0.9.8 replaces several instances of the "All" and "Version*" enums with strongly-typed equivalents. This is a breaking change. If you are affected by this change, replace these enums with the ones suggested by your compiler.
|
||||
|
||||
OpenTK 0.9.8 removes several OpenGL overloads that take arrays of a single item. This is a breaking change. If you are affected by this change, please use the 'ref' or 'out' overload for the relevant function.
|
||||
[0.9.9]
|
||||
|
||||
OpenTK 0.9.8 removes or replaces several invalid tokens in the DrawBuffer(s) methods. This is a breaking change.
|
||||
1. GameWindow.Resize and GameWindow.OnResize have changed signatures:
|
||||
|
||||
ResizeEventHandler Resize(object, ResizeEventArgs) -> EventHandler<EventArgs> Resize(object, EventArgs)
|
||||
OnResize(ResizeEventArgs) -> OnResize(EventArgs)
|
||||
|
||||
Please replace all instances of "ResizeEventHandler" by "EventHandler<EventArgs> and replace "e.Width" / "e.Height" by "this.Width" and "this.Height".
|
||||
|
||||
|
||||
[0.9.8]
|
||||
|
||||
1. OpenTK 0.9.8 replaces several instances of the "All" and "Version*" enums with strongly-typed equivalents. This is a breaking change. If you are affected by this change, replace these enums with the ones suggested by your compiler.
|
||||
|
||||
The 'v' suffix has been removed from several OpenTK.Graphics.GL functions. Please search and replace any of the following functions (list non-inclusive):
|
||||
|
||||
Uniform1v -> Uniform1
|
||||
Materialv -> Material
|
||||
Lightv -> Light
|
||||
|
||||
|
||||
2. Several instances of the "Version12" enum have been replaced with strongly-typed equivalents. This is a breaking change that affects programs using the imaging subset of OpenGL 1.2.
|
||||
|
||||
If you are affected by this change, please replace all relevant instances of "Version12" with the correct enum, as indicated by your compiler.
|
||||
|
||||
|
||||
3. OpenTK 0.9.8 removes several OpenGL overloads that take arrays of a single item. This is a breaking change. If you are affected by this change, please use the 'ref' or 'out' overload for the relevant function.
|
||||
|
||||
|
||||
[0.9.7]
|
||||
|
||||
OpenTK 0.9.7 replaces several instances of the "All" and "Version30" enums with strongly-typed equivalents. This is a breaking change that potentially affects programs using OpenGL 3.0 functionality. If you are affected by this change, please replace the relevant instances of "All" or "Version30" with the correct enum, as reported by your IDE.
|
||||
|
||||
OpenTK 0.9.7 also fixes the naming of several core and extension functions ending in "Instanced", "Indexed" or "Varyings". If you are affected by this change, please add the missing 'd' or 's' to the relevant functions.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[OpenTK.Graphics.GraphicsContext]
|
||||
+ FSAA support (very simple, now that GL3 support has been added.)
|
||||
+ Implement GL3 support on Mac OS X.
|
||||
+ Improve API for context sharing (add a sharedContext parameter to the context constructor).
|
||||
|
||||
[OpenTK.GLControl]
|
||||
+ Improve the designer interface.
|
||||
|
|
|
@ -1,11 +1,3 @@
|
|||
OpenTK.OpenGL.Bind 0.9.4 todos:
|
||||
|
||||
Major:
|
||||
+ Change the output of extensions from GL.BlahARB to GL.ARB.Blah
|
||||
+ Use generics instead of object overloads.
|
||||
+ Add ref overloads for arrays
|
||||
|
||||
Minor:
|
||||
+ Clean up the reader.
|
||||
+ Add more settings to Settings.cs (the name of the files to read).
|
||||
+ Comment the code.
|
||||
+ Improve inline documentation for function overloads (parameters are incorrect).
|
||||
+ Clean up the code.
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnResize
|
||||
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
|
@ -111,7 +111,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnUpdateFrame
|
||||
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
{
|
||||
|
@ -123,7 +123,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnRenderFrame
|
||||
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.MatrixMode(MatrixMode.Modelview);
|
||||
GL.LoadIdentity();
|
||||
|
|
|
@ -63,13 +63,11 @@ namespace Examples.Tutorial
|
|||
/// <remarks>
|
||||
/// You want the OpenGL viewport to match the window. This is the place to do it!
|
||||
/// </remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
double aspect_ratio = e.Width / (double)e.Height;
|
||||
double aspect_ratio = Width / (double)Height;
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
if (Keyboard[OpenTK.Input.Key.Space])
|
||||
|
@ -95,7 +93,7 @@ namespace Examples.Tutorial
|
|||
/// Place your control logic here. This is the place to respond to user input,
|
||||
/// update object positions etc.
|
||||
/// </remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
{
|
||||
|
@ -111,7 +109,7 @@ namespace Examples.Tutorial
|
|||
/// <summary>
|
||||
/// Place your rendering code here.
|
||||
/// </summary>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
|
@ -121,7 +119,7 @@ namespace Examples.Tutorial
|
|||
0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0);
|
||||
|
||||
angle += rotation_speed * (float)e.ScaleFactor;
|
||||
angle += rotation_speed * (float)e.Time;
|
||||
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
DrawCube();
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains information on the new GameWindow size.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
this.Exit();
|
||||
|
@ -110,7 +110,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
||||
|
|
|
@ -84,13 +84,13 @@ namespace Examples.Tutorial
|
|||
/// <remarks>
|
||||
/// You want the OpenGL viewport to match the window. This is the place to do it!
|
||||
/// </remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
double ratio = e.Width / (double)e.Height;
|
||||
double ratio = Width / (double)Height;
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
@ -108,7 +108,7 @@ namespace Examples.Tutorial
|
|||
/// Place your control logic here. This is the place to respond to user input,
|
||||
/// update object positions etc.
|
||||
/// </remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
// Escape quits.
|
||||
if (Keyboard[Key.Escape])
|
||||
|
@ -143,7 +143,7 @@ namespace Examples.Tutorial
|
|||
/// <summary>
|
||||
/// Place your rendering code here.
|
||||
/// </summary>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
|
@ -155,7 +155,7 @@ namespace Examples.Tutorial
|
|||
0.0, 1.0, 0.0
|
||||
);
|
||||
|
||||
angle += rotation_speed * (float)e.ScaleFactor;
|
||||
angle += rotation_speed * (float)e.Time;
|
||||
|
||||
if (angle >= 360.0f)
|
||||
angle -= 360.0f;
|
||||
|
|
|
@ -78,13 +78,13 @@ namespace Examples.Tutorial
|
|||
/// <remarks>
|
||||
/// You want the OpenGL viewport to match the window. This is the place to do it!
|
||||
/// </remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
double ratio = e.Width / (double)e.Height;
|
||||
double ratio = Width / (double)Height;
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
@ -102,7 +102,7 @@ namespace Examples.Tutorial
|
|||
/// Place your control logic here. This is the place to respond to user input,
|
||||
/// update object positions etc.
|
||||
/// </remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ namespace Examples.Tutorial
|
|||
/// <summary>
|
||||
/// Place your rendering code here.
|
||||
/// </summary>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
|
|
|
@ -73,11 +73,11 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnResize override
|
||||
|
||||
protected override void OnResize(ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
double ratio = e.Width / (double)e.Height;
|
||||
double ratio = Width / (double)Height;
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
@ -95,7 +95,7 @@ namespace Examples.Tutorial
|
|||
/// Place your control logic here. This is the place to respond to user input,
|
||||
/// update object positions etc.
|
||||
/// </remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
this.Exit();
|
||||
|
@ -105,7 +105,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnRenderFrame
|
||||
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnRenderFrame(e);
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ namespace Examples.Tutorial
|
|||
GL.Ext.DeleteFramebuffers(1, ref FBOHandle);
|
||||
}
|
||||
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
|
@ -230,7 +230,7 @@ namespace Examples.Tutorial
|
|||
base.OnResize(e);
|
||||
}
|
||||
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnUpdateFrame(e);
|
||||
|
||||
|
@ -244,7 +244,7 @@ namespace Examples.Tutorial
|
|||
this.Exit();
|
||||
}
|
||||
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains information on the new GameWindow size.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
// Magic numbers so the fractal almost fits inside the window.
|
||||
// If changing this, also change the -1.6f offset in the fragment shader accordingly.
|
||||
|
@ -237,7 +237,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
base.OnUpdateFrame(e);
|
||||
|
||||
|
@ -256,7 +256,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
//this.Title = "FPS: " + 1 / e.Time;
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
|
|
@ -192,11 +192,11 @@ namespace Examples.Tutorial
|
|||
/// <remarks>
|
||||
/// You want the OpenGL viewport to match the window. This is the place to do it!
|
||||
/// </remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
double ratio = e.Width / (double)e.Height;
|
||||
double ratio = Width / (double)Height;
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
|
@ -214,7 +214,7 @@ namespace Examples.Tutorial
|
|||
/// Place your control logic here. This is the place to respond to user input,
|
||||
/// update object positions etc.
|
||||
/// </remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[OpenTK.Input.Key.Escape])
|
||||
this.Exit();
|
||||
|
@ -234,7 +234,7 @@ namespace Examples.Tutorial
|
|||
/// <summary>
|
||||
/// Place your rendering code here.
|
||||
/// </summary>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit |
|
||||
ClearBufferMask.DepthBufferBit);
|
||||
|
@ -245,7 +245,7 @@ namespace Examples.Tutorial
|
|||
0.0, 0.0, 0.0,
|
||||
0.0, 1.0, 0.0);
|
||||
|
||||
angle += rotation_speed * (float)e.ScaleFactor;
|
||||
angle += rotation_speed * (float)e.Time;
|
||||
GL.Rotate(angle, 0.0f, 1.0f, 0.0f);
|
||||
|
||||
GL.EnableClientState(EnableCap.VertexArray);
|
||||
|
|
|
@ -135,7 +135,7 @@ namespace Examples
|
|||
|
||||
#region OnResize
|
||||
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
|
@ -246,7 +246,7 @@ namespace Examples
|
|||
|
||||
#region OnRenderFrame
|
||||
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnResize
|
||||
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnUpdateFrame
|
||||
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
if (Keyboard[Key.Space])
|
||||
scroll_speed = 0;
|
||||
|
@ -103,7 +103,7 @@ namespace Examples.Tutorial
|
|||
|
||||
#region OnRenderFrame
|
||||
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace Examples
|
|||
/// </summary>
|
||||
/// <param name="e">Contains information on the new GameWindow size.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace Examples
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
// Nothing to do!
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ namespace Examples
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
||||
|
|
|
@ -68,15 +68,13 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains information on the new GameWindow size.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
GL.MatrixMode(MatrixMode.Projection);
|
||||
GL.LoadIdentity();
|
||||
GL.Ortho(-1.0, 1.0, -1.0, 1.0, 0.0, 4.0);
|
||||
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -88,7 +86,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnUpdateFrame(UpdateFrameEventArgs e)
|
||||
protected override void OnUpdateFrame(FrameEventArgs e)
|
||||
{
|
||||
// Nothing to do!
|
||||
}
|
||||
|
@ -102,7 +100,7 @@ namespace Examples.Tutorial
|
|||
/// </summary>
|
||||
/// <param name="e">Contains timing information.</param>
|
||||
/// <remarks>There is no need to call the base implementation.</remarks>
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@ namespace Examples.Tests
|
|||
T GetNext<T>(T t)
|
||||
{
|
||||
if (!(t is Enum))
|
||||
throw new ArgumentException(String.Format("Should be an Enum type (is {0}).", t.GetType().ToString()),
|
||||
"t");
|
||||
throw new ArgumentException(String.Format("Should be an Enum type (is {0}).", t.GetType().ToString()), "t");
|
||||
|
||||
string[] names = Enum.GetNames(t.GetType());
|
||||
T[] values = (T[])Enum.GetValues(t.GetType());
|
||||
|
@ -45,8 +44,7 @@ namespace Examples.Tests
|
|||
T GetPrevious<T>(T t)
|
||||
{
|
||||
if (!(t is Enum))
|
||||
throw new ArgumentException(String.Format("Should be an Enum type (is {0}).", t.GetType().ToString()),
|
||||
"t");
|
||||
throw new ArgumentException(String.Format("Should be an Enum type (is {0}).", t.GetType().ToString()), "t");
|
||||
|
||||
string[] names = Enum.GetNames(t.GetType());
|
||||
T[] values = (T[])Enum.GetValues(t.GetType());
|
||||
|
@ -111,12 +109,12 @@ namespace Examples.Tests
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnResize(OpenTK.Platform.ResizeEventArgs e)
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
}
|
||||
|
||||
public override void OnRenderFrame(RenderFrameEventArgs e)
|
||||
protected override void OnRenderFrame(FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
|
||||
|
|
|
@ -51,24 +51,24 @@ namespace Examples.Tests
|
|||
hidden = new GameWindow(320, 240, GraphicsMode.Default, "OpenTK | Hidden input window");
|
||||
hidden.Load += hidden_Load;
|
||||
hidden.Unload += hidden_Unload;
|
||||
hidden.RenderFrame += new OpenTK.RenderFrameEvent(hidden_RenderFrame);
|
||||
hidden.RenderFrame += hidden_RenderFrame;
|
||||
hidden.Run(60.0, 0.0);
|
||||
}
|
||||
|
||||
void hidden_RenderFrame(GameWindow sender, RenderFrameEventArgs e)
|
||||
void hidden_RenderFrame(object sender, FrameEventArgs e)
|
||||
{
|
||||
GL.Clear(ClearBufferMask.ColorBufferBit);
|
||||
sender.SwapBuffers();
|
||||
((GameWindow)sender).SwapBuffers();
|
||||
}
|
||||
|
||||
void hidden_Load(GameWindow sender, EventArgs e)
|
||||
void hidden_Load(object sender, EventArgs e)
|
||||
{
|
||||
hidden.VSync = VSyncMode.On;
|
||||
start = true;
|
||||
GL.ClearColor(Color.Black);
|
||||
}
|
||||
|
||||
void hidden_Unload(GameWindow sender, EventArgs e)
|
||||
void hidden_Unload(object sender, EventArgs e)
|
||||
{
|
||||
this.BeginInvoke(on_hidden_unload, sender, e, this);
|
||||
}
|
||||
|
|
8
Source/Examples/Properties/Resources.Designer.cs
generated
8
Source/Examples/Properties/Resources.Designer.cs
generated
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:2.0.50727.4918
|
||||
// Runtime Version:4.0.20506.1
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
|
@ -19,7 +19,7 @@ namespace Examples.Properties {
|
|||
// class via a tool like ResGen or Visual Studio.
|
||||
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||
// with the /str option, or rebuild your VS project.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
@ -579,9 +579,7 @@ namespace Examples.Properties {
|
|||
///using System.Diagnostics;
|
||||
///
|
||||
///using OpenTK;
|
||||
///using OpenTK.Graphics.OpenGL;
|
||||
///using OpenTK.Graphics;
|
||||
///using OpenTK.Graphics.OpenGL.Enums;
|
||||
///using OpenTK.Input;
|
||||
///
|
||||
///namespace Examples.Tutorial
|
||||
|
@ -589,7 +587,7 @@ namespace Examples.Properties {
|
|||
/// /// <summary>
|
||||
/// /// Demonstrates the GameWindow class.
|
||||
/// /// </summary>
|
||||
/// [Exampl [rest of string was truncated]";.
|
||||
/// [Example("Simple Window", ExampleCategory.OpenTK, "GameWindow", Documentati [rest of string was truncated]";.
|
||||
/// </summary>
|
||||
internal static string SimpleWindow {
|
||||
get {
|
||||
|
|
|
@ -307,11 +307,15 @@ namespace OpenTK
|
|||
|
||||
#endregion
|
||||
|
||||
#region --- Internal Members ---
|
||||
|
||||
internal GraphicsMode ToGraphicsMode()
|
||||
{
|
||||
return new GraphicsMode(this.Color.BitsPerPixel, this.DepthBits, this.StencilBits, 0, this.AuxBits, this.Buffers, this.Stereo);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Overrides ---
|
||||
|
||||
/// <summary>
|
||||
|
|
70
Source/OpenTK/FrameEventArgs.cs
Normal file
70
Source/OpenTK/FrameEventArgs.cs
Normal file
|
@ -0,0 +1,70 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the arguments for frame events.
|
||||
/// A FrameEventArgs instance is only valid for the duration of the relevant event;
|
||||
/// do not store references to FrameEventArgs outside this event.
|
||||
/// </summary>
|
||||
public class FrameEventArgs : EventArgs
|
||||
{
|
||||
double elapsed;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new FrameEventArgs instance.
|
||||
/// </summary>
|
||||
public FrameEventArgs()
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new FrameEventArgs instance.
|
||||
/// </summary>
|
||||
/// <param name="elapsed">The amount of time that has elapsed since the previous event, in seconds.</param>
|
||||
public FrameEventArgs(double elapsed)
|
||||
{
|
||||
Time = elapsed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="System.Double"/> that indicates how many seconds of time elapsed since the previous event.
|
||||
/// </summary>
|
||||
public double Time
|
||||
{
|
||||
get { return elapsed; }
|
||||
internal set
|
||||
{
|
||||
if (value <= 0)
|
||||
throw new ArgumentOutOfRangeException();
|
||||
elapsed = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -81,7 +81,7 @@ namespace OpenTK
|
|||
if (DesignMode)
|
||||
implementation = new Platform.Dummy.DummyGLControl();
|
||||
else
|
||||
implementation = Platform.Factory.CreateGLControl(mode, this);
|
||||
implementation = Platform.Factory.Default.CreateGLControl(mode, this);
|
||||
|
||||
this.CreateControl();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -11,7 +11,7 @@ using System.Collections.Generic;
|
|||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenTK.Graphics
|
||||
{
|
||||
|
@ -27,6 +27,8 @@ namespace OpenTK.Graphics
|
|||
// TODO: Does not detect changes to primary device.
|
||||
// TODO: Mono does not support System.Windows.Forms.Screen.BitsPerPixel -- find workaround!
|
||||
|
||||
#region --- Fields ---
|
||||
|
||||
DisplayResolution current_resolution, original_resolution;
|
||||
List<DisplayResolution> available_resolutions = new List<DisplayResolution>();
|
||||
bool primary;
|
||||
|
@ -38,23 +40,13 @@ namespace OpenTK.Graphics
|
|||
|
||||
static IDisplayDeviceDriver implementation;
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Constructors ---
|
||||
|
||||
static DisplayDevice()
|
||||
{
|
||||
implementation = Platform.Factory.CreateDisplayDeviceDriver();
|
||||
|
||||
//lock (display_lock)
|
||||
//{
|
||||
// int i = 0;
|
||||
// foreach (System.Windows.Forms.Screen scr in System.Windows.Forms.Screen.AllScreens)
|
||||
// {
|
||||
// available_displays.Add(new DisplayDevice(scr.Bounds.Width, scr.Bounds.Height, 32, 0, scr.Primary));
|
||||
// if (scr.Primary)
|
||||
// primary_display = available_displays[i];
|
||||
// ++i;
|
||||
// }
|
||||
//}
|
||||
implementation = Platform.Factory.Default.CreateDisplayDeviceDriver();
|
||||
}
|
||||
|
||||
internal DisplayDevice(DisplayResolution currentResolution, bool primary,
|
||||
|
@ -79,6 +71,18 @@ namespace OpenTK.Graphics
|
|||
|
||||
#region --- Public Methods ---
|
||||
|
||||
#region public Rectangle Bounds
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Drawing.Rectangle that contains the current bounds of this DisplayDevice.
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return current_resolution.Bounds; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public int Width
|
||||
|
||||
/// <summary>Gets a System.Int32 that contains the width of this display in pixels.</summary>
|
||||
|
|
|
@ -10,13 +10,14 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenTK.Graphics
|
||||
{
|
||||
/// <summary>Contains information regarding a monitor's display resolution.</summary>
|
||||
public class DisplayResolution
|
||||
{
|
||||
int width, height;
|
||||
Rectangle bounds;
|
||||
int bits_per_pixel;
|
||||
float refresh_rate;
|
||||
|
||||
|
@ -32,7 +33,7 @@ namespace OpenTK.Graphics
|
|||
/// <param name="bitsPerPixel">The requested bits per pixel in bits.</param>
|
||||
/// <param name="refreshRate">The requested refresh rate in Herz.</param>
|
||||
/// <remarks>OpenTK will select the closest match between all available resolutions on the primary DisplayDevice.</remarks>
|
||||
internal DisplayResolution(int width, int height, int bitsPerPixel, float refreshRate)
|
||||
internal DisplayResolution(int x, int y, int width, int height, int bitsPerPixel, float refreshRate)
|
||||
{
|
||||
// Refresh rate may be zero, since this information may not be available on some platforms.
|
||||
if (width <= 0) throw new ArgumentOutOfRangeException("width", "Must be greater than zero.");
|
||||
|
@ -40,8 +41,7 @@ namespace OpenTK.Graphics
|
|||
if (bitsPerPixel <= 0) throw new ArgumentOutOfRangeException("bitsPerPixel", "Must be greater than zero.");
|
||||
if (refreshRate < 0) throw new ArgumentOutOfRangeException("refreshRate", "Must be greater than, or equal to zero.");
|
||||
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.bounds = new Rectangle(x, y, width, height);
|
||||
this.bits_per_pixel = bitsPerPixel;
|
||||
this.refresh_rate = refreshRate;
|
||||
}
|
||||
|
@ -84,17 +84,29 @@ namespace OpenTK.Graphics
|
|||
|
||||
#region --- Public Methods ---
|
||||
|
||||
#region Bounds
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Drawing.Rectangle that contains the bounds of this display device.
|
||||
/// </summary>
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get { return bounds; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public int Width
|
||||
|
||||
/// <summary>Gets a System.Int32 that contains the width of this display in pixels.</summary>
|
||||
public int Width { get { return width; } }
|
||||
public int Width { get { return bounds.Width; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region public int Height
|
||||
|
||||
/// <summary>Gets a System.Int32 that contains the height of this display in pixels.</summary>
|
||||
public int Height { get { return height; } }
|
||||
public int Height { get { return bounds.Height; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -129,7 +141,7 @@ namespace OpenTK.Graphics
|
|||
/// <returns>A System.String representing this DisplayResolution.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("{0}x{1}x{2}@{3}Hz", width, height, bits_per_pixel, refresh_rate);
|
||||
return String.Format("{0}x{1}@{2}Hz", Bounds, bits_per_pixel, refresh_rate);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -163,7 +175,7 @@ namespace OpenTK.Graphics
|
|||
/// <returns>A System.Int32 that may serve as a hash code for this resolution.</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return width ^ height ^ bits_per_pixel ^ (int)refresh_rate;
|
||||
return Bounds.GetHashCode() ^ bits_per_pixel ^ refresh_rate.GetHashCode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace OpenTK.Graphics
|
|||
|
||||
static GraphicsContext()
|
||||
{
|
||||
GetCurrentContext = Factory.CreateGetCurrentGraphicsContext();
|
||||
GetCurrentContext = Factory.Default.CreateGetCurrentGraphicsContext();
|
||||
}
|
||||
|
||||
// Necessary to allow creation of dummy GraphicsContexts (see CreateDummyContext static method).
|
||||
|
@ -116,7 +116,7 @@ namespace OpenTK.Graphics
|
|||
if (designMode)
|
||||
implementation = new Platform.Dummy.DummyGLContext();
|
||||
else
|
||||
implementation = Factory.CreateGLContext(mode, window, shareContext, DirectRendering, major, minor, flags);
|
||||
implementation = Factory.Default.CreateGLContext(mode, window, shareContext, DirectRendering, major, minor, flags);
|
||||
|
||||
lock (context_lock)
|
||||
{
|
||||
|
@ -378,13 +378,13 @@ namespace OpenTK.Graphics
|
|||
/// <summary>
|
||||
/// Makes the GraphicsContext the current rendering target.
|
||||
/// </summary>
|
||||
/// <param name="info">A System.Platform.IWindowInfo structure for the window this context is bound to.</param>
|
||||
/// <param name="window">A valid <see cref="OpenTK.Platform.IWindowInfo" /> structure.</param>
|
||||
/// <remarks>
|
||||
/// You can use this method to bind the GraphicsContext to a different window than the one it was created from.
|
||||
/// </remarks>
|
||||
public void MakeCurrent(IWindowInfo info)
|
||||
public void MakeCurrent(IWindowInfo window)
|
||||
{
|
||||
implementation.MakeCurrent(info);
|
||||
implementation.MakeCurrent(window);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace OpenTK.Graphics
|
|||
|
||||
static GraphicsMode()
|
||||
{
|
||||
implementation = Platform.Factory.CreateGraphicsMode();
|
||||
implementation = Platform.Factory.Default.CreateGraphicsMode();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
85
Source/OpenTK/IGameWindow.cs
Normal file
85
Source/OpenTK/IGameWindow.cs
Normal file
|
@ -0,0 +1,85 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.Platform
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the interface for a GameWindow.
|
||||
/// </summary>
|
||||
interface IGameWindow : INativeWindow
|
||||
{
|
||||
/// <summary>
|
||||
/// Enters the game loop of the GameWindow using the maximum update rate.
|
||||
/// </summary>
|
||||
/// <seealso cref="Run(double)"/>
|
||||
void Run();
|
||||
|
||||
/// <summary>
|
||||
/// Enters the game loop of the GameWindow using the specified update rate.
|
||||
/// </summary>
|
||||
void Run(double updateRate);
|
||||
|
||||
/// <summary>
|
||||
/// Makes the GraphicsContext current on the calling thread.
|
||||
/// </summary>
|
||||
void MakeCurrent();
|
||||
|
||||
/// <summary>
|
||||
/// Swaps the front and back buffers of the current GraphicsContext, presenting the rendered scene to the user.
|
||||
/// </summary>
|
||||
void SwapBuffers();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before the window is displayed for the first time.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Load;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs before the window is destroyed.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Unload;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when it is time to update a frame.
|
||||
/// </summary>
|
||||
event EventHandler<FrameEventArgs> UpdateFrame;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when it is time to render a frame.
|
||||
/// </summary>
|
||||
event EventHandler<FrameEventArgs> RenderFrame;
|
||||
}
|
||||
|
||||
[Obsolete] public delegate void UpdateFrameEvent(GameWindow sender, UpdateFrameEventArgs e);
|
||||
[Obsolete] public delegate void RenderFrameEvent(GameWindow sender, RenderFrameEventArgs e);
|
||||
[Obsolete] public delegate void LoadEvent(GameWindow sender, EventArgs e);
|
||||
[Obsolete] public delegate void UnloadEvent(GameWindow sender, EventArgs e);
|
||||
}
|
226
Source/OpenTK/INativeWindow.cs
Normal file
226
Source/OpenTK/INativeWindow.cs
Normal file
|
@ -0,0 +1,226 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using OpenTK.Platform;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace OpenTK
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines the interface for a native window.
|
||||
/// </summary>
|
||||
public interface INativeWindow : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="System.Drawing.Icon"/> of the window.
|
||||
/// </summary>
|
||||
Icon Icon { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title of the window.
|
||||
/// </summary>
|
||||
string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Boolean that indicates whether this window has input focus.
|
||||
/// </summary>
|
||||
bool Focused { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a System.Boolean that indicates whether the window is visible.
|
||||
/// </summary>
|
||||
bool Visible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Boolean that indicates whether the window has been created and has not been destroyed.
|
||||
/// </summary>
|
||||
bool Exists { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="OpenTK.Platform.IWindowInfo"/> for this window.
|
||||
/// </summary>
|
||||
IWindowInfo WindowInfo { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="OpenTK.WindowState"> for this window.
|
||||
/// </summary>
|
||||
WindowState WindowState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="OpenTK.WindowBorder"> for this window.
|
||||
/// </summary>
|
||||
WindowBorder WindowBorder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="System.Drawing.Rectangle"/> structure the contains the external bounds of this window, in screen coordinates.
|
||||
/// External bounds include the title bar, borders and drawing area of the window.
|
||||
/// </summary>
|
||||
Rectangle Bounds { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="System.Drawing.Point"> structure that contains the location of this window on the desktop.
|
||||
/// </summary>
|
||||
Point Location { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="System.Drawing.Size"> structure that contains the external size of this window.
|
||||
/// </summary>
|
||||
Size Size { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the horizontal location of this window on the desktop.
|
||||
/// </summary>
|
||||
int X { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the vertical location of this window on the desktop.
|
||||
/// </summary>
|
||||
int Y { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the external width of this window.
|
||||
/// </summary>
|
||||
int Width { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the external height of this window.
|
||||
/// </summary>
|
||||
int Height { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="System.Drawing.Rectangle"/> structure that contains the internal bounds of this window, in client coordinates.
|
||||
/// The internal bounds include the drawing area of the window, but exclude the titlebar and window borders.
|
||||
/// </summary>
|
||||
Rectangle ClientRectangle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the internal size this window.
|
||||
/// </summary>
|
||||
Size ClientSize { get; set; }
|
||||
|
||||
[Obsolete]
|
||||
OpenTK.Input.IInputDriver InputDriver { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Closes this window. Equivalent to <see cref="INativeWindow.Dispose()"/>.
|
||||
/// </summary>
|
||||
void Close();
|
||||
|
||||
/// <summary>
|
||||
/// Processes pending window events.
|
||||
/// </summary>
|
||||
void ProcessEvents();
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the specified point from screen to client coordinates.
|
||||
/// </summary>
|
||||
/// <param name="point">
|
||||
/// A <see cref="System.Drawing.Point"/> to transform.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The point transformed to client coordinates.
|
||||
/// </returns>
|
||||
Point PointToClient(Point point);
|
||||
|
||||
/// <summary>
|
||||
/// Transforms the specified point from client to screen coordinates.
|
||||
/// </summary>
|
||||
/// <param name="point">
|
||||
/// A <see cref="System.Drawing.Point"/> to transform.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// The point transformed to screen coordinates.
|
||||
/// </returns>
|
||||
Point PointToScreen(Point point);
|
||||
|
||||
/// <summary>
|
||||
/// Occurs whenever the window is moved.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Move;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs whenever the window is resized.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Resize;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the window is about to close.
|
||||
/// </summary>
|
||||
event EventHandler<CancelEventArgs> Closing;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs after the window has closed.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Closed;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the window is disposed.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> Disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="Icon"/> property of the window changes.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> IconChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="Title"/> property of the window changes.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> TitleChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="Visible"/> property of the window changes.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> VisibleChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the <see cref="Focused"/> property of the window changes.
|
||||
/// </summary>
|
||||
event EventHandler<EventArgs> FocusedChanged;
|
||||
|
||||
//event EventHandler<EventArgs> MouseEnter;
|
||||
//event EventHandler<MouseEventArgs> MouseMove;
|
||||
//event EventHandler<MouseEventArgs> MouseWheel;
|
||||
//event EventHandler<MouseEventArgs> MouseDown;
|
||||
//event EventHandler<MouseEventArgs> MouseUp;
|
||||
//event EventHandler<MouseEventArgs> MouseClick;
|
||||
//event EventHandler<MouseEventArgs> MouseDoubleClick;
|
||||
|
||||
//event EventHandler<KeyEventArgs> KeyDown;
|
||||
//event EventHandler<KeyEventArgs> KeyUp;
|
||||
//event EventHandler<KeyEventArgs> KeyPress;
|
||||
|
||||
//event EventHandler<DragEventArgs> DragDrop;
|
||||
//event EventHandler<DragEventArgs> DragEnter;
|
||||
//event EventHandler<DragEventArgs> DragOver;
|
||||
//event EventHandler<EventArgs> DragLeave;
|
||||
}
|
||||
}
|
|
@ -203,8 +203,10 @@ namespace OpenTK.Input
|
|||
/// </summary>
|
||||
public enum Key : int
|
||||
{
|
||||
None = 0,
|
||||
|
||||
// Modifiers
|
||||
ShiftLeft = 0,
|
||||
ShiftLeft,
|
||||
ShiftRight,
|
||||
ControlLeft,
|
||||
ControlRight,
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
@ -6,10 +33,16 @@ namespace OpenTK.Platform
|
|||
{
|
||||
using Graphics;
|
||||
|
||||
static class Factory
|
||||
class Factory : IPlatformFactory
|
||||
{
|
||||
#region Fields
|
||||
|
||||
static IPlatformFactory implementation;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static Factory()
|
||||
{
|
||||
if (Configuration.RunningOnWindows) implementation = new Windows.WinFactory();
|
||||
|
@ -18,32 +51,46 @@ namespace OpenTK.Platform
|
|||
else implementation = new UnsupportedPlatform();
|
||||
}
|
||||
|
||||
internal static INativeGLWindow CreateNativeGLWindow()
|
||||
#endregion
|
||||
|
||||
#region Public Members
|
||||
|
||||
public static IPlatformFactory Default
|
||||
{
|
||||
return implementation.CreateGLNative();
|
||||
get { return implementation; }
|
||||
}
|
||||
|
||||
internal static IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
#endregion
|
||||
|
||||
#region IPlatformFactory Members
|
||||
|
||||
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title,
|
||||
GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
return implementation.CreateNativeWindow(x, y, width, height, title, mode, options, device);
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
return implementation.CreateGLControl(mode, owner);
|
||||
}
|
||||
|
||||
internal static IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
public IDisplayDeviceDriver CreateDisplayDeviceDriver()
|
||||
{
|
||||
return implementation.CreateDisplayDeviceDriver();
|
||||
}
|
||||
|
||||
internal static IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
||||
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return implementation.CreateGLContext(mode, window, shareContext, directRendering, major, minor, flags);
|
||||
}
|
||||
|
||||
internal static GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
|
||||
public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
|
||||
{
|
||||
return implementation.CreateGetCurrentGraphicsContext();
|
||||
}
|
||||
|
||||
internal static IGraphicsMode CreateGraphicsMode()
|
||||
public IGraphicsMode CreateGraphicsMode()
|
||||
{
|
||||
return implementation.CreateGraphicsMode();
|
||||
}
|
||||
|
@ -57,6 +104,11 @@ namespace OpenTK.Platform
|
|||
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
|
||||
}
|
||||
|
||||
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
{
|
||||
throw new PlatformNotSupportedException("Please, refer to http://www.opentk.com for more information.");
|
||||
|
@ -85,5 +137,7 @@ namespace OpenTK.Platform
|
|||
|
||||
#endregion
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#region --- License ---
|
||||
/* Copyright (c) 2006, 2007 Stefanos Apostolopoulos
|
||||
* See license.txt for license info
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenTK.Platform
|
||||
{
|
||||
interface IGameWindow : INativeGLWindow
|
||||
{
|
||||
void Run();
|
||||
|
||||
void OnRenderFrame(RenderFrameEventArgs e);
|
||||
void OnUpdateFrame(UpdateFrameEventArgs e);
|
||||
void OnLoad(EventArgs e);
|
||||
void Exit();
|
||||
|
||||
void SwapBuffers();
|
||||
|
||||
event UpdateFrameEvent UpdateFrame;
|
||||
event RenderFrameEvent RenderFrame;
|
||||
event LoadEvent Load;
|
||||
event UnloadEvent Unload;
|
||||
|
||||
bool IsExiting { get; }
|
||||
//IList<OpenTK.Input.Keyboard> Keyboard { get; }
|
||||
//IList<OpenTK.Input.Mouse> Mouse { get; }
|
||||
|
||||
OpenTK.Input.KeyboardDevice Keyboard { get; }
|
||||
OpenTK.Input.MouseDevice Mouse { get; }
|
||||
}
|
||||
|
||||
public delegate void UpdateFrameEvent(GameWindow sender, UpdateFrameEventArgs e);
|
||||
public delegate void RenderFrameEvent(GameWindow sender, RenderFrameEventArgs e);
|
||||
public delegate void LoadEvent(GameWindow sender, EventArgs e);
|
||||
public delegate void UnloadEvent(GameWindow sender, EventArgs e);
|
||||
}
|
|
@ -16,8 +16,9 @@ using System.Drawing;
|
|||
|
||||
namespace OpenTK.Platform
|
||||
{
|
||||
internal interface INativeGLWindow : IResizable, IDisposable
|
||||
internal interface INativeGLWindow : IDisposable
|
||||
{
|
||||
[Obsolete]
|
||||
void CreateWindow(int width, int height, GraphicsMode mode, int major, int minor, GraphicsContextFlags flags, out IGraphicsContext context);
|
||||
void DestroyWindow();
|
||||
void ProcessEvents();
|
||||
|
|
|
@ -1,18 +1,47 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace OpenTK.Platform
|
||||
{
|
||||
interface IPlatformFactory
|
||||
{
|
||||
INativeGLWindow CreateGLNative();
|
||||
INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device);
|
||||
|
||||
IGLControl CreateGLControl(OpenTK.Graphics.GraphicsMode mode, GLControl owner);
|
||||
IGLControl CreateGLControl(GraphicsMode mode, GLControl owner);
|
||||
|
||||
OpenTK.Graphics.IDisplayDeviceDriver CreateDisplayDeviceDriver();
|
||||
IDisplayDeviceDriver CreateDisplayDeviceDriver();
|
||||
|
||||
OpenTK.Graphics.IGraphicsContext CreateGLContext(OpenTK.Graphics.GraphicsMode mode, IWindowInfo window, OpenTK.Graphics.IGraphicsContext shareContext, bool DirectRendering, int major, int minor, OpenTK.Graphics.GraphicsContextFlags flags);
|
||||
IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool DirectRendering, int major, int minor, GraphicsContextFlags flags);
|
||||
|
||||
OpenTK.Graphics.GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext();
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
public static void Run(CarbonGLNative window)
|
||||
{
|
||||
window.Destroy += MainWindowClosed;
|
||||
window.Show();
|
||||
window.Visible = true;
|
||||
|
||||
API.RunApplicationEventLoop();
|
||||
|
||||
|
|
|
@ -81,6 +81,11 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
return string.Format(
|
||||
"Rect: [{0}, {1}, {2}, {3}]", X, Y, Width, Height);
|
||||
}
|
||||
|
||||
public System.Drawing.Rectangle ToRectangle()
|
||||
{
|
||||
return new System.Drawing.Rectangle(X, Y, Width, Height);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -444,6 +449,8 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
internal static extern OSStatus RepositionWindow(IntPtr window, IntPtr parentWindow, WindowPositionMethod method);
|
||||
[DllImport(carbon)]
|
||||
internal static extern void SizeWindow(IntPtr window, short w, short h, bool fUpdate);
|
||||
[DllImport(carbon)]
|
||||
internal static extern void MoveWindow(IntPtr window, short x, short y, bool fUpdate);
|
||||
|
||||
[DllImport(carbon)]
|
||||
static extern OSStatus GetWindowBounds(IntPtr window, WindowRegionCode regionCode, out Rect globalBounds);
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// xCSCarbon
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Created by Erik Ylvisaker on 3/17/08.
|
||||
// Copyright 2008 __MyCompanyName__. All rights reserved.
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -18,8 +36,10 @@ namespace OpenTK.Platform.MacOS
|
|||
using Carbon;
|
||||
using Graphics;
|
||||
|
||||
class CarbonGLNative : INativeGLWindow
|
||||
class CarbonGLNative : INativeGLWindow, INativeWindow
|
||||
{
|
||||
#region Fields
|
||||
|
||||
CarbonWindowInfo window;
|
||||
CarbonInput mInputDriver;
|
||||
GraphicsContext context;
|
||||
|
@ -29,8 +49,7 @@ namespace OpenTK.Platform.MacOS
|
|||
IntPtr uppHandler;
|
||||
|
||||
string title = "OpenTK Window";
|
||||
short mWidth, mHeight;
|
||||
short mWindowedWidth, mWindowedHeight;
|
||||
System.Drawing.Rectangle bounds, windowedBounds, clientRectangle;
|
||||
bool mIsDisposed = false;
|
||||
|
||||
WindowAttributes mWindowAttrib;
|
||||
|
@ -42,36 +61,48 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
static Dictionary<IntPtr, WeakReference> mWindows = new Dictionary<IntPtr, WeakReference>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
static CarbonGLNative()
|
||||
{
|
||||
Application.Initialize();
|
||||
}
|
||||
public CarbonGLNative()
|
||||
|
||||
CarbonGLNative()
|
||||
: this(WindowClass.Document,
|
||||
WindowAttributes.StandardDocument |
|
||||
WindowAttributes.StandardHandler |
|
||||
WindowAttributes.InWindowMenu |
|
||||
WindowAttributes.LiveResize)
|
||||
{
|
||||
{ }
|
||||
|
||||
}
|
||||
private CarbonGLNative(WindowClass @class, WindowAttributes attrib)
|
||||
|
||||
CarbonGLNative(WindowClass @class, WindowAttributes attrib)
|
||||
{
|
||||
mWindowClass = @class;
|
||||
mWindowAttrib = attrib;
|
||||
|
||||
|
||||
}
|
||||
~CarbonGLNative()
|
||||
|
||||
public CarbonGLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
Dispose(false);
|
||||
CreateNativeWindow(WindowClass.Document,
|
||||
WindowAttributes.StandardDocument | WindowAttributes.StandardHandler |
|
||||
WindowAttributes.InWindowMenu | WindowAttributes.LiveResize,
|
||||
new Rect((short)x, (short)y, (short)width, (short)height));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (mIsDisposed)
|
||||
|
@ -92,19 +123,26 @@ namespace OpenTK.Platform.MacOS
|
|||
DisposeUPP();
|
||||
}
|
||||
|
||||
private void DisposeUPP()
|
||||
~CarbonGLNative()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Members
|
||||
|
||||
void DisposeUPP()
|
||||
{
|
||||
if (uppHandler != IntPtr.Zero)
|
||||
{
|
||||
//API.RemoveEventHandler(uppHandler);
|
||||
//API.DisposeEventHandlerUPP(uppHandler);
|
||||
|
||||
}
|
||||
|
||||
uppHandler = IntPtr.Zero;
|
||||
}
|
||||
|
||||
|
||||
void CreateNativeWindow(WindowClass @class, WindowAttributes attrib, Rect r)
|
||||
{
|
||||
Debug.Print("Creating window...");
|
||||
|
@ -115,6 +153,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
window = new CarbonWindowInfo(windowRef, true, false);
|
||||
|
||||
SetLocation(r.X, r.Y);
|
||||
SetSize(r.Width, r.Height);
|
||||
|
||||
Debug.Unindent();
|
||||
|
@ -133,6 +172,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
System.Diagnostics.Debug.Print("Attached window events.");
|
||||
}
|
||||
|
||||
void ConnectEvents()
|
||||
{
|
||||
mInputDriver = new CarbonInput();
|
||||
|
@ -165,25 +205,12 @@ namespace OpenTK.Platform.MacOS
|
|||
Application.WindowEventHandler = this;
|
||||
}
|
||||
|
||||
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return title;
|
||||
}
|
||||
set
|
||||
{
|
||||
API.SetWindowTitle(window.WindowRef, value);
|
||||
title = value;
|
||||
}
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
void Activate()
|
||||
{
|
||||
API.SelectWindow(window.WindowRef);
|
||||
}
|
||||
public void Show()
|
||||
|
||||
void Show()
|
||||
{
|
||||
IntPtr parent = IntPtr.Zero;
|
||||
|
||||
|
@ -191,27 +218,37 @@ namespace OpenTK.Platform.MacOS
|
|||
API.RepositionWindow(window.WindowRef, parent, WindowPositionMethod);
|
||||
API.SelectWindow(window.WindowRef);
|
||||
}
|
||||
public void Hide()
|
||||
|
||||
void Hide()
|
||||
{
|
||||
API.HideWindow(window.WindowRef);
|
||||
}
|
||||
public bool Visible
|
||||
|
||||
void SetFullscreen()
|
||||
{
|
||||
get { return API.IsWindowVisible(window.WindowRef); }
|
||||
set
|
||||
{
|
||||
if (value && Visible == false)
|
||||
Show();
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
windowedBounds = bounds;
|
||||
|
||||
((AglContext)(context as IGraphicsContextInternal).Implementation).SetFullScreen(window);
|
||||
|
||||
Debug.Print("Prev Size: {0}, {1}", Width, Height);
|
||||
|
||||
bounds = DisplayDevice.Default.Bounds;
|
||||
|
||||
Debug.Print("New Size: {0}, {1}", Width, Height);
|
||||
}
|
||||
public bool IsDisposed
|
||||
|
||||
void UnsetFullscreen()
|
||||
{
|
||||
((AglContext)(context as IGraphicsContextInternal).Implementation).UnsetFullScreen(window);
|
||||
SetSize((short)windowedBounds.Width, (short)windowedBounds.Height);
|
||||
}
|
||||
|
||||
bool IsDisposed
|
||||
{
|
||||
get { return mIsDisposed; }
|
||||
}
|
||||
|
||||
public WindowPositionMethod WindowPositionMethod
|
||||
WindowPositionMethod WindowPositionMethod
|
||||
{
|
||||
get { return mPositionMethod; }
|
||||
set { mPositionMethod = value; }
|
||||
|
@ -276,7 +313,6 @@ namespace OpenTK.Platform.MacOS
|
|||
default:
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private OSStatus ProcessKeyboardEvent(IntPtr inCaller, IntPtr inEvent, EventInfo evt, IntPtr userData)
|
||||
|
@ -321,7 +357,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
case WindowEventKind.WindowClose:
|
||||
CancelEventArgs cancel = new CancelEventArgs();
|
||||
OnQueryWindowClose(cancel);
|
||||
OnClosing(cancel);
|
||||
|
||||
if (cancel.Cancel)
|
||||
return OSStatus.NoError;
|
||||
|
@ -329,7 +365,7 @@ namespace OpenTK.Platform.MacOS
|
|||
return OSStatus.EventNotHandled;
|
||||
|
||||
case WindowEventKind.WindowClosed:
|
||||
OnWindowClosed();
|
||||
OnClosed();
|
||||
|
||||
return OSStatus.NoError;
|
||||
|
||||
|
@ -356,7 +392,7 @@ namespace OpenTK.Platform.MacOS
|
|||
MouseButton button = MouseButton.Primary;
|
||||
HIPoint pt = new HIPoint();
|
||||
|
||||
OSStatus err ;
|
||||
OSStatus err;
|
||||
|
||||
if (this.windowState == WindowState.Fullscreen)
|
||||
{
|
||||
|
@ -498,31 +534,29 @@ namespace OpenTK.Platform.MacOS
|
|||
return retval;
|
||||
}
|
||||
|
||||
public int Width
|
||||
void SetLocation(short x, short y)
|
||||
{
|
||||
get { return mWidth; }
|
||||
set { SetSize(value, mHeight); }
|
||||
if (windowState == WindowState.Fullscreen)
|
||||
return;
|
||||
|
||||
API.MoveWindow(window.WindowRef, x, y, false);
|
||||
}
|
||||
public int Height
|
||||
{
|
||||
get { return mHeight; }
|
||||
set { SetSize(mWidth, value); }
|
||||
}
|
||||
public void SetSize(int width, int height)
|
||||
|
||||
void SetSize(short width, short height)
|
||||
{
|
||||
if (WindowState == WindowState.Fullscreen)
|
||||
return;
|
||||
|
||||
mWidth = (short)width;
|
||||
mHeight = (short)height;
|
||||
|
||||
API.SizeWindow(window.WindowRef, mWidth, mHeight, true);
|
||||
// Todo: why call SizeWindow twice?
|
||||
API.SizeWindow(window.WindowRef, width, height, true);
|
||||
bounds.Width = (short)width;
|
||||
bounds.Height = (short)height;
|
||||
|
||||
Rect contentBounds = API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion);
|
||||
|
||||
Rect newSize = new Rect(0, 0,
|
||||
(short)(2 * mWidth - contentBounds.Width),
|
||||
(short)(2 * mHeight - contentBounds.Height));
|
||||
(short)(2 * width - contentBounds.Width),
|
||||
(short)(2 * height - contentBounds.Height));
|
||||
|
||||
Debug.Print("Content region was: {0}", contentBounds);
|
||||
Debug.Print("Resizing window to: {0}", newSize);
|
||||
|
@ -531,6 +565,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
contentBounds = API.GetWindowBounds(window.WindowRef, WindowRegionCode.ContentRegion);
|
||||
Debug.Print("New content region size: {0}", contentBounds);
|
||||
clientRectangle = contentBounds.ToRectangle();
|
||||
}
|
||||
|
||||
protected void OnResize()
|
||||
|
@ -551,26 +586,22 @@ namespace OpenTK.Platform.MacOS
|
|||
if (WindowState == WindowState.Fullscreen)
|
||||
return;
|
||||
|
||||
Rect region = GetRegion();
|
||||
|
||||
mWidth = (short)(region.Width);
|
||||
mHeight = (short)(region.Height);
|
||||
bounds = GetRegion().ToRectangle();
|
||||
}
|
||||
|
||||
protected virtual void OnQueryWindowClose(CancelEventArgs e)
|
||||
protected virtual void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (QueryWindowClose != null)
|
||||
QueryWindowClose(this, e);
|
||||
if (Closing != null)
|
||||
Closing(this, e);
|
||||
}
|
||||
protected virtual void OnWindowClosed()
|
||||
|
||||
protected virtual void OnClosed()
|
||||
{
|
||||
if (Destroy != null)
|
||||
Destroy(this, EventArgs.Empty);
|
||||
|
||||
if (Closed != null)
|
||||
Closed(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public event CancelEventHandler QueryWindowClose;
|
||||
|
||||
#endregion
|
||||
|
||||
#region INativeGLWindow Members
|
||||
|
||||
|
@ -650,12 +681,6 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#endregion
|
||||
|
||||
#region IResizable Members
|
||||
|
||||
public event ResizeEvent Resize;
|
||||
|
||||
#endregion
|
||||
|
||||
#region INativeGLWindow Members
|
||||
|
||||
public WindowState WindowState
|
||||
|
@ -728,28 +753,6 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetFullscreen()
|
||||
{
|
||||
((AglContext)(context as IGraphicsContextInternal).Implementation).SetFullScreen(window);
|
||||
|
||||
mWindowedWidth = mWidth;
|
||||
mWindowedHeight = mHeight;
|
||||
|
||||
Debug.Print("Prev Size: {0}, {1}", Width, Height);
|
||||
|
||||
mWidth = (short)DisplayDevice.Default.Width;
|
||||
mHeight = (short)DisplayDevice.Default.Height;
|
||||
|
||||
Debug.Print("New Size: {0}, {1}", Width, Height);
|
||||
|
||||
}
|
||||
private void UnsetFullscreen()
|
||||
{
|
||||
((AglContext)(context as IGraphicsContextInternal).Implementation).UnsetFullScreen(window);
|
||||
SetSize(mWindowedWidth, mWindowedHeight);
|
||||
}
|
||||
|
||||
public WindowBorder WindowBorder
|
||||
{
|
||||
get
|
||||
|
@ -775,5 +778,180 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#endregion
|
||||
|
||||
#region INativeWindow Members
|
||||
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return title;
|
||||
}
|
||||
set
|
||||
{
|
||||
API.SetWindowTitle(window.WindowRef, value);
|
||||
title = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Visible
|
||||
{
|
||||
get { return API.IsWindowVisible(window.WindowRef); }
|
||||
set
|
||||
{
|
||||
if (value && Visible == false)
|
||||
Show();
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
public System.Drawing.Icon Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Focused
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public System.Drawing.Rectangle Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return bounds;
|
||||
}
|
||||
set
|
||||
{
|
||||
Location = value.Location;
|
||||
Size = value.Size;
|
||||
}
|
||||
}
|
||||
|
||||
public System.Drawing.Point Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return bounds.Location;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetLocation((short)value.X, (short)value.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public System.Drawing.Size Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return bounds.Size;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetSize((short)value.Width, (short)value.Height);
|
||||
}
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get { return Bounds.Width; }
|
||||
set { Size = new System.Drawing.Size(value, Height); }
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get { return Bounds.Height; }
|
||||
set { Size = new System.Drawing.Size(Width, value); }
|
||||
}
|
||||
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return bounds.X;
|
||||
}
|
||||
set
|
||||
{
|
||||
Location = new System.Drawing.Point(value, Y);
|
||||
}
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return bounds.Y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Location = new System.Drawing.Point(X, value);
|
||||
}
|
||||
}
|
||||
|
||||
public System.Drawing.Rectangle ClientRectangle
|
||||
{
|
||||
get
|
||||
{
|
||||
return clientRectangle;
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public System.Drawing.Size ClientSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return clientRectangle.Size;
|
||||
}
|
||||
set
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public event EventHandler<EventArgs> Idle;
|
||||
|
||||
public event EventHandler<EventArgs> Load;
|
||||
|
||||
public event EventHandler<EventArgs> Unload;
|
||||
|
||||
public event EventHandler<EventArgs> Move;
|
||||
|
||||
public event EventHandler<EventArgs> Resize;
|
||||
|
||||
public event EventHandler<CancelEventArgs> Closing;
|
||||
|
||||
public event EventHandler<EventArgs> Closed;
|
||||
|
||||
public event EventHandler<EventArgs> Disposed;
|
||||
|
||||
public event EventHandler<EventArgs> IconChanged;
|
||||
|
||||
public event EventHandler<EventArgs> TitleChanged;
|
||||
|
||||
public event EventHandler<EventArgs> ClientSizeChanged;
|
||||
|
||||
public event EventHandler<EventArgs> VisibleChanged;
|
||||
|
||||
public event EventHandler<EventArgs> WindowInfoChanged;
|
||||
|
||||
public event EventHandler<EventArgs> FocusedChanged;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
@ -12,7 +39,12 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public INativeGLWindow CreateGLNative()
|
||||
{
|
||||
return new CarbonGLNative();
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
return new CarbonGLNative(x, y, width, height, title, mode, options, device);
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
//Debug.Print("Mode {0} is {1}x{2}x{3} @ {4}.", j, width, height, bpp, freq);
|
||||
|
||||
DisplayResolution thisRes = new DisplayResolution(width, height, bpp, (float)freq);
|
||||
DisplayResolution thisRes = new DisplayResolution(0, 0, width, height, bpp, (float)freq);
|
||||
opentk_dev_available_res.Add(thisRes);
|
||||
|
||||
if (current)
|
||||
|
|
|
@ -217,21 +217,20 @@ namespace OpenTK.Platform
|
|||
#region --- Creating a Graphics Context ---
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Graphics context and for a window or control.
|
||||
/// Creates an IGraphicsContext instance for the specified window.
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
///
|
||||
/// <param name="major">Major version number of OpenGL context to create.</param>
|
||||
/// <param name="minor">Minor version number of OpenGL context to create.</param>
|
||||
/// <param name="flags"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="info"></param>
|
||||
public static Graphics.GraphicsContext CreateGraphicsContext(
|
||||
Graphics.GraphicsMode mode, IWindowInfo info,
|
||||
int major, int minor, OpenTK.Graphics.GraphicsContextFlags flags)
|
||||
/// <param name="mode">The GraphicsMode for the GraphicsContext.</param>
|
||||
/// <param name="window">An IWindowInfo instance describing the parent window for this IGraphicsContext.</param>
|
||||
/// <param name="major">The major OpenGL version number for this IGraphicsContext.</param>
|
||||
/// <param name="minor">The minor OpenGL version number for this IGraphicsContext.</param>
|
||||
/// <param name="flags">A bitwise collection of GraphicsContextFlags with specific options for this IGraphicsContext.</param>
|
||||
/// <returns>A new IGraphicsContext instance.</returns>
|
||||
public static Graphics.IGraphicsContext CreateGraphicsContext(
|
||||
Graphics.GraphicsMode mode, IWindowInfo window,
|
||||
int major, int minor, Graphics.GraphicsContextFlags flags)
|
||||
{
|
||||
Graphics.GraphicsContext context = new Graphics.GraphicsContext(mode, info, major, minor, flags);
|
||||
context.MakeCurrent(info);
|
||||
Graphics.GraphicsContext context = new Graphics.GraphicsContext(mode, window, major, minor, flags);
|
||||
context.MakeCurrent(window);
|
||||
|
||||
(context as OpenTK.Graphics.IGraphicsContextInternal).LoadAll();
|
||||
|
||||
|
@ -239,29 +238,29 @@ namespace OpenTK.Platform
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates GraphicsContext and IWindowInfo objects for a WinForms control.
|
||||
/// Creates an IGraphicsContext instance for the specified System.Windows.Forms.Control.
|
||||
/// </summary>
|
||||
/// <param name="cntrl"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="mode"></param>
|
||||
/// <param name="mode">The GraphicsMode for the GraphicsContext.</param>
|
||||
/// <param name="cntrl">A System.Windows.Forms.Control.</param>
|
||||
/// <param name="context">A new IGraphicsContext instance.</param>
|
||||
/// <param name="info">An IWindowInfo instance for the specified cntrl.</param>
|
||||
[Obsolete("Create the IWindowInfo object first by calling CreateWindowInfo, then use the CreateGraphicsContext overload which takes major, minor and flags parameters.")]
|
||||
public static void CreateGraphicsContext(Graphics.GraphicsMode mode, Control cntrl,
|
||||
out Graphics.GraphicsContext context, out IWindowInfo info)
|
||||
out Graphics.IGraphicsContext context, out IWindowInfo info)
|
||||
{
|
||||
CreateGraphicsContext(mode, cntrl.Handle, out context, out info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates GraphicsContext and IWindowInfo objects for a WinForms control.
|
||||
/// Creates an IGraphicsContext instance for the specified System.Windows.Forms.Control.
|
||||
/// </summary>
|
||||
/// <param name="cntrlHandle"></param>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="info"></param>
|
||||
/// <param name="mode"></param>
|
||||
/// <param name="mode">The GraphicsMode for the GraphicsContext.</param>
|
||||
/// <param name="cntrlHandle">A System.IntPtr that contains the handle for a System.Windows.Forms.Control.</param>
|
||||
/// <param name="context">A new IGraphicsContext instance.</param>
|
||||
/// <param name="info">An IWindowInfo instance for the specified ctrl.</param>
|
||||
[Obsolete("Create the IWindowInfo object first by calling CreateWindowInfo, then use the CreateGraphicsContext overload which takes major, minor and flags parameters.")]
|
||||
public static void CreateGraphicsContext(Graphics.GraphicsMode mode, IntPtr cntrlHandle,
|
||||
out Graphics.GraphicsContext context, out IWindowInfo info)
|
||||
out Graphics.IGraphicsContext context, out IWindowInfo info)
|
||||
{
|
||||
info = CreateWindowInfo(mode, cntrlHandle);
|
||||
|
||||
|
|
|
@ -28,6 +28,9 @@ namespace OpenTK.Platform.Windows
|
|||
using HWND = System.IntPtr;
|
||||
using HINSTANCE = System.IntPtr;
|
||||
using HMENU = System.IntPtr;
|
||||
using HICON = System.IntPtr;
|
||||
using HBRUSH = System.IntPtr;
|
||||
using HCURSOR = System.IntPtr;
|
||||
|
||||
using LRESULT = System.IntPtr;
|
||||
using LPVOID = System.IntPtr;
|
||||
|
@ -56,6 +59,8 @@ namespace OpenTK.Platform.Windows
|
|||
using WNDPROC = System.IntPtr;
|
||||
using LPDEVMODE = DeviceMode;
|
||||
|
||||
using HRESULT = System.IntPtr;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
@ -130,7 +135,10 @@ namespace OpenTK.Platform.Windows
|
|||
/// Found Winuser.h, user32.dll
|
||||
/// </remarks>
|
||||
[DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern BOOL AdjustWindowRect([In, Out] ref RECT lpRect, WindowStyle dwStyle, BOOL bMenu);
|
||||
internal static extern BOOL AdjustWindowRect([In, Out] ref Rectangle lpRect, WindowStyle dwStyle, BOOL bMenu);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "AdjustWindowRectEx", CallingConvention = CallingConvention.StdCall, SetLastError = true), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern bool AdjustWindowRectEx(ref Rectangle lpRect, WindowStyle dwStyle, bool bMenu, ExtendedWindowStyle dwExStyle);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -138,16 +146,16 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr CreateWindowEx(
|
||||
[In]ExtendedWindowStyle ExStyle,
|
||||
[In]string className,
|
||||
[In]string windowName,
|
||||
[In]WindowStyle Style,
|
||||
[In]int X, int Y,
|
||||
[In]int Width, int Height,
|
||||
[In]IntPtr HandleToParentWindow,
|
||||
[In]IntPtr Menu,
|
||||
[In]IntPtr Instance,
|
||||
[In]IntPtr Param);
|
||||
ExtendedWindowStyle ExStyle,
|
||||
[MarshalAs(UnmanagedType.LPTStr)] string className,
|
||||
[MarshalAs(UnmanagedType.LPTStr)] string windowName,
|
||||
WindowStyle Style,
|
||||
int X, int Y,
|
||||
int Width, int Height,
|
||||
IntPtr HandleToParentWindow,
|
||||
IntPtr Menu,
|
||||
IntPtr Instance,
|
||||
IntPtr Param);
|
||||
/*
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern int CreateWindowEx(
|
||||
|
@ -165,7 +173,7 @@ namespace OpenTK.Platform.Windows
|
|||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern IntPtr CreateWindowEx(
|
||||
ExtendedWindowStyle ExStyle,
|
||||
IntPtr ClassName,
|
||||
IntPtr ClassAtom,
|
||||
IntPtr WindowName,
|
||||
WindowStyle Style,
|
||||
int X, int Y,
|
||||
|
@ -185,79 +193,128 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region RegisterClass
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern short RegisterClass(WindowClass window_class);
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern ushort RegisterClass(ref WindowClass window_class);
|
||||
|
||||
#endregion
|
||||
|
||||
#region RegisterClassEx
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern ushort RegisterClassEx(ref ExtendedWindowClass window_class);
|
||||
|
||||
#endregion
|
||||
|
||||
#region UnregisterClass
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern short UnregisterClass(string className, IntPtr instance);
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern short UnregisterClass([MarshalAs(UnmanagedType.LPTStr)] LPCTSTR className, IntPtr instance);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern short UnregisterClass(IntPtr className, IntPtr instance);
|
||||
|
||||
#endregion
|
||||
|
||||
[CLSCompliant(false)]
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern LRESULT CallWindowProc(
|
||||
WNDPROC lpPrevWndFunc,
|
||||
HWND hWnd,
|
||||
UINT Msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam
|
||||
);
|
||||
#region GetClassInfoEx
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern BOOL GetClassInfoEx(HINSTANCE hinst,
|
||||
[MarshalAs(UnmanagedType.LPTStr)] LPCTSTR lpszClass, ref ExtendedWindowClass lpwcx);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern BOOL GetClassInfoEx(HINSTANCE hinst, UIntPtr lpszClass, ref ExtendedWindowClass lpwcx);
|
||||
|
||||
#endregion
|
||||
|
||||
#region CallWindowProc
|
||||
|
||||
#if RELEASE
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
internal static extern LRESULT CallWindowProc(
|
||||
WNDPROC lpPrevWndFunc,
|
||||
HWND hWnd,
|
||||
INT Msg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam
|
||||
);
|
||||
internal static extern LRESULT CallWindowProc(WNDPROC lpPrevWndFunc, HWND hWnd, WindowMessage Msg,
|
||||
WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endregion
|
||||
|
||||
#region SetWindowLong
|
||||
|
||||
internal static IntPtr SetWindowLong(IntPtr handle, GetWindowLongOffsets index, IntPtr newValue)
|
||||
// SetWindowLongPtr does not exist on x86 platforms (it's a macro that resolves to SetWindowLong).
|
||||
// We need to detect if we are on x86 or x64 at runtime and call the correct function
|
||||
// (SetWindowLongPtr on x64 or SetWindowLong on x86). Fun!
|
||||
internal static IntPtr SetWindowLong(IntPtr handle, GetWindowLongOffsets item, IntPtr newValue)
|
||||
{
|
||||
if (IntPtr.Size == 4)
|
||||
return (IntPtr)SetWindowLong(handle, index, (LONG)newValue);
|
||||
// SetWindowPos defines its error condition as an IntPtr.Zero retval and a non-0 GetLastError.
|
||||
// We need to SetLastError(0) to ensure we are not detecting on older error condition (from another function).
|
||||
|
||||
return SetWindowLongPtr(handle, index, newValue);
|
||||
IntPtr retval = IntPtr.Zero;
|
||||
SetLastError(0);
|
||||
|
||||
if (IntPtr.Size == 4)
|
||||
retval = new IntPtr(SetWindowLong(handle, item, newValue.ToInt32()));
|
||||
else
|
||||
retval = SetWindowLongPtr(handle, item, newValue);
|
||||
|
||||
if (retval == IntPtr.Zero)
|
||||
{
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
if (error != 0)
|
||||
throw new PlatformException(String.Format("Failed to modify window border. Error: {0}", error));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
internal static IntPtr SetWindowLong(IntPtr handle, WindowProcedure newValue)
|
||||
{
|
||||
return SetWindowLong(handle, GetWindowLongOffsets.WNDPROC, Marshal.GetFunctionPointerForDelegate(newValue));
|
||||
}
|
||||
|
||||
#if RELASE
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern LONG SetWindowLong(HWND hWnd, GetWindowLongOffsets nIndex, LONG dwNewLong);
|
||||
|
||||
#if RELASE
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern LONG_PTR SetWindowLongPtr(HWND hWnd, GetWindowLongOffsets nIndex, LONG_PTR dwNewLong);
|
||||
|
||||
#if RELASE
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern LONG SetWindowLong(HWND hWnd, GetWindowLongOffsets nIndex,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)]WindowProcedure dwNewLong);
|
||||
|
||||
#if RELASE
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern LONG_PTR SetWindowLongPtr(HWND hWnd, GetWindowLongOffsets nIndex,
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)]WindowProcedure dwNewLong);
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetWindowLong
|
||||
|
||||
internal static IntPtr GetWindowLong(IntPtr handle, GetWindowLongOffsets index)
|
||||
internal static UIntPtr GetWindowLong(IntPtr handle, GetWindowLongOffsets index)
|
||||
{
|
||||
if (IntPtr.Size == 4)
|
||||
return (IntPtr)GetWindowLongInternal(handle, index);
|
||||
return (UIntPtr)GetWindowLongInternal(handle, index);
|
||||
|
||||
return GetWindowLongPtrInternal(handle, index);
|
||||
}
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport("user32.dll", SetLastError = true, EntryPoint="GetWindowLong")]
|
||||
static extern LONG GetWindowLongInternal(HWND hWnd, GetWindowLongOffsets nIndex);
|
||||
static extern ULONG GetWindowLongInternal(HWND hWnd, GetWindowLongOffsets nIndex);
|
||||
|
||||
[SuppressUnmanagedCodeSecurity]
|
||||
[DllImport("user32.dll", SetLastError = true, EntryPoint = "GetWindowLongPtr")]
|
||||
static extern LONG_PTR GetWindowLongPtrInternal(HWND hWnd, GetWindowLongOffsets nIndex);
|
||||
static extern UIntPtr GetWindowLongPtrInternal(HWND hWnd, GetWindowLongOffsets nIndex);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -306,6 +363,13 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region SendMessage
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern LRESULT SendMessage(HWND hWnd, WindowMessage Msg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#endregion
|
||||
|
||||
#region PostMessage
|
||||
|
||||
[CLSCompliant(false)]
|
||||
|
@ -330,12 +394,24 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region DispatchMessage
|
||||
|
||||
#if RELEASE
|
||||
[System.Security.SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("User32.dll"), CLSCompliant(false)]
|
||||
internal static extern LRESULT DispatchMessage(ref MSG msg);
|
||||
|
||||
#endregion
|
||||
|
||||
#region TranslateMessage
|
||||
|
||||
#if RELEASE
|
||||
[System.Security.SuppressUnmanagedCodeSecurity]
|
||||
#endif
|
||||
[DllImport("User32.dll"), CLSCompliant(false)]
|
||||
internal static extern BOOL TranslateMessage(ref MSG lpMsg);
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetQueueStatus
|
||||
|
||||
/// <summary>
|
||||
|
@ -367,6 +443,13 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region DefWindowProc
|
||||
|
||||
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||
public extern static IntPtr DefWindowProc(HWND hWnd, WindowMessage msg, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Timing
|
||||
|
@ -428,6 +511,13 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region GetWindowDC
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
internal static extern IntPtr GetWindowDC(IntPtr hwnd);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ReleaseDC
|
||||
|
||||
/// <summary>
|
||||
|
@ -493,6 +583,13 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region DLL handling
|
||||
|
||||
#region SetLastError
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
internal static extern void SetLastError(DWORD dwErrCode);
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetModuleHandle
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
|
@ -594,8 +691,8 @@ namespace OpenTK.Platform.Windows
|
|||
/// <para>The SetWindowText function does not expand tab characters (ASCII code 0x09). Tab characters are displayed as vertical bar (|) characters. </para>
|
||||
/// <para>Windows 95/98/Me: SetWindowTextW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems .</para>
|
||||
/// </remarks>
|
||||
[DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern BOOL SetWindowText(HWND hWnd, LPCTSTR lpString);
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern BOOL SetWindowText(HWND hWnd, [MarshalAs(UnmanagedType.LPTStr)] string lpString);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -616,9 +713,8 @@ namespace OpenTK.Platform.Windows
|
|||
/// <para>To retrieve the text of a control in another process, send a WM_GETTEXT message directly instead of calling GetWindowText.</para>
|
||||
/// <para>Windows 95/98/Me: GetWindowTextW is supported by the Microsoft Layer for Unicode (MSLU). To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me</para>
|
||||
/// </remarks>
|
||||
[DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity]
|
||||
internal static extern int GetWindowText(HWND hWnd,
|
||||
[MarshalAs(UnmanagedType.LPTStr), Out] StringBuilder lpString, int nMaxCount);
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
internal static extern int GetWindowText(HWND hWnd, [MarshalAs(UnmanagedType.LPTStr), In, Out] StringBuilder lpString, int nMaxCount);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -672,7 +768,24 @@ namespace OpenTK.Platform.Windows
|
|||
/// </returns>
|
||||
/// <remarks>In conformance with conventions for the RECT structure, the bottom-right coordinates of the returned rectangle are exclusive. In other words, the pixel at (right, bottom) lies immediately outside the rectangle.</remarks>
|
||||
[DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity]
|
||||
internal extern static BOOL GetClientRect(HWND windowHandle, out RECT clientRectangle);
|
||||
internal extern static BOOL GetClientRect(HWND windowHandle, out Rectangle clientRectangle);
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetWindowRect
|
||||
|
||||
/// <summary>
|
||||
/// The GetWindowRect function retrieves the dimensions of the bounding rectangle of the specified window. The dimensions are given in screen coordinates that are relative to the upper-left corner of the screen.
|
||||
/// </summary>
|
||||
/// <param name="windowHandle">Handle to the window whose client coordinates are to be retrieved.</param>
|
||||
/// <param name="windowRectangle"> Pointer to a structure that receives the screen coordinates of the upper-left and lower-right corners of the window.</param>
|
||||
/// <returns>
|
||||
/// <para>If the function succeeds, the return value is nonzero.</para>
|
||||
/// <para>If the function fails, the return value is zero. To get extended error information, call GetLastError.</para>
|
||||
/// </returns>
|
||||
/// <remarks>In conformance with conventions for the RECT structure, the bottom-right coordinates of the returned rectangle are exclusive. In other words, the pixel at (right, bottom) lies immediately outside the rectangle.</remarks>
|
||||
[DllImport("user32.dll", SetLastError = true), SuppressUnmanagedCodeSecurity]
|
||||
internal extern static BOOL GetWindowRect(HWND windowHandle, out Rectangle windowRectangle);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -683,6 +796,20 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region DwmGetWindowAttribute
|
||||
|
||||
[DllImport("dwmapi.dll")]
|
||||
unsafe public static extern HRESULT DwmGetWindowAttribute(HWND hwnd, DwmWindowAttribute dwAttribute, void* pvAttribute, DWORD cbAttribute);
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetFocus
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern HWND GetFocus();
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region Display settings
|
||||
|
@ -706,40 +833,47 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region ChangeDisplaySettingsEx
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern LONG ChangeDisplaySettingsEx(LPCTSTR lpszDeviceName, LPDEVMODE lpDevMode,
|
||||
HWND hwnd, ChangeDisplaySettingsEnum dwflags, LPVOID lParam);
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern LONG ChangeDisplaySettingsEx([MarshalAs(UnmanagedType.LPTStr)] LPCTSTR lpszDeviceName,
|
||||
LPDEVMODE lpDevMode, HWND hwnd, ChangeDisplaySettingsEnum dwflags, LPVOID lParam);
|
||||
|
||||
#endregion
|
||||
|
||||
#region EnumDisplayDevices
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet=CharSet.Auto)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern BOOL EnumDisplayDevices([MarshalAs(UnmanagedType.LPStr)] LPCTSTR lpDevice,
|
||||
public static extern BOOL EnumDisplayDevices([MarshalAs(UnmanagedType.LPTStr)] LPCTSTR lpDevice,
|
||||
DWORD iDevNum, [In, Out] WindowsDisplayDevice lpDisplayDevice, DWORD dwFlags);
|
||||
|
||||
#endregion
|
||||
|
||||
#region EnumDisplaySettings
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern BOOL EnumDisplaySettings([MarshalAs(UnmanagedType.LPStr)] string device_name,
|
||||
int graphics_mode, [Out] DeviceMode device_mode);
|
||||
internal static extern BOOL EnumDisplaySettings([MarshalAs(UnmanagedType.LPTStr)] string device_name,
|
||||
int graphics_mode, [In, Out] DeviceMode device_mode);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern BOOL EnumDisplaySettings([MarshalAs(UnmanagedType.LPStr)] string device_name,
|
||||
DisplayModeSettingsEnum graphics_mode, [Out] DeviceMode device_mode);
|
||||
internal static extern BOOL EnumDisplaySettings([MarshalAs(UnmanagedType.LPTStr)] string device_name,
|
||||
DisplayModeSettingsEnum graphics_mode, [In, Out] DeviceMode device_mode);
|
||||
|
||||
#endregion
|
||||
|
||||
#region EnumDisplaySettingsEx
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern BOOL EnumDisplaySettingsEx([MarshalAs(UnmanagedType.LPTStr)] LPCTSTR lpszDeviceName, DisplayModeSettingsEnum iModeNum,
|
||||
[In, Out] DeviceMode lpDevMode, DWORD dwFlags);
|
||||
|
||||
#endregion
|
||||
|
||||
#region GetMonitorInfo
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
public static extern BOOL EnumDisplaySettingsEx([MarshalAs(UnmanagedType.LPStr)] LPCTSTR lpszDeviceName, DisplayModeSettingsEnum iModeNum,
|
||||
[Out] DeviceMode lpDevMode, DWORD dwFlags);
|
||||
public static extern BOOL GetMonitorInfo(IntPtr hMonitor, ref MonitorInfo lpmi);
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -1240,6 +1374,17 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region GDI functions
|
||||
|
||||
#region GetStockObject
|
||||
|
||||
[DllImport("gdi32.dll", SetLastError = true)]
|
||||
internal static extern IntPtr GetStockObject(int index);
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
@ -1428,6 +1573,26 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region StyleStruct
|
||||
|
||||
struct StyleStruct
|
||||
{
|
||||
public WindowStyle Old;
|
||||
public WindowStyle New;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ExtendedStyleStruct
|
||||
|
||||
struct ExtendedStyleStruct
|
||||
{
|
||||
public ExtendedWindowStyle Old;
|
||||
public ExtendedWindowStyle New;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PixelFormatDescriptor
|
||||
|
||||
/// <summary>
|
||||
|
@ -1613,7 +1778,7 @@ namespace OpenTK.Platform.Windows
|
|||
#endif
|
||||
} DEVMODE;
|
||||
*/
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal class DeviceMode
|
||||
{
|
||||
internal DeviceMode()
|
||||
|
@ -1629,14 +1794,18 @@ namespace OpenTK.Platform.Windows
|
|||
internal short DriverExtra;
|
||||
internal int Fields;
|
||||
|
||||
internal short Orientation;
|
||||
internal short PaperSize;
|
||||
internal short PaperLength;
|
||||
internal short PaperWidth;
|
||||
internal short Scale;
|
||||
internal short Copies;
|
||||
internal short DefaultSource;
|
||||
internal short PrintQuality;
|
||||
//internal short Orientation;
|
||||
//internal short PaperSize;
|
||||
//internal short PaperLength;
|
||||
//internal short PaperWidth;
|
||||
//internal short Scale;
|
||||
//internal short Copies;
|
||||
//internal short DefaultSource;
|
||||
//internal short PrintQuality;
|
||||
|
||||
internal POINT Position;
|
||||
internal DWORD DisplayOrientation;
|
||||
internal DWORD DisplayFixedOutput;
|
||||
|
||||
internal short Color;
|
||||
internal short Duplex;
|
||||
|
@ -1668,7 +1837,7 @@ namespace OpenTK.Platform.Windows
|
|||
/// <summary>
|
||||
/// The DISPLAY_DEVICE structure receives information about the display device specified by the iDevNum parameter of the EnumDisplayDevices function.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Ansi)]
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
internal class WindowsDisplayDevice
|
||||
{
|
||||
internal WindowsDisplayDevice()
|
||||
|
@ -1693,11 +1862,11 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region WindowClass
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal class WindowClass
|
||||
internal struct WindowClass
|
||||
{
|
||||
internal WindowClassStyle style = WindowClassStyle.VRedraw | WindowClassStyle.HRedraw | WindowClassStyle.OwnDC;
|
||||
internal ClassStyle Style;
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)]
|
||||
internal WindowProcedureEventHandler WindowProcedure;
|
||||
internal WindowProcedure WindowProcedure;
|
||||
internal int ClassExtraBytes;
|
||||
internal int WindowExtraBytes;
|
||||
//[MarshalAs(UnmanagedType.
|
||||
|
@ -1707,12 +1876,39 @@ namespace OpenTK.Platform.Windows
|
|||
internal IntPtr BackgroundBrush;
|
||||
//[MarshalAs(UnmanagedType.LPStr)]
|
||||
internal IntPtr MenuName;
|
||||
//[MarshalAs(UnmanagedType.LPStr)]
|
||||
internal IntPtr ClassName;
|
||||
[MarshalAs(UnmanagedType.LPTStr)]
|
||||
internal string ClassName;
|
||||
//internal string ClassName;
|
||||
|
||||
internal static int SizeInBytes = Marshal.SizeOf(default(WindowClass));
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ExtendedWindowClass
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
|
||||
struct ExtendedWindowClass
|
||||
{
|
||||
public UINT Size;
|
||||
public ClassStyle Style;
|
||||
//public WNDPROC WndProc;
|
||||
[MarshalAs(UnmanagedType.FunctionPtr)]
|
||||
public WindowProcedure WndProc;
|
||||
public int cbClsExtra;
|
||||
public int cbWndExtra;
|
||||
public HINSTANCE Instance;
|
||||
public HICON Icon;
|
||||
public HCURSOR Cursor;
|
||||
public HBRUSH Background;
|
||||
public IntPtr MenuName;
|
||||
public IntPtr ClassName;
|
||||
public HICON IconSm;
|
||||
|
||||
public static uint SizeInBytes = (uint)Marshal.SizeOf(default(ExtendedWindowClass));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal struct MinMaxInfo
|
||||
|
||||
/// <summary>
|
||||
|
@ -1721,11 +1917,11 @@ namespace OpenTK.Platform.Windows
|
|||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct MINMAXINFO
|
||||
{
|
||||
System.Drawing.Point ptReserved;
|
||||
System.Drawing.Point ptMaxSize;
|
||||
System.Drawing.Point ptMaxPosition;
|
||||
System.Drawing.Point ptMinTrackSize;
|
||||
System.Drawing.Point ptMaxTrackSize;
|
||||
System.Drawing.Point Reserved;
|
||||
public System.Drawing.Size MaxSize;
|
||||
public System.Drawing.Point MaxPosition;
|
||||
public System.Drawing.Size MinTrackSize;
|
||||
public System.Drawing.Size MaxTrackSize;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -2326,30 +2522,6 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region GetWindowLongOffsets
|
||||
|
||||
/// <summary>
|
||||
/// Window field offsets for GetWindowLong() and GetWindowLongPtr().
|
||||
/// </summary>
|
||||
internal static class GWL
|
||||
{
|
||||
private static bool x64;
|
||||
static GWL()
|
||||
{
|
||||
unsafe
|
||||
{
|
||||
x64 = sizeof(void*) == 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal static readonly int WNDPROC = (-4);
|
||||
internal static readonly int HINSTANCE = (-6);
|
||||
internal static readonly int HWNDPARENT = (-8);
|
||||
internal static readonly int STYLE = (-16);
|
||||
internal static readonly int EXSTYLE = (-20);
|
||||
internal static readonly int USERDATA = (-21);
|
||||
internal static readonly int ID = (-12);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Rectangle
|
||||
|
@ -2394,6 +2566,31 @@ namespace OpenTK.Platform.Windows
|
|||
{
|
||||
return String.Format("({0},{1})-({2},{3})", left, top, right, bottom);
|
||||
}
|
||||
|
||||
internal System.Drawing.Rectangle ToRectangle()
|
||||
{
|
||||
return System.Drawing.Rectangle.FromLTRB(left, top, right, bottom);
|
||||
}
|
||||
|
||||
internal static Rectangle From(System.Drawing.Rectangle value)
|
||||
{
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.left = value.Left;
|
||||
rect.right = value.Right;
|
||||
rect.top = value.Top;
|
||||
rect.bottom = value.Bottom;
|
||||
return rect;
|
||||
}
|
||||
|
||||
internal static Rectangle From(System.Drawing.Size value)
|
||||
{
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.left = 0;
|
||||
rect.right = value.Width;
|
||||
rect.top = 0;
|
||||
rect.bottom = value.Height;
|
||||
return rect;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -2450,11 +2647,69 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region MonitorInfo
|
||||
|
||||
struct MonitorInfo
|
||||
{
|
||||
public DWORD Size;
|
||||
public RECT Monitor;
|
||||
public RECT Work;
|
||||
public DWORD Flags;
|
||||
|
||||
public static readonly int SizeInBytes = Marshal.SizeOf(default(MonitorInfo));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NcCalculateSize
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack=1)]
|
||||
internal struct NcCalculateSize
|
||||
{
|
||||
public Rectangle NewBounds;
|
||||
public Rectangle OldBounds;
|
||||
public Rectangle OldClientRectangle;
|
||||
unsafe public WindowPosition* Position;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Enums ---
|
||||
|
||||
#region
|
||||
#region GetWindowLongOffset
|
||||
|
||||
/// <summary>
|
||||
/// Window field offsets for GetWindowLong() and GetWindowLongPtr().
|
||||
/// </summary>
|
||||
enum GWL
|
||||
{
|
||||
WNDPROC = (-4),
|
||||
HINSTANCE = (-6),
|
||||
HWNDPARENT = (-8),
|
||||
STYLE = (-16),
|
||||
EXSTYLE = (-20),
|
||||
USERDATA = (-21),
|
||||
ID = (-12),
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region SizeMessage
|
||||
|
||||
internal enum SizeMessage
|
||||
{
|
||||
MAXHIDE = 4,
|
||||
MAXIMIZED = 2,
|
||||
MAXSHOW = 3,
|
||||
MINIMIZED = 1,
|
||||
RESTORED = 0
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NcCalcSizeOptions
|
||||
|
||||
internal enum NcCalcSizeOptions
|
||||
{
|
||||
|
@ -2516,13 +2771,13 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region internal enum WindowStyle : int
|
||||
#region internal enum WindowStyle : uint
|
||||
|
||||
[Flags]
|
||||
internal enum WindowStyle : int
|
||||
internal enum WindowStyle : uint
|
||||
{
|
||||
Overlapped = 0x00000000,
|
||||
Popup = unchecked((int)0x80000000),
|
||||
Popup = 0x80000000,
|
||||
Child = 0x40000000,
|
||||
Minimize = 0x20000000,
|
||||
Visible = 0x10000000,
|
||||
|
@ -2556,10 +2811,10 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region internal enum ExtendedWindowStyle : int
|
||||
#region internal enum ExtendedWindowStyle : uint
|
||||
|
||||
[Flags]
|
||||
internal enum ExtendedWindowStyle : int
|
||||
internal enum ExtendedWindowStyle : uint
|
||||
{
|
||||
DialogModalFrame = 0x00000001,
|
||||
NoParentNotify = 0x00000004,
|
||||
|
@ -2675,9 +2930,9 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region WindowClassStyle enum
|
||||
#region ClassStyle enum
|
||||
[Flags]
|
||||
internal enum WindowClassStyle
|
||||
internal enum ClassStyle
|
||||
{
|
||||
//None = 0x0000,
|
||||
VRedraw = 0x0001,
|
||||
|
@ -3232,7 +3487,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#region WindowMessage
|
||||
|
||||
internal enum WindowMessage
|
||||
internal enum WindowMessage : uint
|
||||
{
|
||||
NULL = 0x0000,
|
||||
CREATE = 0x0001,
|
||||
|
@ -3523,7 +3778,7 @@ namespace OpenTK.Platform.Windows
|
|||
/// Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
|
||||
/// </summary>
|
||||
SHOWNORMAL = 1,
|
||||
//NORMAL = 1,
|
||||
NORMAL = 1,
|
||||
/// <summary>
|
||||
/// Activates the window and displays it as a minimized window.
|
||||
/// </summary>
|
||||
|
@ -3532,7 +3787,7 @@ namespace OpenTK.Platform.Windows
|
|||
/// Activates the window and displays it as a maximized window.
|
||||
/// </summary>
|
||||
SHOWMAXIMIZED = 3,
|
||||
//MAXIMIZE = 3,
|
||||
MAXIMIZE = 3,
|
||||
/// <summary>
|
||||
/// Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
|
||||
/// </summary>
|
||||
|
@ -3641,24 +3896,32 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
#endregion
|
||||
|
||||
#region DwmWindowAttribute
|
||||
|
||||
enum DwmWindowAttribute
|
||||
{
|
||||
NCRENDERING_ENABLED = 1,
|
||||
NCRENDERING_POLICY,
|
||||
TRANSITIONS_FORCEDISABLED,
|
||||
ALLOW_NCPAINT,
|
||||
CAPTION_BUTTON_BOUNDS,
|
||||
NONCLIENT_RTL_LAYOUT,
|
||||
FORCE_ICONIC_REPRESENTATION,
|
||||
FLIP3D_POLICY,
|
||||
EXTENDED_FRAME_BOUNDS,
|
||||
HAS_ICONIC_BITMAP,
|
||||
DISALLOW_PEEK,
|
||||
EXCLUDED_FROM_PEEK,
|
||||
LAST
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region --- Callbacks ---
|
||||
|
||||
internal delegate void WindowProcedure(ref System.Windows.Forms.Message msg);
|
||||
|
||||
[UnmanagedFunctionPointerAttribute(CallingConvention.Winapi)]
|
||||
internal delegate void WindowProcedureEventHandler(object sender, WindowProcedureEventArgs e);
|
||||
|
||||
internal class WindowProcedureEventArgs : EventArgs
|
||||
{
|
||||
private System.Windows.Forms.Message msg;
|
||||
internal System.Windows.Forms.Message Message
|
||||
{
|
||||
get { return msg; }
|
||||
set { msg = value; }
|
||||
}
|
||||
}
|
||||
internal delegate IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
#region Message
|
||||
|
||||
|
|
|
@ -52,10 +52,12 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
// The second function should only be executed when the first one fails
|
||||
// (e.g. when the monitor is disabled)
|
||||
if (Functions.EnumDisplaySettings(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.CurrentSettings, monitor_mode) ||
|
||||
Functions.EnumDisplaySettings(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.RegistrySettings, monitor_mode))
|
||||
if (Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.CurrentSettings, monitor_mode, 0) ||
|
||||
Functions.EnumDisplaySettingsEx(dev1.DeviceName.ToString(), DisplayModeSettingsEnum.RegistrySettings, monitor_mode, 0))
|
||||
{
|
||||
opentk_dev_current_res = new DisplayResolution(monitor_mode.PelsWidth, monitor_mode.PelsHeight,
|
||||
opentk_dev_current_res = new DisplayResolution(
|
||||
monitor_mode.Position.X, monitor_mode.Position.Y,
|
||||
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
|
||||
monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);
|
||||
opentk_dev_primary =
|
||||
(dev1.StateFlags & DisplayDeviceStateFlags.PrimaryDevice) != DisplayDeviceStateFlags.None;
|
||||
|
@ -66,6 +68,7 @@ namespace OpenTK.Platform.Windows
|
|||
while (Functions.EnumDisplaySettings(dev1.DeviceName.ToString(), mode_count++, monitor_mode))
|
||||
{
|
||||
DisplayResolution res = new DisplayResolution(
|
||||
monitor_mode.Position.X, monitor_mode.Position.Y,
|
||||
monitor_mode.PelsWidth, monitor_mode.PelsHeight,
|
||||
monitor_mode.BitsPerPel, monitor_mode.DisplayFrequency);
|
||||
|
||||
|
@ -75,7 +78,9 @@ namespace OpenTK.Platform.Windows
|
|||
// Construct the OpenTK DisplayDevice through the accumulated parameters.
|
||||
// The constructor will automatically add the DisplayDevice to the list
|
||||
// of available devices.
|
||||
opentk_dev = new OpenTK.Graphics.DisplayDevice(opentk_dev_current_res, opentk_dev_primary,
|
||||
opentk_dev = new OpenTK.Graphics.DisplayDevice(
|
||||
opentk_dev_current_res,
|
||||
opentk_dev_primary,
|
||||
opentk_dev_available_res);
|
||||
|
||||
available_device_names.Add(opentk_dev, dev1.DeviceName);
|
||||
|
|
|
@ -1,3 +1,30 @@
|
|||
#region License
|
||||
//
|
||||
// The Open Toolkit Library License
|
||||
//
|
||||
// Copyright (c) 2006 - 2009 the Open Toolkit library.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
@ -13,7 +40,12 @@ using OpenTK.Input;
|
|||
|
||||
public INativeGLWindow CreateGLNative()
|
||||
{
|
||||
return new WinGLNative();
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
return new WinGLNative(x, y, width, height, title, options, device);
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
|
@ -28,7 +60,7 @@ using OpenTK.Input;
|
|||
|
||||
public IGraphicsContext CreateGLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext, bool directRendering, int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
return new WinGLContext(mode, window, shareContext, major, minor, flags);
|
||||
return new WinGLContext(mode, (WinWindowInfo)window, shareContext, major, minor, flags);
|
||||
}
|
||||
|
||||
public GraphicsContext.GetCurrentContextDelegate CreateGetCurrentGraphicsContext()
|
||||
|
|
|
@ -26,12 +26,10 @@ namespace OpenTK.Platform.Windows
|
|||
/// </summary>
|
||||
internal sealed class WinGLContext : IGraphicsContext, IGraphicsContextInternal//, IGLContextCreationHack
|
||||
{
|
||||
WinWindowInfo currentWindow;
|
||||
ContextHandle renderContext;
|
||||
static IntPtr opengl32Handle;
|
||||
static bool wgl_loaded;
|
||||
const string opengl32Name = "OPENGL32.DLL";
|
||||
//WinWindowInfo windowInfo = new WinWindowInfo();
|
||||
|
||||
GraphicsMode format;
|
||||
//DisplayMode mode = null;
|
||||
|
@ -54,18 +52,17 @@ namespace OpenTK.Platform.Windows
|
|||
}
|
||||
}
|
||||
|
||||
public WinGLContext(GraphicsMode format, IWindowInfo window, IGraphicsContext sharedContext,
|
||||
public WinGLContext(GraphicsMode format, WinWindowInfo window, IGraphicsContext sharedContext,
|
||||
int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
if (window == null)
|
||||
throw new ArgumentNullException("window", "Must point to a valid window.");
|
||||
currentWindow = (WinWindowInfo)window;
|
||||
if (currentWindow.WindowHandle == IntPtr.Zero)
|
||||
if (window.WindowHandle == IntPtr.Zero)
|
||||
throw new ArgumentException("window", "Must be a valid window.");
|
||||
|
||||
this.format = format;
|
||||
|
||||
Debug.Print("OpenGL will be bound to handle: {0}", currentWindow.WindowHandle);
|
||||
Debug.Print("OpenGL will be bound to handle: {0}", window.WindowHandle);
|
||||
Debug.Write("Setting pixel format... ");
|
||||
this.SetGraphicsModePFD(format, (WinWindowInfo)window);
|
||||
|
||||
|
@ -75,8 +72,8 @@ namespace OpenTK.Platform.Windows
|
|||
// We cannot rely on OpenTK.Platform.Wgl until we create the context and call Wgl.LoadAll().
|
||||
Debug.Print("Creating temporary context for wgl extensions.");
|
||||
|
||||
ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(currentWindow.DeviceContext));
|
||||
Wgl.Imports.MakeCurrent(currentWindow.DeviceContext, temp_context.Handle);
|
||||
ContextHandle temp_context = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext));
|
||||
Wgl.Imports.MakeCurrent(window.DeviceContext, temp_context.Handle);
|
||||
Wgl.LoadAll();
|
||||
Wgl.MakeCurrent(IntPtr.Zero, IntPtr.Zero);
|
||||
Wgl.DeleteContext(temp_context.Handle);
|
||||
|
@ -103,7 +100,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
renderContext = new ContextHandle(
|
||||
Wgl.Arb.CreateContextAttribs(
|
||||
currentWindow.DeviceContext,
|
||||
window.DeviceContext,
|
||||
sharedContext != null ? (sharedContext as IGraphicsContextInternal).Context.Handle : IntPtr.Zero,
|
||||
attributes.ToArray()));
|
||||
if (renderContext == ContextHandle.Zero)
|
||||
|
@ -119,9 +116,9 @@ namespace OpenTK.Platform.Windows
|
|||
{
|
||||
// Failed to create GL3-level context, fall back to GL2.
|
||||
Debug.Write("Falling back to GL2... ");
|
||||
renderContext = new ContextHandle(Wgl.Imports.CreateContext(currentWindow.DeviceContext));
|
||||
renderContext = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext));
|
||||
if (renderContext == ContextHandle.Zero)
|
||||
renderContext = new ContextHandle(Wgl.Imports.CreateContext(currentWindow.DeviceContext));
|
||||
renderContext = new ContextHandle(Wgl.Imports.CreateContext(window.DeviceContext));
|
||||
if (renderContext == ContextHandle.Zero)
|
||||
throw new GraphicsContextException(
|
||||
String.Format("Context creation failed. Wgl.CreateContext() error: {0}.",
|
||||
|
@ -145,7 +142,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
public void SwapBuffers()
|
||||
{
|
||||
if (!Functions.SwapBuffers(currentWindow.DeviceContext))
|
||||
if (!Functions.SwapBuffers(Wgl.GetCurrentDC()))
|
||||
throw new GraphicsContextException(String.Format(
|
||||
"Failed to swap buffers for context {0} current. Error: {1}", this, Marshal.GetLastWin32Error()));
|
||||
}
|
||||
|
@ -163,7 +160,6 @@ namespace OpenTK.Platform.Windows
|
|||
if (((WinWindowInfo)window).WindowHandle == IntPtr.Zero)
|
||||
throw new ArgumentException("window", "Must point to a valid window.");
|
||||
|
||||
currentWindow = (WinWindowInfo)window;
|
||||
success = Wgl.Imports.MakeCurrent(((WinWindowInfo)window).DeviceContext, this.renderContext.Handle);
|
||||
}
|
||||
else
|
||||
|
@ -352,9 +348,7 @@ namespace OpenTK.Platform.Windows
|
|||
{
|
||||
get
|
||||
{
|
||||
if (currentWindow != null)
|
||||
return currentWindow.DeviceContext;
|
||||
return IntPtr.Zero;
|
||||
return Wgl.GetCurrentDC();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +386,8 @@ namespace OpenTK.Platform.Windows
|
|||
}
|
||||
else
|
||||
{
|
||||
Debug.Print("[Warning] OpenGL context {0} leaked. Did you forget to call IGraphicsContext.Dispose()?", renderContext.Handle);
|
||||
Debug.Print("[Warning] OpenGL context {0} leaked. Did you forget to call IGraphicsContext.Dispose()?",
|
||||
renderContext.Handle);
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
public GraphicsContext CreateContext(int major, int minor, GraphicsContextFlags flags)
|
||||
{
|
||||
// Make sure the Control exists before creating the context.
|
||||
// Make sure the Control exists before create the context.
|
||||
if (window_info == null)
|
||||
window_info = new WinWindowInfo(control.Handle, null);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -37,6 +37,7 @@ namespace OpenTK.Platform.Windows
|
|||
{
|
||||
if (dc == IntPtr.Zero)
|
||||
dc = Functions.GetDC(this.WindowHandle);
|
||||
//dc = Functions.GetWindowDC(this.WindowHandle);
|
||||
return dc;
|
||||
}
|
||||
//set { dc = value; }
|
||||
|
|
|
@ -124,9 +124,14 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
[DllImport("libX11", EntryPoint = "XReparentWindow")]
|
||||
public extern static int XReparentWindow(IntPtr display, IntPtr window, IntPtr parent, int x, int y);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XMoveResizeWindow")]
|
||||
public extern static int XMoveResizeWindow(IntPtr display, IntPtr window, int x, int y, int width, int height);
|
||||
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XResizeWindow")]
|
||||
public extern static int XMoveWindow(IntPtr display, IntPtr w, int x, int y);
|
||||
|
||||
[DllImport("libX11", EntryPoint = "XResizeWindow")]
|
||||
public extern static int XResizeWindow(IntPtr display, IntPtr window, int width, int height);
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
#region IPlatformFactory Members
|
||||
|
||||
public INativeGLWindow CreateGLNative()
|
||||
public INativeWindow CreateNativeWindow(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
return new X11GLNative();
|
||||
return new X11GLNative(x, y, width, height, title, mode, options, device);
|
||||
}
|
||||
|
||||
public IGLControl CreateGLControl(GraphicsMode mode, GLControl owner)
|
||||
|
|
|
@ -201,21 +201,28 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
public void MakeCurrent(IWindowInfo window)
|
||||
{
|
||||
X11WindowInfo w = (X11WindowInfo)window;
|
||||
bool result;
|
||||
|
||||
Debug.Write(String.Format("Making context {0} current on thread {1} (Display: {2}, Screen: {3}, Window: {4})... ",
|
||||
context, System.Threading.Thread.CurrentThread.ManagedThreadId, w.Display, w.Screen, w.WindowHandle));
|
||||
|
||||
if (w.Display == IntPtr.Zero || w.WindowHandle == IntPtr.Zero || context == ContextHandle.Zero)
|
||||
throw new InvalidOperationException("Invalid display, window or context.");
|
||||
|
||||
result = Glx.MakeCurrent(w.Display, w.WindowHandle, context);
|
||||
|
||||
if (!result)
|
||||
throw new GraphicsContextException("Failed to make context current.");
|
||||
if (window == null)
|
||||
{
|
||||
Glx.MakeCurrent(currentWindow.Display, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
else
|
||||
Debug.WriteLine("done!");
|
||||
{
|
||||
X11WindowInfo w = (X11WindowInfo)window;
|
||||
bool result;
|
||||
|
||||
Debug.Write(String.Format("Making context {0} current on thread {1} (Display: {2}, Screen: {3}, Window: {4})... ",
|
||||
context, System.Threading.Thread.CurrentThread.ManagedThreadId, w.Display, w.Screen, w.WindowHandle));
|
||||
|
||||
if (w.Display == IntPtr.Zero || w.WindowHandle == IntPtr.Zero || context == ContextHandle.Zero)
|
||||
throw new InvalidOperationException("Invalid display, window or context.");
|
||||
|
||||
result = Glx.MakeCurrent(w.Display, w.WindowHandle, context);
|
||||
|
||||
if (!result)
|
||||
throw new GraphicsContextException("Failed to make context current.");
|
||||
else
|
||||
Debug.WriteLine("done!");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -366,24 +373,20 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
if (!disposed)
|
||||
{
|
||||
// Clean unmanaged resources:
|
||||
try
|
||||
{
|
||||
Functions.XLockDisplay(currentWindow.Display);
|
||||
Glx.MakeCurrent(currentWindow.Display, IntPtr.Zero, IntPtr.Zero);
|
||||
Glx.DestroyContext(currentWindow.Display, context);
|
||||
//Functions.XFree(visual);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Functions.XUnlockDisplay(currentWindow.Display);
|
||||
}
|
||||
|
||||
if (manuallyCalled)
|
||||
{
|
||||
if (GraphicsContext.CurrentContext != null &&
|
||||
((IGraphicsContextInternal)GraphicsContext.CurrentContext).Context == context)
|
||||
GraphicsContext.CurrentContext.MakeCurrent(null);
|
||||
|
||||
Glx.DestroyContext(currentWindow.Display, context);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Print("[Warning] {0} leaked.", this.GetType().Name);
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
~X11GLContext()
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -38,6 +38,7 @@ namespace OpenTK.Platform.X11
|
|||
// Get available resolutions. Then, for each resolution get all
|
||||
// available rates.
|
||||
// TODO: Global X11 lock.
|
||||
// TODO: Use xinerama to get the bounds of each monitor.
|
||||
for (int screen = 0; screen < API.ScreenCount; screen++)
|
||||
{
|
||||
IntPtr timestamp_of_last_update;
|
||||
|
@ -63,11 +64,11 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
if (rate != 0)
|
||||
foreach (int depth in depths)
|
||||
available_res.Add(new DisplayResolution(size.Width, size.Height, depth, (float)rate));
|
||||
available_res.Add(new DisplayResolution(0, 0, size.Width, size.Height, depth, (float)rate));
|
||||
}
|
||||
// Keep the index of this resolution - we will need it for resolution changes later.
|
||||
foreach (int depth in depths)
|
||||
screenResolutionToIndex[screen].Add(new DisplayResolution(size.Width, size.Height, depth, 0),
|
||||
screenResolutionToIndex[screen].Add(new DisplayResolution(0, 0, size.Width, size.Height, depth, 0),
|
||||
resolution_count);
|
||||
|
||||
++resolution_count;
|
||||
|
@ -84,8 +85,10 @@ namespace OpenTK.Platform.X11
|
|||
int current_resolution_index = Functions.XRRConfigCurrentConfiguration(screen_config, out current_rotation);
|
||||
|
||||
DisplayDevice current_device = new DisplayDevice(
|
||||
new DisplayResolution(available_res[current_resolution_index].Width, available_res[current_resolution_index].Height,
|
||||
current_depth, current_refresh_rate),
|
||||
new DisplayResolution(
|
||||
0, 0,
|
||||
available_res[current_resolution_index].Width, available_res[current_resolution_index].Height,
|
||||
current_depth, current_refresh_rate),
|
||||
screen == Functions.XDefaultScreen(API.DefaultDisplay),
|
||||
available_res);
|
||||
|
||||
|
@ -162,7 +165,7 @@ namespace OpenTK.Platform.X11
|
|||
int new_resolution_index;
|
||||
if (resolution != null)
|
||||
new_resolution_index = screenResolutionToIndex[screen]
|
||||
[new DisplayResolution(resolution.Width, resolution.Height, resolution.BitsPerPixel, 0)];
|
||||
[new DisplayResolution(0, 0, resolution.Width, resolution.Height, resolution.BitsPerPixel, 0)];
|
||||
else
|
||||
new_resolution_index = deviceToDefaultResolution[device];
|
||||
|
||||
|
|
Loading…
Reference in a new issue