[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdeedu/kstars/kstars
From:       Akarsh Simha <akarshsimha () gmail ! com>
Date:       2011-01-01 4:27:16
Message-ID: 20110101042716.E47CDAC8B2 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1210551 by asimha:

Working OpenGL version. Still hackish, ugly and hardcoded.

 M  +3 -0      kstarsinit.cpp  
 M  +2 -0      skymap.cpp  
 M  +1 -1      skymap.h  
 M  +3 -1      skymapgldraw.cpp  
 M  +3 -0      texture.cpp  
 M  +14 -6     texturemanager.cpp  
 M  +14 -0     texturemanager.h  


--- trunk/KDE/kdeedu/kstars/kstars/kstarsinit.cpp #1210550:1210551
@@ -45,6 +45,7 @@
 #include "oal/equipmentwriter.h"
 #include "oal/observeradd.h"
 #include "skycomponents/skymapcomposite.h"
+#include "texturemanager.h"
 
 #include <config-kstars.h>
 
@@ -653,6 +654,8 @@
 }
 
 void KStars::buildGUI() {
+    //create the texture manager
+    TextureManager::Create();
     //create the skymap
     skymap = SkyMap::Create();
     connect(skymap, SIGNAL(mousePointChanged(SkyPoint*)), \
                SLOT(slotShowPositionBar(SkyPoint*)));
--- trunk/KDE/kdeedu/kstars/kstars/skymap.cpp #1210550:1210551
@@ -58,6 +58,7 @@
 #include "projections/orthographicprojector.h"
 #include "projections/azimuthalequidistantprojector.h"
 #include "projections/equirectangularprojector.h"
+#include "texturemanager.h"
 
 #include "skymapqdraw.h"
 #include "skymapgldraw.h"
@@ -232,6 +233,7 @@
     */
 
     // HARDCODE GL ENGINE
+    Q_ASSERT( TextureManager::getContext() );
     SkyMapGLDraw *smgld = new SkyMapGLDraw( this );
     m_SkyMapDraw = smgld;
     m_SkyMapDrawWidget = smgld;
--- trunk/KDE/kdeedu/kstars/kstars/skymap.h #1210550:1210551
@@ -18,7 +18,7 @@
 #ifndef SKYMAP_H_
 #define SKYMAP_H_
 
-// #define USEGL
+#define USEGL
 
 #include <QTimer>
 #include <QGraphicsView>
--- trunk/KDE/kdeedu/kstars/kstars/skymapgldraw.cpp #1210550:1210551
@@ -14,12 +14,14 @@
  *                                                                         *
  ***************************************************************************/
 
+#include "texturemanager.h"
 #include "skymapcomposite.h"
 #include "skyglpainter.h"
 #include "skymapgldraw.h"
 #include "skymap.h"
 
-SkyMapGLDraw::SkyMapGLDraw( SkyMap *sm ) : SkyMapDrawAbstract( sm ), QGLWidget( \
QGLFormat(QGL::SampleBuffers), sm ) { +
+SkyMapGLDraw::SkyMapGLDraw( SkyMap *sm ) : SkyMapDrawAbstract( sm ), QGLWidget( \
TextureManager::getContext(), sm ) {  // TODO: Any construction to be done?
     if( !format().testOption( QGL::SampleBuffers ) )
         qWarning() << "No sample buffer; can't use multisampling (antialiasing)";
--- trunk/KDE/kdeedu/kstars/kstars/texture.cpp #1210550:1210551
@@ -18,8 +18,11 @@
 */
 
 #include "texture.h"
+#include "texturemanager.h"
 #include "skymap.h"
 
+#include <QGLContext>
+
 Texture::Texture(QObject* parent): QObject(parent)
 {
     m_ready = false;
--- trunk/KDE/kdeedu/kstars/kstars/texturemanager.cpp #1210550:1210551
@@ -18,20 +18,21 @@
 */
 
 #include "texturemanager.h"
+#include "skymap.h"
+#include "kstars.h"
 
 #include <kstandarddirs.h>
 
-#include "skymap.h"
-#include "kstars.h"
+#include <QGLWidget>
 
 TextureManager* TextureManager::m_p;
+QGLContext* TextureManager::m_context = 0;
 
 const Texture* TextureManager::getTexture(const QString& name)
 {
-    if(!m_p) {
-        m_p = new TextureManager(KStars::Instance());
-    }
     
+    Create();
+
     Texture *tex = m_p->m_textures.value(name,0);
     if( !tex ) {
         QString filename = \
KStandardDirs::locate("appdata",QString("textures/%1.png").arg(name)); @@ -61,9 \
+62,16 @@  }
 }
 
+TextureManager *TextureManager::Create() {
+    if( !m_p )
+        m_p = new TextureManager( KStars::Instance() );
+    if( !m_context )
+        m_context = new QGLContext( QGLFormat(QGL::SampleBuffers) );
+    return m_p;
+}
+
 TextureManager::TextureManager(QObject* parent): QObject(parent)
 {
     
 }
 
-
--- trunk/KDE/kdeedu/kstars/kstars/texturemanager.h #1210550:1210551
@@ -25,6 +25,8 @@
 
 #include "texture.h"
 
+class QGLContext;
+
 /** @brief a singleton class to manage texture loading/retrieval */
 class TextureManager : public QObject
 {
@@ -39,10 +41,22 @@
         but which have not yet been set up for use with GL,
         this function will set them up. */
     static void genTextures();
+
+    /**
+     *@return the QGLContext that is used for the textures
+     */
+    static inline QGLContext* getContext() { return (m_p ? m_p->m_context : 0); }
+
+    /**
+     *@short Create the instance of TextureManager
+     */
+    static TextureManager *Create();
+
 protected:
     TextureManager(QObject* parent = 0);
     static TextureManager* m_p;
     QHash<QString,Texture*> m_textures;
+    static QGLContext *m_context; // GL Context to bind textures to.
 };
 
 #endif // KSTEXTUREMANAGER_H


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic