server/dep/include/g3dlite/G3D/WrapMode.h
Lynx3d ae3ad10bcf [10097] Update G3D up to v8.0b4
+ Got rid of zip lib requirement in G3D...
  Still can re-enable code by defining _HAVE_ZIP...

+ Remove silly X11 lib dependency from G3D
  Code doesn't seem to do anything yet anyway, and even if, we don't want it :p

+ Fix another weird G3D build problem...

+ Remove some __asm usage in g3d, which is not available on Win64
  My editor also decided to remove a ton of trailing white spaces...tss...

+ Reapply G3D fixes for 64bit VC

+ not use SSE specific header when SSE not enabled in *nix

+ Updated project files

+ New vmap_assembler VC90/VC80 Project

+ vmap assembler binaries updates

NOTE: Old vmap fikes expected work (as tests show) with new library version.
      But better use new generated versions. Its different in small parts to bad or good...

(based on Lynx3d's repo commit 44798d3)

Signed-off-by: VladimirMangos <vladimir@getmangos.com>
2010-06-23 06:45:25 +04:00

93 lines
2.1 KiB
C++

/**
@file WrapMode.h
@maintainer Morgan McGuire, http://graphics.cs.williams.edu
@created 2007-04-17
@edited 2007-04-17
Copyright 2000-2010, Morgan McGuire.
All rights reserved.
*/
#ifndef G3D_WrapMode_h
#define G3D_WrapMode_h
#include "G3D/platform.h"
#include "G3D/enumclass.h"
#ifdef IGNORE
# undef IGNORE
#endif
#ifdef ZERO
# undef ZERO
#endif
#ifdef ERROR
# undef ERROR
#endif
namespace G3D {
/**
Describes the behavior of G3D::Texture, G3D::Map2D, G3D::Image3,
etc. when accessing an out-of-bounds pixel. Not all classes support
all modes.
Refer to these as scoped enums, e.g., <code>WrapMode m = WrapMode::CLAMP;</code>.
WrapMode::IGNORE silently discards attempts to write to out
of bounds locations and returns an undefined value for reading
from out of bounds locations.
WrapMode::ERROR generates an error when the
pixel indices are out of bounds
WrapMode::CLAMP makes out of bounds pixels equal to the last in-range pixel along that dimension.
WrapMode::TILE computes out of bounds pixels modulo the dimension
WrapMode::ZERO treats out of bounds values as the zero value, which varies in definition
according to the class used. For example, with a G3D::Texture, ZERO = Color4(0,0,0,0).
Uses the "Intelligent Enum" design pattern
http://www.codeguru.com/cpp/cpp/cpp_mfc/article.php/c4001/
*/
class WrapMode {
public:
/** Don't use this enum; use WrapMode instances instead. */
enum Value {
CLAMP,
TILE,
ZERO,
IGNORE,
ERROR
};
private:
Value value;
public:
G3D_DECLARE_ENUM_CLASS_METHODS(WrapMode);
inline const char* toString() const {
static const char* s[] = {"CLAMP", "TILE", "ZERO", "IGNORE", "ERROR"};
return s[value];
}
inline explicit WrapMode(const std::string& x) : value(ERROR) {
static const char* s[] = {"CLAMP", "TILE", "ZERO", "IGNORE", "ERROR"};
for (int i = 0; i < 5; ++i) {
if (x == s[i]) {
value = (Value)i;
}
}
}
};
} // namespace G3D
G3D_DECLARE_ENUM_CLASS_HASHCODE(G3D::WrapMode);
#endif