Posted: Sat Sep 16, 2006 10:21 am
ok , i got it.
thank you esaptonor for post the image test.
bey
thank you esaptonor for post the image test.
bey
Official forum of the Irrlicht Engine
https://irrlicht.sourceforge.io/forum/
Code: Select all
cgCombin->AddToPixelProgram(" color = (Col1+Col2) * 0.70 ; ");
Code: Select all
class DLL_EXPORT TImageStrip
{
f32 Coords[4][2];
f32 fWidth,fHeight;
s32 TotalFrm;
s32 stepww,stephh;
f32 sx,sy;
s32* Map;
s32 xRepeat,yRepeat;
s32 MapCellWidth,MapCellHeight;
s32 ScrnX,ScrnY;
s32 MaxX,MinX,MaxY,MinY;
TImageTexture* Matr;
public:
TImageStrip();
~TImageStrip(){};
void LoadImageStrip(char* filename,s32 frmWidth,s32 frmHeight,bool useClrKey=false);
inline void setFrame(int n);
void DrawElement(f32 x = 0, f32 y = 0);
void SetTileMap(s32* tileMap,int mpw,int mph,int srx=1000,int sry=1000);
void LoadTileMap(char* MapFileName);
void SaveTileMap(char* MapFileName);
void SetCell(s32 x,s32 y, s32 val);
void FillMap(s32 val);
void FullScreenScrolTileMap(f32 XOff=0,f32 YOff=0,bool forward=true);
void ScrolTileMap(f32 x=0,f32 y=0,f32 XOff=0,f32 YOff=0,bool forward=true);
};
Code: Select all
/************************************
Scrolling Mirror Font Demo
From Anos Basic of Amiga
By Emil Halim
*************************************/
#include <MagicIncludes.h>
// global declration of Irrlicht interfaces
IrrlichtDevice* device;
IVideoDriver* driver;
ISceneManager* smgr;
bool ProgramRun;
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");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
/// setting current Directory path of media folder
SetMediaDir("../../MagicLibrary/media/");
/// creating Rainbow Image
u32 RianColor[] =
{
0x11,0x22,0x33,0x44,
0x55,0x66,0x77,0x88,
0x99,0xaa,0xbb,0xcc,
0xdd,0xee,0xff,
0x11ff,0x22ff,0x33ff,
0x44ff,0x55ff,0x66ff,
0x77ff,0x88ff,
0x11aa,0x1199,0x1188,0x1177,
0x66,0x55,0x44,0x33,0x22,0x11
};
TImageTexture* Ranbow = new TImageTexture;
Ranbow->CreateImage(2,64);
for(int h=0;h<33;h++)
{
for(int w=0;w<2;w++)
Ranbow->ImageData[w+h*2] = 0xFF000000|RianColor[h];
}
Ranbow->Update();
/// creating Font
TImageTexture* FontA = new TImageTexture;
FontA->LoadImage(GetMediaFile("mrfont.bmp"));
FontA->setColorKey(0,0);
MFont* fnt_2 = CreateFont(FontA,39,45,40);
SetBaseChar(fnt_2,65);
SetFont(fnt_2);
// small letter f represntes a space char because image has no space char
char* Msg = new char[2048];
strcpy(Msg, "HAYfDOfYOUfBELIVEfTHATffTHISfSCROLLINGfFONTfDEMOfWASfWRITING");
strcat(Msg, "fMOREfTHANfTENfYEARSfAGOfBYfAMOSfBASICfLANGUAGEfFORfAMIGAfCOMPUTER");
s32 MsgLen = TextLength(fnt_2,Msg);
ProgramRun = true;
int lastFPS = -1;
while(device->run()&& ProgramRun)
{
driver->beginScene(true, true, SColor(0,0,0,0));
if(KeyDown(KEY_ESCAPE))ProgramRun=false;
ViewOrtho();
SetBlend(ALPHABLEND);
SetViewport(0,0,640,480);
SetColor(255,255,255);
SetScale(320,4);
Ranbow->SetTexture();
DrawImage(Ranbow,320,413);
static f32 X=640,Y=0,base=375,sx=0;
SetScale(2,2);
Y = 35+sin(sx)*40; sx+=0.01*4;
X-=0.5*4;
if(X < -TextLength(fnt_2,Msg)) X=640;
SetViewport(40,0,600-40,base);
SetColor(255,0,0);
FontA->SetTexture();
DrawText(Msg,X,base-Y);
SetViewport(40,base,600-40,60);
SetAlpha(0.25f);
SetScale(2,1.5);
DrawInversedText(Msg,X,base+Y);
SetAlpha(1.0f);
ViewPerspective();
WaitVBL(); //just like Amos "Wait vbl" function
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps)
{
wchar_t tmp[1024];
swprintf(tmp, 1024, L" Scrolling Mirror Font Demo(%s)(fps:%d)",driver->getName(), fps);
device->setWindowCaption(tmp);
lastFPS = fps;
}
}
device->drop();
return 0;
}
Code: Select all
now let us see how we could use it
===================================
1- create an instance of the class
TSystemFont* SysFont = new TSystemFont;
2- spcify the attributes of font and create it
+----- name of the font
| +---- width of the font
| | + ---- hight of the font
| | | + ---- how bold the font will be
| | | | + ---- italic flag
| | | | | +---- underline flag
| | | | | | +---- size of texture that hold
| | | | | | | the font
| | | | | | |
SysFont->Create("Raster fonts",8,12,900,false,true,512);
3- in loop of your program , set the textuer first then draw your texts as you want
SysFont->SetTexture();
static char* str = "System Font is your way for drawing real time window font";
f32 cen = SysFont->CenterX(str);
SetColor(255,255,0);
SysFont->DrawString(str,cen,300);
+---- pointer to string
| +---- starting x coordinate
| | +---- starting y coordinate
| | | +---- red component of outer color
| | | | +---- green component of outer color
| | | | | +---- blue component of outer color
| | | | | | +---- red component of inner color
| | | | | | | +---- green component of inner color
| | | | | | | | +---- blue component of inner color
| | | | | | | | | +---- thikness of outer color
| | | | | | | | | |
SysFont->DrawOutLinedString(str,100,450,255,0,0,255,255,0,1);
Hello Emil_halim,Emil_halim wrote:Hi everybody
this time i have improved TileMap stuff, (TImageStrip class).
this class allows you to build a TileMap the scroll it in full screen or part of screen see the screenshot below , here is the prototype of the classCode: Select all
class DLL_EXPORT TImageStrip { ... };
Code: Select all
Project : Irrlicht Project
Compiler : GNU GCC Compiler (called directly)
Directory : E:\irrlicht-1.1\MagicLibrary\Examples\Basic4GL\2LayersBackGroundMap\
--------------------------------------------------------------------------------
Switching to target: default
Linking console executable: ..\..\..\..\bin\Win32-gcc\2LayersBackGroundMap.exe
...
.objs\main.o:main.cpp:(.text+0x31c): undefined reference to `_imp___ZN11TImageStrip10SetTileMapEPiiiii'
.objs\main.o:main.cpp:(.text+0x373): undefined reference to `_imp___ZN11TImageStrip10SetTileMapEPiiiii'
.objs\main.o:main.cpp:(.text+0x4a3): undefined reference to `_imp___ZN11TImageStrip22FullScreenScrolTileMapEffb'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
0 errors, 0 warnings