14 GLint previousAlignment = 0;
17 glGetIntegerv(GL_UNPACK_ALIGNMENT, &previousAlignment);
21 glCreateTextures(GL_TEXTURE_2D, 1, &m_ID);
25 glTextureStorage2D(m_ID, 1, GL_RGBA8,
static_cast<GLsizei
>(m_Width),
static_cast<GLsizei
>(m_Height));
28 glTextureStorage2D(m_ID, 1, GL_RGB8,
static_cast<GLsizei
>(m_Width),
static_cast<GLsizei
>(m_Height));
29 m_HasSemiTransparency =
false;
35 glTextureParameteri(m_ID, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
36 glTextureParameteri(m_ID, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
39 glTextureParameteri(m_ID, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
40 glTextureParameteri(m_ID, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
46 glTextureParameteri(m_ID, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
47 glTextureParameteri(m_ID, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
50 glTextureParameteri(m_ID, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
51 glTextureParameteri(m_ID, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
54 glTextureParameteri(m_ID, GL_TEXTURE_WRAP_S, GL_REPEAT);
55 glTextureParameteri(m_ID, GL_TEXTURE_WRAP_T, GL_REPEAT);
61 glTextureSubImage2D(m_ID, 0, 0, 0,
static_cast<GLsizei
>(m_Width),
static_cast<GLsizei
>(m_Height), GL_RGBA, GL_UNSIGNED_BYTE, pixelData);
64 glTextureSubImage2D(m_ID, 0, 0, 0,
static_cast<GLsizei
>(m_Width),
static_cast<GLsizei
>(m_Height), GL_RGB, GL_UNSIGNED_BYTE, pixelData);
68 if (previousAlignment != 0) {
69 glPixelStorei(GL_UNPACK_ALIGNMENT, previousAlignment);
void Bind(uint32_t slot) const override
Binds the texture to the slot.
~OpenGLTexture2D() override
void Upload(const void *pixelData, const uint32_t width, const uint32_t height, const Params ¶ms) override
bool HasSemiTransparency() const override
Checks if texture has semi transparency.
Params to use when creating a texture.
int32_t m_UnpackAlignment
Generally you want to leave this by default if you're creating a texture from an image,...
PixelFormat m_PixelFormat
bool m_HasSemiTransparency
Whether or no to flag the texture as semi transparent.