Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Emil_halim

Pages: [1] 2
1
Purebasic / OgreMagic for PureBasic
« on: August 26, 2007 »
Hi PureBasic users

Just want to tell that , OgreMagic is supporting PureBasic now. So you can easlly use OgreMagic Library with your favorite basic language.
 
Here is a small test programe.
Code: [Select]

;**********************************************
;
;
;  OgreMagic Library with PureBasic Test
;
;             By Emil Halim
;
;               22/8/2007
;
;**********************************************

XIncludeFile #PB_Compiler_Home + "Includes\Imports\Dx9.pbi"
XIncludeFile #PB_Compiler_Home + "Includes\Imports\OgreMagic.pbi"

Global D3DDevice.IDirect3DDevice9  
  
OpenWindow(1,0,0,640,480,"OgreMagic with PureBasic",#PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget )

SetWindowPos_(WindowID(1),#HWND_TOPMOST,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE)
 
D3DDevice = D3D_OpenWindowedScreen(WindowID(1),640,480)

InitialMagicLibrary(D3DDevice,640,480)

If(ML_FileExist("MagicMedia.cfg"))
   ML_SetMediaDirectoryFromFile("MagicMedia.cfg")
Else
   ML_SetMediaDirectory("../OgreMagic/MagicMedia/")
EndIf

Tweety.l = ML_LoadStaticSprite("Tweety.bmp",0)
ML_SetSpriteColorKeyFromPoint(Tweety,0,0)

Repeat
  
  D3DDevice\Clear(0,0,#D3DCLEAR_TARGET,0,0,0)  
  D3DDevice\BeginScene()
  
  ML_UseOrthogonalView()
  ML_SetAlpha(1.0,#AllPoints)
  ML_SetColor(255,255,255,#AllPoints)
  ML_SetBlendMode(#ALPHABLEND)
  
  ML_SetSpriteTexture(ML_GetDefualtFont(),0)
  ML_SetColor(255,255,0,#AllPoints)
  ML_DrawString("Welcome To OgreMagic World",200,350)
  
  ML_SetSpriteTexture(Tweety,0)
  ML_DrawSprite(Tweety,320,240)
    
  ML_DrawLogo(0.8,75,60)
  
  ML_UsePerspectiveView()
  
  D3DDevice\EndScene()
  D3DDevice\Present(0,0,0,0)
  EventID = WindowEvent()
  
Until EventID = #PB_Event_CloseWindow  


D3D_Release(D3DDevice)
End


2
Freebasic / software rotation question.
« on: July 16, 2007 »

Hi all

Suppos I have a rectangle which has coordinates P1,P2,P3,P4. I want to rotate it by angle a. how to calculate the new coordinate of the rectangle ?

3
General chat / Happy Birthday slippy!
« on: July 14, 2007 »


 Happy Birthday  slippy! :cheers:

4
Freebasic / good spline tutorial
« on: July 05, 2007 »
Hi all

I really need a good tutorial For Spline , my idea is to put some control point for not only translation but for translation and rotation and scaling and may be color to be smooth interplated.

so the first step is to know a good on for translation , any help ?

5
Hi all

Does any one know a good algorithm of Magnification filter of Image processing ?

To make it more simple , I really need a very high quality Mag Filter algorithm, just like the flash movie player, the DirectX filter is poor when compared with flash player.

Any help appreciated .   

6
Freebasic / software library
« on: April 23, 2007 »
Hi all

Here is my first attempt to make my software library , it looks like My OgerMagic Library , it has not optimized yet.

If you have any idea ,let me know , and feel free to modify it or add any function that you want.

Here is the code

Code: [Select]
'============================================================
'
'   SoftWare ImageProcessing Library
'            By Emil Halim
'              23/4/2007
'
'============================================================

        OPTION STATIC
        OPTION EXPLICIT

        #DEFINE PTC_WIN
        #INCLUDE "TINYPTC.BI"
        #INCLUDE "windows.BI"
        
        CONST   XRES = 640  'WIDTH
        CONST   YRES = 480  'HEIGHT
        DIM SHARED AS UINTEGER BUFFER ( XRES * YRES )  
        
        
        type IMAGE
             Ibuf    as UINTEGER ptr
             IbufLen as UINTEGER
             Iwidth  as UINTEGER
             Iheight as UINTEGER
        end type  
        
        declare Function LoadBMPImage(file as string) as IMAGE ptr  
        declare sub SetColorKey(img as IMAGE ptr,clr as uinteger)
        declare sub DrawSolidImage( img as IMAGE ptr,x as integer, y as integer)
        declare sub DrawTransparentImage( img as IMAGE ptr,x as integer, y as integer)
        ''To Do Functions List
        declare sub DrawAlphaImage( img as IMAGE ptr,x as integer, y as integer,a as Dword)  
          
  
        If( PTC_OPEN( "SoftWare Library By Emil Halim", XRES, YRES ) = 0 ) Then
        End -1
        End If
        
        dim as IMAGE ptr Image_1,Image_2
        
        Image_1 =  LoadBMPImage("planet.bmp")
        Image_2 =  LoadBMPImage("crashtitle.bmp")
        
        
        while(1)
          
            DrawSolidImage(Image_2,0,240)
          ' DrawAlphaImage(Image_1,0,0,1.0)
            PTC_UPDATE @BUFFER(0)
              
        wend
        
        
    Function LoadBMPImage(file as string) as IMAGE ptr
           dim pic AS HBITMAP , iDC as HDC
               dim bm  as BITMAP
               dim bi24BitInfo As BITMAPINFO
               dim buf as uInteger ptr
    
               pic =  LoadImage(0,file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE or LR_CREATEDIBSECTION)
               GetObject(pic, SIZEOF(BITMAP), @bm)
      
               With  bi24BitInfo.bmiHeader
                    .biBitCount = 32
                    .biCompression = BI_RGB
                    .biPlanes = 1
                    .biSize = SIZEOF(BITMAPINFO)
                    .biWidth = bm.bmWidth
                    .biHeight = bm.bmHeight
               End With
              
               buf = allocate(bm.bmWidth*bm.bmHeight*4)    
               iDC = CreateCompatibleDC(0)
               SelectObject(iDC, pic)
               GetDIBits(iDC, pic, 0, bm.bmHeight, buf, @bi24BitInfo, DIB_RGB_COLORS)
               DeleteObject(pic)
               DeleteDC(iDC)
              
               dim as IMAGE ptr img = allocate(Len(IMAGE))
               img->Iwidth  = bm.bmWidth
               img->Iheight = bm.bmHeight  
               img->Ibuf    = allocate(bm.bmWidth*bm.bmHeight*4)    
               img->IbufLen = bm.bmWidth*bm.bmHeight*4
              
              
               dim as integer x,y
               for x = 0 to bm.bmWidth-1
                for y = 0 to  bm.bmHeight -1
                    img->Ibuf[x+y*bm.bmWidth]=buf[x+(bm.bmHeight-y-1)*bm.bmWidth]    
                next
               next      
               Deallocate(buf)      
         return img
        end function
        
        sub SetColorKey(img as IMAGE ptr,clr as uinteger)
               dim as integer x,y
               for x = 0 to img->Iwidth-1
                for y = 0 to  img->Iheight-1
                    dim as uinteger ndx
                    ndx = x+y*img->Iwidth
                    if(img->Ibuf[ndx]=clr) then  img->Ibuf[ndx] = 0  
                next
               next    
        end sub
        sub DrawSolidImage( img as IMAGE ptr,x as integer, y as integer)
              dim as integer xx,yy
              dim as integer sx,sy,sw,sh
              if(x<0)then sx = img->Iwidth+x else sx = 0
              if(y<0)then sy = img->Iheight+y else sy = 0
              if(x+img->Iwidth > XRES) then sw = XRES - x else sw = img->Iwidth-1
              if(y+img->Iheight > YRES) then sh = YRES - y else sh = img->Iheight-1
              for yy=sy to sh
                dim as integer ds = x+(y+yy)*XRES
                dim as integer sr = yy*img->Iwidth
                for xx=sx to sw
                     BUFFER(xx+ds) =  img->Ibuf[xx+sr]
                next
              next  
        end sub
        sub DrawTransparentImage( img as IMAGE ptr,x as integer, y as integer)
              dim as integer xx,yy
              dim as integer sx,sy,sw,sh
              if(x<0)then sx = img->Iwidth+x else sx = 0
              if(y<0)then sy = img->Iheight+y else sy = 0
              if(x+img->Iwidth > XRES) then sw = XRES - x else sw = img->Iwidth-1
              if(y+img->Iheight > YRES) then sh = YRES - y else sh = img->Iheight-1
              for yy=sy to sh
                dim as integer ds = x+(y+yy)*XRES
                dim as integer sr = yy*img->Iwidth
                for xx=sx to sw
                    if(BUFFER(xx+ds) > 0 ) then BUFFER(xx+ds) =  img->Ibuf[xx+sr]
                next
              next  
        end sub

        ' TO DO
        sub DrawAlphaImage( img as IMAGE ptr,x as integer, y as integer,a as Dword)
      
        end sub

   end

7
Freebasic / Fast Normalize vector
« on: April 12, 2007 »
Hi all

really i did not use asm 2 years ago or more, i was a big Fan of assembly code.

anyway , i have found this code by navigating the net , so i port it to freebasic, it normalize a vector by using SSE asm.

the problem that i still did not solve is , it works with a 4 members vector not 3 members vector, so i want to apply the code to array of 3 members vector.

BTW you can use it with software render , it is very fast becuse it manipulate with 4 single variables at the same time.

any help please?

Code: [Select]

' 4 members vector
type Vec4
    as single x,y,z,w
end type

sub SSE_Normalize ( vectors as single ptr)
   asm
movups xmm0, [vectors]
movaps xmm2, xmm0
mulps xmm0, xmm0
movaps xmm1, xmm0
shufps xmm0, xmm1, 0x4e
addps xmm0, xmm1
movaps xmm1, xmm0
shufps xmm1, xmm1, 0x11
addps xmm0,   xmm1
rsqrtps xmm0, xmm0
mulps xmm2, xmm0
movups [vectors], xmm2
end asm

end sub

   

8
GFX & sound / OgreMagic Logo
« on: April 07, 2007 »
Hi all

I need to make a Logo to my OgreMagic Library, but i am not an artist and i do not know how to make it.

so if someone help and make the Logo that will be stromglly approciated.

thanks for any help.

9
General chat / Happy Easter
« on: April 03, 2007 »
Hi all

We are in a very holy days this week , Jesus dead  for us so what a great  love that he give us , he dead for every one to live.

Next Sunday is a great event , So I want to say happy Easter for every one here and wishing a good shinning future for all of you.

Emil. 

10
Freebasic / Off Topic : naming Functions
« on: April 02, 2007 »
Hi all

I want some help to name some of functions of my library.

I have implemented a 3 functions for pixel collision detection , the first one chack the collision between 2 static sprites , the second check the collision between a static sprite and animated sprite , the last one check the collision between 2 animated sprites.

so what is the best names for them?

thanks for any help.


11
Useful links / Anti Grain Geometry
« on: March 17, 2007 »
Hi shocky.

While I am navigating in Ogre Forum I have saw this link. So I think it may be useful for someone else.

I really did not get involved with it yet , but I will.

Here is the link

http://www.antigrain.com/

12
C / C++ /C# / Tiny PTC with DX9
« on: March 11, 2007 »
Hi All

This is my first attempet to make tiny Ptc framework under directX9 , not tested yet sorry has no time.

the idea is to create a texture then update it with PTC_UPDATE(Buffer) then draw it.

here are the sources c++ code, the first is the sturtup code and the second is your software work, you must merge them in a project then compile the project.

Edited:

I deleted the source here , it was buggy sorry,now download it from here

TinyPCT_Cpp.zip

13
C / C++ /C# / Shocky 's Lib in C/C++
« on: March 11, 2007 »
Hi all

i have converted some functions of shocky 's lib for software drawing  to C/C++ , also i have added it to my OgreMagic library , so i posted it here in the hope that it will be usefull for some one.

Code: [Select]
     void DOT(int x,int y,unsigned int color)
       {
           if(x>0 && x<Xres && y>0 && y<Yres-1)
             {
                Buffer[ x + y * Xres  ] = color;
             }
       }

      void EDGE(int x1,int y1,int x2,int y2,unsigned int color)
       {
            if(!Buffer) FireError(3);

            double  xdistance,ydistance;
            int     h2;
            double  StartX,StartY,XRatio,YRatio;

            xdistance = x2 - x1;
            ydistance = y2 - y1;

            h2 = sqrt( xdistance * xdistance + ydistance * ydistance );

            StartX = x1;
            StartY = y1;

            XRatio = xdistance * ( 1.0 / h2 );
            YRatio = ydistance * ( 1.0 / h2 );

        for(int i = 0; i<h2; i++)
         {
            if(StartX>0 && StartX<Xres && StartY>0 && StartY<Yres-1)
             {
                Buffer[ int(StartX) + (int(StartY) * Xres ) ] = color;
             }
            StartX = StartX + XRatio;
            StartY = StartY + YRatio;
         }
       }

      void Curve(int x0, int y0,int x3,int y3,int x1,int y1,int x2,int y2,unsigned int color)
       {
           int x,y,cx,bx,ax,cy,by,ay,ox,oy;

           cx = 3*(x1-x0);
           bx = 3*(x2-x1)-cx;
           ax = x3-x0-cx-bx;
           cy=3*(y1-y0);
           by=3*(y2-y1)-cy;
           ay=y3-y0-cy-by;
           for(double t=0;  t<1.01; t+=0.01)
            {
               if (t>0)
                {
                  ox=x;
                  oy=y;
                }
               x = ax * pow(t,3) + bx * pow(t,2) + cx * t + x0;
               y = ay * pow(t,3) + by * pow(t,2) + cy * t + y0;
               if (t>0)
                 EDGE(x,y,ox,oy,color);
            }
       }

      void Rect(int X1,int Y1,int XW,int YH,unsigned int color)
       {

           int  slice,LP,TC;

           if (X1 < 0)
            {
               XW = XW +  X1;
               X1 = 0;
            }

           if (Y1 < 0)
            {
               YH = YH +  Y1;
               Y1=0;
            }

           if (XW + X1 > Xres) XW = Xres - X1;

           if (YH + Y1 > Yres) YH = (Yres - Y1);

           if (XW>0 && YH>0) TC = color;

           for (LP =Y1; LP<(YH+Y1); LP++)
            {
               int* pp=(int*)&Buffer[(DA_rowSkip*LP)+X1];
                slice = XW;

                if (slice>0)
                  for(register int k=0; k<slice; k++) pp[k]=TC;

             }
        }

      void Circle(int cx,int cy,int r,unsigned int color)
       {
           int r2,cc,loopy,ww,l,clipl , clipr,slice,tc;

           r2=r*r;
           cc=-r;
           for(int loopy = cc; loopy<r; loopy++)
            {
                 ww = sqrt(r2-loopy*loopy);
                 if(loopy+cy>=0 && loopy+cy<Yres)
                 {
                    clipl = cx-ww;
                    clipr = (cx+ww)-1;
                    if(clipl<0) clipl=0;
                    if(clipr>Xres-1) clipr = Xres-1;
                    int* pp=(int*)&Buffer[DA_rowSkip*(loopy+cy)+clipl];
                    slice = clipr-clipl;

                     if (slice>0)
                      for(register int k=0; k<slice; k++) pp[k]=color;
                 }
            }

       }

      void Triangle(int X1,int Y1,int X2,int Y2,int X3,int Y3,unsigned int color)
       {
             int TEMPX,TEMPY;
             int PX[4],PY[4],TFLAG=0;
             int IL1,IL2,SLICE;
             PX[1]= X1;
             PX[2]= X2;
             PX[3]= X3;
             PY[1]= Y1;
             PY[2]= Y2;
             PY[3]= Y3;
             for(int L0=1; L0<=2; L0++)
              for(int LI=1; LI<=2; LI++)
                  if (PY[LI+1] <= PY[LI])
                   {
                      TEMPX = PX[LI]; TEMPY = PY[LI];
                      PX[LI] = PX[LI+1];
                      PY[LI] = PY[LI+1];
                      PX[LI+1] = TEMPX;
                      PY[LI+1] = TEMPY;
                   }

            ///    BOOT OUT INVISIBLE TRIANGLES!
             if(PX[1]<0 && PX[2]<0  && PX[3]< 0) TFLAG=1;
             if(PX[1]>Xres && PX[2]>Xres && PX[3]>Xres) TFLAG=1;
             if(PY[1]>Yres && PY[2]>Yres && PY[3]>Yres) TFLAG=1;
             double XP1,XP2; /// SCREEN POSITIONS.
             double XI1,XI2; /// INTERPOLATIONS.
             /***
             '*** REGULAR TRIANGLE (Y1<Y2 Y2<Y3)
             '***/
             if(PY[1]<PY[2] && PY[2]<PY[3] || (PY[2] = PY[3]))
              {
                 TFLAG=1;
                 XP1 = PX[1];
                 XP2 = PX[1];
                 XI1 = (PX[1]-PX[2]) / (PY[2] - PY[1]);
                 XI2 = (PX[1]-PX[3]) / (PY[3] - PY[1]);
                 for(int L0=PY[1]; L0<PY[2]; L0++)
                  {
                     if(L0>=0 && L0<Yres)
                      {
                        if(XP1<=XP2)
                         {
                             IL1=XP1;
                             IL2=XP2;
                         }
                        else
                         {
                             IL1=XP2;
                             IL2=XP1;
                         }
                        if(IL2>Xres) IL2=Xres;
                        if(IL1<0)  IL1=0;

                        SLICE = IL2-IL1;
                        int* pp=(int*)&Buffer[IL1+(L0*DA_rowSkip)];
                        if (SLICE>0)
                            for(register int k=0; k<SLICE; k++) pp[k]=color;
                      }
                     XP1=XP1-XI1;
                     XP2=XP2-XI2;
                  }

             /* this part crashed so i comment it
                 XI1 = (PX[2]-PX[3]) / (PY[3] - PY[2]);
                 XP1 = PX[2];
                 for(int L0=PY[2]; L0<=PY[3]; L0++)
                  {
                     if(L0>=0 && L0<Yres)
                      {
                         if(XP1<=XP2)
                          {
                             IL1=XP1;
                             IL2=XP2;
                          }
                         else
                          {
                             IL1=XP2;
                             IL2=XP1;
                          }
                         if(IL2>Xres) IL2=Xres;
                         if(IL1<0) IL1=0;

                         SLICE = IL2-IL1;
                         int* pp=(int*)&Buffer[IL1+(L0*DA_rowSkip)];
                         if (SLICE>0)
                            for(register int k=0; k<SLICE; k++) pp[k]=color;
                      }
                     XP1=XP1-XI1;
                     XP2=XP2-XI2;
                  }
               */
              }


            /***
            '*** FLAT TOPPED TRIANGLE Y1=Y2
            '***/
            if(TFLAG==0 && PY[1]== PY[2])
             {
                 TFLAG=1;
                 XP1 = PX[1];
                 XP2 = PX[2];
                 XI1 = (PX[1]-PX[3]) / (PY[3] - PY[1]);
                 XI2 = (PX[2]-PX[3]) / (PY[3] - PY[2]);
                 for(int L0=PY[1]; L0<PY[3]; L0++)
                  {
                      if(L0>=0 && L0<Yres)
                       {
                         if(XP1<=XP2)
                          {
                            IL1=XP1;
                            IL2=XP2;
                          }
                         else
                          {
                            IL1=XP2;
                            IL2=XP1;
                          }
                         if(IL2>Xres) IL2=Xres;
                         if(IL1<0) IL1=0;

                         SLICE = IL2-IL1;
                         int* pp=(int*)&Buffer[IL1+(L0*DA_rowSkip)];
                         if (SLICE>0)
                            for(register int k=0; k<SLICE; k++) pp[k]=color;
                       }
                     XP1=XP1-XI1;
                     XP2=XP2-XI2;
                  }
             }
       }

14
Freebasic / POST MORTEM / OgreMagic
« on: March 09, 2007 »
Hi Shocky

This time I have merged your  beautiful  POST MORTEM demo with my work , so I have put your work in a rotating cube in the front of playing movie , I want you to test it , for better viewing just maximum your demo window.

Download here
POSTMORTEMtest.zip

Screenshot


Edited :
Source code with exe in the POSTMORTEMtest.zip

15
Freebasic / OgerMagic installer
« on: March 07, 2007 »
Hi all

Here is the first alpha version of freebasic installer , just install it in your FreeBasic folder.

Test it and please feed back your opinion.

Download it here

OgreMagic_fb.exe


16
Freebasic / OgreMagic VS Tiny PCT
« on: March 07, 2007 »
Hi shochy

I have made a little change im my OgreMagic library for allowing mix your software work which uses Tiny PCT  to be  combine with my OgerMagic Library, so that I can include your  code as is with a small change ( change the Array Integer  Buffer to a pointer of Integer) then I can make some OgreMagic effect , such as scaling ,fading , rotating your entire work.

In a word you can think it as copy your work to a n OgreMagic sprite .

The good news is there is no big drop in the frame per second , just the drop ranges from 10 to 15 FPS in my system , and I thinks it is a reasonable result.

Here are 2 screenshots  , the first on is your original program , and the second on is mine





Here is the source code , sorry it is big code.

Code: [Select]
''------------------------------------------------------------------------------
''
''              Magic Library For Ogre
''                beta version 0.40
''                  by Emil Halim
''
''        Name    :  test
''        Date    :  20/02/2007
''        Purpose :  testing OgreMagic VS Tiny PCT
''
''       website  :  http://www.freewebs.com/ogremagic/index.htm
''
''------------------------------------------------------------------------------

OPTION EXPLICIT

#include once "windows.bi"
#include once "win/d3d9.bi"
#include once "win/d3dx9.bi"

#include once "MagicLibrary.bi"

''-----------------------------------------------------------------------------
'' GLOBALS
''-----------------------------------------------------------------------------
dim shared as HWND              g_hWnd         = NULL
dim shared as LPDIRECT3D9       g_pD3D         = NULL
dim shared as LPDIRECT3DDEVICE9 g_pd3dDevice   = NULL

dim shared as SpriteData       ptr   SpriteBuffer
dim shared as HLSLProgramData  ptr   HLSLProgram

'-------------------------------------------------------------------------
' Variable Definitions.
'-------------------------------------------------------------------------
        Dim Shared LP As Integer: ' Used In Loops.
        Dim Shared As Integer ptr Buffer '( 640 * 480 ):' Screen Buffer.
        DIM SHARED AS INTEGER CPAL (255):' Holds Palette.
        Dim Shared GADD As Integer:' General Purpose Variable Just Ticks Up.
        Dim Shared SMSIN As DOUBLE:' Holds X Movement.
        DIM SHARED SMCOS As DOUBLE:' Holds Y Movement.
        DIM SHARED ZMCOS As DOUBLE:' Holds Z Movement.
        DIM SHARED STPTR AS INTEGER:' Pointer Used When Looping Through Stars.
        DIM SHARED STST AS INTEGER:' Holds Deepest Star Pos.
        DIM SHARED A AS INTEGER:' Holds Colour Multiplier.
       
'----------------------------
'---    Set Up Starfield; ---
'----------------------------

        Dim Shared STARS As Integer=1500:' Holds Max Number Of Stars
        Dim Shared INZP As Double:' Used When Defining Stars To Hold ZP
        Dim Shared INZPA As Double:' Used When Defining Stars (ZP Increment)
        Dim Shared TX AS INTEGER:' Holds Translated Star X
        Dim Shared TY As Integer:' Holds Translated Star Y
        dim shared customcop (640*480) as integer:' Holds Custom Fake "Copperlist"
       
        DIM SHARED STX (1 TO STARS) AS DOUBLE: ' Hold X Pos Of Star
        DIM SHARED STY (1 TO STARS) AS DOUBLE: ' Hold Y Pos Of Star
        DIM SHARED STZ (1 TO STARS) AS DOUBLE: ' Hold Z Pos Of Star
       
        '-----------------------
        ' Generate A Palette;---
        '-----------------------
        DIM SHARED R1,G1,B1 AS integer
       
        '===============================================================================
        '       Scroller Stuff;
        '===============================================================================
        DIM SHARED SCPTR AS INTEGER:' Letter Pointer In Scroll String.
        DIM SHARED SCOFF AS DOUBLE:' Offset Used To Scroll Text
       
        Dim Shared scrolltext as string:' Holds Text.
       
        '---------------
        '-Debug Stuff; -
        '---------------
        dim shared oldtime,newtime as double
        dim shared TST as string
        dim shared ticks as integer
       
        '--------------------------
        ' Read In Our Star Bobs;---
        '--------------------------
        dim shared BOB (36*5) AS INTEGER
       
        '-----------------------------------------------------------------
        'Read In Our Font;
        '-----------------------------------------------------------------
        dim shared FONT (81 * 59) as integer

''-----------------------------------------------------------------------------
'' PROTOTYPES
''-----------------------------------------------------------------------------
declare function WindowProc( byval hWnd as HWND, byval msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
declare sub init()
declare sub shutDown()
declare sub render()


        Declare Sub STARFIELD()
        DECLARE SUB DRAWBOB (BYVAL BX AS INTEGER , BYVAL BY AS INTEGER , BYVAL BNM AS INTEGER , BYVAL CL AS INTEGER)
        Declare Sub Clearscreen()
        declare sub DBFTEXT(BYVAL BX AS INTEGER , BYVAL BY AS INTEGER , BYVAL CH AS INTEGER , BYVAL CLR AS INTEGER)
        DECLARE SUB MESSAGE()
        declare SUB Millisecs()

''-----------------------------------------------------------------------------
'' Name: init()
'' Desc: Initializes Direct3D under DirectX 9.0
''-----------------------------------------------------------------------------
sub init( )
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION )

    dim as D3DDISPLAYMODE d3ddm

    IDirect3D9_GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT, @d3ddm )

    dim as D3DPRESENT_PARAMETERS d3dpp
    clear( d3dpp, 0, len(d3dpp) )

    d3dpp.Windowed               = false 'TRUE
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD
    d3dpp.BackBufferFormat       = d3ddm.Format
    d3dpp.EnableAutoDepthStencil = TRUE
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16
    d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE
   
    d3dpp.BackBufferWidth = 640
    d3dpp.BackBufferHeight = 480
    d3dpp.BackBufferCount = 2
   

    IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
                          D3DCREATE_HARDWARE_VERTEXPROCESSING, _
                          @d3dpp, @g_pd3dDevice )
   
    IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_LIGHTING, FALSE)
IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_CULLMODE, D3DCULL_NONE)

dim as D3DXMATRIX mProjection
    D3DXMatrixPerspectiveFovLH( @mProjection, D3DXToRadian( 45.0f ), 1.0f, 1.0f, 100.0f )
    IDirect3DDevice9_SetTransform(g_pd3dDevice, D3DTS_PROJECTION, @mProjection )                     
   
    '' Initial Magic Library here
    InitialMagicLibrary(g_pd3dDevice,640, 480)
   
    ML_SetMediaDirectory("../MagicMedia/")
   
    SpriteBuffer = ML_CreateStaticSprite(640,480)
   
    HLSLProgram = ML_CreateHLSLProgram() 
    ML_EditPixelProgram(HLSLProgram)                               
    ML_AddToProgram("sampler2D tex0;                                          ")
    ML_AddToProgram("float4   main(  float2 TexCoord : TEXCOORD0) : COLOR0    ")
    ML_AddToProgram("{                                                        ")
    ML_AddToProgram("       float4 col = tex2D( tex0, TexCoord);              ")
    ML_AddToProgram("       return float4(col.rgb,1);                         ")
    ML_AddToProgram("}                                                        ")
    ML_CompilePixelProgram(HLSLProgram,"main")     
   
     
        '--------------------------
        ' Read In Our Star Bobs;---
        '--------------------------
       
       
        FOR LP=1 TO (36*5)
            READ BOB(LP)
        NEXT
       
        '-----------------------------------------------------------------
        'Read In Our Font;
        '-----------------------------------------------------------------
       
        FOR LP=1 TO (81*59)
                READ FONT(LP)
        NEXT
       
        '----------------------------
        '---    Set Up Starfield; ---
        '----------------------------
       
       
       
        INZP=30:' Initial Z = 0.
        INZPA = 30 / STARS:' Calculate Increment.
        STPTR=1:' Holds Star Number During Starfield Sub Loop.
        STST=1:' Used To Store Starting Star (deepest).
        For LP = 1 To Stars
             STX (LP) = ((RND(1) * 20000)-10000 )
             STY (LP) = ((RND(1) * 20000)-10000 )
             STZ (LP) = INZP
             INZP=INZP-INZPA
        next
     
        '-----------------------
        ' Generate A Palette;---
        '-----------------------
       
        FOR LP=1 TO 255
            CPAL(LP) =RGB(R1,G1,B1)
            IF R1<255 THEN R1=R1+1
            IF G1<255 THEN G1=G1+1
            IF B1<254 THEN B1=B1+2
           
        NEXT LP
       
        '------------------------------
        ' Generate Fake Copperlist; ---
        '------------------------------
       
        for LP=1 to 640*480
            customcop(LP)=&h020004
            SELECT CASE LP
            CASE 0 TO 640*10
                customcop(LP)=&h0a000b
            CASE 640*10 TO 640*20
                customcop(LP)=&h0c000d
            CASE 640*20 TO 640*30
                customcop(LP)=&h0e000f
            CASE 640*30 TO 640*40
                customcop(LP)=&h110012
            CASE 640*40 TO 640*50
                customcop(LP)=&h130014
            CASE 640*470 TO 640*480
                customcop(LP)=&h0a000b
            CASE 640*460 TO 640*470
                customcop(LP)=&h0c000d
            CASE 640*450 TO 640*460
                customcop(LP)=&h0e000f
            CASE 640*440 TO 640*450
                customcop(LP)=&h110012
            CASE 640*430 TO 640*440
                customcop(LP)=&h130014                                   
            END SELECT
        next
       
        '=======================================================================
        'Our Text;
        '=======================================================================
        scrolltext="                                                                 "
        scrolltext=scrolltext+"                                                           "
        scrolltext=scrolltext+"DARK BIT FACTORY ARE BACK WITH A LITTLE INTRO..........       "
        scrolltext=scrolltext+"THIS ONE WAS CODED BY SHOCKWAVE!!          ALTHOUGH IT LOOKS PRETTY "
        scrolltext=scrolltext+"BORING IT IS QUITE COOL.....                      IT IS ALL MADE USING THE TINYPTC LIB, "
        scrolltext=scrolltext+"WHICH IS IN ITS SELF A PAIN IN THE ASS!!                 EVERYTHING YOU SEE "
        scrolltext=scrolltext+"HERE IS HARD CODED...                   EVEN THE FONT IS CONSTRUCTED IN THE SOURCE!!! "
        scrolltext=scrolltext+"...OUT OF BINARY...             AAAARRRGGGHHHH!!!!            FOR ALL THE HARD WORK IT COMPRESSES DOWN TO ABOUT 15KB SO THAT CAN'T BE TOO BAD!"
        scrolltext=scrolltext+"         OH WELL....        I GUESS I HAD BETTER ADD SOME MORE EFFECTS......   AND THEN DO SOMETHING USEFUL LIKE SOME OPENGL STUFF "
        scrolltext=scrolltext+"INSTEAD??!!       THATS ALL FOR NOW.........              "
        scrolltext=scrolltext+"                                                           "
        scrolltext=scrolltext+"                                                           "
        scrolltext=scrolltext+"                                                           "
        SCOFF=0
        SCPTR=0
       
        '---------------
        '-Debug Stuff; -
        '---------------
        ticks=0
       
        oldtime=timer
       
       
end sub

''-----------------------------------------------------------------------------
'' Name: render()
'' Desc: Render or draw our scene to the monitor.
''-----------------------------------------------------------------------------
sub render( )
    IDirect3DDevice9_Clear( g_pd3dDevice, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, _
                            D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 )
                           
           
           Buffer = ML_StartDrawingToSprite(SpriteBuffer)
           
           Clearscreen():' Clear The Screen.
           STARFIELD():' Do The Starfield. 
           '----------------------------
           ' Draw White Lines On Screen;
           '----------------------------
           FOR LP = 0 TO 639
               Buffer [(50*640) +LP]=RGB (155,55,155)
               Buffer [(430*640)+LP]=RGB (155,55,155)
           NEXT
           MESSAGE():' Do Scroller.
           MILLISECS()
       
           ML_StopDrawingToSprite(SpriteBuffer)
           
           ticks=ticks+1                 
                           
''
'' begin drawing
''
IDirect3DDevice9_BeginScene(g_pd3dDevice)
   
   
    '' Magic Stuff
    ''
        ML_UseOrthogonalView
       
        ML_SetAlpha(1)
        ML_SetColor(255,255,255)
       
        ML_SetBlendMode(ALPHABLEND)
       
        ML_SetScale(0.75,0.75)
        ML_StartShaderProgram(HLSLProgram) 
        ML_SetSpriteTexture(SpriteBuffer)
        ML_DrawSprite(SpriteBuffer,320,240)
        ML_StopShaderProgram()

        ML_UsePerspectiveView
   
''
'' end drawing
''
IDirect3DDevice9_EndScene(g_pd3dDevice)
    IDirect3DDevice9_Present(g_pd3dDevice, NULL, NULL, NULL, NULL )
   
end sub


''-----------------------------------------------------------------------------
'' Name: WinMain()
'' Desc: The application's entry point
''-----------------------------------------------------------------------------
function WinMain(byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval lpCmdLine as string, _
byval nCmdShow as integer _
) as integer

dim as WNDCLASSEX winClass
dim as MSG        uMsg

with winClass
.lpszClassName = @"MY_WINDOWS_CLASS"
.cbSize        = len(WNDCLASSEX)
.style         = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc   = @WindowProc
.hInstance     = hInstance
.hIcon        = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
    .hIconSm    = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hCursor       = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = cast(HBRUSH,GetStockObject(BLACK_BRUSH))
.lpszMenuName  = NULL
.cbClsExtra    = 0
.cbWndExtra    = 0
end with

if( RegisterClassEx( @winClass ) = FALSE ) then
return E_FAIL
end if

g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", _
                             "Direct3D (DX9) - Primitive Types", _
     WS_OVERLAPPEDWINDOW or WS_VISIBLE, _
         0, 0, 640, 480, NULL, NULL, hInstance, NULL )

if( g_hWnd = NULL ) then
return E_FAIL
end if

    ShowWindow( g_hWnd, nCmdShow )
    UpdateWindow( g_hWnd )

init()

do while( uMsg.message <> WM_QUIT )
if( PeekMessage( @uMsg, NULL, 0, 0, PM_REMOVE ) ) then
TranslateMessage( @uMsg )
DispatchMessage( @uMsg )
        else
    render()
end if
loop

shutDown()

    UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance )

return uMsg.wParam
end function

''-----------------------------------------------------------------------------
'' Name: WindowProc()
'' Desc: The window's message handler
''-----------------------------------------------------------------------------
function WindowProc( byval hWnd as HWND, _
byval msg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM _
   ) as LRESULT

    select case ( msg )
        case WM_KEYDOWN
select case( wParam )
case VK_ESCAPE
PostQuitMessage(0)

end select

case WM_CLOSE
PostQuitMessage(0)

        case WM_DESTROY
            PostQuitMessage(0)

case else
return DefWindowProc( hWnd, msg, wParam, lParam )
end select

return 0
end function

''-----------------------------------------------------------------------------
'' Name: shutDown()
'' Desc: Release all Direct3D resources.
''-----------------------------------------------------------------------------
sub shutDown( )

    if( g_pd3dDevice <> NULL ) then
        IDirect3DDevice9_Release(g_pd3dDevice)
    end if

    if( g_pD3D <> NULL ) then
        IDirect3D9_Release( g_pD3D )
    end if
end sub



'-------------------------------------------------------------------------------
' Display FPS.
'-------------------------------------------------------------------------------
SUB Millisecs()
    dim t=timer

if  t-oldtime >=1 then
    newtime = ticks
    ticks=0
    oldtime=timer
end if

    TST = str( (newtime) )
    TST = "FPS "+TST
    for LP=1 to len(tst)
        dim CH=(ASC(MID(TST,LP,1)))-31
        DBFTEXT((LP*10),1,CH,&h443333)
    NEXT
   
end sub
'-------------------------------------------------------------------------------
' Scrolling Message Routine By Shockwave / DBF
'-------------------------------------------------------------------------------
SUB MESSAGE()
    dim hop,ecl as integer
   
    HOP=0:' Used to jumpto next letter pos
    ECL=0:' Used For Colour.
   
    FOR LP=1 TO 66
        IF LP<20 THEN ECL=ECL+10:' Change Colours
        IF LP>46 THEN ECL=ECL-10
       
        dim CH=(ASC(MID(SCROLlTEXT,LP+SCPTR,1)))-31:' Get Ascii for char
        '-----------------------------------------------------------------------
        ' Call DBF Custom Text Routine;
        '-----------------------------------------------------------------------
        DBFTEXT (HOP-scoff,455+12*SIN((LP+GADD)/30),CH,RGB(ECL+30,ECL,ECL+40))
        HOP=HOP+10
    NEXT
    '--------------------------------
    'Scroll And Update If Needed; ---
    '--------------------------------
    scoff=scoff+1
    if scoff> 10 then
        scptr=scptr+1
        if scptr>(len(scrolltext)-66) then scptr=0
        scoff=scoff-10
    end if
   
END SUB

'---------------------------------------
'---    MULTI DIRECTIONAL STARFIELD. ---
'---------------------------------------

SUB STARFIELD()
    GADD=GADD+1
    dim bb as integer
    '---------------
    ' Movements; ---
    '---------------
   
    SMSIN=30*SIN(GADD/470)
    SMCOS=40*COS(GADD/777)
    ZMCOS=0.1*COS(GADD/907)
   
    '---------------------------
    ' Get Deepest Star First;---
    '---------------------------
   
    STPTR=STST
   
    for LP = 1 To STARS
       
        '---------------------------------
        ' Translate Star To 2D Co-Ords ---
        '---------------------------------
       
        TX = INT((STX(STPTR) / STZ(STPTR))+320)
        TY = INT((STY(STPTR) / STZ(STPTR))+240)
       
        '--------------------
        ' Is It Onscreen? ---
        '--------------------
       
        if TX>-5 and TX<639 AND TY>-5 And TY<479 THEN
           
            '--------------------------------
            ' Calculate Colour Multiplier;---
            '--------------------------------
           
            A=INT(-STZ(STPTR) + 32) shl 1
            '-------------------------------------
            ' Draw Bob Size According To Depth;---
            '-------------------------------------
            bb=((int(STZ(STPTR)))/6)+1
            'if bb<1 then bb=1
           
            DRAWBOB (TX,TY,5,A)
            'IF STZ(STPTR) < 10 THEN DRAWBOB (TX,TY,BB,A)
            'IF STZ(STPTR >= 10) AND (STZ(STPTR) <20 ) THEN DRAWBOB (TX,TY,2,A)
            'IF STZ(STPTR) >= 20 THEN DRAWBOB (TX,TY,1,A)
        ENDIF
       
        '---------------
        ' Move Star; ---
        '---------------
       
        STX(STPTR)=STX(STPTR)+SMSIN
        STY(STPTR)=STY(STPTR)+SMCOS
        STZ(STPTR)=STZ(STPTR)+ZMCOS
       
        '------------------
        ' Bounds Checks;---
        '------------------
        ' X Checks;
        IF SMSIN>0 THEN
            IF STX(STPTR)>=10000 THEN STX(STPTR)=STX(STPTR)-20000
        ENDIF
        IF SMSIN<0 THEN
            IF STX(STPTR)<=-10000 THEN STX(STPTR)=STX(STPTR)+20000
        ENDIF
        ' Y Checks;
        IF SMCOS>0 THEN
            IF STY(STPTR)>=10000 THEN STY(STPTR)=STY(STPTR)-20000
        ENDIF
        IF SMCOS<0 THEN
            IF STY(STPTR)<=-10000 THEN STY(STPTR)=STY(STPTR)+20000
        ENDIF
        ' Z Checks;
        IF ZMCOS>0 THEN
            IF STZ(STPTR)>=30 THEN STZ(STPTR)=STZ(STPTR)-30
            STST=STST-1
            IF STST<1 THEN STST=STARS
        ENDIF
        IF ZMCOS<0 THEN
            IF STZ(STPTR)<=0 THEN STZ(STPTR)=STZ(STPTR)+30
            STST=STST+1
            IF STST>STARS THEN STST=1
           
        ENDIF
        STPTR=STPTR+1:' Update Pointer.
        IF STPTR>STARS THEN STPTR=1:'Bounds Check.
    next
   
   
END SUB

'-------------------------------------------------------------------------
'Sub To Draw A Letter AnyWhere On The Screen (With Clipping);
'-------------------------------------------------------------------------
sub DBFTEXT(BYVAL BX AS INTEGER , BYVAL BY AS INTEGER , BYVAL CH AS INTEGER , BYVAL CLR AS INTEGER)
dim blx,bly as integer
    '---------------------------------
    'Calculate Offset In Font Data;---
    '---------------------------------
    dim bm=(ch*81)-81
    FOR BLY=0 TO 8
    FOR BLX=1 TO 9
        '--------
        'Clip;---
        '--------
        IF (BX+BLX>0) AND (BX+BLX<639) AND (BY+BLY>0) AND (BY+BLY<479) THEN
           
            '----------------------------------------------------
            'Draw Pixel In Buffer If Onscreen And If Binary 1 ---
            '----------------------------------------------------
           
            dim MM= FONT(((BLY*9)+BLX)+BM)
            IF MM >0 THEN BUFFER [((BY+BLY)*640)+BX+BLX]=CLR
        END IF
    NEXT
    NEXT
END SUB

'-------------------------------------------------------------------------
' Sub To Draw A Bob Anywhere On The Screen;
'-------------------------------------------------------------------------

SUB DRAWBOB (BYVAL BX AS INTEGER , BYVAL BY AS INTEGER, BYVAL BNM AS INTEGER , BYVAL CL AS INTEGER)
   
    DIM BLX , BLY AS INTEGER
   
    '-----------------------
    'Set Offset In Bob Bank;
    '-----------------------
    dim BM=(BNM*36)-36
    dim MM
    FOR BLY=0 TO 5
    FOR BLX=1 TO 6
        '---------
        'CLIPPING;
        '---------
        IF (BX+BLX>0) AND (BX+BLX<639) AND (BY+BLY>0) AND (BY+BLY<479) THEN
            '-------------
            'COLOUR VALUE;
            '-------------
            if (by+BLY> 50) and (by+bly<430) then
                MM= (BOB(((BLY*6)+BLX)+BM))*CL
            else
                MM= ((BOB(((BLY*6)+BLX)+BM))*CL) shr 1
            endif
            if MM>255 then MM=255
            '------------------
            'DRAW PIXEL OF BOB;
            '------------------
            IF MM >0 THEN BUFFER [((BY+BLY)*640)+BX+BLX]=CPAL(MM)
        END IF
    NEXT
    NEXT

END SUB

'--------------------------------------------------------
' Clear Out Old Screen Buffer With Our Fake "Copperlist"
'--------------------------------------------------------

Sub ClearScreen()
Dim i as integer
for i = 0 to 640*480
    buffer[i]=customcop(i)
next
End Sub

   ''
''
''
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )


'--------------------------------------------------------
' Our "Bobs"
' 0's are not blitted.
' The Higher The Number, The Brighter The Pixel.
'--------------------------------------------------------

'tiny
data 0,0,0,0,0,0
data 0,0,0,0,0,0
data 0,0,1,1,0,0
data 0,0,1,1,0,0
data 0,0,0,0,0,0
data 0,0,0,0,0,0
'small
data 0,0,0,0,0,0
data 0,0,1,1,0,0
data 0,1,2,2,1,0
data 0,1,2,2,1,0
data 0,0,1,1,0,0
data 0,0,0,0,0,0
'medium
data 0,0,1,1,0,0
data 0,0,2,2,0,0
data 1,2,3,3,2,1
data 1,2,3,3,2,1
data 0,0,2,2,0,0
data 0,0,1,1,0,0
'large
data 0,0,1,1,0,0
data 0,2,3,3,2,0
data 1,3,4,4,3,1
data 1,3,4,4,3,1
data 0,2,3,3,2,0
data 0,0,1,1,0,0
'Maximum
data 0,1,2,2,1,0
data 1,2,3,3,2,1
data 2,3,5,5,3,2
data 2,3,5,5,3,2
data 1,2,3,3,2,1
data 0,1,2,2,1,0

'==============================================================================
' Binary Font By Shockwave / DBF; (59 Chars)
'==============================================================================

'space
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'!
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
'"
data 0,1,1,0,1,1,0,0,0
data 0,1,1,0,1,1,0,0,0
data 0,1,1,0,1,1,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'#
data 0,0,0,0,0,0,0,0,0
data 0,1,1,0,0,0,1,1,0
data 1,1,1,1,1,1,1,1,1
data 0,1,1,0,0,0,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,1,1,0,0,0,1,1,0
data 1,1,1,1,1,1,1,1,1
data 0,1,1,0,0,0,1,1,0
data 0,0,0,0,0,0,0,0,0
'£
data 0,0,1,1,1,1,0,0,0
data 0,1,1,1,1,1,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,1,1,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,0
'%
data 0,0,0,0,0,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,0,0,0,1,0,0
data 0,0,0,0,0,1,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,1,0,0,0,0,0
data 0,0,1,0,0,0,1,1,0
data 0,0,0,0,0,0,1,1,0
data 0,0,0,0,0,0,0,0,0
'&
data 0,0,0,1,1,1,0,0,0
data 0,0,1,1,1,1,1,0,0
data 0,0,1,1,0,1,1,0,0
data 0,0,0,1,1,1,0,0,0
data 0,0,1,1,0,1,1,0,0
data 0,1,1,0,0,1,1,1,1
data 0,1,1,1,0,0,1,1,0
data 0,0,1,1,1,1,1,0,0
data 0,0,0,0,1,1,0,0,0
''
data 0,1,1,0,0,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'(
data 0,0,0,0,0,1,1,1,0
data 0,0,0,0,1,1,1,1,0
data 0,0,0,0,1,1,0,0,0
data 0,0,0,0,1,1,0,0,0
data 0,0,0,0,1,1,0,0,0
data 0,0,0,0,1,1,0,0,0
data 0,0,0,0,1,1,0,0,0
data 0,0,0,0,1,1,1,1,0
data 0,0,0,0,0,1,1,1,0
')
data 0,1,1,1,0,0,0,0,0
data 0,1,1,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,1,1,1,1,0,0,0,0
data 0,1,1,1,0,0,0,0,0
'*
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'+
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
''
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
'-
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'.
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
'/
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'0
data 0,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'1
data 0,0,0,1,1,0,0,0,0
data 0,0,1,1,1,0,0,0,0
data 0,0,1,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,1,1,1,1,1,0,0,0
data 0,1,1,1,1,1,0,0,0
'2
data 0,0,1,1,1,1,1,1,0
data 0,0,1,1,1,1,1,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,1,1,1,1,1,1,1,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
'3
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,0
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,1,1,1,1,0
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,0
'4
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,1,1,0,0,0
data 1,1,0,0,1,1,0,0,0
data 1,1,1,1,1,1,1,1,1
data 0,0,0,0,0,1,1,0,0
data 0,0,0,0,0,1,1,0,0
data 0,0,0,0,0,1,1,0,0
data 0,0,0,0,0,1,1,0,0
'5
data 0,1,1,1,1,1,1,0,0
data 0,1,1,1,1,1,1,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,0,0,0,0,0,0
data 0,1,1,1,1,1,1,1,0
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,0
'6
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,0
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'7
data 0,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,1,1,1,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,1,1,0
data 0,0,0,0,0,0,1,1,0
data 0,0,0,0,0,0,1,1,0
'8
data 0,0,1,1,1,1,1,0,0
data 0,1,1,1,1,1,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,0,1,1,1,1,1,0,0
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'9
data 0,0,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,1
data 0,1,1,0,0,0,0,1,1
data 0,1,1,0,0,0,0,1,1
data 0,0,1,1,1,1,1,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
':
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
';
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'<
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'=
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'>
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'?
data 0,0,1,1,1,1,1,0,0
data 0,1,1,1,1,1,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,0,0,0,0,0,1,1,0
data 0,0,0,1,1,1,1,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,1,1,0,0,0,0
data 0,0,0,1,1,0,0,0,0
'@
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
data 0,0,0,0,0,0,0,0,0
'a
data 0,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,0
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
'b
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,0
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
'c
data 0,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,1
'd
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,0
'e
data 0,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,1
'f
data 0,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
'g
data 0,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'h
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
'i
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
'j
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,0
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,0
'k
data 1,1,0,0,0,0,1,1,0
data 1,1,0,0,0,0,1,1,0
data 1,1,0,0,0,0,1,1,0
data 1,1,0,0,0,0,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
'l
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,1
'm
data 0,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
'n
data 0,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1

'o
data 0,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'p
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
'q
data 0,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,1,0,1,1
data 1,1,0,0,0,0,1,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'r
data 1,1,1,1,1,1,1,1,0
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,0
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
's
data 0,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,0,0,0,0,0,0,0
data 1,1,0,0,0,0,0,0,0
data 0,1,1,1,1,1,1,1,0
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,0
't
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
data 0,0,0,0,1,0,0,0,0
'u
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'v
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,1,0,0,0,1,1,1
data 0,1,1,1,1,1,1,1,0
data 0,0,1,1,1,1,1,0,0
'w
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,0,0,1,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 0,1,1,1,1,1,1,1,0
'x
data 0,1,1,0,0,0,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,1,1,0,0,0,1,1,0
data 0,1,1,1,1,1,1,1,0
data 1,1,1,0,0,0,1,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
'y
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 1,1,0,0,0,0,0,1,1
data 0,1,1,1,1,1,1,1,1
data 0,0,0,0,0,0,0,1,1
data 0,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,0
'z
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1
data 0,0,0,0,0,0,1,1,1
data 0,0,0,0,1,1,1,0,0
data 0,0,0,1,1,1,0,0,0
data 0,0,1,1,1,0,0,0,0
data 1,1,1,0,0,0,0,0,0
data 1,1,1,1,1,1,1,1,1
data 1,1,1,1,1,1,1,1,1

'===============================================================================
'                                     ***END***
'===============================================================================

17
Freebasic / Prophecy2Demo / OgreMagic
« on: March 05, 2007 »
Hi all

After i have seen the Deviance.exe of alpha one , shocky was posting it in this forum , i liked the 3D text scrolling.

so i have changed the prophecy to be a 3D spiral text scrolling. this is the first step to port his demo.

download it here

prophecy2.zip

here is the screen shot


here is the source code

Code: [Select]
''----------------------------------------------------------------------------------
''
''              Magic Library For Ogre
''                beta version 0.40
''                  by Emil Halim
''
''        Name    :  prophecy2Demo
''        Date    :  20/02/2007
''        Purpose :  ported from Amiga demos
''                   to FreeBasic by Emil Halim.
''
''       website  :  http://www.freewebs.com/ogremagic/index.htm
''
''       Amiga    :  http://www.flashtro.com/list.php?c=art&s=title&w=asc&o=&p=&d=250 
''
''-----------------------------------------------------------------------------------

OPTION EXPLICIT

#include once "windows.bi"
#include once "win/d3d9.bi"
#include once "win/d3dx9.bi"

#include once "staticMagicLibrary.bi"

''-----------------------------------------------------------------------------
'' GLOBALS
''-----------------------------------------------------------------------------
dim shared as HWND              g_hWnd         = NULL
dim shared as LPDIRECT3D9       g_pD3D         = NULL
dim shared as LPDIRECT3DDEVICE9 g_pd3dDevice   = NULL

dim shared as SpriteData      ptr  Prophecy
dim shared as SpriteData      ptr  bob
dim shared as SpriteData      ptr  Copper
dim shared as SpriteData      ptr  CLine
dim shared as HLSLProgramData ptr  LineProgram
dim shared as HLSLProgramData ptr  CopperProgram
dim shared as ScreenSurfaceData ptr Scren
dim shared as BitmapFontData  ptr  font

'/ star field
   #define StarCount 700
   #define SCREEN_WIDTH 640
   #define SCREEN_HEIGHT 420
   #define Speed 0.3
   #define NoOfLayers 3
   type STAR
        as single    x
        as single    y
   end type
dim shared as  STAR    Stars(0 to StarCount)
dim shared as string               Msg
dim shared as integer              MsgLen
dim shared as MusicSoundData      ptr   song
''-----------------------------------------------------------------------------
'' PROTOTYPES
''-----------------------------------------------------------------------------
declare function WindowProc( byval hWnd as HWND, byval msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
declare sub init()
declare sub shutDown()
declare sub render()

''-----------------------------------------------------------------------------
'' Name: init()
'' Desc: Initializes Direct3D under DirectX 9.0
''-----------------------------------------------------------------------------
sub init( )
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION )

    dim as D3DDISPLAYMODE d3ddm

    IDirect3D9_GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT, @d3ddm )

    dim as D3DPRESENT_PARAMETERS d3dpp
    clear( d3dpp, 0, len(d3dpp) )

    d3dpp.Windowed               = TRUE
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD
    d3dpp.BackBufferFormat       = d3ddm.Format
    d3dpp.EnableAutoDepthStencil = TRUE
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16
    d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE

    IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
                          D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
                          @d3dpp, @g_pd3dDevice )
   
    IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_LIGHTING, FALSE)
IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_CULLMODE, D3DCULL_NONE)

dim as D3DXMATRIX mProjection
    D3DXMatrixPerspectiveFovLH( @mProjection, D3DXToRadian( 45.0f ), 1.0f, 1.0f, 1000.0f )
    IDirect3DDevice9_SetTransform(g_pd3dDevice, D3DTS_PROJECTION, @mProjection )                     
   
    '' Initial Magic Library here
    InitialMagicLibrary(g_pd3dDevice,640, 480)
    FmodInit()
   
    ML_SetMediaDirectory("../CracktroMedia/")
   
    song = ML_LoadMusicSound("1.mp3")
    ML_SetMusicSoundVolume(song,250)
    'L_SetSoundFreq(song,10)
   
    Prophecy = ML_LoadStaticSprite("prophecy.bmp")
   
    bob = ML_LoadStaticSprite("bob.bmp")
    ML_SetSpriteColorKeyFromPoint(bob,0,0)
   
    Copper = ML_CreateStaticSprite(1,300)
    ML_StartDrawingToSprite(Copper)
    ML_ClearDrawingArea(&HFF000000)
    dim h
    for h=0 to 150
        ML_WriteRedChannel(  0,h,120+119*sin((300-h)/133.0))
        ML_WriteGreenChannel(0,h,120+119*sin((300-h)/73.0 ))
        ML_WriteBlueChannel( 0,h,120+119*sin((300-h)/53.0 ))
        ML_WriteRedChannel(  0,h+150,120+119*sin((h+150)/133.0))
        ML_WriteGreenChannel(0,h+150,120+119*sin((h+150)/73.0 ))
        ML_WriteBlueChannel( 0,h+150,120+119*sin((h+150)/53.0 ))
    next
    ML_StopDrawingToSprite(Copper)

    CLine = ML_CreateStaticSprite(640,1)
   
    LineProgram = ML_CreateHLSLProgram()
    ML_EditPixelProgram(LineProgram)
    ML_AddToProgram("sampler2D tex0;                                          ")
    ML_AddToProgram("float  S1,S2,S3;                                         ")
    ML_AddToProgram("float4  main(  float2 TexCoord : TEXCOORD0) : COLOR0     ")
    ML_AddToProgram("{                                                        ")
    ML_AddToProgram("   float red,grn,blu;                                    ")
    ML_AddToProgram("   red = 0.392+ 0.388 * sin(S1+TexCoord.x*4.848484);     ")
    ML_AddToProgram("   grn = 0.392+ 0.388 * sin(S2+TexCoord.x*3.475524);     ")
    ML_AddToProgram("   blu = 0.392+ 0.388 * sin(S3+TexCoord.x*5.444444);     ")
    ML_AddToProgram("   return float4(red,grn,blu,1);                         ")
    ML_AddToProgram("}                                                        ")
    ML_CompilePixelProgram(LineProgram,"main")
   
    CopperProgram = ML_CreateHLSLProgram()
    ML_EditPixelProgram(CopperProgram)
    ML_AddToProgram("sampler2D tex0;                                          ")
    ML_AddToProgram("sampler2D tex1;                                          ")
    ML_AddToProgram("float4  main(  float2 TexCoord : TEXCOORD0) : COLOR0     ")
    ML_AddToProgram("{                                                        ")
    ML_AddToProgram("       float4 col0 = tex2D( tex0, TexCoord);             ")
    ML_AddToProgram("       float4 col1 = tex2D( tex1, TexCoord);             ")
    ML_AddToProgram("       return  float4(col1.rgb,col0.a);                  ")
    ML_AddToProgram("}                                                        ")
    ML_CompilePixelProgram(CopperProgram,"main")
   
    Scren = ML_CreateScreenSurface(640, 480)
    ML_SetScreenClearColor(0,0,0,0)
   
    ML_SetMediaDirectory("../MagicMedia/")
    font = ML_LoadBitmapFont("font/Amigafont.bmp",24,24,22)
    ML_SetSpriteColorKeyFromPoint(font,0,0)
    ML_SetActiveBitmapFont(font)


    randomize (GetTickCount()/1000)
    dim i
    for i=0 to StarCount-1
        reRndX:
            Stars(i).x  = rnd*(SCREEN_WIDTH)
            if(Stars(i).x > SCREEN_WIDTH or Stars(i).x < 0) goto reRndX
        reRndY:
            Stars(i).y  = rnd*(SCREEN_HEIGHT)+150
            if(Stars(i).y > SCREEN_HEIGHT or Stars(i).y < 0) goto reRndY
    next
   
    Msg  = "Welcome Here.... this is a new 2D programming world so you will find that "
    Msg += "there are more impressive work that you could produce with this Library..."
    Msg += "you could mix 2D with 3D world...  playing GIF animation... playing animated Image... "
    Msg += "Fading in and out... doing wave Effects... doing 3D star field Effect... scrolling text... "
    Msg += "using many fonts... !! please if you found the library is useful for you "
    Msg += "so let me know.. see you later.. by..........."
   
    MsgLen = 440
   
end sub

''-----------------------------------------------------------------------------
'' Name: render()
'' Desc: Render or draw our scene to the monitor.
''-----------------------------------------------------------------------------
sub render( )
    IDirect3DDevice9_Clear( g_pd3dDevice, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, _
                            D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 )
''
'' begin drawing
''
IDirect3DDevice9_BeginScene(g_pd3dDevice)
   
   
    '' Magic Stuff
    ''
        ML_PlayMusicSound(song)
       
        ML_UseOrthogonalView
       
        ML_SetAlpha(1)
        ML_SetColor(255,255,255)
       
        ML_SetBlendMode(ALPHABLEND)
       
        ML_SetScale(2,1.5)
        ML_SetSpriteTexture(Prophecy)
        ML_DrawSprite(Prophecy,320,60)
                 
        ML_SetScale(1,1)
        ML_SetSpriteTexture(bob)
        dim k,i,c
        for k=0 to NoOfLayers-1
            c = k*70+50
            ML_SetColor(c,c,c)
            for i=0 to StarCount/NoOfLayers step NoOfLayers
                 Stars(i+k).x  +=  Speed * (k+1)
                 if(Stars(i+k).x >SCREEN_WIDTH) then Stars(i+k).x=0
                 ML_DrawSprite(bob,Stars(i+k).x,Stars(i+k).y)       
            next         
        next 
        ML_SetColor(255,255,255)
        static as single S1=0,S2=0,S3=0
        S1=ML_GetDurationFromBaseTime()/80
        S2=ML_GetDurationFromBaseTime()/245
        S3=ML_GetDurationFromBaseTime()/415
        ML_SetScale(1,2)
        ML_StartShaderProgram(LineProgram)
        ML_SetPixelVariable(0,@S1,1)
        ML_SetPixelVariable(1,@S2,1)
        ML_SetPixelVariable(2,@S3,1)
        ML_SetSpriteTexture(CLine)
        ML_DrawSprite(CLine,320,140)
        ML_SetHorizontalFlip(true)
        ML_DrawSprite(CLine,320,140+300)
        ML_SetHorizontalFlip(false)
        ML_StopShaderProgram() 
       
        ML_UsePerspectiveView
       
        ML_Use3DWorld(false,true)
       
        ML_SetScale(0.5,0.7)
        ML_StartRenderingTo(Scren)
        ML_SetSpriteTexture(font)
        static as single a,sy(25),MsgX=70
        MsgX -= 0.05
        if(MsgX < -730) then MsgX=70       
        static as single zz(25),yy(25),aa,kk
        kk = 60
        aa -= 0.01
        'if aa<-3.14*2 then aa=0
        for k=0 to 24
            zz(k) = cos(aa+(k*15*3.14159265/180))*kk
            yy(k) = sin(aa+(k*15*3.14159265/180))*kk
        next 
        for i=0 to MsgLen   
            ML_SetAlpha(0.8-0.5*zz(i mod 24)/kk)
            ML_SetHorizontalRotation(3.14-aa)
            ML_Draw3DChar(Msg[i],MsgX+1.5*i,yy(i mod 24),200+zz(i mod 24))
        next   
        ML_SetHorizontalRotation(0)
        ML_SetAlpha(1)
        ML_StopUsing3DWorld()
         
        ML_RenderToOriginalScreen()
       
        ML_UseOrthogonalView
       
        ML_SetScale(1,280/480)
        ML_StartShaderProgram(CopperProgram)
        ML_SetScreenSurfaceAsTexture(Scren)
        ML_SetSpriteTexture(Copper,1)
        ML_DarwScreenSurface(Scren,320,290)
        ML_StopShaderProgram()
 
        ML_UsePerspectiveView
       
''
'' end drawing
''
IDirect3DDevice9_EndScene(g_pd3dDevice)
    IDirect3DDevice9_Present(g_pd3dDevice, NULL, NULL, NULL, NULL )
   
end sub


''-----------------------------------------------------------------------------
'' Name: WinMain()
'' Desc: The application's entry point
''-----------------------------------------------------------------------------
function WinMain(byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval lpCmdLine as string, _
byval nCmdShow as integer _
) as integer

dim as WNDCLASSEX winClass
dim as MSG        uMsg

with winClass
.lpszClassName = @"MY_WINDOWS_CLASS"
.cbSize        = len(WNDCLASSEX)
.style         = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc   = @WindowProc
.hInstance     = hInstance
.hIcon        = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
    .hIconSm    = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hCursor       = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = cast(HBRUSH,GetStockObject(BLACK_BRUSH))
.lpszMenuName  = NULL
.cbClsExtra    = 0
.cbWndExtra    = 0
end with

if( RegisterClassEx( @winClass ) = FALSE ) then
return E_FAIL
end if

g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", _
                             "Direct3D (DX9) - Primitive Types", _
     WS_OVERLAPPEDWINDOW or WS_VISIBLE, _
         0, 0, 640, 480, NULL, NULL, hInstance, NULL )

if( g_hWnd = NULL ) then
return E_FAIL
end if

    ShowWindow( g_hWnd, nCmdShow )
    UpdateWindow( g_hWnd )

init()

do while( uMsg.message <> WM_QUIT )
if( PeekMessage( @uMsg, NULL, 0, 0, PM_REMOVE ) ) then
TranslateMessage( @uMsg )
DispatchMessage( @uMsg )
        else
    render()
end if
loop

shutDown()

    UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance )

return uMsg.wParam
end function

''-----------------------------------------------------------------------------
'' Name: WindowProc()
'' Desc: The window's message handler
''-----------------------------------------------------------------------------
function WindowProc( byval hWnd as HWND, _
byval msg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM _
   ) as LRESULT

    select case ( msg )
        case WM_KEYDOWN
select case( wParam )
case VK_ESCAPE
PostQuitMessage(0)

end select

case WM_CLOSE
PostQuitMessage(0)

        case WM_DESTROY
            PostQuitMessage(0)

case else
return DefWindowProc( hWnd, msg, wParam, lParam )
end select

return 0
end function

''-----------------------------------------------------------------------------
'' Name: shutDown()
'' Desc: Release all Direct3D resources.
''-----------------------------------------------------------------------------
sub shutDown( )

    if( g_pd3dDevice <> NULL ) then
        IDirect3DDevice9_Release(g_pd3dDevice)
    end if

    if( g_pD3D <> NULL ) then
        IDirect3D9_Release( g_pD3D )
    end if
end sub

''
''
''
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )


18
Freebasic / prophecyDemo / OgreMagic
« on: March 03, 2007 »
Hi all

This demo I have found it in the flashtro website but I did not find the source code , I liked it very much , also the music is fantastic.

So I have ported to OgreMagic , download it from here

prophecy.zip


Here is the source code

Code: [Select]
''----------------------------------------------------------------------------------
''
''              Magic Library For Ogre
''                beta version 0.40
''                  by Emil Halim
''
''        Name    :  prophecyDemo
''        Date    :  20/02/2007
''        Purpose :  ported from Amiga demos
''                   to FreeBasic by Emil Halim.
''
''       website  :  http://www.freewebs.com/ogremagic/index.htm
''
''       Amiga    :  http://www.flashtro.com/list.php?c=art&s=title&w=asc&o=&p=&d=250 
''
''-----------------------------------------------------------------------------------

OPTION EXPLICIT

#include once "windows.bi"
#include once "win/d3d9.bi"
#include once "win/d3dx9.bi"

#include once "MagicLibrary.bi"

''-----------------------------------------------------------------------------
'' GLOBALS
''-----------------------------------------------------------------------------
dim shared as HWND              g_hWnd         = NULL
dim shared as LPDIRECT3D9       g_pD3D         = NULL
dim shared as LPDIRECT3DDEVICE9 g_pd3dDevice   = NULL

dim shared as SpriteData      ptr  Prophecy
dim shared as SpriteData      ptr  bob
dim shared as SpriteData      ptr  Copper
dim shared as SpriteData      ptr  CLine
dim shared as HLSLProgramData ptr  LineProgram
dim shared as HLSLProgramData ptr  CopperProgram
dim shared as ScreenSurfaceData ptr Scren
dim shared as BitmapFontData  ptr  font

'/ star field
   #define StarCount 700
   #define SCREEN_WIDTH 640
   #define SCREEN_HEIGHT 420
   #define Speed 0.3
   #define NoOfLayers 3
   type STAR
        as single    x
        as single    y
   end type
dim shared as  STAR    Stars(0 to StarCount)
dim shared as string               Msg
dim shared as integer              MsgLen
dim shared as SoundData      ptr   song
''-----------------------------------------------------------------------------
'' PROTOTYPES
''-----------------------------------------------------------------------------
declare function WindowProc( byval hWnd as HWND, byval msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
declare sub init()
declare sub shutDown()
declare sub render()

''-----------------------------------------------------------------------------
'' Name: init()
'' Desc: Initializes Direct3D under DirectX 9.0
''-----------------------------------------------------------------------------
sub init( )
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION )

    dim as D3DDISPLAYMODE d3ddm

    IDirect3D9_GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT, @d3ddm )

    dim as D3DPRESENT_PARAMETERS d3dpp
    clear( d3dpp, 0, len(d3dpp) )

    d3dpp.Windowed               = TRUE
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD
    d3dpp.BackBufferFormat       = d3ddm.Format
    d3dpp.EnableAutoDepthStencil = TRUE
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16
    d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE

    IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
                          D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
                          @d3dpp, @g_pd3dDevice )
   
    IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_LIGHTING, FALSE)
IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_CULLMODE, D3DCULL_NONE)

dim as D3DXMATRIX mProjection
    D3DXMatrixPerspectiveFovLH( @mProjection, D3DXToRadian( 45.0f ), 1.0f, 1.0f, 100.0f )
    IDirect3DDevice9_SetTransform(g_pd3dDevice, D3DTS_PROJECTION, @mProjection )                     
   
    '' Initial Magic Library here
    InitialMagicLibrary(g_pd3dDevice,640, 480)
    FmodInit()
   
    ML_SetMediaDirectory("../CracktroMedia/")
   
    song = ML_LoadSoundData("1.mp3",MusicType)
    ML_SetSoundVolume(song,250)
    'L_SetSoundFreq(song,10)
   
    Prophecy = ML_LoadStaticSprite("prophecy.bmp")
   
    bob = ML_LoadStaticSprite("bob.bmp")
    ML_SetSpriteColorKeyFromPoint(bob,0,0)
   
    Copper = ML_CreateStaticSprite(1,300)
    ML_StartDrawingToSprite(Copper)
    ML_ClearDrawingArea(&HFF000000)
    dim h
    for h=0 to 150
        ML_WriteRedChannel(  0,h,120+119*sin((300-h)/133.0))
        ML_WriteGreenChannel(0,h,120+119*sin((300-h)/73.0 ))
        ML_WriteBlueChannel( 0,h,120+119*sin((300-h)/53.0 ))
        ML_WriteRedChannel(  0,h+150,120+119*sin((h+150)/133.0))
        ML_WriteGreenChannel(0,h+150,120+119*sin((h+150)/73.0 ))
        ML_WriteBlueChannel( 0,h+150,120+119*sin((h+150)/53.0 ))
    next
    ML_StopDrawingToSprite(Copper)

    CLine = ML_CreateStaticSprite(640,1)
   
    LineProgram = ML_CreateHLSLProgram()
    ML_EditPixelProgram(LineProgram)
    ML_AddToProgram("sampler2D tex0;                                          ")
    ML_AddToProgram("float  S1,S2,S3;                                         ")
    ML_AddToProgram("float4  main(  float2 TexCoord : TEXCOORD0) : COLOR0     ")
    ML_AddToProgram("{                                                        ")
    ML_AddToProgram("   float red,grn,blu;                                    ")
    ML_AddToProgram("   red = 0.392+ 0.388 * sin(S1+TexCoord.x*4.848484);     ")
    ML_AddToProgram("   grn = 0.392+ 0.388 * sin(S2+TexCoord.x*3.475524);     ")
    ML_AddToProgram("   blu = 0.392+ 0.388 * sin(S3+TexCoord.x*5.444444);     ")
    ML_AddToProgram("   return float4(red,grn,blu,1);                         ")
    ML_AddToProgram("}                                                        ")
    ML_CompilePixelProgram(LineProgram,"main")
   
    CopperProgram = ML_CreateHLSLProgram()
    ML_EditPixelProgram(CopperProgram)
    ML_AddToProgram("sampler2D tex0;                                          ")
    ML_AddToProgram("sampler2D tex1;                                          ")
    ML_AddToProgram("float4  main(  float2 TexCoord : TEXCOORD0) : COLOR0     ")
    ML_AddToProgram("{                                                        ")
    ML_AddToProgram("       float4 col0 = tex2D( tex0, TexCoord);             ")
    ML_AddToProgram("       float4 col1 = tex2D( tex1, TexCoord);             ")
    ML_AddToProgram("       return  float4(col1.rgb,col0.a);                  ")
    ML_AddToProgram("}                                                        ")
    ML_CompilePixelProgram(CopperProgram,"main")
   
    Scren = ML_CreateScreenSurface(640, 480)
    ML_SetScreenClearColor(0,0,0,0)
   
    ML_SetMediaDirectory("../MagicMedia/")
    font = ML_LoadBitmapFont("font/Amigafont.bmp",24,24,22)
    ML_SetSpriteColorKeyFromPoint(font,0,0)
    ML_SetActiveBitmapFont(font)


    randomize (GetTickCount()/1000)
    dim i
    for i=0 to StarCount-1
        reRndX:
            Stars(i).x  = rnd*(SCREEN_WIDTH)
            if(Stars(i).x > SCREEN_WIDTH or Stars(i).x < 0) goto reRndX
        reRndY:
            Stars(i).y  = rnd*(SCREEN_HEIGHT)+150
            if(Stars(i).y > SCREEN_HEIGHT or Stars(i).y < 0) goto reRndY
    next
   
    Msg  = "Welcome Here.... this is a new 2D programming world so you will find that "
    Msg += "there are more impressive work that you could produce with this Library..."
    Msg += "you could mix 2D with 3D world...  playing GIF animation... playing animated Image... "
    Msg += "Fading in and out... doing wave Effects... doing 3D star field Effect... scrolling text... "
    Msg += "using many fonts... !! please if you found the library is useful for you "
    Msg += "so let me know.. see you later.. by..........."
   
    MsgLen = 440
   
end sub

''-----------------------------------------------------------------------------
'' Name: render()
'' Desc: Render or draw our scene to the monitor.
''-----------------------------------------------------------------------------
sub render( )
    IDirect3DDevice9_Clear( g_pd3dDevice, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, _
                            D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 )
''
'' begin drawing
''
IDirect3DDevice9_BeginScene(g_pd3dDevice)
   
   
    '' Magic Stuff
    ''
        ML_PlaySound(song)
       
        ML_UseOrthogonalView
       
        ML_SetAlpha(1)
        ML_SetColor(255,255,255)
       
        ML_SetBlendMode(ALPHABLEND)
       
        ML_SetScale(2,1.5)
        ML_SetSpriteTexture(Prophecy)
        ML_DrawSprite(Prophecy,320,60)
                 
        ML_SetScale(1,1)
        ML_SetSpriteTexture(bob)
        dim k,i,c
        for k=0 to NoOfLayers-1
            c = k*70+50
            ML_SetColor(c,c,c)
            for i=0 to StarCount/NoOfLayers step NoOfLayers
                 Stars(i+k).x  +=  Speed * (k+1)
                 if(Stars(i+k).x >SCREEN_WIDTH) then Stars(i+k).x=0
                 ML_DrawSprite(bob,Stars(i+k).x,Stars(i+k).y)       
            next         
        next 
        ML_SetColor(255,255,255)
        static as single S1=0,S2=0,S3=0
        S1=ML_GetDurationFromBaseTime()/80
        S2=ML_GetDurationFromBaseTime()/245
        S3=ML_GetDurationFromBaseTime()/415
        ML_SetScale(1,2)
        ML_StartShaderProgram(LineProgram)
        ML_SetPixelVariable(0,@S1,1)
        ML_SetPixelVariable(1,@S2,1)
        ML_SetPixelVariable(2,@S3,1)
        ML_SetSpriteTexture(CLine)
        ML_DrawSprite(CLine,320,140)
        ML_SetHorizontalFlip(true)
        ML_DrawSprite(CLine,320,140+300)
        ML_SetHorizontalFlip(false)
        ML_StopShaderProgram() 
       
        ML_SetScale(0.6,1.5)
        ML_StartRenderingTo(Scren)
        ML_SetSpriteTexture(font)
        static as single a,sy(25),MsgX=640
        MsgX -= 0.5*2
        if(MsgX < -9700) then MsgX=640
        if(a >= 360-0.5) then
             a = 0
        else
             a += 0.5
        end if     
        for k=0 to 24
            sy(k) = sin((a+15*k)*3.14159265/180)*200
        next
        for i=0 to MsgLen
            ML_DrawChar(Msg[i],MsgX+i*14,240+sy(i mod 24))
        next   
        ML_RenderToOriginalScreen()
 
        ML_SetScale(1,280/480)
        ML_StartShaderProgram(CopperProgram)
        ML_SetScreenSurfaceAsTexture(Scren)
        ML_SetSpriteTexture(Copper,1)
        ML_DarwScreenSurface(Scren,320,290)
        ML_StopShaderProgram()
 

        ML_UsePerspectiveView
   
''
'' end drawing
''
IDirect3DDevice9_EndScene(g_pd3dDevice)
    IDirect3DDevice9_Present(g_pd3dDevice, NULL, NULL, NULL, NULL )
   
end sub


''-----------------------------------------------------------------------------
'' Name: WinMain()
'' Desc: The application's entry point
''-----------------------------------------------------------------------------
function WinMain(byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval lpCmdLine as string, _
byval nCmdShow as integer _
) as integer

dim as WNDCLASSEX winClass
dim as MSG        uMsg

with winClass
.lpszClassName = @"MY_WINDOWS_CLASS"
.cbSize        = len(WNDCLASSEX)
.style         = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc   = @WindowProc
.hInstance     = hInstance
.hIcon        = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
    .hIconSm    = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hCursor       = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = cast(HBRUSH,GetStockObject(BLACK_BRUSH))
.lpszMenuName  = NULL
.cbClsExtra    = 0
.cbWndExtra    = 0
end with

if( RegisterClassEx( @winClass ) = FALSE ) then
return E_FAIL
end if

g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", _
                             "Direct3D (DX9) - Primitive Types", _
     WS_OVERLAPPEDWINDOW or WS_VISIBLE, _
         0, 0, 640, 480, NULL, NULL, hInstance, NULL )

if( g_hWnd = NULL ) then
return E_FAIL
end if

    ShowWindow( g_hWnd, nCmdShow )
    UpdateWindow( g_hWnd )

init()

do while( uMsg.message <> WM_QUIT )
if( PeekMessage( @uMsg, NULL, 0, 0, PM_REMOVE ) ) then
TranslateMessage( @uMsg )
DispatchMessage( @uMsg )
        else
    render()
end if
loop

shutDown()

    UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance )

return uMsg.wParam
end function

''-----------------------------------------------------------------------------
'' Name: WindowProc()
'' Desc: The window's message handler
''-----------------------------------------------------------------------------
function WindowProc( byval hWnd as HWND, _
byval msg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM _
   ) as LRESULT

    select case ( msg )
        case WM_KEYDOWN
select case( wParam )
case VK_ESCAPE
PostQuitMessage(0)

end select

case WM_CLOSE
PostQuitMessage(0)

        case WM_DESTROY
            PostQuitMessage(0)

case else
return DefWindowProc( hWnd, msg, wParam, lParam )
end select

return 0
end function

''-----------------------------------------------------------------------------
'' Name: shutDown()
'' Desc: Release all Direct3D resources.
''-----------------------------------------------------------------------------
sub shutDown( )

    if( g_pd3dDevice <> NULL ) then
        IDirect3DDevice9_Release(g_pd3dDevice)
    end if

    if( g_pD3D <> NULL ) then
        IDirect3D9_Release( g_pD3D )
    end if
end sub

''
''
''
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )


19
Freebasic / BlackWhiteShaderMovieDemo / OgreMagic
« on: March 03, 2007 »
Hi all

Here is an other demo , I was madding it for Ogre.

It is playing movie and uses the tweety sprite as a maske to part of movie that played with some effect such as grayscale , Sharpen and  Emboss effect by using pixel shader program, also use the time line for control the timing of each effect , i.e when the  effect will start and duration of playing for each effect.

Code: [Select]
''------------------------------------------------------------------------------
''
''              Magic Library For Ogre
''                beta version 0.40
''                  by Emil Halim
''
''        Name    :  ShaderMovieDemo
''        Date    :  03/03/2007
''        Purpose :  applying many shader effects to 
''                   Movie.
''
''       website  :  http://www.freewebs.com/ogremagic/index.htm
''
''------------------------------------------------------------------------------

/'
It is playing movie and uses the tweety sprite as a maske to part of movie
that played with some effect such as grayscale , Sharpen and  Emboss effect by
using pixel shader program, also use the time line for control the timing
of each effect , i.e when the  effect will start and the duration of playing for each effect.
'/

OPTION EXPLICIT

#include once "windows.bi"
#include once "win/d3d9.bi"
#include once "win/d3dx9.bi"

#include once "MagicLibrary.bi"

''-----------------------------------------------------------------------------
'' GLOBALS
''-----------------------------------------------------------------------------
dim shared as HWND              g_hWnd         = NULL
dim shared as LPDIRECT3D9       g_pD3D         = NULL
dim shared as LPDIRECT3DDEVICE9 g_pd3dDevice   = NULL

dim shared as MovieData         ptr   Movie                ' pointer to movie structure
dim shared as SpriteData        ptr   MovieSprite          ' uesed to display the movie
dim shared as SpriteData        ptr   Tweety               ' used as a mask when playing movie
dim shared as TimeLineData      ptr   BlackWhiteTime       ' holds the start time and duration of blackWhite effect   
dim shared as TimeLineData      ptr   SharpenTime          ' holds the start time and duration of Sharpen effect 
dim shared as TimeLineData      ptr   EmbossTime           ' holds the start time and duration of Emboss effect
dim shared as HLSLProgramData   ptr   BlackWhiteProgram    ' shader program for doing blackWhite effect
dim shared as HLSLProgramData   ptr   SharpenProgram       ' shader program for doing Sharpen effect
dim shared as HLSLProgramData   ptr   EmbossProgram        ' shader program for doing Emboss effect 

''-----------------------------------------------------------------------------
'' PROTOTYPES
''-----------------------------------------------------------------------------
declare function WindowProc( byval hWnd as HWND, byval msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
declare sub init()
declare sub shutDown()
declare sub render()

''-----------------------------------------------------------------------------
'' Name: init()
'' Desc: Initializes Direct3D under DirectX 9.0
''-----------------------------------------------------------------------------
sub init( )
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION )

    dim as D3DDISPLAYMODE d3ddm

    IDirect3D9_GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT, @d3ddm )

    dim as D3DPRESENT_PARAMETERS d3dpp
    clear( d3dpp, 0, len(d3dpp) )

    d3dpp.Windowed               = TRUE
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD
    d3dpp.BackBufferFormat       = d3ddm.Format
    d3dpp.EnableAutoDepthStencil = TRUE
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16
    d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE

    IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
                          D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
                          @d3dpp, @g_pd3dDevice )
    IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_LIGHTING, FALSE)
    IDirect3DDevice9_SetRenderState(g_pd3dDevice,D3DRS_CULLMODE, D3DCULL_NONE)

dim as D3DXMATRIX mProjection
    D3DXMatrixPerspectiveFovLH( @mProjection, D3DXToRadian( 45.0f ), 1.0f, 1.0f, 100.0f )
    IDirect3DDevice9_SetTransform(g_pd3dDevice, D3DTS_PROJECTION, @mProjection )

                     
   
    '' Initial Magic Library here
    InitialMagicLibrary(g_pd3dDevice,640, 480)
   
    ML_SetMediaDirectory("../MagicMedia/")

    Movie = ML_LoadMovie("movie/ahly_america1-0.wmv")     ' load ahly_america1-0.wmv movie
    ML_SetMovieFramePerSocand(Movie,25)                   ' set movie frame per second to 25
    dim as integer wwidth = ML_GetMovieWidth(Movie)       ' get the movie width for later using
    dim as integer height = ML_GetMovieHeight(Movie)      ' get the movie height for later using
    MovieSprite = ML_CreateStaticSprite(wwidth,height)    ' create an empty sprite with the same size of movie

    Tweety  = ML_LoadStaticSprite("Tweety.Bmp")           ' load Tweety sprite , uesed as a musk
    ML_SetSpriteColorKeyFromPoint(Tweety,0,0)             ' Set the transparent color of Tweety sprite

    ML_SetBaseTimeNow()                                   ' must be called before initializing timers
    BlackWhiteTime = ML_CreateNewTimeLine(0000,30000)     ' start at 0 second and play for 30 seconds
    SharpenTime    = ML_CreateNewTimeLine(30000,40000)    ' start at 30 seconds and play for 40 seconds
    EmbossTime     = ML_CreateNewTimeLine(70000,40000)    ' start at 70 seconds and play for 40 seconds

    BlackWhiteProgram = ML_CreateHLSLProgram()            ' creating BlackWhite shader program

    ML_EditPixelProgram(BlackWhiteProgram)   
    ML_AddToProgram("sampler2D tex0;                                                       ")
    ML_AddToProgram("sampler2D tex1;                                                       ")
    ML_AddToProgram("float4   main(  float2 TexCoord : TEXCOORD0) : COLOR0                 ")
    ML_AddToProgram("{                                                                     ")
    ML_AddToProgram("       float4 col = tex2D( tex0, TexCoord );                          ")
    ML_AddToProgram("       float4 col1= tex2D( tex1, TexCoord );                          ")
    ML_AddToProgram("       float  gray = col1.r * 0.299 + col1.g * 0.587 +col1.b * 0.184; ")
    ML_AddToProgram("       return float4(gray,gray,gray,col.a);                           ")
    ML_AddToProgram("}                                                                     ")
    ML_CompilePixelProgram(BlackWhiteProgram,"main")

    SharpenProgram = ML_CreateHLSLProgram()               ' creating Sharpen shader program
    ML_EditPixelProgram(SharpenProgram)     
    ML_AddToProgram("sampler2D tex0;                                                       ")
    ML_AddToProgram("sampler2D tex1;                                                       ")
    ML_AddToProgram("float4   main(  float2 TexCoord : TEXCOORD0) : COLOR0                 ")
    ML_AddToProgram("{                                                                     ")
    ML_AddToProgram("       float4 col = tex2D( tex0, TexCoord );                          ")
    ML_AddToProgram("       float4 col1= tex2D( tex1, TexCoord );                          ")
    ML_AddToProgram("       float4 ncol1 = tex2D( tex1, TexCoord + float2(0.001,0));       ")
    ML_AddToProgram("       float4 ncol2 = tex2D( tex1, TexCoord + float2(-0.001,0));      ")
    ML_AddToProgram("       float4 ncol3 = tex2D( tex1, TexCoord + float2(0,0.001));       ")
    ML_AddToProgram("       float4 ncol4 = tex2D( tex1, TexCoord + float2(0,-0.001));      ")
    ML_AddToProgram("       float4 ncol5 = tex2D( tex1, TexCoord + float2(0.001,0.001));   ")
    ML_AddToProgram("       float4 ncol6 = tex2D( tex1, TexCoord + float2(0.001,-0.001));  ")
    ML_AddToProgram("       float4 ncol7 = tex2D( tex1, TexCoord + float2(-0.001,0.001));  ")
    ML_AddToProgram("       float4 ncol8 = tex2D( tex1, TexCoord + float2(-0.001,-0.001)); ")
    ML_AddToProgram("       float4 sum   = ncol1+ncol2+ncol3+ncol4+ncol5+ncol6+ncol7+ncol8;")
    ML_AddToProgram("       float4 sharp = (27*col1-2*sum)/9;                              ")
    ML_AddToProgram("       return float4(sharp.r,sharp.g,sharp.b,col.a) ;                 ")
    ML_AddToProgram("}                                                                     ")
    ML_CompilePixelProgram(SharpenProgram,"main")

    EmbossProgram = ML_CreateHLSLProgram()               ' creating Emboss shader program
    ML_EditPixelProgram(EmbossProgram)
    ML_AddToProgram("sampler2D tex0;                                                       ")
    ML_AddToProgram("sampler2D tex1;                                                       ")
    ML_AddToProgram("float4   main(  float2 TexCoord : TEXCOORD0) : COLOR0                 ")
    ML_AddToProgram("{                                                                     ")
    ML_AddToProgram("       float4 col = tex2D( tex0, TexCoord );                          ")
    ML_AddToProgram("       float4 col1= tex2D( tex1, TexCoord );                          ")
    ML_AddToProgram("       float4 ncol1 = tex2D( tex1, TexCoord + float2(0.001,0));       ")
    ML_AddToProgram("       float4 ncol2 = tex2D( tex1, TexCoord + float2(-0.001,0));      ")
    ML_AddToProgram("       float4 Emboss= (2*ncol1-2*ncol2)+float4(.5,.5,.5,1);           ")
    ML_AddToProgram("       float  avrg = (Emboss.r+Emboss.g+Emboss.b)/3;                  ")
    ML_AddToProgram("       return  float4(avrg,avrg,avrg,col.a);                          ")
    ML_AddToProgram("}                                                                     ")
    ML_CompilePixelProgram(EmbossProgram,"main")
   
end sub

''-----------------------------------------------------------------------------
'' Name: render()
'' Desc: Render or draw our scene to the monitor.
''-----------------------------------------------------------------------------
sub render( )
    IDirect3DDevice9_Clear( g_pd3dDevice, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, _
                            D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 )
''
'' begin drawing
''
IDirect3DDevice9_BeginScene(g_pd3dDevice)
   
   
    '' Magic Stuff
    ''
        ML_UseOrthogonalView                                               ' starting 2d mode
       
        ML_SetAlpha(1)                                                     ' set alpha blending factor
        ML_SetColor(255,255,255)
       
        ML_SetBlendMode(ALPHABLEND)                                        ' set blending mod
       
        ML_GetNextMovieFrame(Movie)                                        ' update the movie for next Frame
        ML_SetScale(2,2)                                                   ' set the scale in X-X and Y-Y axis   
        dim as integer wwidth = ML_GetMovieWidth(Movie)                    ' get the wdith of movie for uesed when drawing it to sprite
        dim as integer height= ML_GetMovieHeight(Movie)                    ' get the height of movie for uesed when drawing it to sprite
        ML_DrawMovieFrameToSprite(MovieSprite,0,0,Movie,0,0,wwidth,height) ' draw the movie frame to sprite
        ML_SetSpriteTexture(MovieSprite)                                   ' we must set the sprite texture before drawing it
        ML_DrawSprite(MovieSprite,320,240)                                 ' actually drawing the sprite at 320 , 240 coordinates

        ML_SetSpriteTexture(Tweety)                                        ' pass the sprite image to shader program
        ML_SetSpriteTexture(MovieSprite,1)                                 ' pass the movie image to shader program
        if(ML_CheckFireTime(BlackWhiteTime)) then ML_StartPixelProgram(BlackWhiteProgram) ' if we are in BlackWhite period effect
        if(ML_CheckFireTime(SharpenTime))    then ML_StartPixelProgram(SharpenProgram)    ' if we are in Sharpen period effect
        if(ML_CheckFireTime(EmbossTime))     then ML_StartPixelProgram(EmbossProgram)     ' if we are in Emboss period effect
        ML_DrawSprite(MovieSprite,320,240)                                 ' draw the teh movie by using shader program
        ML_StopShaderProgram()                                             ' we finished our effect and did not need the shader progrem

        ML_UsePerspectiveView                                              ' stop 2D mode and return to Original 3D mode
   
''
'' end drawing
''
IDirect3DDevice9_EndScene(g_pd3dDevice)
    IDirect3DDevice9_Present(g_pd3dDevice, NULL, NULL, NULL, NULL )
   
end sub


''-----------------------------------------------------------------------------
'' Name: WinMain()
'' Desc: The application's entry point
''-----------------------------------------------------------------------------
function WinMain(byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval lpCmdLine as string, _
byval nCmdShow as integer _
) as integer

dim as WNDCLASSEX winClass
dim as MSG        uMsg

with winClass
.lpszClassName = @"MY_WINDOWS_CLASS"
.cbSize        = len(WNDCLASSEX)
.style         = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc   = @WindowProc
.hInstance     = hInstance
.hIcon        = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
    .hIconSm    = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hCursor       = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = cast(HBRUSH,GetStockObject(BLACK_BRUSH))
.lpszMenuName  = NULL
.cbClsExtra    = 0
.cbWndExtra    = 0
end with

if( RegisterClassEx( @winClass ) = FALSE ) then
return E_FAIL
end if

g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", _
                             "Direct3D (DX9) - Primitive Types", _
     WS_OVERLAPPEDWINDOW or WS_VISIBLE, _
         0, 0, 640, 480, NULL, NULL, hInstance, NULL )

if( g_hWnd = NULL ) then
return E_FAIL
end if

    ShowWindow( g_hWnd, nCmdShow )
    UpdateWindow( g_hWnd )

init()

do while( uMsg.message <> WM_QUIT )
if( PeekMessage( @uMsg, NULL, 0, 0, PM_REMOVE ) ) then
TranslateMessage( @uMsg )
DispatchMessage( @uMsg )
        else
    render()
end if
loop

shutDown()

    UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance )

return uMsg.wParam
end function

''-----------------------------------------------------------------------------
'' Name: WindowProc()
'' Desc: The window's message handler
''-----------------------------------------------------------------------------
function WindowProc( byval hWnd as HWND, _
byval msg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM _
   ) as LRESULT

    select case ( msg )
        case WM_KEYDOWN
select case( wParam )
case VK_ESCAPE
PostQuitMessage(0)

end select

case WM_CLOSE
PostQuitMessage(0)

        case WM_DESTROY
            PostQuitMessage(0)

case else
return DefWindowProc( hWnd, msg, wParam, lParam )
end select

return 0
end function

''-----------------------------------------------------------------------------
'' Name: shutDown()
'' Desc: Release all Direct3D resources.
''-----------------------------------------------------------------------------
sub shutDown( )

    if( g_pd3dDevice <> NULL ) then
        IDirect3DDevice9_Release(g_pd3dDevice)
    end if

    if( g_pD3D <> NULL ) then
        IDirect3D9_Release( g_pD3D )
    end if
end sub

''
''
''
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )


20
Freebasic / ResterDemo / OgreMagic
« on: February 28, 2007 »
Hi shocky.

just for fun, here is the source code of raster demo that was written by you for Cobra

i have ported to OgreMagic , please i want you to make a FPS comparison and tell us.

Code: [Select]
''------------------------------------------------------------------------------
''
''              Magic Library For Ogre
''                beta version 0.40
''                  by Emil Halim
''
''        Name    :  RASTER EFFECT Demo
''        Date    :  28/02/2007
''        Purpose :  written by BY SHOCKWAVE
''                   for Cobra language
''                   ported to OgreMagic by Emil Halim
''
''       website  :  http://www.freewebs.com/ogremagic/index.htm
''
''------------------------------------------------------------------------------


#include once "windows.bi"
#include once "win/d3d9.bi"

#include once "MagicLibrary.bi"

''-----------------------------------------------------------------------------
'' GLOBALS
''-----------------------------------------------------------------------------
dim shared as HWND              g_hWnd         = NULL
dim shared as LPDIRECT3D9       g_pD3D         = NULL
dim shared as LPDIRECT3DDEVICE9 g_pd3dDevice   = NULL

dim shared as SpriteData           ptr   Rester
dim shared as HLSLProgramData      ptr   HLSLProgram  

''-----------------------------------------------------------------------------
'' PROTOTYPES
''-----------------------------------------------------------------------------
declare function WindowProc( byval hWnd as HWND, byval msg as UINT, byval wParam as WPARAM, byval lParam as LPARAM ) as LRESULT
declare sub init()
declare sub shutDown()
declare sub render()

''-----------------------------------------------------------------------------
'' Name: init()
'' Desc: Initializes Direct3D under DirectX 9.0
''-----------------------------------------------------------------------------
sub init( )
    g_pD3D = Direct3DCreate9( D3D_SDK_VERSION )

    dim as D3DDISPLAYMODE d3ddm

    IDirect3D9_GetAdapterDisplayMode( g_pD3D, D3DADAPTER_DEFAULT, @d3ddm )

    dim as D3DPRESENT_PARAMETERS d3dpp
    clear( d3dpp, 0, len(d3dpp) )

    d3dpp.Windowed               = TRUE
    d3dpp.SwapEffect             = D3DSWAPEFFECT_DISCARD
    d3dpp.BackBufferFormat       = d3ddm.Format
    d3dpp.EnableAutoDepthStencil = TRUE
    d3dpp.AutoDepthStencilFormat = D3DFMT_D16
    d3dpp.PresentationInterval   = D3DPRESENT_INTERVAL_IMMEDIATE

    IDirect3D9_CreateDevice( g_pD3D, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, g_hWnd, _
                           D3DCREATE_SOFTWARE_VERTEXPROCESSING, _
                           @d3dpp, @g_pd3dDevice )
   
    '' Initial Magic Library here
    InitialMagicLibrary(g_pd3dDevice,640, 480)
    
    ML_SetMediaDirectory("../MagicMedia/")
    
    Rester = ML_CreateStaticSprite(1,480)    
    
    HLSLProgram = ML_CreateHLSLProgram()
    ML_EditPixelProgram(HLSLProgram)                              
    ML_AddToProgram("sampler2D tex0;                                                                    ")
    ML_AddToProgram("float GADD,GADD2,GADD3;                                                            ")
    ML_AddToProgram("float4   main(  float2 TexCoord : TEXCOORD0) : COLOR0                              ")
    ML_AddToProgram("{                                                                                  ")
    ML_AddToProgram("    float4 col0 = tex2D( tex0, TexCoord);                                          ")
    ML_AddToProgram("    float  y = TexCoord.y *10;                                                     ")
    ML_AddToProgram("    float RD = (125+((sin(y+GADD3)*50)+(cos(y+GADD2)*50)-(sin(y+GADD)*24)))/255.0; ")
    ML_AddToProgram("    float GR = (125+((sin(y+GADD2)*50)+(cos(y+GADD)*50)+(sin(y+GADD3)*24)))/255.0; ")
    ML_AddToProgram("    float BL = (125+((sin(y+GADD)*50)-(cos(y+GADD3)*50)-(sin(y+GADD2)*24)))/255.0; ")
    ML_AddToProgram("    return  float4(RD,GR,BL,1);                                                    ")
    ML_AddToProgram("}                                                                                  ")
    ML_CompilePixelProgram(HLSLProgram,"main")                            
    
end sub

''-----------------------------------------------------------------------------
'' Name: render()
'' Desc: Render or draw our scene to the monitor.
''-----------------------------------------------------------------------------
sub render( )
    IDirect3DDevice9_Clear( g_pd3dDevice, 0, NULL, D3DCLEAR_TARGET or D3DCLEAR_ZBUFFER, _
                            D3DCOLOR_COLORVALUE(0.0f,0.0f,0.0f,1.0f), 1.0f, 0 )
''
'' begin drawing
''
IDirect3DDevice9_BeginScene(g_pd3dDevice)
    
    
    '' Magic Stuff
    ''
        ML_UseOrthogonalView
        
        ML_SetAlpha(1)
        ML_SetColor(255,255,255)
        
        ML_SetBlendMode(ALPHABLEND)
        
        ML_SetScale(640,1)
        static as single GADD,GADD2,GADD3
        GADD  += 0.01
        GADD2 += 0.02
        GADD3 += 0.03
        ML_SetPixelVariable(0,@GADD,1)
        ML_SetPixelVariable(1,@GADD2,1)
        ML_SetPixelVariable(2,@GADD3,1)
        ML_StartShaderProgram(HLSLProgram)  
        ML_DrawSprite(Rester,320,240)
        ML_StopShaderProgram()  

        ML_UsePerspectiveView
    
''
'' end drawing
''
IDirect3DDevice9_EndScene(g_pd3dDevice)
    IDirect3DDevice9_Present(g_pd3dDevice, NULL, NULL, NULL, NULL )
    
end sub


''-----------------------------------------------------------------------------
'' Name: WinMain()
'' Desc: The application's entry point
''-----------------------------------------------------------------------------
function WinMain(byval hInstance as HINSTANCE, _
byval hPrevInstance as HINSTANCE, _
byval lpCmdLine as string, _
byval nCmdShow as integer _
) as integer

dim as WNDCLASSEX winClass
dim as MSG        uMsg

with winClass
.lpszClassName = @"MY_WINDOWS_CLASS"
.cbSize        = len(WNDCLASSEX)
.style         = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc   = @WindowProc
.hInstance     = hInstance
.hIcon       = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
     .hIconSm   = LoadIcon(hInstance, cast(LPCTSTR,IDI_APPLICATION))
.hCursor       = LoadCursor(NULL, IDC_ARROW)
.hbrBackground = cast(HBRUSH,GetStockObject(BLACK_BRUSH))
.lpszMenuName  = NULL
.cbClsExtra    = 0
.cbWndExtra    = 0
end with

if( RegisterClassEx( @winClass ) = FALSE ) then
return E_FAIL
end if

g_hWnd = CreateWindowEx( NULL, "MY_WINDOWS_CLASS", _
                             "Direct3D (DX9) - Primitive Types", _
    WS_OVERLAPPEDWINDOW or WS_VISIBLE, _
        0, 0, 640, 480, NULL, NULL, hInstance, NULL )

if( g_hWnd = NULL ) then
return E_FAIL
end if

    ShowWindow( g_hWnd, nCmdShow )
    UpdateWindow( g_hWnd )

init()

do while( uMsg.message <> WM_QUIT )
if( PeekMessage( @uMsg, NULL, 0, 0, PM_REMOVE ) ) then
TranslateMessage( @uMsg )
DispatchMessage( @uMsg )
        else
   render()
end if
loop

shutDown()

    UnregisterClass( "MY_WINDOWS_CLASS", winClass.hInstance )

return uMsg.wParam
end function

''-----------------------------------------------------------------------------
'' Name: WindowProc()
'' Desc: The window's message handler
''-----------------------------------------------------------------------------
function WindowProc( byval hWnd as HWND, _
byval msg as UINT, _
byval wParam as WPARAM, _
byval lParam as LPARAM _
  ) as LRESULT

    select case ( msg )
        case WM_KEYDOWN
select case( wParam )
case VK_ESCAPE
PostQuitMessage(0)

end select

case WM_CLOSE
PostQuitMessage(0)

        case WM_DESTROY
            PostQuitMessage(0)

case else
return DefWindowProc( hWnd, msg, wParam, lParam )
end select

return 0
end function

''-----------------------------------------------------------------------------
'' Name: shutDown()
'' Desc: Release all Direct3D resources.
''-----------------------------------------------------------------------------
sub shutDown( )

    if( g_pd3dDevice <> NULL ) then
        IDirect3DDevice9_Release(g_pd3dDevice)
    end if

    if( g_pD3D <> NULL ) then
        IDirect3D9_Release( g_pD3D )
    end if
end sub

''
''
''
end WinMain( GetModuleHandle( null ), null, Command( ), SW_NORMAL )


Pages: [1] 2