//----------------------------------------------------------------------------- // // kwave - Waveing Flag Screen Saver for KDE 2 // // Copyright (c) Ian Reinhart Geiser 2001 // #include #include #include #include #include #include #include #include #include #include #include "wave.h" #include "wave.moc" #ifdef TQ_WS_MACX #include #include #else #include #include #endif #include #include #include #include #include #include #include #include #ifndef GLU_NURBS_TEXTURE_COORD #define GLU_NURBS_TEXTURE_COORD 100168 #endif // libkscreensaver interface extern "C" { KDE_EXPORT const char *kss_applicationName = "kwave.kss"; KDE_EXPORT const char *kss_description = I18N_NOOP( "Bitmap Wave Screen Saver" ); KDE_EXPORT const char *kss_version = "2.2.0"; KDE_EXPORT KScreenSaver *kss_create( WId id ) { return new KWaveSaver( id ); } KDE_EXPORT TQDialog *kss_setup() { return new KWaveSetup(); } } //----------------------------------------------------------------------------- // dialog to setup screen saver parameters // KWaveSetup::KWaveSetup( TQWidget *parent, const char *name ) : SetupUi( parent, name, TRUE ) { readSettings(); preview->setFixedSize( 220, 170 ); preview->setBackgroundColor( black ); preview->show(); // otherwise saver does not get correct size saver = new KWaveSaver( preview->winId() ); connect( PushButton1, TQT_SIGNAL( clicked() ), TQT_SLOT( slotOkPressed() ) ); connect( PushButton2, TQT_SIGNAL( clicked() ), TQT_SLOT( reject() ) ); connect( PushButton3, TQT_SIGNAL( clicked() ), TQT_SLOT( aboutPressed() ) ); connect( SpinBox1, TQT_SIGNAL( valueChanged(int)), saver, TQT_SLOT( updateSize(int))); connect( RadioButton1, TQT_SIGNAL( toggled(bool)), saver, TQT_SLOT( doStars(bool))); } KWaveSetup::~KWaveSetup( ) { delete saver; } // read settings from config file void KWaveSetup::readSettings() { KConfig *config = KGlobal::config(); config->setGroup( "Settings" ); // color = config->readColorEntry( "Color", &black ); } // Ok pressed - save settings and exit void KWaveSetup::slotOkPressed() { KConfig *config = KGlobal::config(); config->setGroup( "Settings" ); // config->writeEntry( "Color", color ); config->sync(); accept(); } void KWaveSetup::aboutPressed() { KMessageBox::about(this, i18n("

Bitmap Flag Screen Saver

\n

Waving Flag Screen Saver for TDE

\nCopyright (c) Ian Reinhart Geiser 2001")); } //----------------------------------------------------------------------------- KWaveSaver::KWaveSaver( WId id ) : KScreenSaver( id ) { kdDebug() << "Blank" << endl; readSettings(); timer = new TQTimer( this ); timer->start( 50, TRUE ); setBackgroundColor( black ); erase(); wave = new Wave(); embed(wave); wave->show(); connect( timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(blank()) );; } KWaveSaver::~KWaveSaver() { } // read configuration settings from config file void KWaveSaver::readSettings() { KConfig *config = KGlobal::config(); config->setGroup( "Settings" ); // color = config->readColorEntry( "Color", &black ); } void KWaveSaver::blank() { // Play wave wave->updateGL(); timer->start( 100, TRUE ); } Wave::Wave( TQWidget * parent, const char * name) : TQGLWidget (parent,name) { pNurb = 0; nNumPoints = 4; index = 0; } Wave::~Wave() { glDeleteTextures( 1, &texture[0] ); gluDeleteNurbsRenderer(pNurb); } /** setup the GL enviroment */ void Wave::initializeGL () { kdDebug() << "InitGL" << endl; /* Load in the texture */ if ( !LoadGLTextures( ) ) exit(0); /* Enable Texture Mapping ( NEW ) */ glEnable( GL_TEXTURE_2D ); /* Enable smooth shading */ glShadeModel( GL_SMOOTH ); // Light values and coordinates GLfloat specular[] = { 0.7f, 0.0f, 0.0f, 1.0f}; GLfloat shine[] = { 75.0f }; glClearColor(0.0f, 0.0f, 0.0f, 0.0f ); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glMaterialfv(GL_FRONT, GL_SPECULAR, specular); glMaterialfv(GL_FRONT, GL_SHININESS, shine); glEnable(GL_AUTO_NORMAL); pNurb = gluNewNurbsRenderer(); gluNurbsProperty(pNurb, GLU_SAMPLING_TOLERANCE, 25.0f); // Uncomment the next line and comment the one following to produce a // wire frame mesh. //gluNurbsProperty(pNurb, GLU_DISPLAY_MODE, GLU_OUTLINE_POLYGON); gluNurbsProperty(pNurb, GLU_DISPLAY_MODE, (GLfloat)GLU_FILL); glEnable(GL_MAP2_TEXTURE_COORD_3); glEnable(GL_MAP2_VERTEX_3); glEnable(GL_BLEND); } /** resize the gl view */ void Wave::resizeGL ( int w, int h) { kdDebug() << "ResizeGL " << w << "," <