]> Dogcows Code - chaz/yoink/blob - src/Moof/Texture.hh
removed logging from script to fix compile error
[chaz/yoink] / src / Moof / Texture.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
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.
9 *
10 **************************************************************************/
11
12 #ifndef _MOOF_TEXTURE_HH_
13 #define _MOOF_TEXTURE_HH_
14
15 /**
16 * @file Texture.hh
17 * Image-loading and OpenGL texture loading.
18 */
19
20 #include <string>
21
22 #include <boost/shared_ptr.hpp>
23
24 #include <Moof/Image.hh>
25 #include <Moof/OpenGL.hh>
26
27
28 namespace Mf {
29
30
31 class Texture;
32 typedef boost::shared_ptr<Texture> TextureP;
33
34
35 class Texture : public Image
36 {
37 public:
38
39 /**
40 * Possible orientations for texture coordinates.
41 */
42
43 typedef unsigned TileIndex;
44 static const TileIndex NO_TILE = -1;
45
46 typedef enum
47 {
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.
52 } Orientation;
53
54
55 static TextureP alloc(const std::string& name)
56 {
57 return TextureP(new Texture(name));
58 }
59
60 explicit Texture(const std::string& name);
61
62 void bind() const;
63 GLuint getObject() const;
64
65 static void resetBind();
66
67 void setMinFilter(GLuint filter);
68 void setMagFilter(GLuint filter);
69 void setWrapS(GLuint wrap);
70 void setWrapT(GLuint wrap);
71
72
73 /**
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,
76 * then down.
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
83 * (the GL default).
84 * @return True if index is valid, false otherwise.
85 */
86
87 bool getTileCoords(TileIndex index, Scalar coords[8]) const;
88
89
90 /**
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
95 * flip_and_reverse.
96 * @return True if index is valid, false otherwise.
97 */
98
99 bool getTileCoords(TileIndex index, Scalar coords[8],
100 Orientation what) const;
101
102
103 static bool getPath(std::string& name);
104
105 private:
106
107 class Impl;
108 boost::shared_ptr<Impl> mImpl;
109 };
110
111
112 } // namespace Mf
113
114 #endif // _MOOF_TEXTURE_HH_
115
This page took 0.033746 seconds and 4 git commands to generate.