Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Don't use the old fixed-function pipeline, create VAOs and VBOs(<a href="http://www.opengl.org/wiki/Vertex_Specification" rel="nofollow">http://www.opengl.org/wiki/Vertex_Specification</a>) for your vertex attributes of each sphere. </p> <p>Edit: (added more basics about VBOs and VAOs) When you are rendering without VBOs, the geometry data is send each time you render a frame. Using VBOs allows you to send model data to your graphics card and then to render without the cpu-gpu bottleneck.</p> <pre><code>glGenBuffers(1, &amp;vboHandle); // create vbo glBindBuffer(target, vboHandle); // bind vbo glBufferData(target, size, data, usage); // send vertex data (position, normals, ..) </code></pre> <p>then you have to establish a connection between your VBO data and shader attributes</p> <pre><code>// get location of the in-attribute of the shader program vertexLocation = glGetAttribLocation(programHandle,"vertex"); // activate desired VBO glBindBuffer(GL_ARRAY_BUFFER, vboHandle); // set attribute-pointer glVertexAttribPointer(vertexLocation, 4, GL_FLOAT, GL_FALSE, 0, 0); // finally enable attribute-array glEnableVertexAttribArray(vertexLocation); </code></pre> <p>VAOs are used to organize your VBOs - Usually you end up with the following problem:</p> <pre><code>enable vertex attrib1 enable vertex attrib2 enable vertex attrib3 renderModel disable vertex attrib1 disable vertex attrib2 disable vertex attrib3 </code></pre> <p>With VAOs you reduce the code effort to</p> <pre><code>enable VAO renderModel disable VAO </code></pre> <p>So a combined code fragment may look like:</p> <pre><code>// Create and bind VAO glGenVertexArrays(1, &amp;vaoId); glBindVertexArray(vaoId); // create and bind vbo glGenBuffers(1, &amp;vboId); glBindBuffer(GL_ARRAY_BUFFER, vboId); glBufferData(GL_ARRAY_BUFFER, size, data, GL_STATIC_DRAW); GLint loc = glGetAttribLocation(programHandle, "attrib1"); glEnableVertexAttribArray(loc); glVertexAttribPointer(loc, 3, GL_FLOAT, GL_FALSE, 0, 0); // other vbos, attrib pointers ... // UnbindVAO glBindVertexArray(0); glBindBuffer(GL_ARRAY_BUFFER, 0); </code></pre> <p>That's probably the minimal amount of information you'll need, I recommend to read the chapters 8 and 12 of the opengl superbible 5th edition. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload