Browse Source

Documentation clarification and fixes.

pull/277/head
Vladimír Vondruš 13 years ago
parent
commit
c3a5c77f1c
  1. 17
      doc/method-chaining.dox
  2. 4
      src/CubeMapTextureArray.h
  3. 10
      src/Mesh.h
  4. 2
      src/Texture.h

17
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;

4
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);
// ...
}

10
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().

2
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);
}
// ...

Loading…
Cancel
Save