Browse Source

Doc++

pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
c3462ea266
  1. 3
      doc/building.dox
  2. 63
      src/AbstractResourceLoader.h
  3. 2
      src/Math/RectangularMatrix.h
  4. 5
      src/ResourceManager.h
  5. 2
      src/Texture.h

3
doc/building.dox

@ -161,7 +161,8 @@ Tested version is `pepper_22`.
Make sure you have `toolchains` Git submodule updated, as Make sure you have `toolchains` Git submodule updated, as
@ref building-download "explained above". Don't forget to adapt `NACL_PREFIX @ref building-download "explained above". Don't forget to adapt `NACL_PREFIX
variable in `generic/NaCl-glibc-x86-32.cmake` and `generic/NaCl-glibc-x86-64.cmake` variable in `generic/NaCl-glibc-x86-32.cmake` and `generic/NaCl-glibc-x86-64.cmake`
to path where your SDK is installed. Default is `/usr/nacl`. to path where your SDK is installed. Default is `/usr/nacl`. You may need to
adapt also `NACL_TOOLCHAIN_PATH` so CMake is able to find the compiler.
Then create build directories for x86-32 and x86-64 and run cmake and make in Then create build directories for x86-32 and x86-64 and run cmake and make in
them. The toolchains needs access to its platform file, so be sure to properly them. The toolchains needs access to its platform file, so be sure to properly

63
src/AbstractResourceLoader.h

@ -30,7 +30,59 @@ namespace Magnum {
/** /**
@brief Base for resource loaders @brief Base for resource loaders
Provides asynchronous resource loading for ResourceManager. Provides (a)synchronous resource loading for ResourceManager.
@section AbstractResourceLoader-usage Usage and subclassing
Usage is done by subclassing. Subclass instances can be added to
ResourceManager using ResourceManager::setLoader(). After adding the loader,
each call to ResourceManager::get() will call load() implementation unless the
resource is already loaded (or loading is in progress). Note that resources
requested before the loader was added are not be affected by the loader.
Subclassing is done by implementing at least load() function. The loading can
be done synchronously or asynchronously (i.e., in another thread). The base
implementation provides interface to ResourceManager and manages loading
progress (which is then available through functions requestedCount(),
loadedCount() and notFoundCount()). You shouldn't access the ResourceManager
directly when loading the data.
Your load() implementation must call the base implementation at the beginning
so ResourceManager is informed about loading state. Then, after your resources
are loaded, call set() to pass them to ResourceManager or call setNotFound()
to indicate that the resource was not found.
You can also implement name() to provide meaningful names for resource keys.
Example implementation for synchronous mesh loader:
@code
class MeshResourceLoader: public AbstractResourceLoader<Mesh> {
public:
void load(ResourceKey key) {
// Indicate that loading has begun
AbstractResourceLoader<Mesh>::load(key);
// Load the mesh...
// Not found
if(!found) {
setNotFound(key);
return;
}
// Found, pass it to resource manager
set(key, mesh, state, policy);
}
};
@endcode
You can then add it to resource manager instance like this:
@code
MyResourceManager manager;
MeshResourceLoader loader;
manager->setLoader(loader);
@endcode
*/ */
template<class T> class AbstractResourceLoader { template<class T> class AbstractResourceLoader {
friend class Implementation::ResourceManagerData<T>; friend class Implementation::ResourceManagerData<T>;
@ -78,11 +130,12 @@ template<class T> class AbstractResourceLoader {
* *
* If the resource isn't yet loaded or loading, state of the resource * If the resource isn't yet loaded or loading, state of the resource
* is set to @ref Resource::ResourceState "ResourceState::Loading" and count of * is set to @ref Resource::ResourceState "ResourceState::Loading" and count of
* requested features is incremented. * requested features is incremented. Depending on implementation the
* resource might be loaded synchronously or asynchronously.
*
* See class documentation for reimplementation guide.
* *
* The resource might be loaded asynchronously and added to * @see ResourceManager::state(), requestedCount(), notFoundCount(),
* ResourceManager when loading is done.
* @see ResourceManager::state(), requestedCount(), notFountCount(),
* loadedCount() * loadedCount()
*/ */
virtual void load(ResourceKey key) = 0; virtual void load(ResourceKey key) = 0;

2
src/Math/RectangularMatrix.h

@ -128,7 +128,7 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
*/ */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<class ...U> inline constexpr RectangularMatrix(T first, U... next): _data{first, next...} { template<class ...U> inline constexpr RectangularMatrix(T first, U... next): _data{first, next...} {
static_assert(sizeof...(next)+1 == cols*rows, "Improper number of arguments passed to Matrix constructor"); static_assert(sizeof...(next)+1 == cols*rows, "Improper number of arguments passed to RectangularMatrix constructor");
} }
#else #else
template<class ...U> inline constexpr RectangularMatrix(T first, U... next); template<class ...U> inline constexpr RectangularMatrix(T first, U... next);

5
src/ResourceManager.h

@ -325,6 +325,8 @@ cube->draw();
@endcode @endcode
- Destroying resource references and deleting manager instance when nothing - Destroying resource references and deleting manager instance when nothing
references the resources anymore. references the resources anymore.
@see AbstractResourceLoader
*/ */
/* Due to too much work involved with explicit template instantiation (all /* Due to too much work involved with explicit template instantiation (all
Resource combinations, all ResourceManagerData...), this class doesn't have Resource combinations, all ResourceManagerData...), this class doesn't have
@ -460,8 +462,7 @@ template<class... Types> class ResourceManager: private Implementation::Resource
/** /**
* @brief Set loader for given type of resources * @brief Set loader for given type of resources
* *
* The loader will affect only loading of resources requested after * See AbstractResourceLoader documentation for more information.
* that.
*/ */
template<class T> inline void setLoader(AbstractResourceLoader<T>* loader) { template<class T> inline void setLoader(AbstractResourceLoader<T>* loader) {
return this->Implementation::ResourceManagerData<T>::setLoader(loader); return this->Implementation::ResourceManagerData<T>::setLoader(loader);

2
src/Texture.h

@ -34,7 +34,7 @@ In shader, the texture is used via `sampler1D`, `sampler2D` or `sampler3D`
depending on dimension count. Note that you can have more than one texture bound depending on dimension count. Note that you can have more than one texture bound
to the shader - the only requirement is to have each texture in another layer. to the shader - the only requirement is to have each texture in another layer.
@section RectangleTextures Rectangle textures @section Texture-rectangle Rectangle textures
If you want to use rectangle textures, set target in constructor to If you want to use rectangle textures, set target in constructor to
`Target::Rectangle` and in shader use `sampler2DRect`. Unlike `sampler2D`, `Target::Rectangle` and in shader use `sampler2DRect`. Unlike `sampler2D`,

Loading…
Cancel
Save