You are not logged in.

1

Friday, June 20th 2008, 4:23am

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.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
+++++++++++++++++++++++++++++++++++++++++++++ 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

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
+++++++++++++++++++++++++++++++++++++++++++++ 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 );
}

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
++++++++++++++++++++++++++++++++++++++++++++++++++++ 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

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
++++++++++++++++++++++++++++++++++++++++++++++++++++ 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();
}

Similar threads