void RenderJulia(float time) { // draw paramA = cos(time + 0.5f); paramB = sin(time); paramC = 0.0f; color = Vector4f(fabs(paramA) + 0.2f, fabs(paramB) + 0.2f, fabs(paramC) + 0.4f, 1.0); juliaProgram->Bind(); { juliaColorUniform->Set(color); juliaUniformMVP->Set( Matrix4f::ortho(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f) * Matrix4f::scaling(sceneScale.x, sceneScale.y, 1.0f) * Matrix4f::translation(cameraPos.x, cameraPos.y, 0.0f) ); juliaUniformA->Set(paramA); juliaUniformB->Set(paramB); if (juliaUniformDensity) { juliaUniformDensity->Set(density); } quadVBO->Bind( vertexLayout.get() ); device->Draw(TRIANGLE_STRIP, 0, 4); quadVBO->Unbind(); juliaProgram->Unbind(); } }
void Arrow3d::RenderArrow(ScreenBase const & screen, ref_ptr<dp::GpuProgram> program, dp::Color const & color, float dz, bool hasNormals) { program->Bind(); GLFunctions::glBindBuffer(m_bufferId, gl_const::GLArrayBuffer); uint32_t const attributePosition = program->GetAttributeLocation("a_pos"); ASSERT_NOT_EQUAL(attributePosition, -1, ()); GLFunctions::glEnableVertexAttribute(attributePosition); GLFunctions::glVertexAttributePointer(attributePosition, kComponentsInVertex, gl_const::GLFloatType, false, 0, 0); if (hasNormals) { GLFunctions::glBindBuffer(m_bufferNormalsId, gl_const::GLArrayBuffer); uint32_t const attributeNormal = program->GetAttributeLocation("a_normal"); ASSERT_NOT_EQUAL(attributeNormal, -1, ()); GLFunctions::glEnableVertexAttribute(attributeNormal); GLFunctions::glVertexAttributePointer(attributeNormal, 3, gl_const::GLFloatType, false, 0, 0); } dp::UniformValuesStorage uniforms; math::Matrix<float, 4, 4> const modelTransform = CalculateTransform(screen, dz); uniforms.SetMatrix4x4Value("u_transform", modelTransform.m_data); glsl::vec4 const c = glsl::ToVec4(color); uniforms.SetFloatValue("u_color", c.r, c.g, c.b, c.a); dp::ApplyState(m_state, program); dp::ApplyUniforms(uniforms, program); GLFunctions::glDrawArrays(gl_const::GLTriangles, 0, m_vertices.size() / kComponentsInVertex); }