Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>edit</strong>: read some of the comments; responses below.</p> <hr> <p>A couple of random things to try.</p> <pre><code>glBufferData(GL_ARRAY_BUFFER, SizeInBytes, NULL, GL_DYNAMIC_DRAW); </code></pre> <p>Try <code>GL_STATIC_DRAW</code>. It probably won't help in the steady state (since the driver should be noticing that there is not need for reuploads, as there is no modification of the vertex buffer data), but it's worth a shot.</p> <pre><code>glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); //Unbind the buffers glBindBuffer(GL_ARRAY_BUFFER, 0); </code></pre> <p>Don't change the vertex buffer state after each draw, if you don't have to. It it's just one buffer, leave it bound.</p> <pre><code> normal = normalize(gl_NormalMatrix * gl_Normal); /* now normalize the light's direction. Note that according to the OpenGL specification, the light is stored in eye space. Also since we're talking about a directional light, the position field is actually direction */ lightDir = normalize(vec3(gl_LightSource[0].position)); /* compute the cos of the angle between the normal and lights direction. The light is directional so the direction is constant for every vertex. Since these two are normalized the cosine is the dot product. We also need to clamp the result to the [0,1] range. */ NdotL = max(dot(normal, lightDir), 0.0); </code></pre> <p>You can actually optimize this a little bit and save a <code>normalize()</code> (and hence a semi-expensive <code>invsqrt</code>). Note that, for vectors <code>v1</code> and <code>v2</code>, and scalars <code>s1</code> and <code>s2</code>:</p> <pre><code>dot(v1 * s1, v2 * s2) == s1 * s2 * dot(v1, v2); </code></pre> <p>So if <code>v1</code> and <code>v2</code> are unnormalized, you can factor out their squared magnitude, multiply them together, and multiply by the combined <code>invsqrt</code> once to scale their dot product back down.</p> <hr> <p>85k triangles, at about 50 FPS? With a GTX660M I would say you're doing alright. I wouldn't expect to get significantly higher numbers on the hardware you're running.</p> <p>As to the fixed-functionality pipeline -- all the cool kids nowadays are using the fully programmable pipeline. But FF isn't going to lose you perf -- internally the driver compiles the FF state into a set of shaders, so it's being executed on the GPU as a shader anyways.</p> <p>As @JamesSteele mentions, indexed triangles are a good idea, if you can keep good locality of reference in your vertex data. That might require recompiling or otherwise rejiggering your input data though.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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