StelTextureMgr.cpp   StelTextureMgr.cpp 
skipping to change at line 102 skipping to change at line 102
setMipmapsMode(); setMipmapsMode();
setWrapMode(); setWrapMode();
setMinFilter(); setMinFilter();
setMagFilter(); setMagFilter();
setDynamicRangeMode(); setDynamicRangeMode();
} }
/************************************************************************* /*************************************************************************
Internal Internal
*************************************************************************/ *************************************************************************/
STextureSP StelTextureMgr::initTex() StelTextureSP StelTextureMgr::initTex()
{ {
STextureSP tex(new STexture()); StelTextureSP tex(new StelTexture());
// Set parameters than can be set for this texture // Set parameters than can be set for this texture
tex->minFilter = ((mipmapsMode==true) ? GL_LINEAR_MIPMAP_NEAREST : m inFilter); tex->minFilter = ((mipmapsMode==true) ? GL_LINEAR_MIPMAP_NEAREST : m inFilter);
tex->magFilter = magFilter; tex->magFilter = magFilter;
tex->wrapMode = wrapMode; tex->wrapMode = wrapMode;
tex->mipmapsMode = mipmapsMode; tex->mipmapsMode = mipmapsMode;
tex->dynamicRangeMode = dynamicRangeMode; tex->dynamicRangeMode = dynamicRangeMode;
return tex; return tex;
} }
/************************************************************************* /*************************************************************************
Load an image from a file and create a new texture from it. Load an image from a file and create a new texture from it.
*************************************************************************/ *************************************************************************/
STextureSP StelTextureMgr::createTexture(const QString& afilename) StelTextureSP StelTextureMgr::createTexture(const QString& afilename)
{ {
if (afilename.isEmpty()) if (afilename.isEmpty())
return STextureSP(); return StelTextureSP();
STextureSP tex = initTex(); StelTextureSP tex = initTex();
try try
{ {
tex->fullPath = StelApp::getInstance().getFileMgr().findFile (afilename); tex->fullPath = StelApp::getInstance().getFileMgr().findFile (afilename);
} }
catch (std::runtime_error e) catch (std::runtime_error e)
{ {
try try
{ {
tex->fullPath = StelApp::getInstance().getFileMgr(). findFile("textures/" + afilename); tex->fullPath = StelApp::getInstance().getFileMgr(). findFile("textures/" + afilename);
} }
catch (std::runtime_error er) catch (std::runtime_error er)
{ {
qWarning() << "WARNING : Can't find texture file " < < afilename << ": " << er.what() << endl; qWarning() << "WARNING : Can't find texture file " < < afilename << ": " << er.what() << endl;
tex->errorOccured = true; tex->errorOccured = true;
return STextureSP(); return StelTextureSP();
} }
} }
tex->downloaded = true; tex->downloaded = true;
if (tex->fullPath.startsWith(":/")) if (tex->fullPath.startsWith(":/"))
{ {
QFile tmpF(tex->fullPath); QFile tmpF(tex->fullPath);
tmpF.open(QIODevice::ReadOnly); tmpF.open(QIODevice::ReadOnly);
tex->downloadedData = tmpF.readAll(); tex->downloadedData = tmpF.readAll();
} }
// Simply load everything // Simply load everything
if (tex->imageLoad() && tex->glLoad()) if (tex->imageLoad() && tex->glLoad())
return tex; return tex;
else else
return STextureSP(); return StelTextureSP();
} }
/************************************************************************* /*************************************************************************
Load an image from a file and create a new texture from it in a new thread . Load an image from a file and create a new texture from it in a new thread .
*************************************************************************/ *************************************************************************/
STextureSP StelTextureMgr::createTextureThread(const QString& url, const QS tring& fileExtension, bool lazyLoading) StelTextureSP StelTextureMgr::createTextureThread(const QString& url, const QString& fileExtension, bool lazyLoading)
{ {
if (url.isEmpty()) if (url.isEmpty())
return STextureSP(); return StelTextureSP();
STextureSP tex = initTex(); StelTextureSP tex = initTex();
if (!url.startsWith("http://")) if (!url.startsWith("http://"))
{ {
// Assume a local file // Assume a local file
try try
{ {
tex->fullPath = StelApp::getInstance().getFileMgr(). findFile(url); tex->fullPath = StelApp::getInstance().getFileMgr(). findFile(url);
} }
catch (std::runtime_error e) catch (std::runtime_error e)
{ {
try try
{ {
tex->fullPath = StelApp::getInstance().getFi leMgr().findFile("textures/" + url); tex->fullPath = StelApp::getInstance().getFi leMgr().findFile("textures/" + url);
} }
catch (std::runtime_error er) catch (std::runtime_error er)
{ {
qWarning() << "WARNING : Can't find texture file " << url << ": " << er.what() << endl; qWarning() << "WARNING : Can't find texture file " << url << ": " << er.what() << endl;
tex->errorOccured = true; tex->errorOccured = true;
return STextureSP(); return StelTextureSP();
} }
} }
tex->downloaded = true; tex->downloaded = true;
} }
else else
{ {
tex->fullPath = url; tex->fullPath = url;
if (fileExtension.isEmpty()) if (fileExtension.isEmpty())
{ {
const int idx = url.lastIndexOf('.'); const int idx = url.lastIndexOf('.');
skipping to change at line 209 skipping to change at line 209
tex->fileExtension = fileExtension; tex->fileExtension = fileExtension;
if (!lazyLoading) if (!lazyLoading)
tex->bind(); tex->bind();
return tex; return tex;
} }
/************************************************************************* /*************************************************************************
Adapt the scaling for the texture. Return true if there was no errors Adapt the scaling for the texture. Return true if there was no errors
This method is re-entrant This method is re-entrant
*************************************************************************/ *************************************************************************/
bool StelTextureMgr::reScale(STexture* tex) bool StelTextureMgr::reScale(StelTexture* tex)
{ {
const unsigned int nbPix = tex->width*tex->height; const unsigned int nbPix = tex->width*tex->height;
const int bitpix = tex->internalFormat*8; const int bitpix = tex->internalFormat*8;
// Scale input image according to the dynamic range parameters // Scale input image according to the dynamic range parameters
if (tex->format==GL_LUMINANCE) if (tex->format==GL_LUMINANCE)
{ {
switch (tex->dynamicRangeMode) switch (tex->dynamicRangeMode)
{ {
case (STextureTypes::Linear): case (StelTextureTypes::Linear):
{ {
if (tex->internalFormat==1) if (tex->internalFormat==1)
{ {
// Assumes already GLubyte = unsigne d char on 8 bits // Assumes already GLubyte = unsigne d char on 8 bits
return true; return true;
} }
if (tex->internalFormat==2) if (tex->internalFormat==2)
{ {
return true; return true;
} }
skipping to change at line 241 skipping to change at line 241
return true; return true;
} }
if (tex->internalFormat==-4) if (tex->internalFormat==-4)
{ {
return true; return true;
} }
// Unsupported format.. // Unsupported format..
qWarning() << "Internal format: " << tex->in ternalFormat << " is not supported for LUMINANCE texture " << tex->fullPath ; qWarning() << "Internal format: " << tex->in ternalFormat << " is not supported for LUMINANCE texture " << tex->fullPath ;
return false; return false;
} }
case (STextureTypes::MinmaxQuantile): case (StelTextureTypes::MinmaxQuantile):
{ {
// Compute the image histogram // Compute the image histogram
int* histo = (int*)calloc(sizeof(int), 1<<bi tpix); int* histo = (int*)calloc(sizeof(int), 1<<bi tpix);
if (tex->internalFormat==1) if (tex->internalFormat==1)
{ {
// We assume unsigned char = GLubyte // We assume unsigned char = GLubyte
GLubyte* data = (GLubyte*)tex->texel s; GLubyte* data = (GLubyte*)tex->texel s;
for (unsigned int i = 0; i <nbPix ; ++i) for (unsigned int i = 0; i <nbPix ; ++i)
++(histo[(int)data[i]]); ++(histo[(int)data[i]]);
skipping to change at line 348 skipping to change at line 348
else else
{ {
// TODO, no scaling is currently done for color images // TODO, no scaling is currently done for color images
return true; return true;
} }
} }
/************************************************************************* /*************************************************************************
Load the image in memory by calling the associated ImageLoader Load the image in memory by calling the associated ImageLoader
*************************************************************************/ *************************************************************************/
bool StelTextureMgr::loadImage(STexture* tex) bool StelTextureMgr::loadImage(StelTexture* tex)
{ {
if (tex->fileExtension.isEmpty()) if (tex->fileExtension.isEmpty())
tex->fileExtension = QFileInfo(tex->fullPath).suffix(); tex->fileExtension = QFileInfo(tex->fullPath).suffix();
QMap<QString, ImageLoader*>::iterator loadFuncIter = imageLoaders.fi nd(tex->fileExtension); QMap<QString, ImageLoader*>::iterator loadFuncIter = imageLoaders.fi nd(tex->fileExtension);
if (loadFuncIter==imageLoaders.end()) if (loadFuncIter==imageLoaders.end())
{ {
qWarning() << "Unsupported image file extension: " << tex->f ileExtension << " for file: " << tex->fullPath; qWarning() << "Unsupported image file extension: " << tex->f ileExtension << " for file: " << tex->fullPath;
tex->texels = NULL; tex->texels = NULL;
return false; return false;
} }
 End of changes. 15 change blocks. 
15 lines changed or deleted 15 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/