[prev in list] [next in list] [prev in thread] [next in thread]
List: kwin
Subject: Re: Physics Based Animator
From: Martin Graesslin <ubuntu () martin-graesslin ! com>
Date: 2008-03-29 10:38:05
Message-ID: 200803291138.09578.ubuntu () martin-graesslin ! com
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Am Freitag, 28. März 2008 schrieb Premeir Sullivan:
> The reason why its a concern for me is when I began writing code that
> used openGL, I realized that making calls to gl.rotatef() was easy;
> the hard part was initializing openGL in the right way. The only
> openGL effect that I know of is the Coverswitch effect. I didn't want
> to use the coverswitch code as a model because it radically rewrites
> the rendering stack, whereas my plugin only needs to do one or two
> rotations. So I'm left with the question, what openGL initializations
> are necessary and where should I put them?
I know the problem and I would immediatelly rewrite the effect if there were a
way to not do the rendering in this way. It really hurts and causes the
problems like not working with TwinView, etc.
I just tried a little bit and have a demo rotating effect that does not use
the strange code I wrote in coverswitch. I replaced the glOrthon in
scene_opengl by glFrustum so that we have perspective whenever we want ;-)
With that I tried to rotate a window. It is not nice and not working
correctly, but I would say it is a proof of concept ;-)
["rotate.diff" (text/x-diff)]
Index: scene_opengl.cpp
===================================================================
--- scene_opengl.cpp (Revision 783759)
+++ scene_opengl.cpp (Arbeitskopie)
@@ -151,7 +151,8 @@
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
// swap top and bottom to have OpenGL coordinate system match X system
- glOrtho( 0, displayWidth(), displayHeight(), 0, 0, 65535 );
+ //glOrtho( 0, displayWidth(), displayHeight(), 0, 0, 65535 );
+ glFrustum( -displayWidth()*0.5f, displayWidth()*0.5f, displayHeight()*0.5f, \
-displayHeight()*0.5f, 10, 50 ); glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
if( checkGLError( "Init" ))
@@ -162,6 +163,7 @@
kDebug( 1212 ) << "DB:" << db << ", TFP:" << tfp_mode << ", SHM:" << shm_mode
<< ", Direct:" << bool( glXIsDirect( display(), ctxbuffer )) << endl;
init_ok = true;
+ glTranslatef(-displayWidth()*0.5f, -displayHeight()*0.5f, -10.0);
}
SceneOpenGL::~SceneOpenGL()
Index: effects/test/CMakeLists.txt
===================================================================
--- effects/test/CMakeLists.txt (Revision 783759)
+++ effects/test/CMakeLists.txt (Arbeitskopie)
@@ -40,6 +40,7 @@
# opengl test/demo stuff
SET(kwin4_effect_tests_sources ${kwin4_effect_tests_sources}
demo_liquid.cpp
+ demo_rotate.cpp
demo_showpicture.cpp
demo_wavywindows.cpp
test_fbo.cpp
@@ -47,6 +48,7 @@
install( FILES
demo_liquid.desktop
+ demo_rotate.desktop
demo_showpicture.desktop
demo_wavywindows.desktop
test_fbo.desktop
Index: effects/test/demo_rotate.h
===================================================================
--- effects/test/demo_rotate.h (Revision 0)
+++ effects/test/demo_rotate.h (Revision 0)
@@ -0,0 +1,47 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+ Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com
+
+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, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+
+#ifndef KWIN_ROTATE_H
+#define KWIN_ROTATE_H
+
+#include <kwineffects.h>
+
+namespace KWin
+{
+
+class RotateEffect
+ : public QObject, public Effect
+ {
+ Q_OBJECT
+ public:
+ RotateEffect();
+ ~RotateEffect();
+
+ virtual void paintWindow( EffectWindow* w, int mask, QRegion region, \
WindowPaintData& data ); +
+ private slots:
+ void toggle();
+ private:
+ bool mActivated;
+ };
+
+} // namespace
+
+#endif
Index: effects/test/demo_rotate.cpp
===================================================================
--- effects/test/demo_rotate.cpp (Revision 0)
+++ effects/test/demo_rotate.cpp (Revision 0)
@@ -0,0 +1,71 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+ Copyright (C) 2008 Martin Gräßlin <ubuntu@martin-graesslin.com
+
+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, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+#include "demo_rotate.h"
+
+#include <kaction.h>
+#include <kactioncollection.h>
+#include <klocale.h>
+
+#include <GL/gl.h>
+namespace KWin
+{
+
+KWIN_EFFECT( rotate, RotateEffect )
+
+RotateEffect::RotateEffect()
+ : mActivated( false )
+ {
+ KActionCollection* actionCollection = new KActionCollection( this );
+ KAction* a = static_cast< KAction* >( actionCollection->addAction( "DemoRotate" \
)); + a->setText( i18n("DemoRotate" ));
+ a->setGlobalShortcut( KShortcut( Qt::META + Qt::Key_R ));
+ connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle()));
+ }
+
+RotateEffect::~RotateEffect()
+ {
+ }
+
+void RotateEffect::paintWindow( EffectWindow* w, int mask, QRegion region, \
WindowPaintData& data ) + {
+ if( mActivated )
+ {
+ if( effects->activeWindow() != NULL && w == effects->activeWindow() )
+ {
+ glPushMatrix();
+ glRotatef( 0.25, 0.0, 1.0, 0.0 );
+ effects->paintWindow( w, mask, region, data );
+ glPopMatrix();
+ effects->addRepaintFull();
+ }
+ else
+ effects->paintWindow( w, mask, region, data );
+ }
+ else
+ effects->paintWindow( w, mask, region, data );
+ }
+
+void RotateEffect::toggle()
+ {
+ mActivated = !mActivated;
+ effects->addRepaintFull();
+ }
+
+} // namespace
Index: effects/test/demo_rotate.desktop
===================================================================
--- effects/test/demo_rotate.desktop (Revision 0)
+++ effects/test/demo_rotate.desktop (Revision 0)
@@ -0,0 +1,15 @@
+[Desktop Entry]
+Name=Demo Rotate
+
+Type=Service
+X-KDE-ServiceTypes=KWin/Effect
+X-KDE-PluginInfo-Author=Martin Gräßlin
+X-KDE-PluginInfo-Email=ubuntu@martin-graesslin.com
+X-KDE-PluginInfo-Name=kwin4_effect_rotate
+X-KDE-PluginInfo-Version=0.1.0
+X-KDE-PluginInfo-Category=Demos
+X-KDE-PluginInfo-Depends=
+X-KDE-PluginInfo-License=GPL
+X-KDE-PluginInfo-EnabledByDefault=false
+X-KDE-Library=kwin4_effect_tests
+X-KDE-Ordering=50
\ No newline at end of file
["signature.asc" (application/pgp-signature)]
_______________________________________________
Kwin mailing list
Kwin@kde.org
https://mail.kde.org/mailman/listinfo/kwin
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic