]>
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
> texture_ptr
;
35 class texture
: public image
39 static const int no_tile
= -1;
42 * Possible orientations for texture coordinates.
46 normal
= 0, ///< Normal orientation.
47 flip
= 1, ///< Flip over a horizontal axis.
48 reverse
= 2, ///< Flip over a vertical axis.
49 flip_and_reverse
= 3 ///< Flip over both.
53 static texture_ptr
alloc(const std::string
& name
)
55 return texture_ptr(new texture(name
));
58 explicit texture(const std::string
& name
);
61 GLuint
object() const;
63 static void reset_binding();
65 void min_filter(GLuint filter
);
66 void mag_filter(GLuint filter
);
67 void wrap_s(GLuint wrap
);
68 void wrap_t(GLuint wrap
);
72 * Calculate texture coordinates for a tile at a certain index. Tiles
73 * are indexed start with zero as the to-left tile and moving across,
75 * \param index The tile index.
76 * \param coords An array of scalars where the texture coordinates will
77 * be stored after this call. The first coordinate (u,v) will be in
78 * the first two places and so on until all four coordinates are
79 * stored, therefore requiring enough room for an array of eight
80 * scalars. The winding of the coordinates is always counter-clockwise
82 * \return True if index is valid, false otherwise.
84 bool tile_coordinates(int index
, scalar coords
[8]) const;
87 * This version let's you specify an orientation that will be reflected
88 * in the texture coordinates. This allows you to easily map a texture
89 * backwards or upside-down.
90 * \param what The orientation; can be flip, reverse, or
92 * \return True if index is valid, false otherwise.
94 bool tile_coordinates(int index
, scalar coords
[8], orientation what
) const;
100 boost::shared_ptr
<impl
> impl_
;
106 #endif // _MOOF_TEXTURE_HH_
This page took 0.035479 seconds and 4 git commands to generate.