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 repeatedly specifying variable the method is called on. Its primary goal is to
reduce unnecessary repeated names, improving code readability. reduce unnecessary repeated names, improving code readability.
%Magnum uses this feature for configuring OpenGL objects (such as various mesh %Magnum uses this feature mainly for configuring OpenGL objects (such as
and framebuffer options, shader uniforms etc.). Because OpenGL was designed with various mesh and framebuffer options, shader uniforms etc.). Because OpenGL was
"bind-to-modify" approach, most configuration calls need to bind the object designed with "bind-to-modify" approach, most configuration calls internally
first and only after that change the parameters (unless @extension{EXT,direct_state_access} need to bind the object first and only after that change the parameters (unless
extension is available to avoid this). To reduce unneeded bind calls, %Magnum @extension{EXT,direct_state_access} extension is available to avoid this). To
binds the object only if it is not already bound somewhere. Method chaining reduce unneeded bind calls, %Magnum binds the object only if it is not already
encourages you to configure whole object in one run, effectively reducing the bound somewhere. Method chaining encourages you to configure whole object in
number of needed bindings. Consider the following example: one run, effectively reducing the number of needed bindings. Consider the
following example:
@code @code
Texture2D *carDiffuseTexture, *carSpecularTexture, *carBumpTexture; Texture2D *carDiffuseTexture, *carSpecularTexture, *carBumpTexture;

4
src/CubeMapTextureArray.h

@ -59,8 +59,8 @@ for(std::size_t i = 0; i != 16; ++i) {
void* dataPositiveX = ...; void* dataPositiveX = ...;
Image2D imagePositiveX({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, imagePositiveX); Image2D imagePositiveX({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, imagePositiveX);
// ... // ...
texture->setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX); texture.setSubImage(i, CubeMapTextureArray::Coordinate::PositiveX, 0, {}, imagePositiveX);
texture->setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX); texture.setSubImage(i, CubeMapTextureArray::Coordinate::NegativeX, 0, {}, imageNegativeX);
// ... // ...
} }

10
src/Mesh.h

@ -96,13 +96,13 @@ mesh->setPrimitive(Mesh::Primitive::Triangles)
@code @code
// Non-indexed primitive with positions and normals // Non-indexed primitive with positions and normals
Primitives::Plane plane; Trade::MeshData3D plane = Primitives::Plane::solid();
Mesh* mesh; Mesh* mesh;
Buffer* vertexBuffer; Buffer* vertexBuffer;
// Fill vertex buffer with interleaved position and normal data // Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, buffer, Buffer::Usage::StaticDraw, 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 // Set primitive and specify layout of interleaved vertex buffer, vertex count
// has been already set by MeshTools::interleave() // has been already set by MeshTools::interleave()
@ -146,17 +146,17 @@ mesh->setPrimitive(Mesh::Primitive::Triangles)
@code @code
// Indexed primitive // Indexed primitive
Primitives::Cube cube; Trade::MeshData3D cube = Primitives::Cube::solid();
Buffer *vertexBuffer, *indexBuffer; Buffer *vertexBuffer, *indexBuffer;
Mesh* mesh; Mesh* mesh;
// Fill vertex buffer with interleaved position and normal data // Fill vertex buffer with interleaved position and normal data
MeshTools::interleave(mesh, vertexBuffer, Buffer::Usage::StaticDraw, 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 // Fill index buffer with compressed index data
MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw, MeshTools::compressIndices(mesh, indexBuffer, Buffer::Usage::StaticDraw,
*cube.indices()); cube.indices());
// Set primitive and specify layout of interleaved vertex buffer. Index count // Set primitive and specify layout of interleaved vertex buffer. Index count
// and index buffer has been already specified by MeshTools::compressIndices(). // 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) { for(std::size_t i = 0; i != 16; ++i) {
void* data = ...; void* data = ...;
Image2D image({64, 64}, ImageFormat::RGBA, ImageType::UnsignedByte, image); 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