Author Topic: [BMAX]Magnified Rotozoom source  (Read 3487 times)

0 Members and 1 Guest are viewing this topic.

Offline TinDragon

  • Pentium
  • *****
  • Posts: 644
  • Karma: 24
    • View Profile
    • J2K's blog
[BMAX]Magnified Rotozoom source
« on: July 26, 2009 »
Here's the source code to one of my challenge entries, it requires Zawrans software render framework to compile which is also available on the forum.
It's not the best commented source in the world but atleast shows some more uses for Zawrans code for any bmax users interested :)

Code: [Select]
SuperStrict

Framework BRL.GLMax2D
Import BRL.Pixmap
Import BRL.PNGLoader
'Import BRL.Random
Import BRL.Retro

AppTitle="Rotozoom Magnify"

SetGraphicsDriver GLMax2DDriver()

Include "zSoftwareRenderFramework_v04.bmx"
Const XRES:Int=800
Const YRES:Int=600
Graphics XRES,YRES,0

Global timerUpd:Int = MilliSecs()
Global timerFrq:Int = 1000/30 ' 30 fps

' create an image buffer to store the screen in
Global screenBuffer:zImageBuffer = zImageBuffer.make(XRES,YRES)

' create an image buffer used for the magnification frame
Global tmpImg:zImageBuffer = zImageBuffer.make(62,62)


Const hxres:Int=XRES/2
Const hyres:Int=YRES/2

Local ang:Float=0.0
Local c:Int,xo:Int,yo:Int,y:Int,x:Int,i:Int,j:Int

Repeat

' clear screen buffer
screenBuffer.clear()

ang=ang+0.75
c=750*Cos(ang)
xo=200+200*Sin(ang*2)
yo=200+200*Cos(ang*3)
For y=0 To yres-1
For x=0 To xres-192
i=x+xo-hxres
j=y+yo-hyres
screenBuffer.setpixel(x,y,(((i+j*c/256) & 255) ~ ((j-i*c/256) & 255)),0,0,255)
Next
Next

' copy rects from screen buffer to temporary buffers
tmpImg.copyrectblock(screenBuffer,288,208,62,62,0,0)
' draw temporary buffers scaled to the screen buffer
tmpImg.drawScaledBlock(screenBuffer,xres-188,4,3.0,3.0)
tmpImg.drawScaledBlock(screenBuffer,xres-188,204,3.0,3.0)
tmpImg.drawScaledBlock(screenBuffer,xres-188,yres-191,3.0,3.0)
' draw screenbuffer to the screen
screenBuffer.blitToScreen()
Flip

While MilliSecs() < timerUpd+timerFrq
Wend
timerUpd = MilliSecs()

Until KeyDown(KEY_ESCAPE)
End

hehe notice I have a clear screen in there that I dont even thing I need :P

cheers
Jon

Offline zawran

  • Sponsor
  • Pentium
  • *******
  • Posts: 909
  • Karma: 67
    • View Profile
Re: [BMAX]Magnified Rotozoom source
« Reply #1 on: July 26, 2009 »
Yes since you are drawing into the entire screen buffer, you really don't have to clear it first so you can safely do without the following line:

Code: [Select]
screenBuffer.clear()
Thanks for sharing the code, and for using the framework for the entry.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: [BMAX]Magnified Rotozoom source
« Reply #2 on: July 26, 2009 »
Thank you for sharing the code mate K+
Shockwave ^ Codigos
Challenge Trophies Won:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: [BMAX]Magnified Rotozoom source
« Reply #3 on: July 26, 2009 »
inc karma.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won: