CMSC23700 Common Code Library
Support code for CS23700 programming projects
cs237-texture.hxx
Go to the documentation of this file.
1 
8 /*
9  * COPYRIGHT (c) 2013 John Reppy (http://cs.uchicago.edu/~jhr)
10  * All rights reserved.
11  */
12 
13 #ifndef _CS237_TEXTURE_HXX_
14 #define _CS237_TEXTURE_HXX_
15 
16 #ifndef _CS237_HXX_
17 #error "cs237-texture.hxx should not be included directly"
18 #endif
19 
20 namespace cs237 {
21 
22  namespace __detail {
23 
24  class texture_base {
25  public:
26  GLuint Id() const { return this->_obj->_id; }
27  GLenum Target() const { return this->_target; }
28 
30  void Bind ();
31 
33  void Parameter (GLenum param, GLenum value);
34  void Parameter (GLenum param, GLint value);
35  void Parameter (GLenum param, color4f value);
36 
37  protected:
38  texture_base (GLenum target);
39 
40  GLenum _target;
41 
42  private:
43  // wrapper class around GL Texture ID
44  struct Obj {
45  GLuint _id;
46  Obj (GLuint id) : _id(id) { }
47  ~Obj ();
48  };
49 
50  std::shared_ptr<Obj> _obj;
51  };
52 
53  } /* namespace __detail */
54 
57  public:
58 
61  texture1D (image1d *img);
62 
69  texture1D (GLenum target, GLenum ifmt, GLenum wid, GLenum fmt, GLenum ty);
70 
71  };
72 
75  public:
76 
83  texture2D (GLenum target, image2d *img);
84 
92  texture2D (GLenum target, GLenum ifmt, GLenum wid, GLenum ht, GLenum fmt, GLenum ty);
93 
94  };
95 
96 } /* namespace cs237 */
97 
98 #endif /* !_CS237_TEXTURE_HXX_ */
GLuint Id() const
Definition: cs237-texture.hxx:26
GLenum Target() const
Definition: cs237-texture.hxx:27
Definition: cs237-color.hxx:83
Definition: cs237-image.hxx:78
Definition: cs237-texture.hxx:24
texture1D(image1d *img)
create a 1D texture initialized to the given 2D image data.
texture2D(GLenum target, image2d *img)
create a 2D texture initialized to the given 2D image data.
wrapper class for OpenGL 1D textures
Definition: cs237-texture.hxx:56
wrapper class for OpenGL 2D textures
Definition: cs237-texture.hxx:74
Definition: cs237-aabb.hxx:18
GLenum _target
Definition: cs237-texture.hxx:40
void Parameter(GLenum param, GLenum value)
set texture parameter values
Definition: cs237-image.hxx:115
void Bind()
bind this texture as the current texture