Fawkes API  Fawkes Development Version
texture_drawer.h
1 
2 /***************************************************************************
3  * texture_drawer.h - Skeleton Visualization GUI: texture drawer
4  *
5  * Created: Tue Mar 29 17:06:46 2011 (on the way to Magdeburg for GO2011)
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_OPENNI_SKELGUI_TEXTURE_DRAWER_H_
24 #define _PLUGINS_OPENNI_SKELGUI_TEXTURE_DRAWER_H_
25 
26 #include <utils/misc/autofree.h>
27 
28 namespace firevision {
29 class Camera;
30 }
31 
33 {
34 public:
35  SkelGuiTextureDrawer(unsigned int width, unsigned int height);
36  virtual ~SkelGuiTextureDrawer();
37 
38  virtual void fill_texture() = 0;
39 
40  void draw();
41 
42 protected:
43  void copy_rgb_to_texture(const unsigned char *rgb_buf);
44 
45 private:
46  unsigned int get_closest_power_of_two(unsigned int n);
47  void init_texture();
48  void draw_texture();
49  void draw_rectangle(float topLeftX, float topLeftY, float bottomRightX, float bottomRightY);
50 
51 protected:
52  const unsigned int width_; /**< Width of visible area from texture */
53  const unsigned int height_; /**< Height of visible area from texture */
54 
55  const unsigned int texture_width_; /**< Real texture width */
56  const unsigned int texture_height_; /**< Real texture height */
57 
58  unsigned char *texture_; /**< Texture buffer. */
59 
60 private:
61  fawkes::MemAutoFree texture_raii_;
62  bool texture_initialized_;
63  unsigned int texture_id_;
64  float texture_coords_[8];
65 };
66 
67 #endif
SkelGuiTextureDrawer::texture_
unsigned char * texture_
Texture buffer.
Definition: texture_drawer.h:58
SkelGuiTextureDrawer
Definition: texture_drawer.h:32
SkelGuiTextureDrawer::width_
const unsigned int width_
Width of visible area from texture.
Definition: texture_drawer.h:52
SkelGuiTextureDrawer::texture_height_
const unsigned int texture_height_
Real texture height.
Definition: texture_drawer.h:56
SkelGuiTextureDrawer::copy_rgb_to_texture
void copy_rgb_to_texture(const unsigned char *rgb_buf)
Copy an RGB buffer to texture.
Definition: texture_drawer.cpp:150
SkelGuiTextureDrawer::height_
const unsigned int height_
Height of visible area from texture.
Definition: texture_drawer.h:53
SkelGuiTextureDrawer::SkelGuiTextureDrawer
SkelGuiTextureDrawer(unsigned int width, unsigned int height)
Constructor.
Definition: texture_drawer.cpp:55
fawkes::MemAutoFree
Definition: autofree.h:35
SkelGuiTextureDrawer::fill_texture
virtual void fill_texture()=0
SkelGuiTextureDrawer::draw
void draw()
Draw texture to screen.
Definition: texture_drawer.cpp:116
SkelGuiTextureDrawer::texture_width_
const unsigned int texture_width_
Real texture width.
Definition: texture_drawer.h:55
SkelGuiTextureDrawer::~SkelGuiTextureDrawer
virtual ~SkelGuiTextureDrawer()
Destructor.
Definition: texture_drawer.cpp:69