4th Attempt to fix texture rendering on OpenGL 1.1 cards

This commit is contained in:
Enrico Turri 2018-06-22 09:42:56 +02:00
parent be52647440
commit 266a4413bd
2 changed files with 15 additions and 9 deletions

View file

@ -1583,14 +1583,26 @@ GUI::GLCanvas3DManager _3DScene::s_canvas_mgr;
unsigned int _3DScene::TextureBase::finalize() unsigned int _3DScene::TextureBase::finalize()
{ {
if (!m_data.empty()) { //#######################################################################################################################
if ((m_tex_id == 0) && !m_data.empty()) {
// if (!m_data.empty()) {
//#######################################################################################################################
// sends buffer to gpu // sends buffer to gpu
//####################################################################################################################### //#######################################################################################################################
// ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//####################################################################################################################### //#######################################################################################################################
::glGenTextures(1, &m_tex_id); ::glGenTextures(1, &m_tex_id);
::glBindTexture(GL_TEXTURE_2D, m_tex_id); //#######################################################################################################################
::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_tex_width, (GLsizei)m_tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)m_data.data()); ::glBindTexture(GL_TEXTURE_2D, (GLuint)m_tex_id);
// ::glBindTexture(GL_TEXTURE_2D, m_tex_id);
//#######################################################################################################################
//#######################################################################################################################
::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_tex_width, (GLsizei)m_tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)m_data.data());
std::cout << "loaded texture: " << m_tex_width << ", " << m_tex_height << std::endl;
// ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_tex_width, (GLsizei)m_tex_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const GLvoid*)m_data.data());
//#######################################################################################################################
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1); ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1);

View file

@ -3548,9 +3548,6 @@ void GLCanvas3D::_render_warning_texture() const
unsigned int h = _3DScene::get_warning_texture_height(); unsigned int h = _3DScene::get_warning_texture_height();
if ((w > 0) && (h > 0)) if ((w > 0) && (h > 0))
{ {
//###############################################################################################################################
::glDisable(GL_LIGHTING);
//###############################################################################################################################
::glDisable(GL_DEPTH_TEST); ::glDisable(GL_DEPTH_TEST);
::glPushMatrix(); ::glPushMatrix();
::glLoadIdentity(); ::glLoadIdentity();
@ -3584,9 +3581,6 @@ void GLCanvas3D::_render_legend_texture() const
unsigned int h = _3DScene::get_legend_texture_height(); unsigned int h = _3DScene::get_legend_texture_height();
if ((w > 0) && (h > 0)) if ((w > 0) && (h > 0))
{ {
//###############################################################################################################################
::glDisable(GL_LIGHTING);
//###############################################################################################################################
::glDisable(GL_DEPTH_TEST); ::glDisable(GL_DEPTH_TEST);
::glPushMatrix(); ::glPushMatrix();
::glLoadIdentity(); ::glLoadIdentity();