]>
Dogcows Code - chaz/yoink/blob - src/Moof/Texture.hh
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
10 **************************************************************************/
12 #ifndef _MOOF_TEXTURE_HH_
13 #define _MOOF_TEXTURE_HH_
17 * Image-loading and OpenGL texture loading.
22 #include <boost/shared_ptr.hpp>
24 #include <Moof/Image.hh>
25 #include <Moof/OpenGL.hh>
32 typedef boost::shared_ptr
<Texture
> TextureP
;
35 class Texture
: public Image
40 * Possible orientations for texture coordinates.
43 typedef unsigned TileIndex
;
44 static const TileIndex NO_TILE
= -1;
48 NORMAL
= 0, ///< Normal orientation.
49 FLIP
= 1, ///< Flip over a horizontal axis.
50 REVERSE
= 2, ///< Flip over a vertical axis.
51 FLIP_AND_REVERSE
= 3 ///< Flip over both.
55 static TextureP
alloc(const std::string
& name
)
57 return TextureP(new Texture(name
));
60 explicit Texture(const std::string
& name
);
63 GLuint
getObject() const;
65 static void resetBind();
67 void setMinFilter(GLuint filter
);
68 void setMagFilter(GLuint filter
);
69 void setWrapS(GLuint wrap
);
70 void setWrapT(GLuint wrap
);
74 * Calculate texture coordinates for a tile at a certain index. Tiles
75 * are indexed start with zero as the to-left tile and moving across,
77 * @param index The tile index.
78 * @param coords An array of scalars where the texture coordinates will
79 * be stored after this call. The first coordinate (u,v) will be in
80 * the first two places and so on until all four coordinates are
81 * stored, therefore requiring enough room for an array of eight
82 * scalars. The winding of the coordinates is always counter-clockwise
84 * @return True if index is valid, false otherwise.
87 bool getTileCoords(TileIndex index
, Scalar coords
[8]) const;
91 * This version let's you specify an orientation that will be reflected
92 * in the texture coordinates. This allows you to easily map a texture
93 * backwards or upside-down.
94 * @param what The orientation; can be flip, reverse, or
96 * @return True if index is valid, false otherwise.
99 bool getTileCoords(TileIndex index
, Scalar coords
[8],
100 Orientation what
) const;
103 static std::string
getPath(const std::string
& name
);
108 boost::shared_ptr
<Impl
> mImpl
;
114 #endif // _MOOF_TEXTURE_HH_
This page took 0.039599 seconds and 4 git commands to generate.