mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-13 17:58:03 -06:00
Changed use of GL_LIGHTING logic and code cleanup
This commit is contained in:
parent
ac7d21b50a
commit
15c69a90ec
4 changed files with 7 additions and 71 deletions
|
@ -73,15 +73,10 @@ bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmap
|
|||
|
||||
// sends data to gpu
|
||||
|
||||
//#######################################################################################################################
|
||||
::glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
//#######################################################################################################################
|
||||
::glGenTextures(1, &m_id);
|
||||
::glBindTexture(GL_TEXTURE_2D, m_id);
|
||||
//####################################################################################################################################################
|
||||
::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data());
|
||||
// ::glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, (GLsizei)m_width, (GLsizei)m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data());
|
||||
//####################################################################################################################################################
|
||||
if (generate_mipmaps)
|
||||
{
|
||||
// we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
|
||||
|
@ -134,21 +129,10 @@ 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);
|
||||
//#######################################################################################################################
|
||||
|
||||
//#######################################################################################################################
|
||||
bool lighting_enabled = ::glIsEnabled(GL_LIGHTING);
|
||||
//#######################################################################################################################
|
||||
|
||||
::glDisable(GL_LIGHTING);
|
||||
::glEnable(GL_BLEND);
|
||||
::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
//#######################################################################################################################
|
||||
::glEnable(GL_TEXTURE_2D);
|
||||
::glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||
//#######################################################################################################################
|
||||
|
||||
::glBindTexture(GL_TEXTURE_2D, (GLuint)tex_id);
|
||||
|
||||
|
@ -161,14 +145,8 @@ void GLTexture::render_texture(unsigned int tex_id, float left, float right, flo
|
|||
|
||||
::glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
//#######################################################################################################################
|
||||
::glDisable(GL_TEXTURE_2D);
|
||||
//#######################################################################################################################
|
||||
::glDisable(GL_BLEND);
|
||||
//#######################################################################################################################
|
||||
if (lighting_enabled)
|
||||
//#######################################################################################################################
|
||||
::glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
void GLTexture::_generate_mipmaps(wxImage& image)
|
||||
|
@ -203,10 +181,7 @@ void GLTexture::_generate_mipmaps(wxImage& image)
|
|||
data[data_id + 3] = (img_alpha != nullptr) ? img_alpha[i] : 255;
|
||||
}
|
||||
|
||||
//####################################################################################################################################################
|
||||
::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data());
|
||||
// ::glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA8, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data());
|
||||
//####################################################################################################################################################
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue