Development/Tutorials/Games/kglengine/kglengine-simpleBox: Difference between revisions
< Development | Tutorials
No edit summary |
No edit summary |
||
Line 26: | Line 26: | ||
==Installation == | ==Installation == | ||
First , be sure you have libQt4-dev, libQt4-openGL-dev, and kde4-lib devel. | First : install eigen2 librairy. | ||
Second, be sure you have libQt4-dev, libQt4-openGL-dev, and kde4-lib devel. | |||
download KGLEngine source from svn : | download KGLEngine source from svn : | ||
<code>svn co svn://anonsvn.kde.org/home/kde/trunk/playground/games/KGLEngine</code> | |||
cd kglengine | cd kglengine | ||
Line 37: | Line 38: | ||
==First programm == | ==First programm == | ||
<code cppqt> | |||
#include <KApplication> | |||
#include <KAboutData> | |||
#include <KCmdLineArgs> | |||
#include <KGLEngine2d> | |||
#include <KGLItem> | |||
using namespace std; | |||
int main(int argc, char *argv[]) | |||
{ | |||
KAboutData aboutData("kglintro", 0, | |||
ki18n("tutorial1"), "1.0", | |||
ki18n("engine 2d"), | |||
KAboutData::License_GPL, | |||
ki18n("Copyright (c) 2009 Developer")); | |||
KCmdLineArgs::init(argc, argv, &aboutData); | |||
KApplication app; | |||
KGLEngine2d *engine= KGLEngine2d::getInstance(); //init engine | |||
engine->showRepere(true); //show repere line x,y | |||
engine->showFps(true); //show fps | |||
engine->show(); //show window engine | |||
KGLItem * box = new KGLItem(QRectF(0,0,0.5,0.5)); //create an item | |||
box->scale(0.5); //reduce the size | |||
box->translate(-box->transformCenter()); //translate the box to the center | |||
box->rotate(M_PI/4); //rotate it with a radius = 45 deg | |||
box->setColor(Qt::white); //setColor! By default, it's white | |||
engine->addItem(box); //add item to the engine | |||
app.exec(); | |||
return 0; | |||
} | |||
</code> |
Revision as of 13:11, 23 February 2009
KGLEngine tutorial 1
Tutorial Series | KGLEngine2d developement |
Prerequisites | None |
What's Next | Nothing at the moment |
Further Reading | KGLEngine2d's code |
Abstract
KGLengine is a powerfull 2d games engine, for people who want to create hight level of games. Instead QGraphicsView system, KGLEngine use all power of openGL and Eigen mathematic library. Now you will be able to create fullscreen games, particles effects for make smoke or explosion, shadow effects, collision detection with a lot of items, and as soon as possible to use Shaders effects.
Installation
First : install eigen2 librairy.
Second, be sure you have libQt4-dev, libQt4-openGL-dev, and kde4-lib devel.
download KGLEngine source from svn :
svn co svn://anonsvn.kde.org/home/kde/trunk/playground/games/KGLEngine
cd kglengine mkdir build cd build cmake .. make; make install;
First programm
- include <KApplication>
- include <KAboutData>
- include <KCmdLineArgs>
- include <KGLEngine2d>
- include <KGLItem>
using namespace std;
int main(int argc, char *argv[])
{
KAboutData aboutData("kglintro", 0,
ki18n("tutorial1"), "1.0",
ki18n("engine 2d"),
KAboutData::License_GPL,
ki18n("Copyright (c) 2009 Developer"));
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
KGLEngine2d *engine= KGLEngine2d::getInstance(); //init engine
engine->showRepere(true); //show repere line x,y
engine->showFps(true); //show fps
engine->show(); //show window engine
KGLItem * box = new KGLItem(QRectF(0,0,0.5,0.5)); //create an item
box->scale(0.5); //reduce the size
box->translate(-box->transformCenter()); //translate the box to the center
box->rotate(M_PI/4); //rotate it with a radius = 45 deg
box->setColor(Qt::white); //setColor! By default, it's white
engine->addItem(box); //add item to the engine
app.exec();
return 0;
}