Here's a software 3d thing that might be useful.
Here's a software 3d thing that might be useful.
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
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.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
nice demo for the (simple = in BASIC) poly filler
by the way do you compared the fps (vsync off) WireFrame and FilledPoly ;-)
Joshy
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.
Last edited by Dr_D on Sep 08, 2007 4:20, edited 1 time in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
if you use allways RGB you can change
While cstart<cend:*cstart=c:cstart+=1:Wend
to
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)
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
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 )
Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
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
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
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
...
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
Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.
-
- Posts: 8586
- Joined: May 28, 2005 3:28
- Contact:
Last edited by Dr_D on Sep 08, 2007 4:19, edited 1 time in total.