minor changes and added namespace to avoid conflicts when integrating with PanoPainter
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
#include "pch.h"
|
||||
#include "texture.h"
|
||||
#include "image.h"
|
||||
#include "util.h"
|
||||
|
||||
std::map<uint16_t, Texture2D> TextureManager::m_textures;
|
||||
@@ -15,6 +14,11 @@ bool TextureManager::load(const char* path)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TextureManager::assign(uint16_t id, GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint format/* = GL_RGBA*/)
|
||||
{
|
||||
m_textures[id].assign(tex, w, h, format);
|
||||
}
|
||||
|
||||
Texture2D& TextureManager::get(uint16_t id)
|
||||
{
|
||||
return m_textures[id];
|
||||
@@ -31,14 +35,23 @@ bool Texture2D::create(int width, int height, GLint format, const uint8_t* data)
|
||||
unbind();
|
||||
return true;
|
||||
}
|
||||
bool Texture2D::create(const Image& img)
|
||||
bool Texture2D::create(const ui::Image& img)
|
||||
{
|
||||
static GLint formats[] = { 0, 0, GL_RGB, GL_RGBA };
|
||||
return create(img.width, img.height, formats[img.comp - 1], img.data());
|
||||
}
|
||||
|
||||
void Texture2D::assign(GLuint tex, int w/* = -1*/, int h/* = -1*/, GLuint format/* = GL_RGBA*/)
|
||||
{
|
||||
m_tex = tex;
|
||||
m_width = w;
|
||||
m_height = h;
|
||||
m_format = format;
|
||||
}
|
||||
|
||||
bool Texture2D::load(std::string filename)
|
||||
{
|
||||
Image img;
|
||||
ui::Image img;
|
||||
if (!img.load(filename))
|
||||
return false;
|
||||
return create(img);
|
||||
|
||||
Reference in New Issue
Block a user