From 393b5cd1dc438872af89d334ef6e5fcc59f27d47 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 13 Jan 2013 17:24:39 +1000 Subject: Added Irrlicht 1.8, but without all the Windows binaries. --- .../examples/06.2DGraphics/2DGraphics.cbp | 55 +++++ .../examples/06.2DGraphics/2DGraphics.dev | 59 ++++++ .../examples/06.2DGraphics/2DGraphics.vcproj | 163 ++++++++++++++ .../examples/06.2DGraphics/2DGraphics_vc10.vcxproj | 231 ++++++++++++++++++++ .../examples/06.2DGraphics/2DGraphics_vc11.vcxproj | 235 +++++++++++++++++++++ .../examples/06.2DGraphics/2DGraphics_vc8.vcproj | 231 ++++++++++++++++++++ .../examples/06.2DGraphics/2DGraphics_vc9.vcproj | 230 ++++++++++++++++++++ .../irrlicht-1.8/examples/06.2DGraphics/Makefile | 38 ++++ .../irrlicht-1.8/examples/06.2DGraphics/main.cpp | 166 +++++++++++++++ .../examples/06.2DGraphics/tutorial.html | 163 ++++++++++++++ 10 files changed, 1571 insertions(+) create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.cbp create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.dev create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.vcproj create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc10.vcxproj create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc11.vcxproj create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc8.vcproj create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc9.vcproj create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/Makefile create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/main.cpp create mode 100644 libraries/irrlicht-1.8/examples/06.2DGraphics/tutorial.html (limited to 'libraries/irrlicht-1.8/examples/06.2DGraphics') diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.cbp b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.cbp new file mode 100644 index 0000000..0433c93 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.cbp @@ -0,0 +1,55 @@ + + + + + + diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.dev b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.dev new file mode 100644 index 0000000..93694f1 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.dev @@ -0,0 +1,59 @@ +[Project] +FileName=example.dev +Name=Irrlicht Example 06 2D Graphics +UnitCount=1 +Type=1 +Ver=1 +ObjFiles= +Includes=..\..\include +Libs= +PrivateResource= +ResourceIncludes= +MakeIncludes= +Compiler= +CppCompiler= +Linker=../../lib/Win32-gcc/libIrrlicht.a_@@_ +IsCpp=1 +Icon= +ExeOutput=../../bin/Win32-gcc +ObjectOutput=obj +OverrideOutput=1 +OverrideOutputName=06.2DGraphics.exe +HostApplication= +Folders= +CommandLine= +IncludeVersionInfo=0 +SupportXPThemes=0 +CompilerSet=0 +CompilerSettings=0000000000000000000000 +UseCustomMakefile=0 +CustomMakefile= + +[Unit1] +FileName=main.cpp +CompileCpp=1 +Folder=Projekt1 +Compile=1 +Link=1 +Priority=1000 +OverrideBuildCmd=0 +BuildCmd= + +[VersionInfo] +Major=0 +Minor=1 +Release=1 +Build=1 +LanguageID=1033 +CharsetID=1252 +CompanyName= +FileVersion= +FileDescription=Irrlicht Engine example compiled using DevCpp and gcc +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion= +AutoIncBuildNr=0 + diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.vcproj b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.vcproj new file mode 100644 index 0000000..b21c351 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics.vcproj @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc10.vcxproj b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc10.vcxproj new file mode 100644 index 0000000..b0f184e --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc10.vcxproj @@ -0,0 +1,231 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 06.2DGraphics + {E71B6F18-10DC-4101-A541-F6D33F71B2BD} + 2DGraphics + + + + Application + false + MultiByte + + + Application + false + MultiByte + + + Application + false + MultiByte + + + Application + false + MultiByte + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + .\Release/2DGraphics.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release/2DGraphics.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Debug/2DGraphics.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug/2DGraphics.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Disabled + Disabled + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc11.vcxproj b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc11.vcxproj new file mode 100644 index 0000000..66e7aa0 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc11.vcxproj @@ -0,0 +1,235 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + 06.2DGraphics + {E71B6F18-10DC-4101-A541-F6D33F71B2BD} + 2DGraphics + + + + Application + false + MultiByte + v110 + + + Application + false + MultiByte + v110 + + + Application + false + MultiByte + v110 + + + Application + false + MultiByte + v110 + + + + + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + ..\..\bin\Win32-VisualStudio\ + ..\..\bin\Win64-VisualStudio\ + + + AllRules.ruleset + AllRules.ruleset + + + + + AllRules.ruleset + AllRules.ruleset + + + + + + + + .\Release/2DGraphics.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Release/2DGraphics.tlb + + + + + MaxSpeed + OnlyExplicitInline + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + + + Level3 + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + Console + + + + + + + .\Debug/2DGraphics.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win32-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win32-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + .\Debug/2DGraphics.tlb + + + + + Disabled + ..\..\include;%(AdditionalIncludeDirectories) + WIN32;WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + + + Level3 + ProgramDatabase + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c07 + + + ..\..\bin\Win64-VisualStudio\06.2DGraphics.exe + ..\..\lib\Win64-visualstudio;%(AdditionalLibraryDirectories) + true + Console + + + + + + + Disabled + Disabled + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + EnableFastChecks + EnableFastChecks + MaxSpeed + MaxSpeed + %(AdditionalIncludeDirectories) + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + \ No newline at end of file diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc8.vcproj b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc8.vcproj new file mode 100644 index 0000000..8a10914 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc8.vcproj @@ -0,0 +1,231 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc9.vcproj b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc9.vcproj new file mode 100644 index 0000000..e78f8a0 --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/2DGraphics_vc9.vcproj @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/Makefile b/libraries/irrlicht-1.8/examples/06.2DGraphics/Makefile new file mode 100644 index 0000000..6e62b2b --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/Makefile @@ -0,0 +1,38 @@ +# Makefile for Irrlicht Examples +# It's usually sufficient to change just the target name and source file list +# and be sure that CXX is set to a valid compiler +Target = 06.2DGraphics +Sources = main.cpp + +# general compiler settings +CPPFLAGS = -I../../include -I/usr/X11R6/include +CXXFLAGS = -O3 -ffast-math +#CXXFLAGS = -g -Wall + +#default target is Linux +all: all_linux + +ifeq ($(HOSTTYPE), x86_64) +LIBSELECT=64 +endif + +# target specific settings +all_linux: LDFLAGS = -L/usr/X11R6/lib$(LIBSELECT) -L../../lib/Linux -lIrrlicht -lGL -lXxf86vm -lXext -lX11 -lXcursor +all_linux clean_linux: SYSTEM=Linux +all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm +all_win32 clean_win32: SYSTEM=Win32-gcc +all_win32 clean_win32: SUF=.exe +# name of the binary - only valid for targets which set SYSTEM +DESTPATH = ../../bin/$(SYSTEM)/$(Target)$(SUF) + +all_linux all_win32: + $(warning Building...) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) $(Sources) -o $(DESTPATH) $(LDFLAGS) + +clean: clean_linux clean_win32 + $(warning Cleaning...) + +clean_linux clean_win32: + @$(RM) $(DESTPATH) + +.PHONY: all all_win32 clean clean_linux clean_win32 diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/main.cpp b/libraries/irrlicht-1.8/examples/06.2DGraphics/main.cpp new file mode 100644 index 0000000..40e311a --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/main.cpp @@ -0,0 +1,166 @@ +/** Example 006 2D Graphics + +This Tutorial shows how to do 2d graphics with the Irrlicht Engine. +It shows how to draw images, keycolor based sprites, +transparent rectangles, and different fonts. You may consider +this useful if you want to make a 2d game with the engine, or if +you want to draw a cool interface or head up display for your 3d game. + +As always, I include the header files, use the irr namespace, +and tell the linker to link with the .lib file. +*/ +#include +#include "driverChoice.h" + +using namespace irr; + +#ifdef _MSC_VER +#pragma comment(lib, "Irrlicht.lib") +#endif + +/* +At first, we let the user select the driver type, then start up the engine, set +a caption, and get a pointer to the video driver. +*/ +int main() +{ + // ask user for driver + video::E_DRIVER_TYPE driverType=driverChoiceConsole(); + if (driverType==video::EDT_COUNT) + return 1; + + // create device + + IrrlichtDevice *device = createDevice(driverType, + core::dimension2d(512, 384)); + + if (device == 0) + return 1; // could not create selected driver. + + device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo"); + + video::IVideoDriver* driver = device->getVideoDriver(); + + /* + All 2d graphics in this example are put together into one texture, + 2ddemo.png. Because we want to draw colorkey based sprites, we need to + load this texture and tell the engine, which part of it should be + transparent based on a colorkey. + + In this example, we don't tell it the color directly, we just say "Hey + Irrlicht Engine, you'll find the color I want at position (0,0) on the + texture.". Instead, it would be also possible to call + driver->makeColorKeyTexture(images, video::SColor(0,0,0,0)), to make + e.g. all black pixels transparent. Please note that + makeColorKeyTexture just creates an alpha channel based on the color. + */ + video::ITexture* images = driver->getTexture("../../media/2ddemo.png"); + driver->makeColorKeyTexture(images, core::position2d(0,0)); + + /* + To be able to draw some text with two different fonts, we first load + them. Ok, we load just one. As the first font we just use the default + font which is built into the engine. Also, we define two rectangles + which specify the position of the images of the red imps (little flying + creatures) in the texture. + */ + gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont(); + gui::IGUIFont* font2 = + device->getGUIEnvironment()->getFont("../../media/fonthaettenschweiler.bmp"); + + core::rect imp1(349,15,385,78); + core::rect imp2(387,15,423,78); + + /* + Prepare a nicely filtering 2d render mode for special cases. + */ + driver->getMaterial2D().TextureLayer[0].BilinearFilter=true; + driver->getMaterial2D().AntiAliasing=video::EAAM_FULL_BASIC; + + /* + Everything is prepared, now we can draw everything in the draw loop, + between the begin scene and end scene calls. In this example, we are + just doing 2d graphics, but it would be no problem to mix them with 3d + graphics. Just try it out, and draw some 3d vertices or set up a scene + with the scene manager and draw it. + */ + while(device->run() && driver) + { + if (device->isWindowActive()) + { + u32 time = device->getTimer()->getTime(); + + driver->beginScene(true, true, video::SColor(255,120,102,136)); + + /* + First, we draw 3 sprites, using the alpha channel we + created with makeColorKeyTexture. The last parameter + specifies that the drawing method should use this alpha + channel. The last-but-one parameter specifies a + color, with which the sprite should be colored. + (255,255,255,255) is full white, so the sprite will + look like the original. The third sprite is drawn + with the red channel modulated based on the time. + */ + + // draw fire & dragons background world + driver->draw2DImage(images, core::position2d(50,50), + core::rect(0,0,342,224), 0, + video::SColor(255,255,255,255), true); + + // draw flying imp + driver->draw2DImage(images, core::position2d(164,125), + (time/500 % 2) ? imp1 : imp2, 0, + video::SColor(255,255,255,255), true); + + // draw second flying imp with colorcylce + driver->draw2DImage(images, core::position2d(270,105), + (time/500 % 2) ? imp1 : imp2, 0, + video::SColor(255,(time) % 255,255,255), true); + + /* + Drawing text is really simple. The code should be self + explanatory. + */ + + // draw some text + if (font) + font->draw(L"This demo shows that Irrlicht is also capable of drawing 2D graphics.", + core::rect(130,10,300,50), + video::SColor(255,255,255,255)); + + // draw some other text + if (font2) + font2->draw(L"Also mixing with 3d graphics is possible.", + core::rect(130,20,300,60), + video::SColor(255,time % 255,time % 255,255)); + + /* + Next, we draw the Irrlicht Engine logo (without + using a color or an alpha channel). Since we slightly scale + the image we use the prepared filter mode. + */ + driver->enableMaterial2D(); + driver->draw2DImage(images, core::rect(10,10,108,48), + core::rect(354,87,442,118)); + driver->enableMaterial2D(false); + + /* + Finally draw a half-transparent rect under the mouse cursor. + */ + core::position2d m = device->getCursorControl()->getPosition(); + driver->draw2DRectangle(video::SColor(100,255,255,255), + core::rect(m.X-20, m.Y-20, m.X+20, m.Y+20)); + + driver->endScene(); + } + } + + device->drop(); + + return 0; +} + +/* +That's all. I hope it was not too difficult. +**/ diff --git a/libraries/irrlicht-1.8/examples/06.2DGraphics/tutorial.html b/libraries/irrlicht-1.8/examples/06.2DGraphics/tutorial.html new file mode 100644 index 0000000..ea6291a --- /dev/null +++ b/libraries/irrlicht-1.8/examples/06.2DGraphics/tutorial.html @@ -0,0 +1,163 @@ + + +Irrlicht Engine Tutorial + + + + +
+ + + + + + + + +
+
+
+
Tutorial 6. 2D Graphics
+
+
+
+

This Tutorial shows how to do 2d graphics with the Irrlicht Engine. + It shows how to draw images, keycolor based sprites, transparent rectangles + and different fonts. You will may consider this useful if you want to + make a 2d game with the engine, or if you want to draw a cool interface + or head up display for your 3d game.

+

The program which is described here will look like this:

+


+

+
+
+
+ + + + + + + +
+ Lets start!
+

As always, I include the header files, use the irr namespace, and tell + the linker to link with the .lib file.

+ + + + +
#include <irrlicht.h>
#include <iostream>

using namespace irr;
+
#pragma comment(lib, "Irrlicht.lib")
+               
+

At first, we let the user select the driver type, then start up the + engine, set a caption, and get a pointer to the video driver.

+ + + + +
int main()
{
// let user select driver type
video::E_DRIVER_TYPE driverType;

printf("Please select the driver you want for this example:\n"\
" (a) Direct3D 9.0c\n (b) Direct3D 8.1\n (c) OpenGL 1.5\n"\
" (d) Software Renderer\n (e) Apfelbaum Software Renderer\n"\
" (f) NullDevice\n (otherKey) exit\n\n");

char i;
std::cin >> i;

switch(i)
{
case 'a': driverType = video::EDT_DIRECT3D9;break;
case 'b': driverType = video::EDT_DIRECT3D8;break;
case 'c': driverType = video::EDT_OPENGL; break;
case 'd': driverType = video::EDT_SOFTWARE; break;
case 'e': driverType = video::EDT_BURNINGSVIDEO;break;
case 'f': driverType = video::EDT_NULL; break;
default: return 0;
}

// create device
+
  IrrlichtDevice *device = createDevice(driverType,
+         core::dimension2d<s32>(512, 384));
+
  if (device == 0)
+      return 1;
+ 
device->setWindowCaption(L"Irrlicht Engine - 2D Graphics Demo");
+
  video::IVideoDriver* driver = device->getVideoDriver();
+

All 2d graphics in this example are put together into one texture, + 2ddemo.bmp. Because we want to draw colorkey based sprites, we need + to load this texture and tell the engine, which part of it should be + transparent based on a colorkey. In this example, we don't tell it the + color directly, we just say "Hey Irrlicht Engine, you'll find the + color I want at position (0,0) on the texture.". Instead, it would + be also possible to call driver->makeColorKeyTexture(images, + video::SColor(0,0,0,0)), to make e.g. all black pixels transparent. + Please note, that makeColorKeyTexture just creates an alpha channel + based on the color.

+ + + + +
video::ITexture* images = driver->getTexture("../../media/2ddemo.bmp");
driver->makeColorKeyTexture(images, core::position2d<s32>(0,0));
+

To be able to draw some text with two different fonts, we load them. + Ok, we load just one, as first font we just use the default font which + is built into the engine.
+ Also, we define two rectangles, which specify the position of the images + of the red imps (little flying creatures) in the texture.

+ + + + +
gui::IGUIFont* font = device->getGUIEnvironment()->getBuiltInFont();
gui::IGUIFont* font2 = device->getGUIEnvironment()->getFont( + "../../media/fonthaettenschweiler.bmp");
+
core::rect<s32> imp1(349,15,385,78);
+core::rect<s32> imp2(387,15,423,78);
+

Everything is prepared, now we can draw everything in the draw loop, + between the begin scene and end scene calls. In this example, we are + just doing 2d graphics, but it would be no problem to mix them with + 3d graphics. Just try it out, and draw some 3d vertices or set up a + scene with the scene manager and draw it.

+
+ + + + +
while(device->run() && driver)
{
if (device->isWindowActive())
{
u32 time = device->getTimer()->getTime();
driver->beginScene(true, true, video::SColor(0,120,102,136)); +
+

First, we draw 3 sprites, using the alpha channel we created with makeColorKeyTexture. + The last parameter specifiys that the drawing method should use thiw alpha + channel. The parameter before the last one specifies a color, with wich + the sprite should be colored. (255,255,255,255) is full white, so the + sprite will look like the original. The third sprite is drawed colored + based on the time.

+ + + + +
// draw fire & dragons background world
driver->draw2DImage(images, core::position2d<s32>(50,50),
core::rect<s32>(0,0,342,224), 0,
video::SColor(255,255,255,255), true);
+
// draw flying imp 
+driver->draw2DImage(images, core::position2d<s32>(164,125),
+  (time/500 % 2) ? imp1 : imp2, 0, 
+   video::SColor(255,255,255,255), true);
+
// draw second flying imp with colorcylce
+driver->draw2DImage(images, core::position2d<s32>(270,105),
+  (time/500 % 2) ? imp1 : imp2, 0, 
+  video::SColor(255,(time) % 255,255,255), true);
+

Drawing text is really simple. The code should be self explanatory.

+ + + + +
// draw some text
if (font)
font->draw(L"This is some text.",
core::rect<s32>(130,10,300,50),
video::SColor(255,255,255,255));
+
// draw some other text
+if (font2)
+   font2->draw(L"This is some other text.", 
+       core::rect<s32>(130,20,300,60),
+       video::SColor(255,time % 255,time % 255,255));
+

At last, we draw the Irrlicht Engine logo (without using a color or an + alpha channel) and a transparent 2d Rectangle at the position of the mouse + cursor.

+ + + + +
    // draw logo
driver->draw2DImage(images, core::position2d<s32>(10,10),
core::rect<s32>(354,87,442,118));
+
    // draw transparent rect under cursor
+    core::position2d<s32> m = device->getCursorControl()->getPosition();
+    driver->draw2DRectangle(video::SColor(100,255,255,255),
+          core::rect<s32>(m.X-20, m.Y-20, m.X+20, m.Y+20));
+
    driver->endScene();
+  }
+}
+

That's all, it was not really difficult, I hope.

+ + + + +
   device->drop();
+   return 0;
+}
+
+

 

+

 

+ + -- cgit v1.1