From kwin Sat Mar 29 10:38:05 2008 From: Martin Graesslin Date: Sat, 29 Mar 2008 10:38:05 +0000 To: kwin Subject: Re: Physics Based Animator Message-Id: <200803291138.09578.ubuntu () martin-graesslin ! com> X-MARC-Message: https://marc.info/?l=kwin&m=120678714412484 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============0244733642==" --===============0244733642== Content-Type: multipart/signed; boundary="nextPart2334425.tNilfPlzKF"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart2334425.tNilfPlzKF Content-Type: multipart/mixed; boundary="Boundary-01=_Nwh7H3oh0tcspog" Content-Transfer-Encoding: 7bit Content-Disposition: inline --Boundary-01=_Nwh7H3oh0tcspog Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Am Freitag, 28. M=C3=A4rz 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 wer= e a=20 way to not do the rendering in this way. It really hurts and causes the=20 problems like not working with TwinView, etc. I just tried a little bit and have a demo rotating effect that does not use= =20 the strange code I wrote in coverswitch. I replaced the glOrthon in=20 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=20 correctly, but I would say it is a proof of concept ;-) --Boundary-01=_Nwh7H3oh0tcspog Content-Type: text/x-diff; charset="utf-8"; name="rotate.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="rotate.diff" Index: scene_opengl.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- 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 =2D 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:" << s= hm_mode << ", Direct:" << bool( glXIsDirect( display(), ctxbuffer )) << en= dl; init_ok =3D true; + glTranslatef(-displayWidth()*0.5f, -displayHeight()*0.5f, -10.0); } =20 SceneOpenGL::~SceneOpenGL() Index: effects/test/CMakeLists.txt =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- 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 @@ =20 install( FILES demo_liquid.desktop + demo_rotate.desktop demo_showpicture.desktop demo_wavywindows.desktop test_fbo.desktop Index: effects/test/demo_rotate.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- 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=C3=A4=C3=9Flin . +*********************************************************************/ + +#ifndef KWIN_ROTATE_H +#define KWIN_ROTATE_H + +#include + +namespace KWin +{ + +class RotateEffect + : public QObject, public Effect + { + Q_OBJECT + public: + RotateEffect(); + ~RotateEffect(); + + virtual void paintWindow( EffectWindow* w, int mask, QRegion regio= n, WindowPaintData& data ); + + private slots: + void toggle(); + private: + bool mActivated; + }; + +} // namespace + +#endif Index: effects/test/demo_rotate.cpp =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- 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=C3=A4=C3=9Flin . +*********************************************************************/ +#include "demo_rotate.h" + +#include +#include +#include + +#include +namespace KWin +{ + +KWIN_EFFECT( rotate, RotateEffect ) + +RotateEffect::RotateEffect() + : mActivated( false ) + { + KActionCollection* actionCollection =3D new KActionCollection( this ); + KAction* a =3D 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() !=3D NULL && w =3D=3D effects->activeW= indow() ) + { + 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 =3D !mActivated; + effects->addRepaintFull(); + } + +} // namespace Index: effects/test/demo_rotate.desktop =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =2D-- effects/test/demo_rotate.desktop (Revision 0) +++ effects/test/demo_rotate.desktop (Revision 0) @@ -0,0 +1,15 @@ +[Desktop Entry] +Name=3DDemo Rotate + +Type=3DService +X-KDE-ServiceTypes=3DKWin/Effect +X-KDE-PluginInfo-Author=3DMartin Gr=C3=A4=C3=9Flin +X-KDE-PluginInfo-Email=3Dubuntu@martin-graesslin.com +X-KDE-PluginInfo-Name=3Dkwin4_effect_rotate +X-KDE-PluginInfo-Version=3D0.1.0 +X-KDE-PluginInfo-Category=3DDemos +X-KDE-PluginInfo-Depends=3D +X-KDE-PluginInfo-License=3DGPL +X-KDE-PluginInfo-EnabledByDefault=3Dfalse +X-KDE-Library=3Dkwin4_effect_tests +X-KDE-Ordering=3D50 \ No newline at end of file --Boundary-01=_Nwh7H3oh0tcspog-- --nextPart2334425.tNilfPlzKF Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iQCVAwUAR+4cDf7pqVozU+giAQIz7gP8C7OERsl3rEEg2HEugz30zRsBfB2qmrwH 974seSthYEScc/GBEAw8HbZI9NjhZoxSQPujWs+bfmaFs2VsiLRUxxxn/Qj4rfyS xDxhQ7o4zZHv+/56qPelI0MBUs+nnXu7DJYJZteK2+grJgJ5N8bvbiS73/4QRuxz Mokbz7f0tMM= =NLmz -----END PGP SIGNATURE----- --nextPart2334425.tNilfPlzKF-- --===============0244733642== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kwin mailing list Kwin@kde.org https://mail.kde.org/mailman/listinfo/kwin --===============0244733642==--