mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-14 02:07:54 -06:00
Attempt to fix #1067
This commit is contained in:
parent
33175a02f3
commit
0bd8affab9
2 changed files with 7 additions and 4 deletions
|
@ -79,7 +79,8 @@ bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmap
|
||||||
if (generate_mipmaps)
|
if (generate_mipmaps)
|
||||||
{
|
{
|
||||||
// we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
|
// we manually generate mipmaps because glGenerateMipmap() function is not reliable on all graphics cards
|
||||||
_generate_mipmaps(image);
|
unsigned int levels_count = _generate_mipmaps(image);
|
||||||
|
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 1 + levels_count);
|
||||||
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -149,14 +150,14 @@ void GLTexture::render_texture(unsigned int tex_id, float left, float right, flo
|
||||||
::glDisable(GL_BLEND);
|
::glDisable(GL_BLEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLTexture::_generate_mipmaps(wxImage& image)
|
unsigned int GLTexture::_generate_mipmaps(wxImage& image)
|
||||||
{
|
{
|
||||||
int w = image.GetWidth();
|
int w = image.GetWidth();
|
||||||
int h = image.GetHeight();
|
int h = image.GetHeight();
|
||||||
GLint level = 0;
|
GLint level = 0;
|
||||||
std::vector<unsigned char> data(w * h * 4, 0);
|
std::vector<unsigned char> data(w * h * 4, 0);
|
||||||
|
|
||||||
while ((w > 1) && (h > 1))
|
while ((w > 1) || (h > 1))
|
||||||
{
|
{
|
||||||
++level;
|
++level;
|
||||||
|
|
||||||
|
@ -183,6 +184,8 @@ void GLTexture::_generate_mipmaps(wxImage& image)
|
||||||
|
|
||||||
::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_RGBA, (GLsizei)w, (GLsizei)h, 0, GL_RGBA, GL_UNSIGNED_BYTE, (const void*)data.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return (unsigned int)level;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace GUI {
|
||||||
static void render_texture(unsigned int tex_id, float left, float right, float bottom, float top);
|
static void render_texture(unsigned int tex_id, float left, float right, float bottom, float top);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void _generate_mipmaps(wxImage& image);
|
unsigned int _generate_mipmaps(wxImage& image);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace GUI
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue