StelTexture.cpp   StelTexture.cpp 
skipping to change at line 19 skipping to change at line 19
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include <cstdlib> #include <cstdlib>
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "glues.h" #include "glues.h"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include <QThread> #include <QThread>
skipping to change at line 103 skipping to change at line 102
} }
void ImageLoader::directLoad() { void ImageLoader::directLoad() {
QImage image = QImage(path); QImage image = QImage(path);
emit finished(image); emit finished(image);
} }
StelTexture::StelTexture() : loader(NULL), downloaded(false), isLoadingImag e(false), StelTexture::StelTexture() : loader(NULL), downloaded(false), isLoadingImag e(false),
errorOccured(false), id(0), avgLuminance( -1.f) errorOccured(false), id(0), avgLuminance( -1.f)
{ {
#if QT_VERSION>=0x040800
initializeGLFunctions();
#endif
width = -1; width = -1;
height = -1; height = -1;
} }
StelTexture::~StelTexture() StelTexture::~StelTexture()
{ {
if (id != 0) if (id != 0)
{ {
StelPainter::makeMainGLContextCurrent(); StelPainter::makeMainGLContextCurrent();
if (glIsTexture(id)==GL_FALSE) if (glIsTexture(id)==GL_FALSE)
skipping to change at line 145 skipping to change at line 147
errorOccured = true; errorOccured = true;
errorMessage = aerrorMessage; errorMessage = aerrorMessage;
isLoadingImage = false; isLoadingImage = false;
// Report failure of texture loading // Report failure of texture loading
emit(loadingProcessFinished(true)); emit(loadingProcessFinished(true));
} }
/************************************************************************* /*************************************************************************
Bind the texture so that it can be used for openGL drawing (calls glBindTe xture) Bind the texture so that it can be used for openGL drawing (calls glBindTe xture)
*************************************************************************/ *************************************************************************/
bool StelTexture::bind() bool StelTexture::bind()
{ {
// qDebug() << "TEST bind" << fullPath; // qDebug() << "TEST bind" << fullPath;
if (id != 0) if (id != 0)
{ {
// The texture is already fully loaded, just bind and return true; // The texture is already fully loaded, just bind and return true;
#ifdef USE_OPENGL_ES2 #ifdef USE_OPENGL_ES2
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
#endif #endif
glBindTexture(GL_TEXTURE_2D, id); glBindTexture(GL_TEXTURE_2D, id);
return true; return true;
} }
if (errorOccured) if (errorOccured)
return false; return false;
if (!isLoadingImage && loader == NULL) { if (!isLoadingImage && loader == NULL) {
isLoadingImage = true; isLoadingImage = true;
loader = new ImageLoader(fullPath, 100); loader = new ImageLoader(fullPath, 100);
connect(loader, SIGNAL(finished(QImage)), this, SLOT(onImage Loaded(QImage))); connect(loader, SIGNAL(finished(QImage)), this, SLOT(onImage Loaded(QImage)));
skipping to change at line 187 skipping to change at line 191
loader = NULL; loader = NULL;
} }
/************************************************************************* /*************************************************************************
Return the width and heigth of the texture in pixels Return the width and heigth of the texture in pixels
*************************************************************************/ *************************************************************************/
bool StelTexture::getDimensions(int &awidth, int &aheight) bool StelTexture::getDimensions(int &awidth, int &aheight)
{ {
if (width<0 || height<0) if (width<0 || height<0)
{ {
if (!qImage.isNull()) if (!qImage.isNull())
{ {
width = qImage.width(); width = qImage.width();
height = qImage.height(); height = qImage.height();
} }
else else
{ {
// Try to get the size from the file without loading data // Try to get the size from the file without loading data
QImageReader im(fullPath); QImageReader im(fullPath);
if (!im.canRead()) if (!im.canRead())
{ {
return false; return false;
} }
QSize size = im.size(); QSize size = im.size();
width = size.width(); width = size.width();
height = size.height(); height = size.height();
} }
} }
awidth = width; awidth = width;
aheight = height; aheight = height;
return true; return true;
} }
// Actually load the texture to openGL memory // Actually load the texture to openGL memory
bool StelTexture::glLoad() bool StelTexture::glLoad()
{ {
if (qImage.isNull()) if (qImage.isNull())
 End of changes. 6 change blocks. 
1 lines changed or deleted 7 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/