Thursday, August 4, 2022
HomeGame Developmentopengl - What could be a superb strategy to create an abstraction...

opengl – What could be a superb strategy to create an abstraction for a sport object with out textures?


I’m virtually fairly new to OpenGL improvement and proper now doing a little analysis in Java with LWJGL. However it’s actually not a query about Java or C++ (GLFW, and many others.). It’s about OpenGL > 3 api.

Uncooked circumstances:
I wish to create a sport (utilizing LWJGL), that’s sort of a tile primarily based sport, however proper now i do not wish to use textures. I simply want coloured squares. The squares might be of any measurement (relying on the zoom stage). However they’re simply coloured with one coloration, no texture.

What I would like is defining objects which have measurement, place, and coloration (from a visible perspective).

I want to have a category (sth. like Mannequin or VertexArray or ...) that I can feed with vertex knowledge and an array of indices. The category itself supplies a constructor and a render methodology that maintain all of the OpenGL internals (eg. binding buffers, allow vertex attrib arrays, … and eventually doing the glDrawElements(GL_TRIANGLES, this.rely, GL_UNSIGNED_BYTE, 0); or related).

Now I’m a bit confused about Shaders (as I’m a newbie and my wants are primary, it is simply the Vertex and Fragment shaders).

From what I’ve learn, seen and heard, I discovered the next.

  1. I can present the shader program (vertex and fragment) a buffer containing data. With places I can put in geometric knowledge (x, y, z) in addition to coloring data (r, g, b, a) and (I believe) anything I would like. The vertex shader will devour the info it wants and cross via the info it’s not enthusiastic about (eg. coloration). The Fragment shader is the following aspect in OpenGL’s rendering pipeline, which is able to get the colour as an enter, if outlined within the shader program itself. So it is going to be capable of coloration every pixel within the in accordance coloration.

  2. I can present the shader program a buffer with simply details about geometric positions. I do not wish to put in colours into the buffer which is certain and consumed by the shader(s). I wish to present / change the colour through uniforms.

For me it feels extra pure to generate vertex array objects primarily based on pure geometric knowledge and alter the colour by setting uniforms with values that change whereas updating my sport state.

Which one could be the popular manner of reaching this. Or am I on a flawed path?

Whereas I’m asking this, I really feel that I do not perceive the ideas of uniforms and even placing knowledge into buffers, which might be current to shaders like magic.

Is it simply “Many roads result in Rome” or …?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments