void MovingDots::drawFrame(shared_ptr<StimulusDisplay> display) { // // Update dots // currentTime = getElapsedTime(); if (previousTime != currentTime) { updateParameters(); updateDots(); previousTime = currentTime; if (currentNumDots > 0) { gl::BufferBinding<GL_ARRAY_BUFFER> arrayBufferBinding(dotPositionBuffer); glBufferData(GL_ARRAY_BUFFER, dotPositions.size() * sizeof(decltype(dotPositions)::value_type), dotPositions.data(), GL_STREAM_DRAW); } } if (0 == currentNumDots) { // No dots, so nothing to draw return; } // // Draw the dots // gl::ProgramUsage programUsage(program); gl::VertexArrayBinding vertexArrayBinding(vertexArray); auto currentMVPMatrix = GLKMatrix4Translate(display->getProjectionMatrix(), fieldCenterX->getValue().getFloat(), fieldCenterY->getValue().getFloat(), 0.0); currentMVPMatrix = GLKMatrix4Scale(currentMVPMatrix, currentFieldRadius, currentFieldRadius, 1.0); currentMVPMatrix = GLKMatrix4Rotate(currentMVPMatrix, GLKMathDegreesToRadians(direction->getValue().getFloat()), 0.0, 0.0, 1.0); glUniformMatrix4fv(mvpMatrixUniformLocation, 1, GL_FALSE, currentMVPMatrix.m); #if !MWORKS_OPENGL_ES gl::Enabled<GL_PROGRAM_POINT_SIZE> pointSizeEnabled; #endif glUniform1f(pointSizeUniformLocation, dotSize->getValue().getFloat() * dotSizeToPixels); auto currentColor = GLKVector4Make(red->getValue().getFloat(), green->getValue().getFloat(), blue->getValue().getFloat(), alpha->getValue().getFloat()); glUniform4fv(colorUniformLocation, 1, currentColor.v); gl::Enabled<GL_BLEND> blendEnabled; glBlendEquation(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDrawArrays(GL_POINTS, 0, currentNumDots); }
void Camera::update_projection() { projectionMatrix_ = GLKMatrix4MakePerspective(GLKMathDegreesToRadians(fov_), aspectRatio_, near_, far_); }