textures!
parent
58ff67dc5c
commit
725b6963af
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.25)
|
||||
|
||||
set(BLT_GRAPHICS_VERSION 0.9.16)
|
||||
set(BLT_GRAPHICS_VERSION 0.9.17)
|
||||
set(BLT_GRAPHICS_TEST_VERSION 0.0.1)
|
||||
|
||||
project(BLT_WITH_GRAPHICS VERSION ${BLT_GRAPHICS_VERSION})
|
||||
|
|
|
@ -182,12 +182,12 @@ namespace blt::gfx
|
|||
}
|
||||
};
|
||||
|
||||
struct texture_gl2D_base : public texture_gl
|
||||
struct texture_gl2D : public texture_gl
|
||||
{
|
||||
public:
|
||||
texture_gl2D_base(const texture_data& data, GLint type, GLint colorMode = GL_RGBA8);
|
||||
explicit texture_gl2D(const texture_data& data, GLint colorMode = GL_RGBA8);
|
||||
|
||||
texture_gl2D_base(int width, int height, GLint type, GLint colorMode = GL_RGBA8);
|
||||
texture_gl2D(int width, int height, GLint colorMode = GL_RGBA8);
|
||||
|
||||
void upload(void* data, GLint dataColorMode = GL_RGBA, int level = 0, int x_offset = 0, int y_offset = 0, int sub_width = -1,
|
||||
int sub_height = -1, GLint dataMode = GL_UNSIGNED_BYTE) const;
|
||||
|
@ -207,26 +207,22 @@ namespace blt::gfx
|
|||
void resize(int width, int height);
|
||||
};
|
||||
|
||||
struct texture_gl2D : public texture_gl2D_base
|
||||
struct texture_gl2D_multisample : public texture_gl
|
||||
{
|
||||
private:
|
||||
blt::i32 samples;
|
||||
public:
|
||||
explicit texture_gl2D(const texture_data& data, GLint colorMode = GL_RGBA8): texture_gl2D_base(data, GL_TEXTURE_2D, colorMode)
|
||||
{}
|
||||
texture_gl2D_multisample(int width, int height, blt::i32 samples, GLint colorMode = GL_RGBA8);
|
||||
|
||||
texture_gl2D(int width, int height, GLint colorMode = GL_RGBA8): texture_gl2D_base(width, height, GL_TEXTURE_2D, colorMode)
|
||||
{}
|
||||
};
|
||||
|
||||
struct texture_gl2D_multisample : public texture_gl2D_base
|
||||
inline void updateSize(blt::i32 width, blt::i32 height) final
|
||||
{
|
||||
public:
|
||||
explicit texture_gl2D_multisample(const texture_data& data, GLint colorMode = GL_RGBA8):
|
||||
texture_gl2D_base(data, GL_TEXTURE_2D_MULTISAMPLE, colorMode)
|
||||
{}
|
||||
resize(width, height);
|
||||
}
|
||||
|
||||
texture_gl2D_multisample(int width, int height, GLint colorMode = GL_RGBA8):
|
||||
texture_gl2D_base(width, height, GL_TEXTURE_2D_MULTISAMPLE, colorMode)
|
||||
{}
|
||||
/**
|
||||
* Resizes the internal memory for the texture but does NOT resize the texture image stored
|
||||
*/
|
||||
void resize(int width, int height);
|
||||
};
|
||||
|
||||
struct gl_texture2D_array : public texture_gl
|
||||
|
|
|
@ -95,7 +95,7 @@ void blt::gfx::texture_gl::setDefaults() const
|
|||
#endif
|
||||
}
|
||||
|
||||
void blt::gfx::texture_gl2D_base::upload(void* data, GLint dataColorMode, int level, int x_offset, int y_offset, int sub_width, int sub_height,
|
||||
void blt::gfx::texture_gl2D::upload(void* data, GLint dataColorMode, int level, int x_offset, int y_offset, int sub_width, int sub_height,
|
||||
GLint dataMode) const
|
||||
{
|
||||
if (sub_width < 0)
|
||||
|
@ -108,12 +108,21 @@ void blt::gfx::texture_gl2D_base::upload(void* data, GLint dataColorMode, int le
|
|||
unbind();
|
||||
}
|
||||
|
||||
void blt::gfx::texture_gl2D_base::upload(const blt::gfx::texture_data& file_data) const
|
||||
void blt::gfx::texture_gl2D::upload(const blt::gfx::texture_data& file_data) const
|
||||
{
|
||||
upload((void*) file_data.data(), file_data.channels() == 4 ? GL_RGBA : GL_RGB, 0, 0, 0, file_data.width(), file_data.height());
|
||||
}
|
||||
|
||||
void blt::gfx::texture_gl2D_base::resize(int width, int height)
|
||||
void blt::gfx::texture_gl2D::upload(void* data, int width, int height, GLint dataColorMode, GLint dataMode)
|
||||
{
|
||||
bind();
|
||||
glTexImage2D(textureBindType, 0, textureColorMode, width, height, 0, dataColorMode, dataMode, data);
|
||||
generateMipmaps();
|
||||
unbind();
|
||||
}
|
||||
|
||||
|
||||
void blt::gfx::texture_gl2D::resize(int width, int height)
|
||||
{
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
|
@ -122,7 +131,7 @@ void blt::gfx::texture_gl2D_base::resize(int width, int height)
|
|||
unbind();
|
||||
}
|
||||
|
||||
blt::gfx::texture_gl2D_base::texture_gl2D_base(int width, int height, GLint type, GLint colorMode): texture_gl(width, height, type, colorMode)
|
||||
blt::gfx::texture_gl2D::texture_gl2D(int width, int height, GLint colorMode): texture_gl(width, height, GL_TEXTURE_2D, colorMode)
|
||||
{
|
||||
bind();
|
||||
setDefaults();
|
||||
|
@ -131,22 +140,14 @@ blt::gfx::texture_gl2D_base::texture_gl2D_base(int width, int height, GLint type
|
|||
glTexStorage2D(textureBindType, MIPMAP_LEVELS, colorMode, width, height);
|
||||
}
|
||||
|
||||
blt::gfx::texture_gl2D_base::texture_gl2D_base(const blt::gfx::texture_data& data, GLint type, GLint colorMode): texture_gl(data.width(), data.height(), type, colorMode)
|
||||
blt::gfx::texture_gl2D::texture_gl2D(const blt::gfx::texture_data& data, GLint colorMode):
|
||||
texture_gl(data.width(), data.height(), GL_TEXTURE_2D, colorMode)
|
||||
{
|
||||
bind();
|
||||
setDefaults();
|
||||
glTexStorage2D(textureBindType, 4, colorMode, data.width(), data.height());
|
||||
upload((void*) data.data(), data.channels() == 4 ? GL_RGBA : GL_RGB, 0, 0, 0, data.width(), data.height());
|
||||
bind();
|
||||
//glTexImage2D(textureBindType, 0, GL_RGBA, data.width(), data.height(), 0, data.channels() == 4 ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (void*)data.data());
|
||||
generateMipmaps();
|
||||
unbind();
|
||||
}
|
||||
|
||||
void blt::gfx::texture_gl2D_base::upload(void* data, int width, int height, GLint dataColorMode, GLint dataMode)
|
||||
{
|
||||
bind();
|
||||
glTexImage2D(textureBindType, 0, textureColorMode, width, height, 0, dataColorMode, dataMode, data);
|
||||
generateMipmaps();
|
||||
unbind();
|
||||
}
|
||||
|
@ -167,6 +168,20 @@ void blt::gfx::gl_texture2D_array::upload(void* data, int index, GLint dataColor
|
|||
unbind();
|
||||
}
|
||||
|
||||
blt::gfx::texture_gl2D_multisample::texture_gl2D_multisample(int width, int height, blt::i32 samples, GLint colorMode):
|
||||
texture_gl(width, height, GL_TEXTURE_2D_MULTISAMPLE, colorMode), samples(samples)
|
||||
{
|
||||
bind();
|
||||
setDefaults();
|
||||
glTexImage2DMultisample(textureBindType, samples, colorMode, width, height, GL_TRUE);
|
||||
}
|
||||
|
||||
void blt::gfx::texture_gl2D_multisample::resize(int width, int height)
|
||||
{
|
||||
bind();
|
||||
glTexImage2DMultisample(textureBindType, samples, textureColorMode, width, height, GL_TRUE);
|
||||
}
|
||||
|
||||
blt::gfx::gl_texture2D_array::gl_texture2D_array(int width, int height, int layers, GLint colorMode): texture_gl(width, height, layers, colorMode)
|
||||
{
|
||||
bind();
|
||||
|
|
Loading…
Reference in New Issue