TGA and RGB image loading

This commit is contained in:
trotFunky 2019-09-25 00:36:57 +02:00
parent bc4f402580
commit 2fdbf21e28
7 changed files with 169 additions and 3 deletions

38
src/Texture.h Normal file
View file

@ -0,0 +1,38 @@
//
// Created by trotfunky on 24/09/2019.
//
#ifndef TESTS_OPENGL_TEXTURE_H
#define TESTS_OPENGL_TEXTURE_H
#include <GL/glut.h>
#include <string>
#include <fstream>
#include <iostream>
class Texture {
public:
uint16_t width;
uint16_t height;
/// Number of bits describing the colors : 24 (RGB) or 32 (RGBA)
uint8_t color_bits;
uint8_t* image_data;
uint32_t opengl_id[1];
Texture();
~Texture();
/// Load an RGBA image from an RGB TGA file
bool load_rgb_tga(const std::string& rgb_filename);
/// Load an RGBA image from an rgb and an alpha tga file
bool load_rgba_tga(const std::string& rgb_filename,const std::string& mask_filename);
private:
/// Load TGA image file to an array
bool load_tga(const std::string& filename, uint8_t*& data_array);
};
#endif //TESTS_OPENGL_TEXTURE_H