Crossbones+ - Reputation: 8703
Posted 05 November 2012 - 12:12 AM
For that I need to know the general structure of a render if I want to avoid massive refactoring every now and then when I discover new functionality. So that's the issue, what's the general structure of a render? What kind of methods it would involve? What about the parameters of those methods? It's possible to make some generalized "OpenGLClass" or it's better to tailor it for what you currently need and leave it at that?
I'm currently trying with a "GLClass" . Its constructor sets up the display size and the context. It has a few methods:
loadShader(String shaderfile, int shaderType) which takes the location of a file in the form of a string, reads it, compiles it, and returns its integer Id.
createShaderProgram(int shaderIdArray) which takes an array of compiled shader Ids and creates a program out of them, storing its Id into an attribute of GLClass.
draw() which is currently a mess and the incoming parameters change everytime I learn a new way of drawing things (ie, first with vbos, then with vaos, then with interleaved vbos with color and vertex information, etc) and I'm not sure what should do.
disposeOfGL() which deletes all OpenGL's buffers that changes as often as the draw() method.
I haven't come across good ideas for making a "createVAO" method since it always changes depending on how many vbos it has, or how they're organized.
I'm not sure either what GLClass object should store. For now it stores the Id of everything I'm using (vbos, vaos, shaders, etc) though I'm actually passing a lot of those from the main class to the methods as parameters instead of reading them directly from the GLClass object.
I also need to know what kind of other methods should have in the future, load model? load texture? pass textures/models to the gpu?
I understand that I know very little about OpenGL, so maybe its better just to code what I need right now to keep learning and then start over once I can distinguish what can be done and what not, but I'd need someone with more understanding of OpenGL to clarify that for me.
"I AM ZE EMPRAH OPENGL 3.3 THE CORE, I DEMAND FROM THEE ZE SHADERZ AND MATRIXEZ"