summaryrefslogtreecommitdiffstats
path: root/src/komposegl
diff options
context:
space:
mode:
authorMavridis Philippe <mavridisf@gmail.com>2021-04-01 18:38:44 +0300
committerMavridis Philippe <mavridisf@gmail.com>2021-04-01 18:38:44 +0300
commit572c52c8158af1677426eb2807670c3195db1334 (patch)
treec392f8ccb65c73a70255fd9cc1c17c7f1baf20af /src/komposegl
parentb8ab296c94256ca11a4c88ba55ece9ba88dd81f4 (diff)
downloadkompose-572c52c8158af1677426eb2807670c3195db1334.tar.gz
kompose-572c52c8158af1677426eb2807670c3195db1334.zip
Moved currently unused GL-related sources to separate directory.
Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
Diffstat (limited to 'src/komposegl')
-rw-r--r--src/komposegl/komposegldesktopwidget.cpp116
-rw-r--r--src/komposegl/komposeglfullscreenwidget.cpp176
-rw-r--r--src/komposegl/komposegltaskwidget.cpp119
-rw-r--r--src/komposegl/komposeglwidget.cpp119
4 files changed, 530 insertions, 0 deletions
diff --git a/src/komposegl/komposegldesktopwidget.cpp b/src/komposegl/komposegldesktopwidget.cpp
new file mode 100644
index 0000000..6b8d857
--- /dev/null
+++ b/src/komposegl/komposegldesktopwidget.cpp
@@ -0,0 +1,116 @@
+//
+// C++ Implementation: komposegldesktopwidget
+//
+// Description:
+//
+//
+// Author: Hans Oischinger <oisch@sourceforge.net>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "komposegldesktopwidget.h"
+
+#include "komposetask.h"
+#include "komposegltaskwidget.h"
+#include "komposetaskmanager.h"
+
+#include <tqdesktopwidget.h>
+#include <tqobjectlist.h>
+#include <kdebug.h>
+
+#include <GL/gl.h>
+
+KomposeGLDesktopWidget::KomposeGLDesktopWidget(int desktop, TQObject *parent, const char *name)
+ : KomposeGLWidget( parent ),
+ deskNum( desktop )
+{
+ // Retrieve geometry
+ TQDesktopWidget *deskwidget = new TQDesktopWidget();
+ deskRect = deskwidget->availableGeometry();
+ delete deskwidget;
+
+ createTaskWidgets();
+
+ //connect( KomposeTaskManager::instance(), SIGNAL( newTask( KomposeTask* ) ), this, SLOT( createTaskWidget( KomposeTask* ) ) );
+}
+
+
+KomposeGLDesktopWidget::~KomposeGLDesktopWidget()
+{}
+
+void KomposeGLDesktopWidget::createTaskWidgets()
+{
+ TaskList tl = KomposeTaskManager::instance()->getTasks();
+ tqDebug("KomposeGLDesktopWidget::createTaskWidgets() on %d tasks", tl.count());
+ TQPtrListIterator<KomposeTask> it( tl );
+ KomposeTask *task;
+ while ( (task = it.current()) != 0 )
+ {
+ ++it;
+ TQ_CHECK_PTR(task);
+ createTaskWidget( task );
+ }
+}
+
+
+void KomposeGLDesktopWidget::createTaskWidget( KomposeTask* task )
+{
+ if (deskNum == task->onDesktop()-1 )
+ {
+ tqDebug("KomposeGLDesktopWidget::createTaskWidget()" );
+ KomposeGLTaskWidget *taskwidget = new KomposeGLTaskWidget( task, this, 0, "" );
+ }
+}
+
+int KomposeGLDesktopWidget::getHeightForWidth( int w ) const
+{
+ tqDebug("KomposeGLDesktopWidget::getHeightForWidth()");
+ return ((double)w / (double)deskRect.width()) * deskRect.height();
+}
+
+int KomposeGLDesktopWidget::getWidthForHeight( int h ) const
+{
+ tqDebug("KomposeGLDesktopWidget::getWidthForHeight()");
+ return ((double)h / (double)deskRect.height()) * deskRect.width();
+}
+
+double KomposeGLDesktopWidget::getAspectRatio()
+{
+ tqDebug("KomposeGLDesktopWidget::getAspectRatio()");
+ return (double)deskRect.width() / (double)deskRect.height();
+}
+
+
+void KomposeGLDesktopWidget::draw()
+{
+ KomposeGLWidget::draw();
+ tqDebug("KomposeGLDesktopWidget::draw() - %d,%d %dx%d", getRect().x(), getRect().y(), getRect().width(), getRect().height());
+ glColor3f(0.0f, 0.0f, 1.0f);
+
+ glBegin( GL_QUADS );
+ glVertex2i( getRect().x() + getRect().width(), getRect().y() );
+ glVertex2i( getRect().x(), getRect().y() );
+ glVertex2i( getRect().x(), getRect().y() + getRect().height() );
+ glVertex2i( getRect().x() + getRect().width(), getRect().y() + getRect().height() );
+ glEnd();
+
+ // Draw Task Widgets
+ TQPtrListIterator<KomposeGLWidget> it( list );
+
+ // Check or empty list
+ if (it.count() == 0)
+ {
+ tqDebug("KomposeGLDesktopWidget::draw() - empty list... skipping!");
+ return;
+ }
+
+ KomposeGLWidget *widget;
+ while ( (widget = (KomposeGLWidget*)it.current()) != 0 )
+ {
+ ++it;
+ widget->draw();
+ }
+}
+
+#include "komposegldesktopwidget.moc"
diff --git a/src/komposegl/komposeglfullscreenwidget.cpp b/src/komposegl/komposeglfullscreenwidget.cpp
new file mode 100644
index 0000000..774b6ff
--- /dev/null
+++ b/src/komposegl/komposeglfullscreenwidget.cpp
@@ -0,0 +1,176 @@
+//
+// C++ Implementation: komposeglwidget
+//
+// Description:
+//
+//
+// Author: Hans Oischinger <oisch@sourceforge.net>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "komposeglfullscreenwidget.h"
+
+#include "komposelayout.h"
+#include "komposetaskmanager.h"
+#include "komposegldesktopwidget.h"
+#include <kdebug.h>
+
+#include <GL/gl.h>
+#include <GL/glut.h>
+
+KomposeGLFullscreenWidget::KomposeGLFullscreenWidget(TQWidget *parent, const char *name) :
+ TQGLWidget(parent, name)
+{
+ tqDebug("KomposeGLFullscreenWidget::KomposeGLFullscreenWidget()");
+ layout = new KomposeLayout( this );
+
+ setWindowState(TQt::WindowMaximized | TQt::WindowActive);
+ showFullScreen();
+
+ createDesktopWidgets();
+}
+
+
+KomposeGLFullscreenWidget::~KomposeGLFullscreenWidget()
+{}
+
+void KomposeGLFullscreenWidget::createDesktopWidgets()
+{
+ // Create a Widget for every desktop
+ for (int i=0; i < KomposeTaskManager::instance()->getNumDesktops(); ++i)
+ {
+ int row = i / 2;
+ int col = i % 2;
+ //tqDebug("rc %d %d", row, col);
+ desktop[i] = new KomposeGLDesktopWidget(i, this);
+ layout->add(dynamic_cast<KomposeWidgetInterface*>(desktop[i]));
+ }
+}
+
+void KomposeGLFullscreenWidget::initializeGL()
+{
+ // Set up the rendering context, define display lists etc.:
+ if( !format().hasOpenGL() )
+ {
+ tqWarning( "KomposeGLFullscreenWidget::initializeGL() - OpenGL not supported!" );
+ return;
+ }
+
+ if ( !format().doubleBuffer() )
+ {
+ tqWarning( "KomposeGLFullscreenWidget::initializeGL() - Direct rendering enabled !" );
+ }
+// glShadeModel(GL_SMOOTH);
+//
+// format().setDirectRendering( true );
+// format().setDoubleBuffer( true );
+// format().setRgba( true );
+// format().setDepth ( false );
+// format().setAccum( false );
+// format().setStencil( false );
+// format().setAlpha( true );
+
+ // Alpha blend
+// glEnable( GL_BLEND );
+// glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
+
+ // All smoothing stuff
+// glEnable( GL_POLYGON_SMOOTH );
+// glHint( GL_POLYGON_SMOOTH_HINT, GL_FASTEST );
+// glEnable( GL_POINT_SMOOTH );
+// glHint( GL_POINT_SMOOTH_HINT, GL_FASTEST );
+// glEnable( GL_LINE_SMOOTH );
+// glHint( GL_LINE_SMOOTH_HINT, GL_FASTEST );
+
+ // Lighting and Depth Test
+ glDisable( GL_LIGHTING );
+// glDisable( GL_DEPTH_TEST );
+// glDisable( GL_NORMALIZE );
+
+ glClearColor( 0.0, 0.0, 0.0, 0.0 );
+ glClear( GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ACCUM_BUFFER_BIT );
+
+ /*! Setup sizes */
+// glLineWidth( 1.0 );
+// glPointSize( 2.0 );
+
+ setOrthographicProjection();
+}
+
+void KomposeGLFullscreenWidget::resizeGL( int w, int h )
+{
+ // setup viewport, projection etc.:
+ setOrthographicProjection();
+ layout->arrangeLayout();
+}
+
+
+/*! draw OpenGL scene ( called from TQt ) */
+void KomposeGLFullscreenWidget::paintGL()
+{
+ tqDebug("KomposeGLFullscreenWidget::paintGL()");
+
+ glPushMatrix();
+
+ // clears the color buffer (this will set the window to black)
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ // Draw Desktop Widgets
+ for (int i=0; i < KomposeTaskManager::instance()->getNumDesktops(); ++i)
+ {
+ // FIXME: Make desktop arrays dynamic or at least avoid KomposeTaskManager::instance()->getNumDesktops() here
+ desktop[i]->draw();
+ }
+
+ glFlush();
+ glPopMatrix();
+}
+
+
+void KomposeGLFullscreenWidget::setOrthographicProjection()
+{
+ tqDebug("KomposeGLFullscreenWidget::setOrthographicProjection() - %dx%d", width(), height());
+ glViewport( 0, 0, (GLint)width(), (GLint)height() );
+ // switch to projection mode
+ glMatrixMode(GL_PROJECTION);
+ // reset matrix
+ glLoadIdentity();
+ // set a 2D orthographic projection
+ gluOrtho2D(0.0, (GLdouble)width(), 0.0, (GLdouble)height());
+ // invert the y axis, down is positive
+ glScalef(1, -1, 1);
+ // mover the origin from the bottom left corner
+ // to the upper left corner
+ glTranslatef(0, -height(), 0);
+ glMatrixMode(GL_MODELVIEW);;
+}
+
+// Redirect these functions to TQGLWidget
+
+void KomposeGLFullscreenWidget::setGeom ( const TQRect &rect )
+{
+ TQGLWidget::setGeometry( rect );
+}
+
+void KomposeGLFullscreenWidget::setGeom ( const TQSize &size )
+{
+ TQGLWidget::resize( size );
+}
+
+TQSize KomposeGLFullscreenWidget::getSize() const
+{
+ return TQGLWidget::size();
+}
+
+TQRect KomposeGLFullscreenWidget::getRect() const
+{
+ return TQGLWidget::rect();
+}
+
+void KomposeGLFullscreenWidget::removeChildWidget( KomposeWidgetInterface* obj )
+{
+ TQGLWidget::removeChild((TQObject *) obj);
+}
+
+#include "komposeglfullscreenwidget.moc"
diff --git a/src/komposegl/komposegltaskwidget.cpp b/src/komposegl/komposegltaskwidget.cpp
new file mode 100644
index 0000000..a2a7217
--- /dev/null
+++ b/src/komposegl/komposegltaskwidget.cpp
@@ -0,0 +1,119 @@
+//
+// C++ Implementation: komposegltaskwidget
+//
+// Description:
+//
+//
+// Author: Hans Oischinger <oisch@sourceforge.net>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "komposegltaskwidget.h"
+
+#include "komposetaskmanager.h"
+#include "komposetask.h"
+#include "komposelayout.h"
+#include <kdebug.h>
+
+#include <tqgl.h>
+#include <tqimage.h>
+
+
+
+KomposeGLTaskWidget::KomposeGLTaskWidget(KomposeTask *t, TQObject *parent, KomposeLayout *l, const char *name)
+ : KomposeGLWidget(parent, l),
+ task(t)
+{
+ TQImage img = task->getScreenshot().convertToImage();
+ img = img.smoothScale( 256, 256, TQImage::ScaleMin );
+ tex = TQGLWidget::convertToGLFormat( img );
+ glGenTextures(1, &texture);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ /* glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // cheap scaling when image bigger than texture
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // cheap scaling when image smalled than texture*/
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // scale linearly when image bigger than texture
+ glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // scale linearly when image smalled than texture
+
+ glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+
+ glTexImage2D( GL_TEXTURE_2D, 0, 3, 256, 256, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, tex.bits() );
+
+
+
+
+ connect( t, SIGNAL( closed() ), this, SLOT( slotTaskDestroyed() ) );
+ connect( t, SIGNAL( stateChanged() ), this, SLOT( draw() ) );
+}
+
+
+KomposeGLTaskWidget::~KomposeGLTaskWidget()
+{}
+
+void KomposeGLTaskWidget::slotTaskDestroyed()
+{
+ disconnect( task, SIGNAL( closed() ), this, SLOT( slotTaskDestroyed() ) );
+ disconnect( task, SIGNAL( stateChanged() ), this, SLOT( draw() ) );
+ if (KomposeTaskManager::instance()->hasActiveView())
+ {
+ this->parent()->removeChild( this );
+ }
+}
+
+int KomposeGLTaskWidget::getHeightForWidth ( int w ) const
+{
+ tqDebug("KomposeGLTaskWidget::getHeightForWidth()");
+ return task->getHeightForWidth(w);
+}
+
+int KomposeGLTaskWidget::getWidthForHeight ( int h ) const
+{
+ tqDebug("KomposeGLTaskWidget::getWidthForHeight()");
+ return task->getWidthForHeight(h);
+}
+
+double KomposeGLTaskWidget::getAspectRatio()
+{
+ tqDebug("KomposeGLTaskWidget::getAspectRatio()");
+ return task->getAspectRatio();
+}
+
+void KomposeGLTaskWidget::draw()
+{
+ KomposeGLWidget::draw();
+ tqDebug("KomposeGLTaskWidget::draw() - %d,%d %dx%d", getRect().x(), getRect().y(), getRect().width(), getRect().height());
+ glColor3f(1.0f, 0.0f, 0.0f);
+
+ glBindTexture(GL_TEXTURE_2D, texture);
+
+ /* glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
+ glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );*/
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
+ glEnable( GL_TEXTURE_2D );
+
+ // glTexImage2D( GL_TEXTURE_2D, 0, 3, tex.width(), tex.height(), 0,
+ // GL_RGBA, GL_UNSIGNED_BYTE, tex.bits() );
+ // tqDebug("KomposeGLTaskWidget::draw() - tex: %dx%d", tex.width(), tex.height() );
+
+ glBegin( GL_QUADS );
+ glTexCoord2f(0.0, 0.0);
+ glVertex2i( getRect().x(), getRect().y() );
+ glTexCoord2f(0.0, 1.0);
+ glVertex2i( getRect().x(), getRect().y() + getRect().height() );
+ glTexCoord2f(1.0, 1.0);
+ glVertex2i( getRect().x() + getRect().width(), getRect().y() + getRect().height() );
+ glTexCoord2f(1.0, 0.0);
+ glVertex2i( getRect().x() + getRect().width(), getRect().y() );
+ glEnd();
+
+ glDisable( GL_TEXTURE_2D );
+/*
+glRasterPos2i (getRect().x(), getRect().y());
+ glPixelZoom( (GLfloat)(getSize().width())/(GLfloat)(tex.width()), (GLfloat)(getSize().height())/(GLfloat)(tex.height()) );
+ glDrawPixels(tex.width(), tex.height(), GL_RGBA, GL_UNSIGNED_BYTE, tex.bits() ); */
+}
+
+#include "komposegltaskwidget.moc"
diff --git a/src/komposegl/komposeglwidget.cpp b/src/komposegl/komposeglwidget.cpp
new file mode 100644
index 0000000..14c6d5d
--- /dev/null
+++ b/src/komposegl/komposeglwidget.cpp
@@ -0,0 +1,119 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Hans Oischinger *
+ * oisch@sourceforge.net *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include "komposeglwidget.h"
+#include "komposelayout.h"
+
+#include <tqtimer.h>
+#include <kdebug.h>
+
+
+/*
+ * The constructor accepts a custom layout, if none is specified a defaultlayout is used
+ */
+KomposeGLWidget::KomposeGLWidget(TQObject *parent, KomposeLayout *l, const char *name)
+ : TQObject(parent)
+{
+ geometry = TQRect(0,0,1,1);
+ if (!l)
+ layout = new KomposeLayout( this );
+ else
+ layout = l;
+}
+
+
+KomposeGLWidget::~KomposeGLWidget()
+{}
+
+
+/*
+ * Whenever a child is added to the widget it's also added to the layout
+ */
+void KomposeGLWidget::childEvent ( TQChildEvent * ce )
+{
+ if ( !ce->child()->inherits("KomposeGLWidget") )
+ return;
+
+ if ( ce->inserted() )
+ {
+ tqDebug("KomposeGLWidget::childEvent : Added widget " << ce->child()->className() << " to " << className() << endl;
+ list.append( dynamic_cast<KomposeGLWidget*>(ce->child()) );
+ layout->add( dynamic_cast<KomposeWidgetInterface*>(ce->child()) );
+ }
+ else if ( ce->removed() )
+ {
+ tqDebug("KomposeGLWidget::childEvent : Removed widget %s from %s", ce->child()->className(), className() );
+ list.remove( dynamic_cast<KomposeGLWidget*>(ce->child()) );
+ layout->remove( dynamic_cast<KomposeWidgetInterface*>(ce->child()) );
+ }
+
+ // Whenever a child is added/removed: rearrange layout
+ // FIXME: sometimes widget's aren't added in time, so we have to add a short delay:
+ TQTimer::singleShot( 200, layout, SLOT( arrangeLayout() ) );
+}
+
+/*
+ * Main GL draw routine
+ */
+void KomposeGLWidget::draw()
+{
+ tqDebug("KomposeGLWidget::draw - Arranging layout");
+ layout->arrangeLayout();
+}
+
+
+// Redirect these functions to TQWidget
+
+void KomposeGLWidget::setGeom ( const TQRect &rect )
+{
+ geometry = rect;
+}
+
+void KomposeGLWidget::setGeom ( const TQSize &size )
+{
+ geometry.setSize( size );
+}
+
+TQSize KomposeGLWidget::getSize() const
+{
+ return geometry.size();
+}
+
+TQRect KomposeGLWidget::getRect() const
+{
+ return geometry;
+}
+
+KomposeWidgetInterface* KomposeGLWidget::getParentWidget() const
+{
+ if ( TQObject::parent()->inherits("KomposeWidgetInterface") )
+ return (KomposeWidgetInterface*)TQObject::parent();
+ else
+ {
+ tqDebug("KomposeGLWidget::getParentWidget() - TQWidget::parent() does not inherit (KomposeWidgetInterface)");
+ return NULL;
+ }
+}
+
+void KomposeGLWidget::removeChildWidget( KomposeWidgetInterface* obj )
+{
+ TQObject::removeChild((TQObject *) obj);
+}
+
+#include "komposeglwidget.moc"