MVE - Multi-View Environment mve-devel
Loading...
Searching...
No Matches
texture.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015, Simon Fuhrmann
3 * TU Darmstadt - Graphics, Capture and Massively Parallel Computing
4 * All rights reserved.
5 *
6 * This software may be modified and distributed under the terms
7 * of the BSD 3-Clause license. See the LICENSE.txt file for details.
8 */
9
10#ifndef OGL_TEXTURE_HEADER
11#define OGL_TEXTURE_HEADER
12
13#include <memory>
14
15#include "mve/image.h"
16#include "ogl/defines.h"
17#include "ogl/opengl.h"
18
20
25{
26public:
27 typedef std::shared_ptr<Texture> Ptr;
28 typedef std::shared_ptr<Texture const> ConstPtr;
29
30public:
32 Texture (void);
35
37 static Ptr create (void);
38
40 ~Texture (void);
41
43 void bind (void);
44
46 void upload (mve::ByteImage::ConstPtr image);
47
48private:
49 GLuint tex_id;
50};
51
52/* ---------------------------------------------------------------- */
53
54inline
55Texture::Texture (void)
56{
57 glGenTextures(1, &this->tex_id);
58}
59
60inline
61Texture::Texture (mve::ByteImage::ConstPtr image)
62{
63 glGenTextures(1, &this->tex_id);
64 this->upload(image);
65}
66
67inline Texture::Ptr
68Texture::create (void)
69{
70 return Ptr(new Texture);
71}
72
73inline
74Texture::~Texture (void)
75{
76 glDeleteTextures(1, &this->tex_id);
77}
78
79inline void
80Texture::bind (void)
81{
82 glBindTexture(GL_TEXTURE_2D, this->tex_id);
83}
84
86
87#endif /* OGL_TEXTURE_HEADER */
std::shared_ptr< Image< T > const > ConstPtr
Definition image.h:43
OpenGL texture abstraction.
Definition texture.h:25
std::shared_ptr< Texture > Ptr
Definition texture.h:27
std::shared_ptr< Texture const > ConstPtr
Definition texture.h:28
#define OGL_NAMESPACE_END
Definition defines.h:14
#define OGL_NAMESPACE_BEGIN
Definition defines.h:13