kick
/Users/morten/Programmering/cpp/kick/src/kick/texture/texture2d.h
00001 //
00002 //  texture.h
00003 //  KickCPP
00004 //
00005 //  Created by morten on 16/03/14.
00006 //  Copyright (c) 2014 Morten Nobel-Joergensen. All rights reserved.
00007 //
00008 
00009 #pragma once
00010 
00011 #include <vector>
00012 
00013 #include "kick/core/project_asset.h"
00014 #include "kick/core/kickgl.h"
00015 #include "kick/texture/texture_sampler.h"
00016 #include "kick/texture/image_format.h"
00017 #include "kick/texture/texture2d_data.h"
00018 #include "glm/glm.hpp"
00019 
00020 namespace kick {
00021     class Project;
00022     
00023     class Texture2D : public ProjectAsset {
00024     public:
00025         Texture2D(TextureSampler textureSampler = {});
00026         Texture2D(const Texture2D&) = delete;
00027         Texture2D(Texture2D&& m);
00028         ~Texture2D();
00029 
00030         // Create an empty color texture. A simple alternative to setData
00031         void setEmptyColorTexture(int width = 512, int height = 512, int colorChannels = 4, bool fpTexture = false);
00032 
00033         // Create an empty depth texture. A simple alternative to setData
00034         void setEmptyDepthTexture(int width = 512, int height = 512, int bits = 32, bool fpTexture = false);
00035 
00036         void setData(const Texture2DData& data, const ImageFormat& imageFormat = {});
00037         void setData(int width, int height, const char* data, const ImageFormat& imageFormat = {});
00038 
00039         Texture2DData data();
00040 
00041         // return the runtime usage in bytes
00042         int dataSize();
00043 
00044         void bind(int textureSlot);
00045         int width(){ return mWidth; }
00046         int height(){ return mHeight; }
00047         glm::vec2 size() {return glm::vec2{mWidth, mHeight}; }
00048         void setTextureSampler(const TextureSampler & textureSampler);
00049         TextureSampler textureSampler() const;
00050         ImageFormat imageFormat() const;
00051         friend class TextureRenderTarget;
00052 
00053         void saveBMPImage(std::string filename);
00054     private:
00055         GLuint mTextureid;
00056         int mWidth = -1;
00057         int mHeight = -1;
00058         TextureSampler mTextureSampler;
00059         ImageFormat mImageFormat;
00060     };
00061 }
 All Classes Functions Variables