Lachee / raylib-goplus

A newer version of the Go bindings for Raylib
zlib License
76 stars 6 forks source link

[QoL] Loading a Shader returns a pointer #9

Closed Gamerfiend closed 4 years ago

Gamerfiend commented 4 years ago

The Current Issue When loading a new shader, it returns a pointer to the Shader rather than the Shader struct itself. While this isn't a huge inconvenience, it does require immediate de referencing.

tile.Materials[0].Shader = *r.LoadShader("resources/shaders/simpleLight.vs", "resources/shaders/simpleLight.fs")

This functionality could be changed into two possible ways.. One, we could have it return the struct instead of a pointer.. Secondly it could return both an err and the shader.

The Paradigm to Match

myShader, err := r.LoadShader("...", "...")
if err != nil {
//do stuff
}

tile.Materials[0].Shader = *myShader

OR

tile.Materials[0].Shader = r.LoadShader("resources/shaders/simpleLight.vs", "resources/shaders/simpleLight.fs")

The Proposal The first option would follow a more go style of coding, with the error handling being checked right after loading. The second would have the error handling follow more the C style, and just keep trucking along.

Lachee commented 4 years ago

Commit aaff890 fixes the pointer. This is a breaking change and your code will need to be updated.

Goification of the error message relates to issue #3