Move OpenGL image format mapping
This commit is contained in:
@@ -188,9 +188,16 @@ bool Texture2D::create(int width, int height, GLint internal_format, GLint forma
|
||||
}
|
||||
bool Texture2D::create(const Image& img)
|
||||
{
|
||||
static GLint formats[] = { GL_RED, GL_RG, GL_RGB, GL_RGBA };
|
||||
static GLint iformats[] = { GL_R8, GL_RG8, GL_RGB8, GL_RGBA8 };
|
||||
return create(img.width, img.height, iformats[img.comp - 1], formats[img.comp - 1], img.data());
|
||||
const auto format = pp::renderer::gl::texture_format_for_channel_count(static_cast<std::uint32_t>(img.comp));
|
||||
if (format.channel_count == 0U)
|
||||
return false;
|
||||
|
||||
return create(
|
||||
img.width,
|
||||
img.height,
|
||||
static_cast<GLint>(format.internal_format),
|
||||
static_cast<GLint>(format.pixel_format),
|
||||
img.data());
|
||||
}
|
||||
|
||||
void Texture2D::create_mipmaps()
|
||||
|
||||
Reference in New Issue
Block a user