Commit 418c9f48 authored by Rishab Arora's avatar Rishab Arora

Override DSO type if it exceeds range in OpenGL

parent ca4831ec
......@@ -84,6 +84,10 @@ SkyGLPainter::SkyGLPainter( QGLWidget *widget ) :
void SkyGLPainter::drawBuffer(int type)
{
// Prevent crash if type > UNKNOWN
if (type > SkyObject::TYPE_UNKNOWN)
type = SkyObject::TYPE_UNKNOWN;
//printf("Drawing buffer for type %d, has %d objects\n", type, m_idx[type]);
if( m_idx[type] == 0 ) return;
......@@ -122,7 +126,11 @@ bool SkyGLPainter::addItem(SkyPoint* p, int type, float width, char sp)
bool visible = false;
Vector2f vec = m_proj->toScreenVec(p,true,&visible);
if(!visible) return false;
// Prevent crash if type > UNKNOWN
if (type > SkyObject::TYPE_UNKNOWN)
type = SkyObject::TYPE_UNKNOWN;
//If the buffer is full, flush it
if(m_idx[type] == BUFSIZE) {
drawBuffer(type);
......@@ -271,6 +279,11 @@ bool SkyGLPainter::drawDeepSkyObject(DeepSkyObject* obj, bool drawImage)
if( !m_proj->checkVisibility(obj) )
return false;
int type = obj->type();
// Prevent crash if type > UNKNOWN
if (type > SkyObject::TYPE_UNKNOWN)
type = SkyObject::TYPE_UNKNOWN;
//addItem(obj, type, obj->a() * dms::PI * Options::zoomFactor() / 10800.0);
//If it's a star, add it like a star
......
......@@ -64,12 +64,12 @@ TextureManager::CacheIter TextureManager::findTexture(const QString& name)
// Try to load from file in 'textures' subdirectory
QString filename = KStandardDirs::locate("appdata",QString("textures/%1.png").arg(name));
if( !filename.isNull() ) {
return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename) );
return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename,"PNG") );
} else {
// Try to load from file in main data directory
filename = KStandardDirs::locate("appdata",QString("%1.png").arg(name));
if( !filename.isNull() ) {
return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename) );
return (TextureManager::CacheIter)m_p->m_textures.insert( name, QImage(filename,"PNG") );
} else {
return m_p->m_textures.constEnd();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment