Skip to content

Commit 9eadd44

Browse files
authored
Remove image mutate in OpenGL tutorials (#675)
* Stop mutating image in OpenGL tutorials and use inverted UV instead * Removed unused files
1 parent ddec4ae commit 9eadd44

File tree

12 files changed

+88
-340
lines changed

12 files changed

+88
-340
lines changed

examples/CSharp/OpenGL Tutorials/Tutorial 1.4 - Textures/Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ class Program
1818
private static Texture Texture;
1919
private static Shader Shader;
2020

21+
// OpenGL has image origin in the bottom-left corner.
2122
private static readonly float[] Vertices =
2223
{
2324
//X Y Z U V
24-
0.5f, 0.5f, 0.0f, 1f, 1f,
25-
0.5f, -0.5f, 0.0f, 1f, 0f,
26-
-0.5f, -0.5f, 0.0f, 0f, 0f,
27-
-0.5f, 0.5f, 0.5f, 0f, 1f
25+
0.5f, 0.5f, 0.0f, 1f, 0f,
26+
0.5f, -0.5f, 0.0f, 1f, 1f,
27+
-0.5f, -0.5f, 0.0f, 0f, 1f,
28+
-0.5f, 0.5f, 0.5f, 0f, 0f
2829
};
2930

3031
private static readonly uint[] Indices =

examples/CSharp/OpenGL Tutorials/Tutorial 1.4 - Textures/Texture.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ public unsafe Texture(GL gl, string path)
1616
{
1717
//Loading an image using imagesharp.
1818
Image<Rgba32> img = (Image<Rgba32>) Image.Load(path);
19-
//We need to flip our image as image sharps coordinates has origin (0, 0) in the top-left corner,
20-
//whereas openGL has origin in the bottom-left corner.
21-
img.Mutate(x => x.Flip(FlipMode.Vertical));
2219

20+
// OpenGL has image origin in the bottom-left corner.
2321
fixed (void* data = &MemoryMarshal.GetReference(img.GetPixelRowSpan(0)))
2422
{
2523
//Loading the actual image.

examples/CSharp/OpenGL Tutorials/Tutorial 1.5 - Transformations/Program.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class Program
2323
private static readonly float[] Vertices =
2424
{
2525
//X Y Z U V
26-
0.5f, 0.5f, 0.0f, 1f, 1f,
27-
0.5f, -0.5f, 0.0f, 1f, 0f,
28-
-0.5f, -0.5f, 0.0f, 0f, 0f,
29-
-0.5f, 0.5f, 0.5f, 0f, 1f
26+
0.5f, 0.5f, 0.0f, 1f, 0f,
27+
0.5f, -0.5f, 0.0f, 1f, 1f,
28+
-0.5f, -0.5f, 0.0f, 0f, 1f,
29+
-0.5f, 0.5f, 0.5f, 0f, 0f
3030
};
3131

3232
private static readonly uint[] Indices =

examples/CSharp/OpenGL Tutorials/Tutorial 1.5 - Transformations/Texture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public class Texture : IDisposable
1616
public unsafe Texture(GL gl, string path)
1717
{
1818
Image<Rgba32> img = (Image<Rgba32>) Image.Load(path);
19-
img.Mutate(x => x.Flip(FlipMode.Vertical));
20-
19+
2120
fixed (void* data = &MemoryMarshal.GetReference(img.GetPixelRowSpan(0)))
2221
{
2322
Load(gl, data, (uint) img.Width, (uint) img.Height);

examples/CSharp/OpenGL Tutorials/Tutorial 2.2 - Camera/Program.cs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,47 @@ class Program
3939
private static readonly float[] Vertices =
4040
{
4141
//X Y Z U V
42-
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
43-
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
44-
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
45-
0.5f, 0.5f, -0.5f, 1.0f, 1.0f,
46-
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f,
47-
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
48-
49-
-0.5f, -0.5f, 0.5f, 0.0f, 0.0f,
50-
0.5f, -0.5f, 0.5f, 1.0f, 0.0f,
51-
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
52-
0.5f, 0.5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, 0.0f, 0.0f,
82-
-0.5f, 0.5f, -0.5f, 0.0f, 1.0f
54+
-0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
55+
56+
-0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
57+
-0.5f, 0.5f, -0.5f, 1.0f, 0.0f,
58+
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
59+
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
60+
-0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
61+
-0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
62+
63+
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
64+
0.5f, 0.5f, -0.5f, 1.0f, 0.0f,
65+
0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
66+
0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
67+
0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
68+
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
69+
70+
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
71+
0.5f, -0.5f, -0.5f, 1.0f, 0.0f,
72+
0.5f, -0.5f, 0.5f, 1.0f, 1.0f,
73+
0.5f, -0.5f, 0.5f, 1.0f, 1.0f,
74+
-0.5f, -0.5f, 0.5f, 0.0f, 1.0f,
75+
-0.5f, -0.5f, -0.5f, 0.0f, 0.0f,
76+
77+
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f,
78+
0.5f, 0.5f, -0.5f, 1.0f, 0.0f,
79+
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
80+
0.5f, 0.5f, 0.5f, 1.0f, 1.0f,
81+
-0.5f, 0.5f, 0.5f, 0.0f, 1.0f,
82+
-0.5f, 0.5f, -0.5f, 0.0f, 0.0f
8383
};
8484

8585
private static readonly uint[] Indices =

examples/CSharp/OpenGL Tutorials/Tutorial 2.2 - Camera/Texture.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public class Texture : IDisposable
1515
public unsafe Texture(GL gl, string path)
1616
{
1717
Image<Rgba32> img = (Image<Rgba32>) Image.Load(path);
18-
img.Mutate(x => x.Flip(FlipMode.Vertical));
19-
18+
2019
fixed (void* data = &MemoryMarshal.GetReference(img.GetPixelRowSpan(0)))
2120
{
2221
Load(gl, data, (uint) img.Width, (uint) img.Height);

examples/CSharp/OpenGL Tutorials/Tutorial 3.1 - Ambient Lighting/Texture.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

examples/CSharp/OpenGL Tutorials/Tutorial 3.2 - Diffuse Lighting/Texture.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

examples/CSharp/OpenGL Tutorials/Tutorial 3.3 - Specular Lighting/Texture.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

examples/CSharp/OpenGL Tutorials/Tutorial 3.4 - Materials/Texture.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)