Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: Question regarding glUniform; problem from the arcsynthesis tutorial.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Newbie Newbie
    Join Date
    Dec 2012

    Question regarding glUniform; problem from the arcsynthesis tutorial.

    I'm stuck on a fairly easy problem and was hoping someone could point me in the right direction.

    Problem: With vertCalcOffset.cpp, change it so that it draws two triangles moving in a circle, with one a half loopDuration ahead of the other. Simply change the uniforms after the glDrawArrays call and then make the glDrawArrays call again. Add half of the loop duration to the time before setting it the second time.

    Relevant code:

    Code :
    void display()
    	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    	glUniform1f(elapsedTimeUniform, glutGet(GLUT_ELAPSED_TIME) / 1000.0f);
    	glBindBuffer(GL_ARRAY_BUFFER, positionBufferObject);
    	glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 0, 0);
    	glDrawArrays(GL_TRIANGLES, 0, 3);

    I can render two triangles on top of each other by calling glUniform1f again after the first glDrawArrays call, then calling glDrawArrays again, but the only thing I can seem to do is change the speed of the second triangle. How exactly do I "add" half loop duration to one? I feel like this should be really simple and the solution is right under my nose. Thanks.

    SOLVED: Nevermind, figured it out. It wasn't hitting me why glutGet was being divided by 1000 (because it returns time in milliseconds), once I realized what was happening it was trivial: glUniform1f(elapsedTimeUniform, (glutGet(GLUT_ELAPSED_TIME) + 2500.0f) / 1000.0f);
    Last edited by jse_code; 12-20-2012 at 09:54 PM. Reason: solved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts