diff --git a/doc/method-chaining.dox b/doc/method-chaining.dox index 3c8f99407..19cc2d7e1 100644 --- a/doc/method-chaining.dox +++ b/doc/method-chaining.dox @@ -32,14 +32,15 @@ feature which allows you to chain method calls one after another without repeatedly specifying variable the method is called on. Its primary goal is to reduce unnecessary repeated names, improving code readability. -%Magnum uses this feature for configuring OpenGL objects (such as various mesh -and framebuffer options, shader uniforms etc.). Because OpenGL was designed with -"bind-to-modify" approach, most configuration calls need to bind the object -first and only after that change the parameters (unless @extension{EXT,direct_state_access} -extension is available to avoid this). To reduce unneeded bind calls, %Magnum -binds the object only if it is not already bound somewhere. Method chaining -encourages you to configure whole object in one run, effectively reducing the -number of needed bindings. Consider the following example: +%Magnum uses this feature mainly for configuring OpenGL objects (such as +various mesh and framebuffer options, shader uniforms etc.). Because OpenGL was +designed with "bind-to-modify" approach, most configuration calls internally +need to bind the object first and only after that change the parameters (unless +@extension{EXT,direct_state_access} extension is available to avoid this). To +reduce unneeded bind calls, %Magnum binds the object only if it is not already +bound somewhere. Method chaining encourages you to configure whole object in +one run, effectively reducing the number of needed bindings. Consider the +following example: @code Texture2D *carDiffuseTexture, *carSpecularTexture, *carBumpTexture; diff --git a/src/CubeMapTextureArray.h b/src/CubeMapTextureArray.h index 617e3066d..1529d295a 100644 --- a/src/CubeMapTextureArray.h +++ b/src/CubeMapTextureArray.h @@ -59,8 +59,8 @@ for(std::size_t i = 0; i != 16; ++i) { void* dataPositiveX = ...; Image2D imagePositiveX({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, imagePositiveX); // ... - texture->setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX); - texture->setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); + texture.setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX); + texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); // ... } diff --git a/src/Mesh.h b/src/Mesh.h index a68d8bbe7..00f744af0 100644 --- a/src/Mesh.h +++ b/src/Mesh.h @@ -96,13 +96,13 @@ mesh->setPrimitive(Mesh::Primitive::Triangles) @code // Non-indexed primitive with positions and normals -Primitives::Plane plane; +Trade::MeshData3D plane = Primitives::Plane::solid(); Mesh* mesh; Buffer* vertexBuffer; // Fill vertex buffer with interleaved position and normal data MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, - *plane.positions(0), *plane.normals(0)); + plane.positions(0), plane.normals(0)); // Set primitive and specify layout of interleaved vertex buffer, vertex count // has been already set by MeshTools::interleave() @@ -146,17 +146,17 @@ mesh->setPrimitive(Mesh::Primitive::Triangles) @code // Indexed primitive -Primitives::Cube cube; +Trade::MeshData3D cube = Primitives::Cube::solid(); Buffer *vertexBuffer, *indexBuffer; Mesh* mesh; // Fill vertex buffer with interleaved position and normal data MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw, - *cube.positions(0), *cube.normals(0)); + cube.positions(0), cube.normals(0)); // Fill index buffer with compressed index data MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw, - *cube.indices()); + cube.indices()); // Set primitive and specify layout of interleaved vertex buffer. Index count // and index buffer has been already specified by MeshTools::compressIndices(). diff --git a/src/Texture.h b/src/Texture.h index 70a0115a4..fee04c0e3 100644 --- a/src/Texture.h +++ b/src/Texture.h @@ -89,7 +89,7 @@ texture.setMagnificationFilter(Sampler::Filter::Linear) for(std::size_t i = 0; i != 16; ++i) { void* data = ...; Image2D image({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, image); - texture->setSubImage(0, Vector3i::zAxis(i), image); + texture.setSubImage(0, Vector3i::zAxis(i), image); } // ...