OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
texture.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2020 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_GFX_TEXTURE_HH
20 #define OST_GFX_TEXTURE_HH
21 
22 /*
23  texture
24 
25  Author: Ansgar Philippsen
26 */
27 
28 #include <boost/shared_array.hpp>
29 
30 #include "module_config.hh"
31 #include "glext_include.hh"
32 
33 namespace ost { namespace gfx {
34 
35 struct Bitmap;
36 
37 class Texture
38 {
39 public:
41  w_(0),
42  h_(0),
43  d_()
44  {}
45 
46  Texture(GLint w, GLint h):
47  w_(w),
48  h_(h),
49  d_(new float[4*w*h])
50  {}
51 
52  Texture(const Bitmap& b);
53 
54  bool IsValid() const {return static_cast<bool>(d_);}
55 
56  float* data() {return &d_[0];}
57 
58  GLint width() const {return w_;}
59  GLint height() const {return h_;}
60  GLint format() const {return GL_RGBA;}
61  GLint type() const {return GL_FLOAT;}
62  GLint border() const {return 0;}
63 
64 private:
65  GLint w_,h_;
66  boost::shared_array<float> d_;
67 };
68 
69 }} // ns
70 
71 #endif
GLint border() const
Definition: texture.hh:62
GLint width() const
Definition: texture.hh:58
GLint height() const
Definition: texture.hh:59
GLint type() const
Definition: texture.hh:61
GLint format() const
Definition: texture.hh:60
float * data()
Definition: texture.hh:56
bool IsValid() const
Definition: texture.hh:54
Texture(GLint w, GLint h)
Definition: texture.hh:46