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.
''------------------------------------------------------------------------------
''
'' 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 )