Magic Library - True Type windows font

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Emil Halim

Post by Emil Halim »

no, the sound need to be Synchronized with the movie which may drop
some frames from your movie,so when i find a solution i will implement it.

the movie formats that Magic2d allows is any one that you install it's codecs
in your system,so it will play MPEG and WMV if you install WMplayer ver 10.
Gambler
Posts: 10
Joined: Sun Nov 06, 2005 9:53 pm
Location: Germany

Post by Gambler »

Ah, I have a question, could you put the source of Magic2D online? We're discussing if we could use Magic2D for our study project (did everything with irrlicht itself at the moment), but there are a few problems... :D
First, our programmer is getting about 311 errors if Magic2d is implemented, and now he would like to see the code of Magic2d to understand what everything does (like SMaterial, how it works) - and to get rid of those errors :)
I have another question, Magic2d runs only under windows right? Just asking because our game has to run under Linux, too.
Thanks in advance for your answer and sorry if I may sound stupid :)
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

@Gambler

please ,and this for all users of forum, please do not ask or 'push' me to release the source code of Magic2D Library, instead i am offering a nonstop helping and supporting for all users, all the demos are open source to let you know how it works.

so what are your errors, do you use Irrlicht ver 0.14 or a mod one?
please post some of this errors and i will help you.

Magic2D works under wendows ,sorry i have no Linux system.
Xaron
Posts: 310
Joined: Sun Oct 16, 2005 7:39 am
Location: Germany
Contact:

Post by Xaron »

Emil_halim please note, that your link to your library at http://www.freewebs.com/bcxgl/download.htm does not work (for OpenGL) as you still link to version 05.

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

Post by Gambler »

We're using Irrlicht 0.14, not a mod one. Programming with VC++ 6.0
Okay, I'll try to explain :)
If the Magic2D.hpp is included, we get 411 errors and 5 warnings... ehehehe..
First one is in line 47:
"...<filenames>\include\magic2d.hpp(47) : error C2061: Syntaxerror : identifier 'ITexture'
and then some more, but happening really often:
"...<filenames>\include\objidl.h(many) : error(C2872) : 'IUnknown' : ambiguous symbol

Do you have an idea how we could solve it? Would be great :)
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

@Xaron

thank you for remind me, i will fix it sooner, i am busy with Shader language ,still learning it, i have made a TShader
class that will simplify the working with the shader.
when i complete some things usefull i will Release Magic2d ver 0.7 which supports shader.

@Gambler

sorry this informatioms are not enough for me,but i have suspected in the order of includes statment in your code,it seemes that there is some thing conflict with IUnknown interface of Irrlicht so all the interfaces that drived form IUnknown interface will not works.

could you please send a part of your code that containes the includes statments.
Guest

Post by Guest »

First, sorry for my late reply, I'm barely online these days :wink:
Okay, for the includes.
We have different files for graphic, level and so on.
The include statement is in our input file, right behind the irrlicht include.
<code>
#ifndef __INPUT__
#define __INPUT__

#include <irrlicht.h>
#include <Magic2d.hpp>
</code>
And that's all, all of the other code has nothing to do with Magic2d. We wanted to test some of its functions, but it don't like our include (or we are just too stupid :wink: ).
Maybe it'll help if I post our include-hierarchy:
Main.h includes GameEngine.h
GameEngine.h includes events.h, that one includes player.h, and finally player.h includes input.h.
And the input.h includes the irrlicht.h and Magic2d.hpp.
But we include the irrlicht.h twice, second time in our level.h. Maybe that's the reason?
Sorry if that sounds confusing, we just don't really know how to describe it :)
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

first of all ,i will give you small test to see how the order of include files affects the compilation process.

in the hellow example try to put "#include <dshow.h>" before you include irrlicht header "#include <irrlicht.h>" , this will compile ok.

try to put "#include <dshow.h>" after "#include <irrlicht.h>" , this will give you a lot of error.

do not ask me why, but this happend in my computer.

second, you have mintioned that the error first appeare at line #47 because of 'ITexture' , but this was in line #56 in Magic2d.hpp ver 0.6 ,so did you change any thing in it?

finally i suggest that {#include "input.h"} is the first statement in the main.h file which includes Magic2D.hpp ,this may solve the proplem.

i have more question,did you try to compile any magic demo ? and if so did it give you the same errors?

good luck
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Hi all

here is the new Magic2d version 0.07, that supports Shader laguage for creating endless Effects on your work.

TShader class will simplefy working with shader Laguage.

here is some screenshots.
Image
Image
Image
Image

the shader programs is not mine,took from the net.

so with shader laguage you could apply many effect such as Blur,Sharp,Nigative,Emboss,grayscal , on your game.

REMARK: this will work only with Nvidia OpenGL.

download it from here
http://bcxdx.spoilerspace.com/BCXGL/Magic2d_07.rar

have fun with Magic2d Library
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

shader for custom SceneNude

Post by Emil_halim »

Hi All

this example will show you hwo easly can you apply shader effects to a custom SceneNude.

the shader program will apply the Embossed effects to each frame of the movie.

first we declare a global TShader class to allow next custom SceneNude to share the effect.

in the main function we write the shader program by using TShader class.

in the render function of our SceneNude we have to activate the shader program by using {your class}->Start(); the we draw our scenenude the we deactivate it by using {your class}->Stop();.

here is a screen shots of the demo
Image

here is the code

Code: Select all

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

   playing movie with shader
      Embossed effects
*************************************/

#include <irrlicht.h>

#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;

TShader* Embossed;

class CSampleSceneNode : public ISceneNode
{
         aabbox3d<f32> Box;
         SMaterial Material;

       public:
         S3DVertex Vertices[4];

       CSampleSceneNode(ISceneNode* parent, ISceneManager* mgr, s32 id): ISceneNode(parent, mgr, id)
        {
                 float u = 320.0/512.0;
                 float v = 240.0/512.0;
                 Material.Wireframe = false;
                 Material.Lighting = false;
                 Vertices[0] = S3DVertex(-10,-10,0, 0,0,0,SColor(255,255,255,255),0,v);
                 Vertices[1] = S3DVertex( 10,-10,0, 0,0,0,SColor(255,255,255,255),u,v);
                 Vertices[2] = S3DVertex( 10, 10,0, 0,0,0,SColor(255,255,255,255),u,0);
                 Vertices[3] = S3DVertex(-10, 10,0, 0,0,0,SColor(255,255,255,255),0,0);

                 Box.reset(Vertices[0].Pos);
                 for (s32 i=1; i<4; ++i)  Box.addInternalPoint(Vertices[i].Pos);
         }

        virtual void OnPreRender()
         {
                 if (IsVisible)    SceneManager->registerNodeForRendering(this);
                 ISceneNode::OnPreRender();
         }

        virtual void render()
         {
                 u16 indices[] = { 0,1,3, 3,1,2, 1,0,2, 2,0,3 };
                 IVideoDriver* driver = SceneManager->getVideoDriver();
                 driver->setMaterial(Material);
                 SetBlend(ALPHABLEND);
                 Embossed->Start();
                 driver->setTransform(ETS_WORLD, AbsoluteTransformation);
                 driver->drawIndexedTriangleList(&Vertices[0], 4, &indices[0], 4);
                 Embossed->Stop();
         }

        virtual const aabbox3d<f32>& getBoundingBox() const
         {
                 return Box;
         }

        virtual s32 getMaterialCount()
         {
                 return 1;
         }

        virtual SMaterial& getMaterial(s32 i)
         {
                 return Material;
         }
};


int main()
{

    device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32);
    bool rslt = InitMagic(device);
    if(rslt == false)
          printf("Magic Library will only work with OpenGL driver");

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

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

    Embossed = new TShader();
    Embossed->CreatFProg();
    Embossed->AddToFragmnProg("!!ARBfp1.0");
    Embossed->AddToFragmnProg("ATTRIB inTexCoord = fragment.texcoord;");
    Embossed->AddToFragmnProg("OUTPUT outColor   = result.color;");
    Embossed->AddToFragmnProg("PARAM c[2] = { {0.001, 2, 0.5, 1} , {0.33333334} };");
    Embossed->AddToFragmnProg("TEMP R0,R1;");
    Embossed->AddToFragmnProg("ADD R0.xy, inTexCoord, c[0].x;");
    Embossed->AddToFragmnProg("TEX R1, R0, texture, 2D;");
    Embossed->AddToFragmnProg("ADD R0.xy, inTexCoord, -c[0].x;");
    Embossed->AddToFragmnProg("MUL R1,R1,c[0].y;");
    Embossed->AddToFragmnProg("TEX R0, R0, texture, 2D;");
    Embossed->AddToFragmnProg("MAD R0,-R0,c[0].y,R1;");
    Embossed->AddToFragmnProg("ADD R0,R0, c[0].zzzw;");
    Embossed->AddToFragmnProg("ADD R0.x,R0.x, R0.y;");
    Embossed->AddToFragmnProg("ADD R0.x,R0.x, R0.z;");
    Embossed->AddToFragmnProg("MUL outColor.xyz,R0.x,c[1].x;");
    Embossed->AddToFragmnProg("MOV outColor.w, R0;");
    Embossed->AddToFragmnProg("END");
    Embossed->FinishFragmnProg();

    TMovie* movie=new TMovie;
    movie->LoadMovie("../../media/Test.Avi");
   // movie->LoadMovie("../../media/s1.asf");
    movie->SetMovieFPS(65);
   // movie->SetMovieFPS(10);
    movie->SetLooped(true);

    driver->setTextureCreationFlag(ETCF_ALWAYS_32_BIT,TRUE);
    driver->setTextureCreationFlag(ETCF_CREATE_MIP_MAPS,FALSE);
    ITexture* movTxtr = driver->addTexture(dimension2d<s32>(512,512),"");
    smgr->addCameraSceneNode(0,vector3df(0,0,-20),vector3df(0,0,0));
    CSampleSceneNode* myNode=new CSampleSceneNode(smgr->getRootSceneNode(),smgr,666);
    myNode->setMaterialTexture(0,movTxtr);
    myNode->setMaterialType(EMT_TRANSPARENT_VERTEX_ALPHA);
    myNode->setPosition(vector3df(0,0,0));

    int lastFPS = -1;

    movie->Seek(movie->GetFullTime()/2);
    LONGLONG MovieLen = movie->GetFullTime()/10000000; // length of movie in Secs

	while(device->run())
	{

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

                 movie->NextMovieFrame();
                 movie->DrawMovie(0,0,movTxtr);

                 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;
}
Note : you could apply the effect to the entire Scene ,
just activate the effect befor smgr->drawAll(); the deactivate it.

Enjoy it.
Mike
Posts: 17
Joined: Wed Dec 14, 2005 6:42 pm

Post by Mike »

Is that Celine Dion?
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

yes she is.

Celine Dion is one of my favorite singers.
Guest

Post by Guest »

Hi All,
I'm first time use Irrlicht,
and I download Magic2D Lib, but when I use the DxMagicExamples,
I remove the /*.....*/ about play movie,
but the window show black and without anything...
what the problem?... :(

And when I use OpenGLMagicExample and compile that,
the VC++ output an error:
LINK : fatal error LNK1104: Can not open file 'avifil32.lib'
(I'm not sure the message^^^^^^^^^^^^^ in English,
because I'm use Chinese VC++.NET)
And I find out the link code in Magic2d.hpp,
but I doesn't find the file in my computer,
(Only have avifil32.dll , No avifil32.lib)
How can I fix this error?thanks.
jam
Posts: 409
Joined: Fri Nov 04, 2005 3:52 am

Post by jam »

Anonymous wrote:Hi All,
And when I use OpenGLMagicExample and compile that,
the VC++ output an error:
LINK : fatal error LNK1104: Can not open file 'avifil32.lib'
(I'm not sure the message^^^^^^^^^^^^^ in English,
because I'm use Chinese VC++.NET)
And I find out the link code in Magic2d.hpp,
but I doesn't find the file in my computer,
(Only have avifil32.dll , No avifil32.lib)
How can I fix this error?thanks.
Did you link in vfw32.lib?
riya
Posts: 5
Joined: Fri Mar 03, 2006 3:45 pm
Location: Taiwan

Post by riya »

jam wrote: Did you link in vfw32.lib?
Yes, It's in "$(VCInstallDir)PlatformSDK\lib"

BTW,If I change "#include <Magic2d.hpp>" to "#include <DllMagic2d.hpp>",
I can run some OpenGLMagicExample OK,
But the play speed is slow...
thx
Post Reply