Added texture wrap params to global preferences rendering mode (repeat, mirror repeat and clamp to edge)

This commit is contained in:
Paolo Cignoni 2022-12-12 08:46:04 +01:00
parent 744980281d
commit 8d52def3de
3 changed files with 28 additions and 4 deletions

View File

@ -202,7 +202,7 @@ void GLArea::pasteTile()
tileBuffer.format());
uchar* snapPtr = snapBuffer.bits() + (tileBuffer.bytesPerLine() * tileCol) +
((totalCols * tileRow) * tileBuffer.byteCount());
((totalCols * tileRow) * tileBuffer.sizeInBytes());
uchar* tilePtr = tileBuffer.bits();
for (int y = 0; y < tileBuffer.height(); y++) {
@ -2473,10 +2473,28 @@ void GLArea::setupTextureEnv( GLuint textid )
glPushAttrib(GL_ENABLE_BIT);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,textid);
if(glas.textureMagFilter == 0 )
switch(glas.textureWrapST)
{
case 0:
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
break;
case 1:
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT );
break;
case 2:
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
break;
default: assert(0); break;
}
if(glas.textureMagFilter == 0 )
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
else
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
if(glas.textureMinFilter == 0 )
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
else

View File

@ -17,9 +17,12 @@ void GLAreaSetting::initGlobalParameterList(RichParameterList& defaultGlobalPara
QStringList textureMinFilterModes = (QStringList() << "Nearest" << "MipMap");
QStringList textureMagFilterModes = (QStringList() << "Nearest" << "Linear");
QStringList textureWrapSTModes = (QStringList() << "Repeat" << "Mirrored Repeat" << "Clamp to Edge");
defaultGlobalParamSet.addParam(RichEnum(textureMinFilterParam() , 1,textureMinFilterModes,"MeshLab Texture Minification Filtering","MeshLab GLarea's BackGround Color(top corner)"));
defaultGlobalParamSet.addParam(RichEnum(textureMagFilterParam() , 1,textureMagFilterModes,"MeshLab Texture Magnification Filtering","MeshLab GLarea's BackGround Color(top corner)"));
defaultGlobalParamSet.addParam(RichEnum(textureWrapSTParam() , 0,textureWrapSTModes,"MeshLab Texture Clamping","MeshLab Texture Clamping"));
defaultGlobalParamSet.addParam(RichBool(pointDistanceAttenuationParam() , true,"Perspective Varying Point Size","If true the size of the points is drawn with a size proprtional to the distance from the observer."));
defaultGlobalParamSet.addParam(RichBool(pointSmoothParam() , false,"Antialiased Point","If true the points are drawn with small circles instead of fast squared dots."));
defaultGlobalParamSet.addParam(RichFloat(pointSizeParam() , 2.0, "Point Size","The base size of points when drawn"));
@ -45,6 +48,7 @@ void GLAreaSetting::updateGlobalParameterSet( const RichParameterList& rps )
textureMinFilter = rps.getEnum(this->textureMinFilterParam());
textureMagFilter = rps.getEnum(this->textureMagFilterParam());
textureWrapST = rps.getEnum(this->textureWrapSTParam());
pointDistanceAttenuation = rps.getBool(this->pointDistanceAttenuationParam());
pointSmooth = rps.getBool(this->pointSmoothParam());

View File

@ -57,9 +57,11 @@ public:
int textureMagFilter;
int textureMinFilter;
int textureWrapST;
inline static QString textureMinFilterParam() {return "MeshLab::Appearance::textureMinFilter";}
inline static QString textureMagFilterParam() {return "MeshLab::Appearance::textureMagFilter";}
inline static QString textureWrapSTParam() {return "MeshLab::Appearance::textureWrapST";}
bool pointDistanceAttenuation;
inline static QString pointDistanceAttenuationParam() {return "MeshLab::Appearance::pointDistanceAttenuation";}
bool pointSmooth;