123456789101112131415161718192021222324252627282930313233343536 |
- #include "rendering/wrapper/Texture.h"
- #include "rendering/wrapper/GLWrapper.h"
- Texture::Texture() : texture(0) {
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- }
- Texture::~Texture() {
- glDeleteTextures(1, &texture);
- }
- void Texture::setColorData(int width, int height, const Color4* data) {
- setColorData(width, height, GL_RGBA, data);
- }
- void Texture::setColorData(int width, int height, const Color3* data) {
- setColorData(width, height, GL_RGB, data);
- }
- void Texture::setColorData(int width, int height, const Color2* data) {
- setColorData(width, height, GL_RG, data);
- }
- void Texture::setColorData(int width, int height, const Color1* data) {
- setColorData(width, height, GL_RED, data);
- }
- void Texture::bind() const {
- glActiveTexture(GL_TEXTURE0);
- glBindTexture(GL_TEXTURE_2D, texture);
- }
|