Hyprland/src/render/Texture.cpp

33 lines
751 B
C++
Raw Normal View History

2022-04-05 14:33:54 +02:00
#include "Texture.hpp"
CTexture::CTexture() {
// naffin'
}
CTexture::CTexture(wlr_texture* tex) {
RASSERT(wlr_texture_is_gles2(tex), "wlr_texture provided to CTexture that isn't GLES2!");
wlr_gles2_texture_attribs attrs;
wlr_gles2_texture_get_attribs(tex, &attrs);
m_iTarget = attrs.target;
m_iTexID = attrs.tex;
2022-04-05 14:33:54 +02:00
2023-07-11 00:27:13 +02:00
if (m_iTarget == GL_TEXTURE_2D)
2022-04-05 14:33:54 +02:00
m_iType = attrs.has_alpha ? TEXTURE_RGBA : TEXTURE_RGBX;
2023-07-11 00:27:13 +02:00
else
2022-04-05 14:33:54 +02:00
m_iType = TEXTURE_EXTERNAL;
m_vSize = Vector2D(tex->width, tex->height);
}
void CTexture::destroyTexture() {
if (m_iTexID) {
glDeleteTextures(1, &m_iTexID);
m_iTexID = 0;
}
}
void CTexture::allocate() {
2023-07-11 00:27:13 +02:00
if (!m_iTexID)
glGenTextures(1, &m_iTexID);
2022-04-05 14:33:54 +02:00
}