Skip to content
This repository was archived by the owner on Aug 3, 2023. It is now read-only.

Commit 54ed479

Browse files
committed
Fix error with integrated graphics
OpenGL version check can be skipped
1 parent 07c1e4b commit 54ed479

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

Data/Shaders/shader.frag

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ out vec4 FragColor;
44

55
in vec3 fUv;
66

7-
layout (location = 5, binding = 1) uniform sampler2DArray textures;
7+
layout (binding = 1) uniform sampler2DArray textures;
88

99
void main()
1010
{

Program.cs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,19 @@ static void Main(string[] args)
4949
try { version = OpenGLHelper.GetVersion(); } catch { version = "Failed to get version"; }
5050
Console.WriteLine($"OpenGL version: {version}, Min: 4.5.0");
5151
if (int.TryParse(version.Split(' ')[0].Split('.')[0], out int mainVer))
52-
if (mainVer < 4) {
53-
Console.WriteLine("OpenGL version to low. Press any key to exit...");
54-
Console.ReadKey(true);
55-
Environment.Exit(2);
56-
}
57-
else if (int.TryParse(version.Split(' ')[0].Split('.')[1], out int subVer) && mainVer == 4 && subVer < 5) {
58-
Console.WriteLine("OpenGL version to low. Press any key to exit...");
59-
Console.ReadKey(true);
60-
Environment.Exit(2);
61-
}
52+
if (mainVer < 4)
53+
LowVersion();
54+
else if (int.TryParse(version.Split(' ')[0].Split('.')[1], out int subVer) && mainVer == 4 && subVer < 5)
55+
LowVersion();
6256
Window.Run(60d);
6357
}
58+
59+
private static void LowVersion()
60+
{
61+
Console.WriteLine("OpenGL version is low. The editor might not work correctly");
62+
Console.WriteLine("Press ENTER to continue anyway...");
63+
if (Console.ReadKey(true).Key != ConsoleKey.Enter)
64+
Environment.Exit(2);
65+
}
6466
}
6567
}

SubChunk.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ public void Update()
123123
public void Render(Shader s)
124124
{
125125
Matrix4 transform = Matrix4.CreateTranslation(new Vector3(pos.X * VoxelData.ChunkWidth, pos.Y * VoxelData.ChunkHeight, pos.Z * VoxelData.ChunkWidth));
126-
//transform *= Matrix4.CreateRotationX(-90f);
126+
127127
s.Bind();
128128
s.UploadMat4("uTransform", ref transform);
129129
GL.ActiveTexture(TextureUnit.Texture1);
130130
GL.BindTexture(TextureTarget.Texture2DArray, texId);
131-
GL.Uniform1(5, 1);
131+
s.UploadInt("textures", 1);
132132

133133
GL.BindVertexArray(vao);
134134
GL.DrawElements(BeginMode.Triangles, triangles.Count, DrawElementsType.UnsignedInt, 0);

0 commit comments

Comments
 (0)