Here's a software 3d thing that might be useful.

User projects written in or related to FreeBASIC.
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Here's a software 3d thing that might be useful.

Postby Dr_D » Sep 06, 2007 1:26

Well, it's getting there. Here's a 1 level demo. I would have added the source to this, but it's in pretty bad shape right now. The other one is still there anyway. :)

http://www.bes.pbasichasnoballs.com/wik ... n_Demo.rar
Last edited by Dr_D on Sep 17, 2007 7:40, edited 7 times in total.
Deleter
Posts: 975
Joined: Jun 22, 2005 22:33

Postby Deleter » Sep 06, 2007 6:10

I made some ghost models, but they're not in the download version.


boo

[/end pun]

cool
D.J.Peters
Posts: 6960
Joined: May 28, 2005 3:28
Location: Germany

Postby D.J.Peters » Sep 06, 2007 20:53

nice demo for the (simple = in BASIC) poly filler
by the way do you compared the fps (vsync off) WireFrame and FilledPoly ;-)

Joshy
Last edited by D.J.Peters on Sep 06, 2007 21:25, edited 2 times in total.
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Sep 06, 2007 21:23

Last edited by Dr_D on Sep 08, 2007 4:20, edited 1 time in total.
D.J.Peters
Posts: 6960
Joined: May 28, 2005 3:28
Location: Germany

Postby D.J.Peters » Sep 06, 2007 21:25

if you use allways RGB you can change
While cstart<cend:*cstart=c:cstart+=1:Wend
to

Code: Select all

asm
mov edi,[cstart]
mov ecx,[cend]
sub ecx,edi
cmp ecx,4 ' 4 bytes = 1 pixel
jl row_loop_end
shr ecx,2 ' bytes to pixels
mov eax,[c]
row_loop:
  mov [edi],eax
  add edi,4
  dec ecx
jnz row_loop
row_loop_end:
end asm

and the colors (fill and border) should be BYVAL not BYREF
BYREF isn't faster in this case compare it self
mov eax,[c] ' get value of color (BYVAL)
or
mov eax,[c] ' get address of color (BYREF)
mov eax,[eax] ' get value from address
is one step more (for every row in all poly's)

Code: Select all

Declare Sub DJ_triangle( Byref d As pixel Ptr, _
                             p() As Vector2D, _
                         Byval c As pixel, _
                         Byval b As pixel=0, _
                         Byval u As Integer=0 )
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Sep 06, 2007 21:35

Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
D.J.Peters
Posts: 6960
Joined: May 28, 2005 3:28
Location: Germany

Postby D.J.Peters » Sep 06, 2007 23:25

short notes
first use ever double for Timer() (internal it's double too and smoother on linux)
why you call Timer() 4 times per loop ?
with litle changes one call per loop should be good too

Code: Select all

Dim As double lTime, Now_Time, FPS_Start, Last_Loop = Timer
FPS_Start=Last_Loop
Do 
    Now_Time  = Timer
    lTime     = Now_Time-Last_Loop
    Last_Loop = Now_Time
   
    FPS+=1
    If FPS=24 Then ' 24 or any other value
        FPS_Time  = str(int(FPS/(Now_Time-FPS_Start)))
        FPS_Start = Now_time:FPS = 0
    End If
    ...

if you overwrite vars you can speed it up with STATIC vars or the ANY keyword

you can change
dim as anytype example
example=anyvalue
to
dim as anytype example=any
example=anyvalue

or in your case
Dim As Single iMatrix(15) ' internal it will fill all with 0
memcpy( @iMatrix(0), Matrix, MAT_SIZE ) ' now you overwrite all values again

change it to:
static as single iMatrix(15)
memcpy( @iMatrix(0), Matrix, MAT_SIZE )
or
Dim As Single iMatrix(15)=any
memcpy( @iMatrix(0), Matrix, MAT_SIZE )

same with Identy Matrix:
Dim As Single Ptr Matrix = Callocate( MAT_SIZE ) ' will overwrite all values
Matrix_Load_Identity( Matrix )' now overwrite all again

Dim As Single Ptr Matrix = allocate( MAT_SIZE ) ' don't overwrite all values
Matrix_Load_Identity( Matrix )' now overwrite all values

litle bit faster is:
Dim As Single Ptr Matrix = Callocate( MAT_SIZE ) ' all=0
' overwrite only 4 values
Matrix[0]=1:Matrix[5]=1:Matrix[10]=1:Matrix[15]=1
duke4e
Posts: 717
Joined: Dec 04, 2005 0:16
Location: Varazdin, Croatia, Europe
Contact:

Postby duke4e » Sep 06, 2007 23:58

WOW, this is awesome!

I get 49 FPS with 1024x768 res.
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Sep 07, 2007 1:24

Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
D.J.Peters
Posts: 6960
Joined: May 28, 2005 3:28
Location: Germany

Postby D.J.Peters » Sep 07, 2007 2:24

you got it :-)
Last edited by D.J.Peters on Sep 07, 2007 4:07, edited 1 time in total.
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Sep 07, 2007 2:45

Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
D.J.Peters
Posts: 6960
Joined: May 28, 2005 3:28
Location: Germany

Postby D.J.Peters » Sep 07, 2007 2:53

I know all optimized pieces in BASIC are small in speed
(this is why i use inline assembler)
but trust me if you have for example 8 cars with 6000-8000 polys per car
then this differenz is realy dramatically.
(i talk about software rendering without opengl or direct3d)

Joshy
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Sep 07, 2007 3:06

Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
Dr_D
Posts: 2344
Joined: May 27, 2005 4:59
Contact:

Postby Dr_D » Sep 07, 2007 3:29

vdecampo
Posts: 2962
Joined: Aug 07, 2007 23:20
Location: Florida, USA
Contact:

Postby vdecampo » Sep 10, 2007 21:45

Ummmm....Why can't I see any of Dr_D's posts?

Return to “Projects”

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 4 guests