I’m interested in how poeple structure their shader code. It’s probably easiest if I explain the simplistic solution I have just now.
A Model is a list of Parts, one for each Material (to reduce the number of texture binds).
A Part has a VertexArray (for the vertex data) and a Material (for the texture and shader info).
So to draw a Model the psuedo-code is
Foreach part Do part.material.beginUsing() // glUseProgram, glBindTexture etc. part.vertexArray.beginUsing() // glBindBuffer, glEnableClientState, glVertexPointer etc. glDrawArrays(GL_TRIANGLES, 0, part.numFaces*3) part.vertexArray.endUsing() part.material.endUsing() Done
As I said, pretty simplistic. I’m now wanting to improve things and I’m looking to see what other people have done (just high level description is fine).
One problem is I’m not sure what requirements I want. Some of the things I’m thinking about are; how would I have an “effect” shader, i.e. the Model gets drawn as usual, but also use a shader to do something else, or how to deal with setting uniforms to different values for each instance of a Model.
Really just looking for some inspiration on what path to go down since I’m sure people have some nice solutions.