lists.zerezo.com



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

***BOGO*** kdescreensaver template useing QGLWidget



kdescreensaver template useing QGLWidget
 I'm trying to use the kdevelopment kdescreensaver template with QGLWidget. 
The only thing that has changed is "class Ocean : public QGLWidget". It works 
and compiles correctly until I use any OpenGL functions then I get this:
 
 Development/KOceanSaver/src/ocean.cpp:38: undefined reference to 
`glShadeModel'
 Entering directory Development/KOceanSaver/debug
 *** Exited with status: 2 ***
 
 I know this should work because it works when I do it with a "Simple KDE 
Application" template. I added "-lGL -lGLU" to config options. It must be 
that the kdescreensaver template does not include something that the "Simple 
KDE Application" template does that allowes QGLWidget to work. Help I have a 
nice screensaver I would like to make for kde4. its done I just need to get 
it to screensaver.
 
 

  +++++++++++++++++++++++++++++++++++++++++++++ ocean.h

#ifndef OCEAN_H
#define OCEAN_H

#include "qgl.h"
#include <GL/gl.h>
#include <GL/glu.h>

class Ocean : public QGLWidget
{
        public:
                Ocean ( );
                ~Ocean();
                void initializeGL ();
};

#endif

 
 

  +++++++++++++++++++++++++++++++++++++++++++++ ocean.cpp
#include "ocean.h"
#include "qgl.h"
#include <GL/gl.h>
#include <GL/glu.h>

Ocean::Ocean ( )
{

}


Ocean::~Ocean()
{
}


void Ocean::initializeGL ()
{
                glShadeModel ( GL_SMOOTH );

                //glClearColor ( 0.0f, 0.0f, 0.0f, 0.0f );

                //glClearDepth ( 1.0f );

                //glDisable ( GL_DEPTH_TEST );

                //glEnable ( GL_BLEND );

                //glBlendFunc ( GL_SRC_ALPHA, GL_ONE );

                //glHint ( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );

                //glHint ( GL_POINT_SMOOTH_HINT, GL_NICEST );

                //glEnable ( GL_TEXTURE_2D );
}

 

  ++++++++++++++++++++++++++++++++++++++++++++++++++++ koceansaver.h

#ifndef KOceanSaver_H__
#define KOceanSaver_H__

#include <qgl.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include "ocean.h"

#include "kscreensaver.h"
#include "koceansaverui.h"

class KOceanSaver : public KScreenSaver
{
                Q_OBJECT
        public:
                KOceanSaver ( WId drawable );
                virtual ~KOceanSaver();
        private:
                Ocean* ocean;
                void readSettings();
                void blank();
};

class KOceanSaverSetup : public KOceanSaverUI
{
                Q_OBJECT
        public:
                KOceanSaverSetup ( QWidget *parent = NULL, const char *name = 
NULL );

        private slots:
                void slotOkPressed();
                void slotCancelPressed();

        private:
                void readSettings();
                KOceanSaver *saver;
};

#endif


  ++++++++++++++++++++++++++++++++++++++++++++++++++++ koceansaver.cpp
#include <stdlib.h>
#include <qcheckbox.h>
#include <qcolor.h>
#include <kapplication.h>
#include <klocale.h>
#include <kpushbutton.h>
#include <kconfig.h>
#include <kglobal.h>

#include <qgl.h>
#include <GL/gl.h>
#include <GL/glu.h>

#include "koceansaver.h"
#include "koceansaverui.h"


//! libkscreensaver interface
extern "C"
{
        KDE_EXPORT const char *kss_applicationName = "koceansaver.kss";
        KDE_EXPORT const char *kss_description = I18N_NOOP ( "KOceanSaver" );
        KDE_EXPORT const char *kss_version = "2.2.0";

        KDE_EXPORT KOceanSaver *kss_create ( WId id )
        {
                KGlobal::locale()->insertCatalogue ( "koceansaver" );
                return new KOceanSaver ( id );
        }

        KDE_EXPORT QDialog *kss_setup()
        {
                KGlobal::locale()->insertCatalogue ( "koceansaver" );
                return new KOceanSaverSetup();
        }
}

//-----------------------------------------------------------------------------
//! dialog to setup screen saver parameters
KOceanSaverSetup::KOceanSaverSetup ( QWidget *parent, const char *name )
                : KOceanSaverUI ( parent, name, TRUE )
{
        /// @todo
        //Connect your signals and slots here to configure the screen saver.
        connect ( OkayPushButton, SIGNAL ( released() ),
                  SLOT ( slotOkPressed() ) );
        connect ( CancelPushButton, SIGNAL ( released() ),
                  SLOT ( slotCancelPressed() ) );
}


//! read settings from config file
void KOceanSaverSetup::readSettings()
{
        KConfig *config = KGlobal::config();
        config->setGroup ( "Settings" );
        /// @todo
        // Add your config options here...
        CheckBox1->setChecked ( config->readBoolEntry ( "somesetting", 
false ) );
}


//! Ok pressed - save settings and exit
void KOceanSaverSetup::slotOkPressed()
{
        KConfig *config = KGlobal::config();
        config->setGroup ( "Settings" );
        /// @todo
        // Add your config options here.
        config->writeEntry ( "somesetting", CheckBox1->isChecked() );
        config->sync();

        accept();
}

void KOceanSaverSetup::slotCancelPressed()
{
        reject();
}
//-----------------------------------------------------------------------------


KOceanSaver::KOceanSaver ( WId id ) : KScreenSaver ( id )
{
        //setBackgroundColor ( QColor ( black ) );
        //erase();

        //readSettings();



        //blank();
}

KOceanSaver::~KOceanSaver()
{}


//! read configuration settings from config file
void KOceanSaver::readSettings()
{
        KConfig *config = KGlobal::config();
        config->setGroup ( "Settings" );
        /// @todo
        // Add your config options here...
        bool somesetting = config->readBoolEntry ( "somesetting", false );
}


void KOceanSaver::blank()
{
        /// @todo
        //Add your code to render the screen.
        this->ocean = new Ocean();
        embed(ocean);
        ocean->show();
}
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<