mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-19 19:14:42 +00:00
Added updateTexture slot. To allow to external plugins to re-load the current texture
This commit is contained in:
parent
33cd07b71b
commit
bf30681bf3
@ -23,7 +23,7 @@
|
||||
/****************************************************************************
|
||||
History
|
||||
|
||||
$Log$
|
||||
$Log: glarea.cpp,v $
|
||||
Revision 1.143 2008/04/22 16:15:45 bernabei
|
||||
By default, tablet events are treated as mouse events
|
||||
|
||||
@ -111,6 +111,7 @@ GLArea::GLArea(QWidget *parent)
|
||||
cfps=0;
|
||||
lastTime=0;
|
||||
hasToPick=false;
|
||||
hasToUpdateTexture=false;
|
||||
helpVisible=false;
|
||||
takeSnapTile=false;
|
||||
activeDefaultTrackball=true;
|
||||
@ -713,11 +714,19 @@ void GLArea::setColorMode(vcg::GLW::ColorMode mode)
|
||||
rm.colorMode = mode;
|
||||
updateGL();
|
||||
}
|
||||
void GLArea::updateTexture()
|
||||
{
|
||||
hasToUpdateTexture = true;
|
||||
}
|
||||
|
||||
// Texture loading done during the first paint.
|
||||
void GLArea::initTexture()
|
||||
{
|
||||
if(!mm()->cm.textures.empty() && mm()->glw.TMId.empty()){
|
||||
if(hasToUpdateTexture)
|
||||
{
|
||||
hasToUpdateTexture = false;
|
||||
}
|
||||
if(!mm()->cm.textures.empty() && mm()->glw.TMId.empty()){
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
for(unsigned int i =0; i< mm()->cm.textures.size();++i){
|
||||
QImage img, imgScaled, imgGL;
|
||||
@ -725,11 +734,11 @@ void GLArea::initTexture()
|
||||
// image has to be scaled to a 2^n size. We choose the first 2^N <= picture size.
|
||||
int bestW=pow(2.0,floor(::log(double(img.width() ))/::log(2.0)));
|
||||
int bestH=pow(2.0,floor(::log(double(img.height()))/::log(2.0)));
|
||||
|
||||
qDebug("texture[ %i ] = %s ( %i x %i )", mm()->cm.textures[i].c_str(),i , imgGL.width(), imgGL.height());
|
||||
imgScaled=img.scaled(bestW,bestH,Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
|
||||
imgGL=convertToGLFormat(imgScaled);
|
||||
qDebug("loaded texture %s. with id %i w %i h %i",mm()->cm.textures[i].c_str(),i, imgGL.width(), imgGL.height());
|
||||
mm()->glw.TMId.push_back(0);
|
||||
|
||||
glGenTextures( 1, (GLuint*)&(mm()->glw.TMId.back()) );
|
||||
glBindTexture( GL_TEXTURE_2D, mm()->glw.TMId.back() );
|
||||
glTexImage2D( GL_TEXTURE_2D, 0, 3, imgGL.width(), imgGL.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, imgGL.bits() );
|
||||
@ -738,8 +747,7 @@ void GLArea::initTexture()
|
||||
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
qDebug("loaded texture %s. in %i",mm()->cm.textures[i].c_str(),mm()->glw.TMId[i]);
|
||||
qDebug(" will be loaded as GL texture id %i ( %i x %i )",mm()->glw.TMId.back() ,imgGL.width(), imgGL.height());
|
||||
}
|
||||
}
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
/****************************************************************************
|
||||
History
|
||||
|
||||
$Log$
|
||||
$Log: glarea.h,v $
|
||||
Revision 1.85 2008/04/22 14:54:38 bernabei
|
||||
Added support for tablet events
|
||||
|
||||
@ -336,6 +336,8 @@ public:
|
||||
// EndEdit is called only when you press again the same button or when you change editor.
|
||||
|
||||
public slots:
|
||||
void updateTexture(); // slot for forcing the texture reload.
|
||||
|
||||
void endEdit(){
|
||||
if(iEdit && currentEditor)
|
||||
{
|
||||
@ -403,7 +405,8 @@ QMap<QString,QCursor> curMap;
|
||||
bool helpVisible; // Help on screen
|
||||
bool trackBallVisible; // Draws the trackball ?
|
||||
bool activeDefaultTrackball; // keep track on active trackball
|
||||
bool hasToPick; // has to pick during the next redraw.
|
||||
bool hasToUpdateTexture; // has to reload textures at the next redraw
|
||||
bool hasToPick; // has to pick during the next redraw.
|
||||
vcg::Point2i pointToPick;
|
||||
|
||||
//shader support
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user