kick
/Users/morten/Programmering/cpp/kick/src/kick/texture/texture2d_data.cpp
00001 //
00002 // Created by Morten Nobel-Jørgensen on 19/04/15.
00003 //
00004 
00005 #include "texture2d_data.h"
00006 
00007 kick::Texture2DData::Texture2DData(const std::vector<char>& data, int width, int height)
00008         : mData(data), mWidth(width), mHeight(height) {
00009 }
00010 
00011 const char *kick::Texture2DData::data() const {
00012     return mData.data();
00013 }
00014 
00015 int kick::Texture2DData::height() const {
00016     return mHeight;
00017 }
00018 
00019 int kick::Texture2DData::width() const {
00020     return mWidth;
00021 }
00022 
00023 glm::vec4 &kick::Texture2DData::vec4(int x, int y) {
00024     glm::vec4* ptr = reinterpret_cast<glm::vec4*>(mData.data());
00025     return ptr[y* width() +  x];
00026 }
00027 
00028 glm::vec3 &kick::Texture2DData::vec3(int x, int y) {
00029     glm::vec3* ptr = reinterpret_cast<glm::vec3*>(mData.data());
00030     return ptr[y* width() +  x];
00031 }
00032 
00033 glm::vec2 &kick::Texture2DData::vec2(int x, int y) {
00034     glm::vec2* ptr = reinterpret_cast<glm::vec2*>(mData.data());
00035     return ptr[y* width() +  x];
00036 }
00037 
00038 float &kick::Texture2DData::vec1(int x, int y) {
00039     float* ptr = reinterpret_cast<float*>(mData.data());
00040     return ptr[y* width() +  x];
00041 }
00042 
00043 uint8_t *kick::Texture2DData::vec4uc(int x, int y) {
00044     uint8_t* ptr = reinterpret_cast<uint8_t*>(mData.data());
00045     return ptr+ (y*width() +  x)*4;
00046 }
00047 
00048 uint8_t *kick::Texture2DData::vec3uc(int x, int y) {
00049     uint8_t* ptr = reinterpret_cast<uint8_t*>(mData.data());
00050     return ptr+ (y*width() +  x)*3;
00051 }
00052 
00053 uint8_t *kick::Texture2DData::vec2uc(int x, int y) {
00054     uint8_t* ptr = reinterpret_cast<uint8_t*>(mData.data());
00055     return ptr+ (y*width() +  x)*2;
00056 }
00057 
00058 uint8_t &kick::Texture2DData::vec1uc(int x, int y) {
00059     uint8_t* ptr = reinterpret_cast<uint8_t*>(mData.data());
00060     return ptr[y*width() +  x];
00061 }
 All Classes Functions Variables