2nd Attempt to fix texture rendering on OpenGL 1.1 cards

This commit is contained in:
Enrico Turri 2018-06-21 15:43:34 +02:00
parent b139f38784
commit 75cd436ae5
3 changed files with 12 additions and 6 deletions

View file

@ -397,7 +397,7 @@ void GLVolume::render_using_layer_height() const
GLsizei half_h = h / 2;
//#######################################################################################################################
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//#######################################################################################################################
glBindTexture(GL_TEXTURE_2D, layer_height_texture_data.texture_id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
@ -1586,7 +1586,7 @@ unsigned int _3DScene::TextureBase::finalize()
if (!m_data.empty()) {
// sends buffer to gpu
//#######################################################################################################################
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//#######################################################################################################################
::glGenTextures(1, &m_tex_id);
::glBindTexture(GL_TEXTURE_2D, m_tex_id);

View file

@ -500,6 +500,7 @@ void GLCanvas3D::Bed::_render_prusa(float theta) const
//#######################################################################################################################
::glEnable(GL_TEXTURE_2D);
::glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//#######################################################################################################################
::glEnableClientState(GL_VERTEX_ARRAY);
@ -508,7 +509,9 @@ void GLCanvas3D::Bed::_render_prusa(float theta) const
if (theta > 90.0f)
::glFrontFace(GL_CW);
::glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
//#######################################################################################################################
// ::glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
//#######################################################################################################################
::glBindTexture(GL_TEXTURE_2D, (theta <= 90.0f) ? (GLuint)m_top_texture.get_id() : (GLuint)m_bottom_texture.get_id());
::glVertexPointer(3, GL_FLOAT, 0, (GLvoid*)m_triangles.get_vertices());
::glTexCoordPointer(2, GL_FLOAT, 0, (GLvoid*)m_triangles.get_tex_coords());
@ -988,7 +991,7 @@ void GLCanvas3D::LayersEditing::_render_active_object_annotations(const GLCanvas
GLsizei half_h = h / 2;
//#######################################################################################################################
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//#######################################################################################################################
::glBindTexture(GL_TEXTURE_2D, m_z_texture_id);
::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);

View file

@ -74,7 +74,7 @@ bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmap
// sends data to gpu
//#######################################################################################################################
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
// ::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//#######################################################################################################################
::glGenTextures(1, &m_id);
::glBindTexture(GL_TEXTURE_2D, m_id);
@ -131,13 +131,16 @@ const std::string& GLTexture::get_source() const
void GLTexture::render_texture(unsigned int tex_id, float left, float right, float bottom, float top)
{
::glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
//#######################################################################################################################
// ::glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
//#######################################################################################################################
::glDisable(GL_LIGHTING);
::glEnable(GL_BLEND);
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//#######################################################################################################################
::glEnable(GL_TEXTURE_2D);
::glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
//#######################################################################################################################
::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id);