-
-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
249 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<AssemblyName>Tutorial</AssemblyName> | ||
<LangVersion>9</LangVersion> | ||
<LangVersion>latest</LangVersion> | ||
<WarningsAsErrors>0618</WarningsAsErrors> | ||
</PropertyGroup> | ||
</Project> |
14 changes: 14 additions & 0 deletions
14
examples/CSharp/OpenGL Demos/SelfContainedTexturedCube/CameraInfo.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,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SelfContainedTexturedCube; | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public ref struct CameraInfo | ||
{ | ||
public Matrix4x4 ProjectionMatrix; | ||
public Matrix4x4 ViewMatrix; | ||
} |
10 changes: 10 additions & 0 deletions
10
examples/CSharp/OpenGL Demos/SelfContainedTexturedCube/Content/Cube.frag
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,10 @@ | ||
#version 430 core | ||
|
||
in vec2 frag_texCoord; | ||
|
||
out vec4 out_color; | ||
|
||
void main() | ||
{ | ||
out_color = vec4(1.0, 0.5, 0.25, 1.0); | ||
} |
23 changes: 23 additions & 0 deletions
23
examples/CSharp/OpenGL Demos/SelfContainedTexturedCube/Content/Cube.vert
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,23 @@ | ||
#version 430 core | ||
|
||
layout (location = 0) in vec3 aPosition; | ||
layout (location = 1) in vec2 aTexCoord; | ||
|
||
out vec2 frag_texCoord; | ||
|
||
layout (std140, binding = 0) uniform CameraInfo | ||
{ | ||
mat4 ProjectionMatrix; | ||
mat4 ViewMatrix; | ||
}; | ||
|
||
layout (std140, binding = 1) uniform DrawInfo | ||
{ | ||
mat4 ModelMatrix; | ||
}; | ||
|
||
void main() | ||
{ | ||
gl_Position = ProjectionMatrix * ViewMatrix * ModelMatrix * vec4(aPosition, 1.0); | ||
frag_texCoord = aTexCoord; | ||
} |
Binary file added
BIN
+41.5 KB
examples/CSharp/OpenGL Demos/SelfContainedTexturedCube/Content/awesomeface.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
51 changes: 51 additions & 0 deletions
51
examples/CSharp/OpenGL Demos/SelfContainedTexturedCube/Cube.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,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Drawing; | ||
using System.Numerics; | ||
|
||
namespace SelfContainedTexturedCube; | ||
|
||
public struct Cube | ||
{ | ||
public VertexPositionTexture[] Vertices => new[] | ||
{ | ||
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(0, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0.5f), new Vector2(1, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector2(0, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector2(0, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector2(1, 0)), | ||
|
||
new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(0, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(0, 0)), | ||
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector2(1, 0)), | ||
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector2(1, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(0, 1)), | ||
|
||
new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0.5f), new Vector2(0, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(1, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(1, 1)), | ||
new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector2(0, 1)), | ||
new VertexPositionTexture(new Vector3(0.5f, 0.5f, -0.5f), new Vector2(0, 0)), | ||
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, -0.5f), new Vector2(1, 0)), | ||
|
||
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, -0.5f), new Vector2(1, 1)), | ||
new VertexPositionTexture(new Vector3(0.5f, -0.5f, -0.5f), new Vector2(0, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0.5f), new Vector2(0, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0.5f), new Vector2(1, 0)), | ||
new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0.5f), new Vector2(1, 1)), | ||
new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0.5f), new Vector2(0, 1)) | ||
}; | ||
|
||
public uint[] Indices => new uint[] | ||
{ | ||
0, 1, 2, 0, 2, 3, | ||
4, 5, 6, 4, 6, 7, | ||
8, 9, 10, 8, 10, 11, | ||
12, 13, 14, 12, 14, 15, | ||
16, 17, 18, 16, 18, 19, | ||
20, 21, 22, 20, 22, 23 | ||
}; | ||
} |
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
23 changes: 23 additions & 0 deletions
23
examples/CSharp/OpenGL Demos/SelfContainedTexturedCube/VertexPositionTexture.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,23 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Numerics; | ||
using System.Runtime.InteropServices; | ||
|
||
namespace SelfContainedTexturedCube; | ||
|
||
[StructLayout(LayoutKind.Sequential)] | ||
public struct VertexPositionTexture | ||
{ | ||
public Vector3 Position; | ||
public Vector2 TexCoord; | ||
|
||
public VertexPositionTexture(Vector3 position, Vector2 texCoord) | ||
{ | ||
Position = position; | ||
TexCoord = texCoord; | ||
} | ||
|
||
// sizeof(Vector3) + sizeof(Vector2) | ||
public const uint SizeInBytes = 20; | ||
} |