Magic Library - True Type windows font

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Magic Library - True Type windows font

Post by Emil_halim »

this is an addon static library for Irrlicht 3D Engine.

it will extend the 2d features of Irrlicht , so you could easlly mix your 2d work with 3d world.


Features of magic2d library
===========================
+ TMovie class that will enable you to render your movie to a texture ,appleing effects
to movie such as gray scale the movie or nigative and more...(fade in & out)....

+ has some features & functions from BlitzMax basic language, so you could blending an image
with background, rotating ,scaling ,tilling it also, you could convert some BlitzMax programs for
work with Irrlicht.

+ has some features from Basic4Gl language,so you could scrolling a maped background,
or draw your 2d map background.

+ playing Gif animations,yes Gif animations,so you could blend this animation with
your background,also you could fade in and out the Gif animation

+ has some functions for easlly dealing with keyboard & mouse.

+ playing animated Images.

+ has class for fade in & out your images ,Gif animatiom and animated Images.

+ adding splash window in your game or program.

+ has classes for drawing fonts to texture or draw part of texture to an other one.


not will , it will only work with OpenGL driver of irrlicht .

it has a compiled demo to show you what could you do with this library.

please if you like it ,let me know and do not forget to tell my your
FPS when you run the demo in your system.

http://bcxdx.spoilerspace.com/BCXGL/Magic2d_03.zip

thanks
Last edited by Emil_halim on Sun Oct 22, 2006 7:36 pm, edited 40 times in total.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

ooh nice! if only i was writing a 2d game :)
you could do with splitting it up in to several examples though, also i use dev-cpp and theres no source tsk tsk :P
i hoped the sine wave image thing was a built in feature, that would be cool

edit:
forgot the fps! :lol:
500 fps, athlon xp 2800, fx5900
Last edited by bitplane on Tue Nov 08, 2005 11:49 pm, edited 1 time in total.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
MrPotatoes
Posts: 38
Joined: Mon Nov 07, 2005 5:55 am

Post by MrPotatoes »

with the GIF animations i think someone here should use this library to make a 3D game of a bad tripod website lol
Maize
Posts: 163
Joined: Sat Oct 29, 2005 12:12 am
Location: In a cave...
Contact:

Post by Maize »

bitplane wrote:ooh nice! if only i was writing a 2d game :)
you could do with splitting it up in to several examples though, also i use dev-cpp and theres no source tsk tsk :P
i hoped the sine wave image thing was a built in feature, that would be cool

edit:
forgot the fps! :lol:
500 fps, athlon xp 2800, fx5900
Yeah, apparently the wave thing IS NOT built in. thats too bad. I guess I cant use it now. :P
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

thanks you guys very much.

thanks for feeding bach the FPS.

i will splitting it up in to several examples and make some help for explain each functions
and classes.

actually there are many 2d effects that you could apply by this magic library,so if i make
each effect as a built in, i thinks it will not a good idea,instead i will create a new
folder and name it Effects2D for holding snippets from me and other usres.

so what do you think guys?

again thanks for your comments
Gambler
Posts: 10
Joined: Sun Nov 06, 2005 9:53 pm
Location: Germany

Post by Gambler »

Looks very interesting, maybe I can use it for our RPG projekt :)
Explaining the functions would be really great, as I am quiet new to the engine and not that good in C++ :wink:
Making snippets in an extra folder sounds good, it would sure be easier to keep track of the several functions.
The FPS I got with my notebook (Pentium 1,6, 512 MB, Radeon 9700 Mobility): 88
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

hi eveybody,i do not pretend that i am a good writer,but for the sake of heaven,let me know if this is clear and understoodable tutorial or not,
so i could contnuie writing other stuff.

Code: Select all

/************************************
       Magic library manual

    HelloWorld program will teach
    you how to compile your first
    magic 2d program.

*************************************/


/* when you install Magic library in your system, you will have
   gl & Magic2d.hpp header in iclude folder,also having desired libs
   in Lib folder such as Magic2d.lib,glu32.lib,opengl32.lib,glaux.lib.
*/
#include <irrlicht.h>

/* for using magic library with your code you have to include
   Magic2d.hpp header file after including Irrlicht.h file,
*/
#include <Magic2d.hpp>

using namespace irr;


using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

// global declration of Irrlicht interfaces
IrrlichtDevice* device;
IVideoDriver*   driver;
ISceneManager*  smgr;
IGUIEnvironment* guienv;

/* if you need this variable to be global so declare it here.
   FontM will hold the texture of font image ,so we use it later
   when printing some text in our screen.
*/
SMaterial FontM;

int main()
{
    /* NOTE WELL::
       Magic Library has CreateDevice function ,it looks like the orignal createDevice
       of Irrlicht,it will Initial some variables that needed by Magic Library then
       it calls our orignal createDevice of Irrlicht automatically.so if you plan
       to use Magic Library,you have to use it's CreateDevice function instead of orignal one.
    */
    device = CreateDevice(640,480,false);

	device->setWindowCaption(L"Hello World! - Magic 2d library for Irrlicht");

	driver = device->getVideoDriver();
	smgr = device->getSceneManager();
	guienv = device->getGUIEnvironment();

    /* here we load our font image, remmber that FontM is a Matrial
       structur ,so we will load the texture as usual.
       and set the transparent color of our font.
    */
    FontM.Texture1 = driver->getTexture("../../media/Font.bmp");
    driver->makeColorKeyTexture(FontM.Texture1,position2d<s32>(0,0));

    // creat the font and set it as defulet for using it later
    GLuint fnt_1 = CreateFont(FontM,16,16,10);
    SetFont(fnt_1);

    int lastFPS = -1;

	while(device->run())
	{

		driver->beginScene(true, true, SColor(0,0,0,0));

                 /* ViewOrtho tells Irrlicht that we will deal with 2d screen
                    coordinates,no 3d depth,no 3d lighting.
                    the left upper point of screen is the Orignal point (0,0 coords).
                    so when we want to draw by some functios of Magic Library we have
                    to start with this function.
                 */
                 ViewOrtho();

                 /*
                     those functions from BlitzMax.
                     seting the blending value and color of our next drawing
                 */
                 SetBlend(ALPHABLEND);
                 SetColor(255,255,255);
	             SetAlpha(1.0);

                 //first we must set our desired font texture before
                 // drawing any text,we st it as we doing in Irrlicht
                 driver->setMaterial(FontM);
                 DrawText("Magic Library by Emil Halim",200,400);

                 /*after we finishing our 2d drawing, we have to reset screen
                   coordinates,depth,and lighting to 3d world,use ViewPerspective
                   function to do that.
                 */
                 ViewPerspective();

                 // we have to reset blending system for correct 3d render
                 SetBlend(SOLIDBLEND);

                 // finally if we have some 3d stuff to draw , we use the next
                 // two lines
                 smgr->drawAll();
		         guienv->drawAll();

		driver->endScene();
		int fps = driver->getFPS();
         if (lastFPS != fps)
         {
            wchar_t tmp[1024];
            swprintf(tmp, 1024, L"Hello World! - Magic 2d library for Irrlicht (%s)(fps:%d)",driver->getName(), fps);
            device->setWindowCaption(tmp);
            lastFPS = fps;
         }
	}

	device->drop();

	return 0;
}

Gambler
Posts: 10
Joined: Sun Nov 06, 2005 9:53 pm
Location: Germany

Post by Gambler »

So far it's good to read!
tobing
Posts: 9
Joined: Wed Aug 24, 2005 5:59 pm
Location: Germany / Heidelberg
Contact:

Post by tobing »

I agree, but I have a remark.

If you don't use the 'using namepsace' statement and instead qualify the calls it would make it easier to locate where something belongs to. So it is more to write, but easier to understand I think.

Second, you define some global variables, but they are only used within main(). I would consider it better style to move the definitions as late as possible (e.g. IrrlichtDevice*const device = CreateDevice(...);', make them const if they are changed later on, and always initialize variables like 'IrrlichtDevice* device = 0;'.
hybrid

Post by hybrid »

Where are the sources? I'd like to check at which points you introduced your own architecture on top of Irrlicht, and where you reuse existing features. Since you did not change Irrlicht itself it might be that most parts are created on top, but this might introduce additional overhead which could be avoided in some cases.
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

@Gambler:

thanks for your feed back.

@tobing:

+++++++++++++++++++++++++++++++++++++++++++++++++++++
If you don't use the 'using namepsace' statement and instead qualify the calls it would make it easier to locate where something belongs to. So it is more to write, but easier to understand I think.
+++++++++++++++++++++++++++++++++++++++++++++++++++++

i have used to use it like this just for fast typing.

+++++++++++++++++++++++++++++++++++++++++++++++++++++
you define some global variables, but they are only used within main().
+++++++++++++++++++++++++++++++++++++++++++++++++++++

because i past and copy this part from the demo which uses this variables in Splash function {outside of main function},so when you decide to use splash class you have to declare some var as a globle.

thanks for your comment


@hybrid:

+++++++++++++++++++++++++++++++++++++++++++++++++++++
but this might introduce additional overhead which could be avoided in some cases.
+++++++++++++++++++++++++++++++++++++++++++++++++++++

i do not think so,the secret is in OpneGl it self for not changing the Engine.
as you know openGl consistes of many c-function which you could call any function
at any time you want.
here is some source of Magic Library ,so what do you think?

Code: Select all

static GLubyte BZ__color[4];
static GLuint  _currentFont;
static int _BltzScreenWith,_BltzScreenHieght;
f32 _BLTZ_ROT;
f32 _BLTZ_SCLx;
f32 _BLTZ_SCLy;


void ViewOrtho()            // Set Up An Ortho View
{
 glDisable(GL_LIGHTING);
 glDisable(GL_DEPTH_TEST);
 glDisable(GL_CULL_FACE);
 glMatrixMode(GL_PROJECTION);        // Select Projection
 glPushMatrix();            // Push The Matrix
 glLoadIdentity();           // Reset The Matrix
 glOrtho( 0, 640 , 480 , 0, -1, 1 );       // Select Ortho Mode (640x480)
 glMatrixMode(GL_MODELVIEW);         // Select Modelview Matrix
 glPushMatrix();            // Push The Matrix
 glLoadIdentity();           // Reset The Matrix
}

void ViewPerspective()           // Set Up A Perspective View
{
 glMatrixMode( GL_PROJECTION );        // Select Projection
 glPopMatrix();            // Pop The Matrix
 glMatrixMode( GL_MODELVIEW );        // Select Modelview
 glPopMatrix();            // Pop The Matrix
 glEnable(GL_DEPTH_TEST);
 glEnable(GL_CULL_FACE);
}

void SetRotation(f32 r)
{
    _BLTZ_ROT = r;
}

void SetScale(f32 sx,f32 sy)
{
    _BLTZ_SCLx = sx;
    _BLTZ_SCLy = sy;
}

void DrawImage(SMaterial img,f32 x ,f32 y)
{
     dimension2d<s32> size = img.Texture1->getOriginalSize();
     f32 w = (f32)(size.Width>>1);
     f32 h = (f32)(size.Height>>1);
     glLoadIdentity();
     glTranslatef(x,y,0);
     glScalef( _BLTZ_SCLx, _BLTZ_SCLy, 0.0f );
     glRotatef(_BLTZ_ROT, 0.0f, 0.0f, 1.0f );
     glBegin(GL_QUADS);
            glTexCoord2f(0,0);glVertex2f(-w,-h);
            glTexCoord2f(0,1);glVertex2f(-w, h);
            glTexCoord2f(1,1);glVertex2f( w, h);
            glTexCoord2f(1,0);glVertex2f( w,-h);
     glEnd();
}
thanks hybrid
Joe_Oliveri
Posts: 448
Joined: Tue Oct 05, 2004 3:24 am
Location: Boston, MA

Post by Joe_Oliveri »

Very nice, and very interesting. :D
Irrlicht Moderator || Game Designer
Learn the basics at </dream.in.code>
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

thanks SkaterX29527 for your comment.


this is the new release of Magic 2d Library,[ie version 0.2].

i have added some new functions for 2d collision test,also added classes for
defining zones on screen,rectangle and ciecle zone,so you could ckeck if the mouse over any zone then take some action.

i have added new effects and examples and some manual examples which explain some functions and classes.

the bin folder contains all the compiled demos for fast testing.

download the new release from the same site.

try it and let me know your opinion.in the main demo do not forget to cilck the left mouse key to fire the tweety image.

thanks
NoM$please

Post by NoM$please »

[/quote]so what do you think guys?

Why are you doing all this, just to exclude all the DevCpp users or what?
Maybe you want to apply for a job at M$?
In the "Subliminal Advertisement" department, hehe.

Well, before i use this bloated compiler i simply ignore your "sweets".
This is so uncool.
Guest

Post by Guest »

NoM$please wrote:so what do you think guys?

Why are you doing all this, just to exclude all the DevCpp users or what?
Maybe you want to apply for a job at M$?
In the "Subliminal Advertisement" department, hehe.

Well, before i use this bloated compiler i simply ignore your "sweets".
This is so uncool.
please .. shut the hell up :? i hate MS bashing without any reason, and even if i would ask you for one, you would probably come up with "because MS is bad and steals my milk!!!"

so go away troll!
Post Reply