giawa / opengl4csharp

OpenGL 4 Bindings (partially based on OpenTK) for C#
Other
234 stars 61 forks source link

Added VAO.DrawProgram() function which uses the current ShaderProgram #40

Closed gepbird closed 4 years ago

gepbird commented 4 years ago

VAO has a DrawProgram(ShaderProgram) function. Since the ShaderProgram in the VAO is already known by the constructor, it'd make sense to use that. I added a DrawProgram() to do exactly that.

TheAIBot commented 4 years ago

The proposed DrawProgram method does the same as calling Draw. Draw is more efficient as it uses Gl.BindVertexArray(ID); with OGL3 whereas DrawProgram always uses BindAttributes(program);. In the cases where the VAOs own shader is used, the user should use Draw.

Unless i am missing something, then the only thing adding DrawProgram() does is make it possible to draw slower.

gepbird commented 4 years ago

You're right, it does the same thing as Draw. It's a bit weird to me that I need to use a field from an other class. How about making that field private and using a method instead? https://github.com/giawa/opengl4csharp/pull/40/commits/1d89a9ff701c60931831acfba7fe69ace63ee74d

giawa commented 4 years ago

These are public to allow the user to override the draw methods while still having a convenient container. Great care has to be taken to remove anything that was previously public, as some user code may rely on this. For that reason, unless there is some other recommendation, I think it's okay to close this issue for now. Let me know if you would like it re-opened to explore a different path.