StelTexture.cpp   StelTexture.cpp 
skipping to change at line 27 skipping to change at line 27
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#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 "StelMainGraphicsView.hpp" #include "StelPainter.hpp"
#include <QThread> #include <QThread>
#include <QMutexLocker> #include <QMutexLocker>
#include <QSemaphore> #include <QSemaphore>
#include <QImageReader> #include <QImageReader>
#include <QDir> #include <QDir>
#include <QFile> #include <QFile>
#include <QTemporaryFile> #include <QTemporaryFile>
#include <QSize> #include <QSize>
#include <QHttp> #include <QHttp>
skipping to change at line 96 skipping to change at line 96
if (loadThread && loadThread->isRunning()) if (loadThread && loadThread->isRunning())
{ {
// The thread is currently running, it needs to be properly stopped // The thread is currently running, it needs to be properly stopped
loadThread->terminate(); loadThread->terminate();
loadThread->wait(500); loadThread->wait(500);
} }
if (id!=0) if (id!=0)
{ {
StelPainter::makeMainGLContextCurrent();
if (glIsTexture(id)==GL_FALSE) if (glIsTexture(id)==GL_FALSE)
{ {
qDebug() << "WARNING: in StelTexture::~StelTexture() tried to delete invalid texture with ID=" << id << " Current GL ERROR stat us is " << glGetError(); qDebug() << "WARNING: in StelTexture::~StelTexture() tried to delete invalid texture with ID=" << id << " Current GL ERROR stat us is " << glGetError();
} }
else else
{ {
StelMainGraphicsView::getInstance().getOpenGLWin()-> deleteTexture(id); StelPainter::glContext->deleteTexture(id);
} }
id = 0; id = 0;
} }
delete mutex; delete mutex;
mutex = NULL; mutex = NULL;
} }
/************************************************************************* /*************************************************************************
This method should be called if the texture loading failed for any reasons This method should be called if the texture loading failed for any reasons
*************************************************************************/ *************************************************************************/
skipping to change at line 129 skipping to change at line 130
} }
/************************************************************************* /*************************************************************************
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()
{ {
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;
StelApp::makeMainGLContextCurrent();
#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;
// The texture is not yet fully loaded // The texture is not yet fully loaded
skipping to change at line 239 skipping to change at line 239
// 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())
{ {
errorOccured = true; errorOccured = true;
reportError("Unknown error"); reportError("Unknown error");
return false; return false;
} }
#ifdef USE_OPENGL_ES2
glActiveTexture(GL_TEXTURE0);
#endif
QGLContext::BindOptions opt = QGLContext::InvertedYBindOption; QGLContext::BindOptions opt = QGLContext::InvertedYBindOption;
if (loadParams.filtering==GL_LINEAR) if (loadParams.filtering==GL_LINEAR)
opt |= QGLContext::LinearFilteringBindOption; opt |= QGLContext::LinearFilteringBindOption;
// Mipmap seems to be pretty buggy on windows.. // Mipmap seems to be pretty buggy on windows..
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
if (loadParams.generateMipmaps==true) if (loadParams.generateMipmaps==true)
opt |= QGLContext::MipmapBindOption; opt |= QGLContext::MipmapBindOption;
#endif #endif
skipping to change at line 264 skipping to change at line 260
if (qImage.isGrayscale()) if (qImage.isGrayscale())
{ {
glformat = qImage.hasAlphaChannel() ? GL_LUMINANCE_ALPHA : G L_LUMINANCE; glformat = qImage.hasAlphaChannel() ? GL_LUMINANCE_ALPHA : G L_LUMINANCE;
} }
else if (qImage.hasAlphaChannel()) else if (qImage.hasAlphaChannel())
{ {
glformat = GL_RGBA; glformat = GL_RGBA;
} }
else else
glformat = GL_RGB; glformat = GL_RGB;
id = StelMainGraphicsView::getInstance().getOpenGLWin()->bindTexture
(qImage, GL_TEXTURE_2D, glformat, opt); Q_ASSERT(StelPainter::glContext==QGLContext::currentContext());
#ifdef USE_OPENGL_ES2
glActiveTexture(GL_TEXTURE0);
#endif
id = StelPainter::glContext->bindTexture(qImage, GL_TEXTURE_2D, glfo
rmat, opt);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, loadParams.wrapMod e); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, loadParams.wrapMod e);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, loadParams.wrapMod e); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, loadParams.wrapMod e);
StelApp::makeMainGLContextCurrent();
// Release shared memory // Release shared memory
qImage = QImage(); qImage = QImage();
// Report success of texture loading // Report success of texture loading
emit(loadingProcessFinished(false)); emit(loadingProcessFinished(false));
return true; return true;
} }
 End of changes. 7 change blocks. 
11 lines changed or deleted 10 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/