PlayBASIC V1.64O (Work In Progress) Gallery

Started by kevin, January 27, 2013, 10:50:31 PM

Previous topic - Next topic

ATLUS

I run some example(PB1.64L) codes and my codes, work fine.

kevin

Quote from: ATLUS on August 03, 2013, 08:13:06 AM
I run some example(PB1.64L) codes and my codes, work fine.

  Well that's good to know.   Have you tried seeing what you can do with new commands though ????



kevin

#62
   PlayBASIC V1.64O  Beta 21 - Threaded Light Map

     Writing some examples for the threading support in blit image library,  which is not the easiest, but slowly getting somewhere.   Mostly been using other blit image examples such as the light map example as basis of the examples.   To draw a light map we need two images, the opaque version (unlit original image) and the light map image.  These two images are multiplied together and output as the final lit image.  

     Now we've queued threading mode, we can batch some of the work up and push it off onto a second thread.  In this example we're pushing the merge and clear process onto the queue.   When we start this drawing, we start drawing the alternative light map into the second fx image buffer.  Otherwise we'd have to sit and wait, which would make threading those tasks useless.  Wrapping your heads around this is fundamental to being able to use threading successfully.  The more work you can push off and into a single queue the better also.


    PlayBASIC V1.64O Beta 21 version (higher)

PlayBASIC Code: [Select]
   ; Inlude the Blit Image functions
#include "BlitImage"


; Create an FX image the size of the screen
Dim LightMap(2)
LIghtMap(0) =NewImage(GetScreenWidth(),GetScreenHeight(),2)
LIghtMap(1) =NewImage(GetScreenWidth(),GetScreenHeight(),2)


FrontImage =0
BackImage =1-FrontImage


; Create a second FX image the size of the screen
; we'll be using to blend with our other image
Backdrop=NewfxImage(GetScreenWidth(),GetScreenHeight())

; fill the backdrop with something so we can see it
size=64
Tile=NewImage(size,size,2)
RendertoImage Tile
cls $445566
boxc 0,0,size-1,size-1,false, $111111

rendertoIMage Backdrop
TileIMage Tile,0,0,false


LightCol=$f08040


Do

; Set threading mode to capture.
; this allows us to capture the next two blit image functions to
; the interal 'to do' list, so both jobs can be done on the seperate thread.

BlitImageThreadMode 2

; redirect all drawing to screen back buffer
rendertoscreen

ThisLIghtMap=LightMap(FrontImage)

; To do combined Blit (copy) our Image. This
; version multiples the pixels in the blend
; image (MyImage) with the backdrop. So it's
; using the blend image as light map.
BlitImageAlphaMultImage(BackDrop,0,0,ThisLightMap)


rendertoimage ThisLightMap
BlitImageClear(ThisLightMap,0,0,rgb(00,00,00))


BlitImageThreadMode 3


rendertoscreen


; redirect all drawing to this image
RenderToimage LightMap(BackImage)

if LeftMouseButton()<>0 then LightCol=RndRGB()

; draw a circle at the mouses current position

Draw_Light(100,100,150,$445566)

Draw_Light(MouseX(),Mousey(),250,LightCol)


Draw_Light(300,200,150,$ff00000)

Draw_Light(700,400,150,$445566)



rendertoscreen

setcursor 0,0

; make pb wait until our thread queue is done before drawing to the screen.
WaitOnBlitIMageThread()

; Display Message
Text 0,0,"Threaded Queue Example "
Text 0,20,"Left Mouse to change light colour"
text 0,40,Fps()

; slip the light map buffers
FrontImage =1-FrontIMage
BackImage =1-BackImage


; flip the back buffer to the front, so the user can see it
Sync

loop



Function Draw_Light(X#,y#,Radius,Colour=$ffffff)

Colour2=Rgbfade(Colour,5)

Edges=16
steps#=360.0/Edges
inkmode 1+64
For lp=0 to Edges-1
Angle1#=lp*Steps#
Angle2#=wrapangle(Angle1#,Steps#)

x1#=x#+cosradius(angle1#,Radius)
y1#=y#+sinradius(angle1#,Radius)

x2#=X#+cosradius(angle2#,Radius)
y2#=y#+sinradius(angle2#,Radius)

GouraudTri x1#,y1#,Colour2,x2#,y2#,Colour2,x#,y#,Colour

next
inkmode 1

EndFunction






    This example requires V1.64O to function as intended,  since the BlitImageClear command isn't able to read/write to the same buffer due to a  logical error.  


    PlayBASIC V1.64O Beta 20 version

PlayBASIC Code: [Select]
   ; Inlude the Blit Image functions
#include "BlitImage"


; Create an FX image the size of the screen
Dim LightMap(2)
LIghtMap(0) =NewImage(GetScreenWidth(),GetScreenHeight(),2)
LIghtMap(1) =NewImage(GetScreenWidth(),GetScreenHeight(),2)


FrontImage =0
BackImage =1-FrontImage


; Create a second FX image the size of the screen
; we'll be using to blend with our other image
Backdrop=NewfxImage(GetScreenWidth(),GetScreenHeight())

; fill the backdrop with something so we can see it
size=64
Tile=NewImage(size,size,2)
RendertoImage Tile
cls $445566
boxc 0,0,size-1,size-1,false, $111111

rendertoIMage Backdrop
TileIMage Tile,0,0,false


LightCol=$f08040


Do

; Set threading mode to capture.
; this allows us to capture the next two blit image functions to
; the interal 'to do' list, so both jobs can be done on the seperate thread.

BlitImageThreadMode 2

; redirect all drawing to screen back buffer
rendertoscreen

ThisLIghtMap=LightMap(FrontImage)

; To do combined Blit (copy) our Image. This
; version multiples the pixels in the blend
; image (MyImage) with the backdrop. So it's
; using the blend image as light map.
BlitImageAlphaMultImage(BackDrop,0,0,ThisLightMap)


rendertoimage ThisLightMap
;;; BlitImageClear(ThisLightMap,0,0,rgb(00,00,00))
BlitImageAlphaSubColour(ThisLightMap,0,0,rgb(255,255,255))


BlitImageThreadMode 3


rendertoscreen


; redirect all drawing to this image
RenderToimage LightMap(BackImage)

if LeftMouseButton()<>0 then LightCol=RndRGB()

; draw a circle at the mouses current position

Draw_Light(100,100,150,$445566)

Draw_Light(MouseX(),Mousey(),250,LightCol)


Draw_Light(300,200,150,$ff00000)

Draw_Light(700,400,150,$445566)



rendertoscreen

setcursor 0,0

; make pb wait until our thread queue is done before drawing to the screen.
WaitOnBlitIMageThread()

; Display Message
Text 0,0,"Threaded Queue Example "
Text 0,20,"Left Mouse to change light colour"
text 0,40,Fps()

; slip the light map buffers
FrontImage =1-FrontIMage
BackImage =1-BackImage


; flip the back buffer to the front, so the user can see it
Sync

loop



Function Draw_Light(X#,y#,Radius,Colour=$ffffff)

Colour2=Rgbfade(Colour,5)

Edges=16
steps#=360.0/Edges
inkmode 1+64
For lp=0 to Edges-1
Angle1#=lp*Steps#
Angle2#=wrapangle(Angle1#,Steps#)

x1#=x#+cosradius(angle1#,Radius)
y1#=y#+sinradius(angle1#,Radius)

x2#=X#+cosradius(angle2#,Radius)
y2#=y#+sinradius(angle2#,Radius)

GouraudTri x1#,y1#,Colour2,x2#,y2#,Colour2,x#,y#,Colour

next
inkmode 1

EndFunction









ATLUS


kevin


  1300 club

     Today the PlayBASIC documentation reached a staggering 1300 pages.   





kevin

#65
   Sticking a fork in it

       At the end of tonight It's looking like we're ticked all the boxes for this update and a few more for good measure.   Only had a small amount of the PB time today, but manged to run through another cross reference session on the documentation.      So the only thing left to do now is build the next updater, but that's something for tomorrow.   Hopefully the V1.64O final should be up on the server in a day or so.  




kevin


   PlayBASIC V1.64O  Retail Upgrade

      Yep.. finally the  PlayBASIC V1.64O retail update has been built, stuck together and slapped online...  Have fun..

      Download PlayBASIC V1.64O Retail Upgrade  (9th,Aug,2013)



ATLUS


Sigtrygg


kevin


Thanks, but it's a bit late now to start testing, you're meant to be testing during the beta  period not after.  It's too late now to make any such corrections.

Sigtrygg

Yes, of course you are right. I haven't got enough time for PlayBasic during the last months, because I learnt some about C and RobotC and I took part on a robot virtual world competition.
PlayBasic is the most comfortable programming language for me and I have most of fun with it! I very appriciate your work!

Bye,

Sigtrygg