freebasic.net Forum Index
FreeBASIC's Official Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in

Here's a software 3d thing that might be useful.
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic    freebasic.net Forum Index -> Projects
View previous topic :: View next topic  
Author Message
Dr_D
Hero
PostPosted: Sep 06, 2007 1:26    Post subject: Here's a software 3d thing that might be useful. Reply with quote

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/wiki/demos/Pacenstein_Demo.rar


Last edited by Dr_D on Sep 17, 2007 7:40; edited 7 times in total
 
Back to top
View user's profile Visit poster's website
Deleter
Master
PostPosted: Sep 06, 2007 6:10    Post subject: Reply with quote

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


boo

[/end pun]

cool
 
Back to top
View user's profile
D.J.Peters
Guru
PostPosted: Sep 06, 2007 20:53    Post subject: Reply with quote

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
 
Back to top
View user's profile Visit poster's website
Dr_D
Hero
PostPosted: Sep 06, 2007 21:23    Post subject: Reply with quote



Last edited by Dr_D on Sep 08, 2007 4:20; edited 1 time in total
 
Back to top
View user's profile Visit poster's website
D.J.Peters
Guru
PostPosted: Sep 06, 2007 21:25    Post subject: Reply with quote

if you use allways RGB you can change
While cstart<cend:*cstart=c:cstart+=1:Wend
to
Code:
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:
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 )
 
Back to top
View user's profile Visit poster's website
Dr_D
Hero
PostPosted: Sep 06, 2007 21:35    Post subject: Reply with quote



Last edited by Dr_D on Sep 08, 2007 4:19; edited 1 time in total
 
Back to top
View user's profile Visit poster's website
D.J.Peters
Guru
PostPosted: Sep 06, 2007 23:25    Post subject: Reply with quote

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:
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
 
Back to top
View user's profile Visit poster's website
duke4e
Sr. Member
PostPosted: Sep 06, 2007 23:58    Post subject: Reply with quote

WOW, this is awesome!

I get 49 FPS with 1024x768 res.
 
Back to top
View user's profile Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Dr_D
Hero
PostPosted: Sep 07, 2007 1:24    Post subject: Reply with quote



Last edited by Dr_D on Sep 08, 2007 4:19; edited 1 time in total
 
Back to top
View user's profile Visit poster's website
D.J.Peters
Guru
PostPosted: Sep 07, 2007 2:24    Post subject: Reply with quote

you got it :-)

Last edited by D.J.Peters on Sep 07, 2007 4:07; edited 1 time in total
 
Back to top
View user's profile Visit poster's website
Dr_D
Hero
PostPosted: Sep 07, 2007 2:45    Post subject: Reply with quote



Last edited by Dr_D on Sep 08, 2007 4:19; edited 1 time in total
 
Back to top
View user's profile Visit poster's website
D.J.Peters
Guru
PostPosted: Sep 07, 2007 2:53    Post subject: Reply with quote

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
 
Back to top
View user's profile Visit poster's website
Dr_D
Hero
PostPosted: Sep 07, 2007 3:06    Post subject: Reply with quote



Last edited by Dr_D on Sep 08, 2007 4:19; edited 1 time in total
 
Back to top
View user's profile Visit poster's website
Dr_D
Hero
PostPosted: Sep 07, 2007 3:29    Post subject: Reply with quote

 
Back to top
View user's profile Visit poster's website
vdecampo
Hero
PostPosted: Sep 10, 2007 21:45    Post subject: Reply with quote

Ummmm....Why can't I see any of Dr_D's posts?
 
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    freebasic.net Forum Index -> Projects All times are GMT
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



sf.net phatcode