Neverendingo (Talk | contribs) m (Text replace - "</code>" to "</syntaxhighlight>") |
|||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 23: | Line 23: | ||
==Abstract== | ==Abstract== | ||
| + | |||
| + | ( Class names has changed ! This tutorial is currently unvaible ) | ||
| + | |||
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. | 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. | ||
| Line 29: | Line 32: | ||
Second, be sure you have libQt4-dev, libQt4-openGL-dev, and kde4-lib devel. | Second, be sure you have libQt4-dev, libQt4-openGL-dev, and kde4-lib devel. | ||
download KGLEngine source from svn : | download KGLEngine source from svn : | ||
| − | < | + | <syntaxhighlight lang="text">svn co svn://anonsvn.kde.org/home/kde/trunk/playground/games/KGLEngine</syntaxhighlight> |
cd kglengine | cd kglengine | ||
| Line 40: | Line 43: | ||
[[Image:kglengine-tuto1.png]] | [[Image:kglengine-tuto1.png]] | ||
| − | < | + | <syntaxhighlight lang="cpp-qt"> |
#include <KApplication> | #include <KApplication> | ||
| Line 63: | Line 66: | ||
KApplication app; | KApplication app; | ||
| − | KGLEngine2d *engine= KGLEngine2d:: | + | KGLEngine2d *engine= KGLEngine2d::instance(); //init engine |
| − | engine-> | + | engine->setShowAxis(true); //show repere line x,y |
| − | engine-> | + | engine->setShowFps(true); //show fps |
engine->show(); //show window engine | engine->show(); //show window engine | ||
| Line 84: | Line 87: | ||
return 0; | return 0; | ||
} | } | ||
| − | </ | + | </syntaxhighlight> |
| + | |||
| + | == Compilation == | ||
| + | This is the CmakeLists.txt Files. | ||
| + | |||
| + | <syntaxhighlight lang="text"> | ||
| + | |||
| + | project(tutorial1) | ||
| + | |||
| + | find_package(KDE4 REQUIRED) | ||
| + | find_package(Qt4 REQUIRED) | ||
| + | find_package(OpenGL REQUIRED) | ||
| + | find_package(Eigen2 REQUIRED) | ||
| + | |||
| + | include(KDE4Defaults) | ||
| + | |||
| + | include_directories(${KDE4_INCLUDES}) | ||
| + | include_directories(${QT_QTOPENGL_INCLUDE_DIR}) | ||
| + | include_directories(${X11_Xrandr_INCLUDE_PATH}) | ||
| + | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
| + | include_directories(${EIGEN2_INCLUDE_DIR}) | ||
| + | |||
| + | add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS}) | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | ########### next target ############### | ||
| + | |||
| + | set(tutorial1_SRCS | ||
| + | main.cpp | ||
| + | ) | ||
| + | |||
| + | kde4_add_executable(tutorial1 ${tutorial1_SRCS} ) | ||
| + | |||
| + | target_link_libraries(tutorial1 ${KDE4_KDEUI_LIBS} kglengine) | ||
| + | |||
| + | ########### install files ############### | ||
| + | |||
| + | |||
| + | |||
| + | </syntaxhighlight> | ||
| Tutorial Series | KGLEngine2d developement |
| Prerequisites | None |
| What's Next | Nothing at the moment |
| Further Reading | KGLEngine2d's code |
Contents |
( Class names has changed ! This tutorial is currently unvaible )
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.
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;
#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::instance(); //init engine engine->setShowAxis(true); //show repere line x,y engine->setShowFps(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; }
This is the CmakeLists.txt Files.
project(tutorial1)
find_package(KDE4 REQUIRED)
find_package(Qt4 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Eigen2 REQUIRED)
include(KDE4Defaults)
include_directories(${KDE4_INCLUDES})
include_directories(${QT_QTOPENGL_INCLUDE_DIR})
include_directories(${X11_Xrandr_INCLUDE_PATH})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${EIGEN2_INCLUDE_DIR})
add_definitions(${QT_DEFINITIONS} ${KDE4_DEFINITIONS})
########### next target ###############
set(tutorial1_SRCS
main.cpp
)
kde4_add_executable(tutorial1 ${tutorial1_SRCS} )
target_link_libraries(tutorial1 ${KDE4_KDEUI_LIBS} kglengine)
########### install files ###############