97 lines
1.8 KiB
C++
97 lines
1.8 KiB
C++
#ifndef __OPENGLPLAYGROUND_TEXTURE_HH__
|
|
#define __OPENGLPLAYGROUND_TEXTURE_HH__
|
|
|
|
#include <string>
|
|
#include <cstdio>
|
|
#include <cassert>
|
|
#include <algorithm>
|
|
|
|
#include <glbinding/gl/types.h>
|
|
|
|
#include "common.hh"
|
|
|
|
|
|
class Framebuffer {
|
|
public:
|
|
Framebuffer();
|
|
|
|
~Framebuffer();
|
|
|
|
Framebuffer(Framebuffer const& copy) = delete;
|
|
Framebuffer& operator=(Framebuffer const& copy) = delete;
|
|
|
|
Framebuffer(Framebuffer && move);
|
|
|
|
Framebuffer& operator=(Framebuffer && move);
|
|
|
|
void bind() const;
|
|
|
|
gl::GLuint getID() const {
|
|
return _fbID;
|
|
}
|
|
|
|
void attachTexture(GLenum textarget, gl::GLuint texID);
|
|
|
|
private:
|
|
gl::GLuint _fbID;
|
|
};
|
|
|
|
class TextureCubeMap {
|
|
public:
|
|
TextureCubeMap(unsigned size);
|
|
|
|
~TextureCubeMap();
|
|
|
|
TextureCubeMap(TextureCubeMap const& copy) = delete;
|
|
TextureCubeMap& operator=(TextureCubeMap const& copy) = delete;
|
|
|
|
TextureCubeMap(TextureCubeMap && move);
|
|
|
|
TextureCubeMap& operator=(TextureCubeMap && move);
|
|
|
|
void bind() const;
|
|
|
|
gl::GLuint getID() const {
|
|
return _texID;
|
|
}
|
|
|
|
private:
|
|
gl::GLuint _texID;
|
|
};
|
|
|
|
class Texture2D {
|
|
public:
|
|
// Texture2D();
|
|
Texture2D(unsigned width, unsigned height, bool alpha = false);
|
|
Texture2D(std::string const& file);
|
|
Texture2D(SDL_Surface *surface);
|
|
|
|
Texture2D(Texture2D const& copy) = delete;
|
|
Texture2D& operator=(Texture2D const& copy) = delete;
|
|
|
|
Texture2D(Texture2D&& move);
|
|
Texture2D& operator=(Texture2D&& move);
|
|
|
|
~Texture2D();
|
|
|
|
void bind() const;
|
|
|
|
void copyFromSurface(SDL_Surface *src);
|
|
SDLSurfaceUPtr copyToSurface();
|
|
|
|
unsigned getWidth() const { return width_; }
|
|
unsigned getHeight() const { return height_; }
|
|
bool getAlpha() const { return alpha_; }
|
|
|
|
private:
|
|
|
|
void _glCreate(unsigned width, unsigned height, bool alpha = false);
|
|
|
|
gl::GLuint texID_;
|
|
unsigned width_, height_;
|
|
bool alpha_;
|
|
};
|
|
|
|
|
|
#endif
|