Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: rdc on May 22, 2009

Title: FB Raycaster
Post by: rdc on May 22, 2009
I thought I would compare the C++ raycaster on Lode's site to the same prog in FB and I was actually surprised. The FB version is smaller than the C++ version. So much for thinking that the C++ version would be smaller. Here are the files in case you want to look at them. This is a straight conversion from the C code.

Pics:

(http://www.file-pasta.com/thumb/1d1f08722f8f35b4b6f5e93994269143a82bb0d8.jpg) (http://www.file-pasta.com/file/fbcaster2.png)

(http://www.file-pasta.com/thumb/553e465967559f2b6f9227c4ac256ed746dd3cbf.jpg) (http://www.file-pasta.com/file/fbcaster.png)

Source file:

http://www.file-pasta.com/file/fbcaster.zip
Title: Re: FB Raycaster
Post by: Shockwave on May 23, 2009
The FB compiler is surprisingly efficient Rick.

Thanks for the link to the raycaster source too. This is a routine I have never ever written in my life, thought I have seen a few.
Title: Re: FB Raycaster
Post by: Jim on May 24, 2009
The fb compiler is good, but I also would think most C++ compilers would be able to beat it.

There could be two reasons for the code size difference.  One is that the C++ version is using SDL for its graphics library which is huge where the fb one is using fbgfx.bi which is tiny.  The second is what compiler options were used - fb doesn't really have many options so you get what you're given, but gcc and other C++ compilers have hundreds, including optimising for speed instead of optimising for size, removing debugging symbols, etc.

Was the C++ code compiled by you Rick - did you used Codeblocks?

<edit>Do they run about the same speed?  I suspect they do.

Jim
Title: Re: FB Raycaster
Post by: rdc on May 24, 2009
I did compile the code. I have Codeblocks setup to use GCC and I used whatever settings they already had in there, so I am sure that there are switches that could improve the C++ size.

The C++ version is a tad faster, probably due to the buffer updates. I am using just a for-next for the buffer update in the FB code. I am sure putting the screen code inline with the raycast would probably speed things up considerably.
Title: Re: FB Raycaster
Post by: Clyde on May 27, 2009
Ive tried the fb version, and it utterly rocks rdc.
memories flooding back of Wolfenstein.

Nice one.
Clyde.
Title: Re: FB Raycaster
Post by: rdc on May 28, 2009
Yeah, me too. It would be fun to make a look-a-like.
Title: Re: FB Raycaster
Post by: antarman on August 19, 2010
All links is dead!  :vangry:
Title: Re: FB Raycaster
Post by: Moroboshisan on August 19, 2010
All links is dead!  :vangry:

original sources still lives http://www.student.kuleuven.be/~m0216922/CG/index.html (http://www.student.kuleuven.be/~m0216922/CG/index.html)... You'll find the FB conversion by rdc attached here (src & bin).

Cheers.
Title: Re: FB Raycaster
Post by: antarman on August 23, 2010
Thank you!  :updance:
Title: Re: FB Raycaster
Post by: Moroboshisan on August 23, 2010
Thank you!  :updance:

you're welcome! ;-)

just my 2 cents... ^_^