}
EtcTexture::EtcTexture()
- : m_texture_id(0)
+ : m_texture_id(0), m_uploaded(false)
{
}
glDeleteTextures(1, &m_texture_id);
}
+int EtcTexture::textureId() const
+{
+ if (m_texture_id == 0)
+ glGenTextures(1, &const_cast<EtcTexture *>(this)->m_texture_id);
+ return m_texture_id;
+}
+
void EtcTexture::bind()
{
- if (m_texture_id) {
+ if (m_uploaded && m_texture_id) {
glBindTexture(GL_TEXTURE_2D, m_texture_id);
return;
}
- glGenTextures(1, &m_texture_id);
+ if (m_texture_id == 0)
+ glGenTextures(1, &m_texture_id);
glBindTexture(GL_TEXTURE_2D, m_texture_id);
#ifdef ETC_DEBUG
return;
}
+ m_uploaded = true;
updateBindOptions(true);
}
void bind();
QSize textureSize() const { return m_size; }
- int textureId() const { return m_texture_id; }
+ int textureId() const;
bool hasAlphaChannel() const { return false; }
bool hasMipmaps() const { return false; }
QSize m_size;
QSize m_paddedSize;
GLuint m_texture_id;
+ bool m_uploaded;
};
#endif // ETCPROVIDER_H