Page 1 of 1
Raycasting Library 3
Posted: Wed Aug 17, 2005 7:31 pm
by pg
Hello
Here is again the newer version of the raycasting library
with wall, floor and ceilig rendering an many more functions.
It has its own fast pixel-rendering routines.
I hope that some of the coders here can use it.
Library and examples:
http://www.mypage.bluewin.ch/bithandler ... aster3.zip
Posted: Wed Aug 17, 2005 8:06 pm
by Num3
Really cool library!
Posted: Wed Aug 17, 2005 8:11 pm
by thefool
sweet

just play'd purestein for 15 minutes
-you need to use a password
This is your Password for the raycaster.
pass=InitRaycaster(943984,232359,692895,981105)
Why is that?
Posted: Wed Aug 17, 2005 8:32 pm
by pg
Thanks
The Password is just for the InitRaycaster() function. This is, because the lib was used in another projet, where i had to protect it, but i didn't remove it.
I've noticed that PB 3.94 needs other declarations for functions, so
for example:
Declare PutEnemy(a.l,a.l,a.l,a.l,a.l) must be replaced with
Declare PutEnemy(a.l,b.l,c.l,d.l,e.l)
This is used on some examples....
Posted: Wed Aug 17, 2005 8:35 pm
by thefool
oh. well not a big problem

Posted: Thu Aug 25, 2005 11:31 am
by ZeHa
Just one question...
I also started to do a Raycasting Engine in PureBasic, but I did not get too far...
At first, I did one that just was drawing vertical lines, and it was very quick. Then, I tried to add wall textures, but it was very slow - and I did not find any way to get those pixels faster on the screen
How did you do the drawing?
Posted: Thu Aug 25, 2005 11:34 am
by ZeHa
Or didn't you write the library itself in PB at all?
Posted: Thu Aug 25, 2005 8:08 pm
by pg
Hi
I've wrote the Library in Visual C. I've never tried
to do it with PB, but i'm sure it's also possible with
a good speed. If you can't draw the pels from a texture
fast enough, then maybe it's a problem with the
memory access. If you read the Bytes of the texture
directly from a memory location the it it's fast....
Posted: Fri Aug 26, 2005 9:36 am
by ZeHa
Thank you for your reply!
Well, I scanned the texture once and wrote the RGB values into an array.
Then, when I drawed the walls, I got the colors from the array and Plot(x,y)ed them onto the screen.
Could it be faster if I used a memory buffer instead of an array?
And could it be an advantage if I wrote the RGB directly into the drawing buffer (because I think Plot() doesn't do anything else)?
Posted: Fri Aug 26, 2005 10:01 pm
by pg
hi
This code should render a texture fast enough. It's
different than in my C code but it should give you
more or less the same speed.
You need the
"texd.bmp", it must be a
24bit 64*64 texture of your wall, then you can see it.
If you do the same for 8bit it could be faster but then
you need to use a color palette.
the Procedure Render16 does it all...
you can find this rendering function on:
http://mysite.verizon.net/caliarbor75/downloads.html
this is a good page for you!
Code: Select all
InitSprite()
InitKeyboard();
Enumeration
#Buffer1
#Tex
EndEnumeration
Declare Render16( a,b, c, d, e)
WndScrID = OpenScreen(640, 480,16, "")
SetFrameRate(60)
CreateSprite(#Buffer1, 320,200,#PB_Sprite_Memory) ;//screenbuffer
LoadSprite(#Tex,"texd.bmp",#PB_Sprite_Memory ) ;//texture
StartDrawing(SpriteOutput(#Buffer1))
buffer1= DrawingBuffer() ;screenmemory
StopDrawing()
StartDrawing(SpriteOutput(#Tex))
tex= DrawingBuffer() ; texturememory
StopDrawing()
Repeat
;draw the wall with perspective
For a = 1 To 64 ; texture is 64 pixel large
Render16(buffer1,tex,150-a,a,a) ;200-a = height
Next a
DisplaySprite(#Buffer1, 1, 1)
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
End
;/////////////////////RENDER WALL FAST/////////////////////////////
Procedure Render16(screen, bmp, height, screenx, row)
a1=0; .
index=bmp+(128*row); .
factor=(64.0/height)* 65536;
ch=100-height/2
If(ch<0)
a1=factor*(-ch); .
ch=0;
dh=200;
Else
dh=100+height/2;
EndIf
While(ch<dh)
color.w= PeekW(index+((a1>>16)<<1) )
PokeW(screen+((320*ch+screenx)<<1),color )
ch=ch+1
a1=a1+factor
Wend
EndProcedure
;////////////////////////////////////////////////////////////
End
Posted: Sat Aug 27, 2005 10:49 am
by ZeHa
Great!
I think I'll try this with my engine today and I'll tell you if it works.
Thank you!