MonkeyPro63 now up!Monkey Programming Forums/Monkey Programming/MonkeyPro63 now up!
MonkeyPro63 is now up complete with new pixel read/write functions:
'create a new image...single frame only?
Function CreateImage:Image( width,height,flags )
'read from 'backbuffer'...
Function ReadPixels:Void( pixels:Int, x:Int, y:Int, width:Int, height:Int,arrayOffset:Int=0, arrayPitch:Int=0 )
'write to image...must be a CreateImage image.
Method Image.WritePixels( pixels:Int, x:Int, y:Int, width:Int, height:Int, arrayOffset:Int=0, arrayPitch:Int=0 )
mojo.graphics - Added CreateImage, ReadPixels, Image.WritePixels.
android mojo.graphics - Fixed ancient 'textures doesn't render first time' bug!
Removed pss target.
| Why was the pss target removed? |
| And thanks for the read/write pixel functions. |
| Sounds cool. Is this like a manual render to texture then? |
| sexy. might be time to do some ray-tracing.|
pss was removed since sony renamed it to psm. same thing.
| Updated monkey-ext to v63, although the only real change was removing the pss target and updating the trans version number, since Mojo is not part of monkey-ext. |
| Thanks. Those pixel operations seem to work well in HTML5 (IE9 and Chrome). |
| Oh, I wasn't aware that we had the PSM and PSS target already. That makes sence to remove the PSS target. |
| Edit : nevermind nevermind...wow tonight is just sucking for me lol |
| Been waiting for. Thank you for this functional. |
| WOW...thanks Mark. |
| These new functions are very handy thanks.|
Not quite sure I understand how to use them though, a small example would be great.
| Quick example, which draws a player and applies a mask colour (black) so it has alpha:|
| Arggghhh. Monkey is not that portable with TED anymore. Needs a certain Microsoft DLL (MSVCP100.DLL) to work which my work computer has not installed. Hopefully it will work once I copy that DLL at home into the folder were ted.exe is in. |
| Yep, same here with the MSVCR100.dll and MSVCP100.dll on my work computer - looks like I won't get to play today! |
| My god ! Thank you a lot Mark ! |
| Perhaps we'll be seeing some dynamic image loading soon now :) Its the only thing keeping me from using monkey for my web design work! |
| This is brilliant that monkey is getting the ability to manipulate some pixels but there is one major flaw with the implementation. It is not possible to use the backbuffer or any drawing operations outside of OnRender. Essentially you are going to have to be doing a game "update" inside the render method, which is a bit counter-intuitive.|
So this is not currently possible:
Import mojo Function Main() New Game End Class Game Extends App Field land:Image Method OnCreate() 'create land image buffer land = CreateImage(320, 240) 'generate new land GenerateLand() End Method OnUpdate() End Method OnRender() Cls(0, 0, 0) DrawImage(land, 0, 0) End Method GenerateLand() Local pixels:Int[320 * 240] land.WritePixels(pixels, 0, 0, 320, 240) End Method End
| Thanks Mark for this feature and for the fast update!!!|
| Good Work... more power to monkey |
| Realtime image filtering!|
Notice the FPS... ;D
| haha brilliant! |
| sweeet feature. Fast enough to do big pixel operations? Only one way to find out! I'm excited 8D|
great job !
| Hi, |
Thanks for the update!
Sorry for being an absolute beginner but does that mean we could expect something like the SavePixmap command we had in BlitzMax in the future, or not at all?
| does this mean i can draw some images to an image?|
also in the example createimage seems to have more argument than
( width:Int, height:Int, flags:Int=image.defaultflags )
what does the 1 mean?
and in the demo, does this code change the colours?
For Local i:=0 Until w*h*2
Else If i<w*h*4/3
For Local i=0 Until h
For Local j=0 Until w*2
buf[i*w*2+j]=buf[i*w*2+j] & $ffffff | (i*255/h) Shl 24
| The 1 typically refers to frames. Does CreateImage have frames? |
> Yep, same here with the MSVCR100.dll and MSVCP100.dll on my work computer - looks like I won't get to play today!
These made it into the new demo, just not the main release (next time). You should be able to copy these in from the demo 'bin' directory.
> Essentially you are going to have to be doing a game "update" inside the render method, which is a bit counter-intuitive.
Actually, you should be able to safely use Image.WritePixels outside OnRender(), just not ReadPixels - sort of like LoadImage. But yeah, the limitations on when you can render are a bit of a bummer. These are mainly due to android and xna, I'll have a poke around but I'm not sure there's anything I can do.
> also in the example createimage seems to have more argument than
( width:Int, height:Int, flags:Int=image.defaultflags )
Ah yes, that's 'frameCount' - set to '1' for now!
| Any chance in the future could we have: image.ReadPixels? |
Any chance in the future code we have: image.ReadPixels?
I would like that too and a way to change the file outputs from the default MonkeyGame/.monkeystate please.
Any chance in the future could we have: image.ReadPixels?
I'm sure Mark's gonna implement this eventually, but I am just the PSM target away from having a GetImagePixels() function working.
I will post the module here as soon as I'm finished.
| Pixel perfect collisions example using the new commands :)|
| Well, I've lost the fight against the PSM target.. for now. A nice, simple solution doesn't seem plausible, but I'm not too familiar with the API at all.|
All of the other targets appear to be working.
It's usage is something like this:
Local pixels:Int = GetImagePixels(image, x, y, width, height)
And I've included a test project that looks like this:
Import mojo Import imagesextended Class GetPixelsTest Extends App Field firstRender:Bool = True Field drawThing:Bool = False Field img:Image Field newImg:Image Field pixels:Int Method OnCreate() SetUpdateRate(60) img = LoadImage("numbers.png") newImg = CreateImage(128, 128) End Method OnUpdate() If KeyHit(KEY_SPACE) Or KeyHit(KEY_LMB) drawThing = True End End Method OnRender() Cls(110, 110, 110) If firstRender ' I've thrown it in the render cycle here to ensure that the image is loaded, for HTML5. pixels = GetImagePixels(img, 0, 0, 24, 24) firstRender = False End If drawThing ' I've wrapped Image.WritePixels to prevent nasty errors from drawing outside the image WriteImagePixels(newImg, pixels, Rnd(128), Rnd(128), 24, 24) drawThing = False End DrawImage(newImg, 200, 200) End End Function Main() New GetPixelsTest() End
And you can download the module here.
something ugly is going on with images that have an alpha channel - and only when you change the colour. SetColor(255, 255, 255) looks as it should.
Here's the code:
Strict Import mojo Function Main:Int() New TestApp Return 0 End Class TestApp Extends App Field testImage:Image Method OnCreate:Int() SetUpdateRate(60) testImage = LoadImage("imageWithAlphaTest.png") Return 0 End Method OnRender:Int() Cls(255,255,255) SetColor(255,0,0) DrawImage(testImage, 50, 100) SetColor(255,255,255) DrawImage(testImage, 350, 100) Return 0 End End
Result in Monkey v63 (HTML5):
To compare, result in Monkey v62:
Looks like a bug.
> something ugly is going on with images that have an alpha channel - and only when you change the colour. SetColor(255, 255, 255) looks as it should.
Just posted a v63b with a fix for this.
| Great, thanks for the quick update! It works perfectly now. |
Just posted a v63b with a fix for this.
You might want to update the demo again, Mark ;)
| Hi guys. Just upgraded to 63b and am getting these errors:|
2012-08-21 21:49:03.824 xcodebuild[11548:5303] DVTAssertions: Warning in /SourceCache/IDEXcode3ProjectSupport/IDEXcode3ProjectSupport-1559/Xcode3Sources/XcodeIDE/Frameworks/DevToolsBase/pbxcore/SpecificationTypes/XCGccMakefileDependencies.m:87
../glfw/lib/internal.h:58:10: fatal error: 'stdlib.h' file not found
I'm using XCode 4.4.1
| AaronK: Did you delete your build directory? |
| AaronK: Have you installed command line tools? I had to do this before I could compile v63. In Xcode goto XCode->Preferences->Downloads and click on this install button. |
| SQUEEEE!! now i can finish my html5 cardgame. |
| Trans seems quite a bit faster - just my imagination? |
| Yes, much faster here too. |
| That's interesting given that the only change to trans since v61b is the version number... |
Maybe due to binary representation of version number ?
| Maybe the console communication between TED/Trans is faster than Monk/Trans? |
@MikeHart: Maybe the console communication between TED/Trans is faster than Monk/Trans?
This is more likely. I use Jungle, so I couldn't comment. :/
golomp: Maybe due to binary representation of version number ?
Actually, the version number is stored as a string.
| This is going to benefit to my lastest apps. Greatly.|
Before (Blocky shadows):
After (Filtered shadows):
(Made using a 22x18 image then scaling 32x)
| doublepost, sorry|
Edit: Oh, and the 2nd was run in debug ^_^ in release, frame render is 14ms
Rendering something scaled takes a lot of time. I got to check about flash and android, tho.
Edit2: Actually, firefox is really slow at drawing scaled up images; been trying with chrome and the frame render time drops to only 8ms (from 13), and flash also gains the same speed up.
I love this update!
| BlitzProg, for some reason I think the blocky version looks cuter! |
| I'm having trouble with the new WritePixels method, basically I just want to draw to a blank image. but how do I go about specifying a colour as a single integer? the examples so far seem to only deal with modification of a grabbed image. and shifting bits.|
I would be very grateful if someone could post a very 'simple' strict example of a flood fill with random colours in a for next loop using CreateImage instead of modifying a grabbed image. just to let me see how its done, as I'm currently pulling my hair out.
many thanks, grant.
It's cool, I sussed it out :D
/me blames old age!
I'm having trouble with the new WritePixels method, basically I just want to draw to a blank image. but how do I go about specifying a colour as a single integer?
Local argb : Int = ( alpha Shl 24 ) | ( red Shl 16 ) | ( green Shl 8 ) | blue
where alpha, red, green and blue are integers in the range 0 - 255. Setting the pixels to the argb value will produce a colour of your choosing. Hope this helps
| Thanks man, I just sussed that out before I noticed your speedy reply.|
what a community! now to render my metaballs with pixels instead of DrawRects()!
| Hmmm, Everything seems to work as its supposed to, only the android performance seems unusually slow compared to html5, usually its android being faster than html5 for me, but this time html is leaving android standing when using write pixels, not just a little slower, painfully slower to the point of being useless for anything in real time on android.|
my excitement is shot down in flames for the moment :(
has anyone else experienced this?
| android on my game does not work.|
The application Electromon (process com.terem.electromon) has stopped unexpectrdly. Please try again.