2016-02-07 15:42:02 -05:00
|
|
|
//
|
|
|
|
// TextureTarget.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 07/02/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef TextureTarget_hpp
|
|
|
|
#define TextureTarget_hpp
|
|
|
|
|
2016-02-07 17:32:38 -05:00
|
|
|
#include "OpenGL.hpp"
|
2016-02-07 15:42:02 -05:00
|
|
|
|
|
|
|
namespace OpenGL {
|
|
|
|
|
2016-04-19 20:51:34 -04:00
|
|
|
/*!
|
|
|
|
A @c TextureTarget is a framebuffer that can be bound as a texture. So this class
|
|
|
|
handles render-to-texture framebuffer objects.
|
|
|
|
*/
|
2016-02-07 15:42:02 -05:00
|
|
|
class TextureTarget {
|
|
|
|
public:
|
2016-04-19 20:51:34 -04:00
|
|
|
/*!
|
|
|
|
Creates a new texture target.
|
|
|
|
|
|
|
|
Throws ErrorFramebufferIncomplete if creation fails.
|
|
|
|
|
|
|
|
@param width The width of target to create.
|
|
|
|
@param height The height of target to create.
|
|
|
|
*/
|
2016-03-07 18:55:15 -05:00
|
|
|
TextureTarget(GLsizei width, GLsizei height);
|
2016-02-07 15:42:02 -05:00
|
|
|
~TextureTarget();
|
|
|
|
|
2016-04-19 20:51:34 -04:00
|
|
|
/*!
|
|
|
|
Binds this target as a framebuffer and sets the @c glViewport accordingly.
|
|
|
|
*/
|
2016-02-07 15:42:02 -05:00
|
|
|
void bind_framebuffer();
|
2016-04-19 20:51:34 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Binds this target as a texture.
|
|
|
|
*/
|
2016-02-07 15:42:02 -05:00
|
|
|
void bind_texture();
|
|
|
|
|
2016-03-07 18:55:15 -05:00
|
|
|
enum {
|
|
|
|
ErrorFramebufferIncomplete
|
|
|
|
};
|
|
|
|
|
2016-02-07 15:42:02 -05:00
|
|
|
private:
|
|
|
|
GLuint _framebuffer, _texture;
|
2016-03-07 18:55:15 -05:00
|
|
|
GLsizei _width, _height;
|
2016-02-07 15:42:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TextureTarget_hpp */
|