fix old mipmaps code: tex size could be = 0

This commit is contained in:
Garux 2018-06-10 01:27:49 +03:00
parent f83dc2e891
commit c3a110bf2c
3 changed files with 5 additions and 17 deletions

View File

@ -155,10 +155,6 @@ void ResampleGamma( float fGamma ){
}
}
inline const int& min_int( const int& left, const int& right ){
return std::min( left, right );
}
int max_tex_size = 0;
const int max_texture_quality = 3;
LatchedInt g_Textures_textureQuality( 3, "Texture Quality" );
@ -230,8 +226,8 @@ void LoadTextureRGBA( qtexture_t* q, unsigned char* pPixels, int nWidth, int nHe
}
int quality_reduction = max_texture_quality - g_Textures_textureQuality.m_value;
int target_width = min_int( gl_width >> quality_reduction, max_tex_size );
int target_height = min_int( gl_height >> quality_reduction, max_tex_size );
const int target_width = std::max( std::min( gl_width >> quality_reduction, max_tex_size ), 1 );
const int target_height = std::max( std::min( gl_height >> quality_reduction, max_tex_size ), 1 );
while ( gl_width > target_width || gl_height > target_height )
{

View File

@ -609,15 +609,11 @@ int TextureBrowser_TotalHeight( TextureBrowser& textureBrowser ){
return textureBrowser.m_nTotalHeight;
}
inline const int& min_int( const int& left, const int& right ){
return std::min( left, right );
}
void TextureBrowser_clampOriginY( TextureBrowser& textureBrowser ){
if ( textureBrowser.originy > 0 ) {
textureBrowser.originy = 0;
}
int lower = min_int( textureBrowser.height - TextureBrowser_TotalHeight( textureBrowser ), 0 );
const int lower = std::min( textureBrowser.height - TextureBrowser_TotalHeight( textureBrowser ), 0 );
if ( textureBrowser.originy < lower ) {
textureBrowser.originy = lower;
}

View File

@ -427,10 +427,6 @@ gboolean xywnd_chasemouse( gpointer data ){
return TRUE;
}
inline const int& min_int( const int& left, const int& right ){
return std::min( left, right );
}
bool XYWnd::chaseMouseMotion( int pointx, int pointy ){
m_chasemouse_delta_x = 0;
m_chasemouse_delta_y = 0;
@ -442,14 +438,14 @@ bool XYWnd::chaseMouseMotion( int pointx, int pointy ){
m_chasemouse_delta_x = std::max( pointx, 0 ) - epsilon;
}
else if ( ( pointx - m_nWidth ) > -epsilon ) {
m_chasemouse_delta_x = min_int( ( pointx - m_nWidth ), 0 ) + epsilon;
m_chasemouse_delta_x = std::min( ( pointx - m_nWidth ), 0 ) + epsilon;
}
if ( pointy < epsilon ) {
m_chasemouse_delta_y = std::max( pointy, 0 ) - epsilon;
}
else if ( ( pointy - m_nHeight ) > -epsilon ) {
m_chasemouse_delta_y = min_int( ( pointy - m_nHeight ), 0 ) + epsilon;
m_chasemouse_delta_y = std::min( ( pointy - m_nHeight ), 0 ) + epsilon;
}
if ( m_chasemouse_delta_y != 0 || m_chasemouse_delta_x != 0 ) {