-
-
Notifications
You must be signed in to change notification settings - Fork 409
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Start experimenting with a basic triangle program. * Some more work * Include error code in exception message * Remove MakeCurrent * Add a WindowBuilder * Implement the dispatcher ourselves for Update and Render only * Fix the current context bug * Allow invocation on the main thread from the main thread * Invoke within VSync setter * Fix a NRE, assign everything, and remove initialOptions * Fix an InvalidOperationException * Actually fix it :P * Remove the double assignment of UseSingleThreadedWindow * Continue with triangle example * Delete WindowBuilder.cs * Run a Using cleanup on the entire project
- Loading branch information
Showing
20 changed files
with
6,456 additions
and
6,309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
7,046 changes: 3,523 additions & 3,523 deletions
7,046
build/binder_specifications/OpenGL (Compatibility Profile).json
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// This file is part of Silk.NET. | ||
// | ||
// You may modify and distribute Silk.NET under the terms | ||
// of the MIT license. See the LICENSE file for details. | ||
|
||
using System.Drawing; | ||
using Silk.NET.OpenGL; | ||
using Silk.NET.Windowing; | ||
using Silk.NET.Windowing.Common; | ||
|
||
namespace Triangle | ||
{ | ||
public unsafe class Game | ||
{ | ||
private IWindow window; | ||
private GL gl; | ||
|
||
private uint vbo; | ||
private uint vao; | ||
|
||
private float[] vertices = { | ||
-0.5f, -0.5f, 0.0f, //Bottom-left vertex | ||
0.5f, -0.5f, 0.0f, //Bottom-right vertex | ||
0.0f, 0.5f, 0.0f //Top vertex | ||
}; | ||
|
||
public Game() | ||
{ | ||
var options = WindowOptions.Default; | ||
|
||
options.UseSingleThreadedWindow = false; | ||
|
||
window = Window.Create(options); | ||
|
||
window.OnLoad += OnLoad; | ||
window.OnRender += OnRender; | ||
window.OnResize += OnResize; | ||
|
||
gl = GL.GetApi(); | ||
} | ||
|
||
public void Run() | ||
{ | ||
window.Run(); | ||
} | ||
|
||
public void OnLoad() | ||
{ | ||
gl.ClearColor(1.0f, 0.4f, 0.3f, 1.0f); | ||
|
||
vbo = gl.GenBuffer(1); | ||
gl.BindBuffer((int)GLEnum.ArrayBuffer, vbo); | ||
|
||
//var size = (uint)vertices.Length * sizeof(float); | ||
//gl.BufferData((int)GLEnum.ArrayBuffer, new UIntPtr(size), vertices, (int)GLEnum.StaticDraw); | ||
} | ||
|
||
public void OnRender(double delta) | ||
{ | ||
gl.Clear((uint)GLEnum.ColorBufferBit); | ||
|
||
window.SwapBuffers(); | ||
} | ||
|
||
public void OnResize(Size size) | ||
{ | ||
gl.Viewport(0, 0, (uint)size.Width, (uint)size.Height); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Triangle | ||
{ | ||
internal class Program | ||
{ | ||
private static void Main() | ||
{ | ||
var game = new Game(); | ||
game.Run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\OpenGL\Silk.NET.OpenGL\Silk.NET.OpenGL.csproj" /> | ||
<ProjectReference Include="..\..\src\Windowing\Silk.NET.Windowing\Silk.NET.Windowing.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Windowing/Silk.NET.Windowing.Common/WindowExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// This file is part of Silk.NET. | ||
// | ||
// You may modify and distribute Silk.NET under the terms | ||
// of the MIT license. See the LICENSE file for details. | ||
|
||
using System; | ||
|
||
namespace Silk.NET.Windowing.Common | ||
{ | ||
public static class WindowExtensions | ||
{ | ||
public static T Invoke<T>(this IWindow window, Func<T> t) | ||
{ | ||
return (T) window.Invoke(t); | ||
} | ||
|
||
public static void Invoke(this IWindow window, Action t) | ||
{ | ||
window.Invoke(t); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.