2021-11-27 19:16:41 +00:00
|
|
|
#pragma once
|
2021-11-27 18:52:48 +00:00
|
|
|
|
2021-12-02 21:56:49 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
#include <GL/glew.h>
|
|
|
|
#include <GL/gl.h>
|
|
|
|
#elif
|
2021-11-27 18:52:48 +00:00
|
|
|
#include <gl/glew.h>
|
|
|
|
#include <gl/gl.h>
|
2021-12-02 21:56:49 +00:00
|
|
|
#endif
|
2021-11-27 18:52:48 +00:00
|
|
|
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
|
|
|
#include <SOIL2/SOIL2.h>
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <vector>
|
|
|
|
#include <iostream>
|
|
|
|
|
2021-11-27 19:11:07 +00:00
|
|
|
namespace simpleengine::gfx {
|
2021-11-27 18:52:48 +00:00
|
|
|
class Texture {
|
|
|
|
private:
|
|
|
|
unsigned char* img_data;
|
|
|
|
unsigned int texture_id;
|
|
|
|
|
|
|
|
unsigned int image_type;
|
|
|
|
public:
|
|
|
|
int height;
|
|
|
|
int width;
|
|
|
|
int channels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Construct a new Texture object from a path.
|
|
|
|
*
|
|
|
|
* @param path The path of the image for the Texture.
|
|
|
|
* @param img_2d Whether or not the texture is 2D.
|
|
|
|
* @param mipmap Whether or not to generate mipmaps for this texture.
|
|
|
|
*/
|
2021-11-27 19:11:07 +00:00
|
|
|
Texture(const char* path, bool img_2d = true, bool mipmap = true);
|
2021-11-27 18:52:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Construct a new Texture object from the loaded file buffer.
|
|
|
|
*
|
|
|
|
* @param buffer The bytes of the loaded file.
|
|
|
|
* @param buffer_length The length of the buffer.
|
|
|
|
* @param img_2d Whether or not the texture is 2D.
|
|
|
|
* @param mipmap Whether or not to generate mipmaps for this texture.
|
|
|
|
*/
|
2021-11-27 19:11:07 +00:00
|
|
|
Texture(const unsigned char *const buffer, int buffer_length, bool img_2d = true, bool mipmap = true);
|
2021-11-27 18:52:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Construct a new Texture object from the loaded file buffer.
|
|
|
|
*
|
|
|
|
* @param buffer The bytes of the loaded file.
|
|
|
|
* @param img_2d Whether or not the texture is 2D.
|
|
|
|
* @param mipmap Whether or not to generate mipmaps for this texture.
|
|
|
|
*/
|
2021-11-27 19:11:07 +00:00
|
|
|
Texture(std::vector<unsigned char> buffer, bool img_2d = true, bool mipmap = true);
|
2021-11-27 18:52:48 +00:00
|
|
|
|
2021-11-27 19:11:07 +00:00
|
|
|
void bind() const;
|
2021-11-27 18:52:48 +00:00
|
|
|
};
|
2021-11-27 19:16:41 +00:00
|
|
|
}
|