You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using VS2022, OpenTK 4, and .NET 6. Here are a few notes on minor issues I've found in the tutorials (opentk.net/learn). If I have time later on, I'll PR the fixes myself, but I thought I'd note them in an Issue as I run through the tutorial myself. (I know shader programming, but new to OpenTK, and also my wife wants to learn this stuff, so I thought I'd preview the material.)
In Shaders it is necessary to mark the shader.vert and shader.frag files as content to copy to the output directory, otherwise the File.ReadAllText calls in the Shader class constructor will fail. This is done by altering the Copy to Output Directory file property to Copy always:
In Compiling the Shaders, you can't use out int success twice within the same method; I used out int vertOk and out int fragOk (and similarly, later on, out int linkOk):
In Linking Vertex Attributes it may be useful to note that the reader shouldn't add any of the code to their program. How to add that to the program is covered in the following Vertex Array Object section.
In Element Buffer Objects the reader is told, "in OnLoad, below where you initialize the VertexBufferObject, we initialize the ElementBufferObject" however, per the highlighted note which follows (element array buffer can only be bound if there is a VAO bound), that code should actually be added after the VertexArrayObject initialization, not the VertexBufferObject. If the code is written as instructed, the program throws a System.AccessViolation exception.
In Uniforms, the _shader field name is inconsistent with earlier sections; it should be shader without the leading underscore. Additionally earlier sections defined the Handle field in the Shader class as int Handle; which defaults to private scoping; it needs to be explicitly declared as public. Finally, it may be helpful to explicitly instruct the reader to add a new class-level field as Stopwatch timer = new(); and it is then necessary to call timer.Start(); in the constructor, otherwise the elapsed time is always zero and the color will not change.
If I notice anything else when I have time to get back to this, I'll add more posts.
Overall, very clear though!
The text was updated successfully, but these errors were encountered:
I don't know if this is too far off-topic, but for the point about copying the shaders to the output directory, there's another possible issue -- if the only file you modify is a shader, VS doesn't consider that a change that should trigger a build, so the updated shader won't be copied if you run the program again. You have to do a Build -> Clean which is kind of a headache.
I am using VS2022, OpenTK 4, and .NET 6. Here are a few notes on minor issues I've found in the tutorials (opentk.net/learn). If I have time later on, I'll PR the fixes myself, but I thought I'd note them in an Issue as I run through the tutorial myself. (I know shader programming, but new to OpenTK, and also my wife wants to learn this stuff, so I thought I'd preview the material.)
In Shaders it is necessary to mark the shader.vert and shader.frag files as content to copy to the output directory, otherwise the
File.ReadAllText
calls in theShader
class constructor will fail. This is done by altering the Copy to Output Directory file property to Copy always:In Compiling the Shaders, you can't use
out int success
twice within the same method; I usedout int vertOk
andout int fragOk
(and similarly, later on,out int linkOk
):In Linking Vertex Attributes it may be useful to note that the reader shouldn't add any of the code to their program. How to add that to the program is covered in the following Vertex Array Object section.
In Element Buffer Objects the reader is told, "in OnLoad, below where you initialize the VertexBufferObject, we initialize the ElementBufferObject" however, per the highlighted note which follows (element array buffer can only be bound if there is a VAO bound), that code should actually be added after the VertexArrayObject initialization, not the VertexBufferObject. If the code is written as instructed, the program throws a
System.AccessViolation
exception.In Uniforms, the
_shader
field name is inconsistent with earlier sections; it should beshader
without the leading underscore. Additionally earlier sections defined theHandle
field in theShader
class asint Handle;
which defaults to private scoping; it needs to be explicitly declared aspublic
. Finally, it may be helpful to explicitly instruct the reader to add a new class-level field asStopwatch timer = new();
and it is then necessary to calltimer.Start();
in the constructor, otherwise the elapsed time is always zero and the color will not change.If I notice anything else when I have time to get back to this, I'll add more posts.
Overall, very clear though!
The text was updated successfully, but these errors were encountered: