SetColor on DrawImage - Alternative?
Monkey Forums/Monkey Programming/SetColor on DrawImage - Alternative?
| ||
I know that SetColor doesnt work with DrawImage using Monkey, but is there an alternative way to do it? |
| ||
(slight hijack) if there isn't a SetColor alternative yet, are we likely to see one, one day? Thanks |
| ||
Yeah, bit disappointed by this actually. Would love to see this added. I had hoped to be able to port my game Irukandji to iOS and XNA for xbox, but without being able to set the colour of the images in code i'd have to make about 200 different versions of the same image in order to make it look accurate. Is there a specific reason it's not present? Cheers Charlie |
| ||
HTML5 canvas doesn't support sprite tinting, so it's not in. If someone wrote a WebGL version of mojo, however... |
| ||
Someone already wrote a GLSL WebGL demo with Monkey, it's kinda insane good: http://www.blitzmax.com/Community/posts.php?topic=93996#1077646 Unfortunately he didn't publish the monkey source, so I don't know how it's done. Unless he hacked the output files completely, it would mean that Monkey's HTML5 already supports WebGL. |
| ||
That's a bit beyond me i suspect. HTML5 isn't really of great interest to me yet, so in the meantime, is there any way of enabling colouring of images for the other targets? I had a quick scan of the code but i couldn't see anything relevant... Cheers Charlie |
| ||
The focus of the first release is on lowest-common-denominator features across platforms until things have settled a bit and the initial quirks have been ironed out. (I want this too!) |
| ||
That makes sense, so the first release of Monkey aims at a robust base functionality, which can then be expanded easily and guaranteed to work again on all platforms. |
| ||
Im pretty close to finishing my first "proper" Monkey game, but my particles/text look pretty boring being white... Are we ever going to get SetColor working with images and if so any ETA? Pleeeeaaassseee!! Thanks! |
| ||
Another vote for SetColor affecting images... I just can't imagine making N versions of font to support different font colors, not to mention working with particles is difficult too. |
| ||
Hello, Here's a hack for iOS to get setColor working with images... Edit Modules -> Modules -> Mojo -> Native -> mojo.ios edit the void gxtkGraphics::BeginRender() method and comment out the following two lines : // glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // glTexCoordPointer( 2,GL_FLOAT,sizeof(Vertex),&verts[0].u ); Now edit the following methods : int gxtkGraphics::DrawSurface( gxtkSurface *surface,float x,float y ) and int gxtkGraphics::DrawSurface2( gxtkSurface *surface,float x,float y,int srcx,int srcy,int srcw,int srch ) and add just before the AddVertex commands glColor4f(this->r/255, this->g/255, this->b/255, this->alpha/255); Im sure there must be a neater / faster way but this is how I have it working today. |
| ||
Im sure there must be a neater / faster way but this is how I have it working today. The neater/faster way is to replace verts[vertCount++].c=acolor; in the second AddVertex definition with verts[vertCount++].c=color; |
| ||
HTML5 canvas doesn't support sprite tinting, so it's not in. In that respect, various channel commands dont seem to be supported on various platforms, like, ChannelState returning nothing but -1 on Android... But thats in... Under the same rule of thumb, if it doesnt work like the rest why is that in! Unless of course, Mark is intending to rejig it to suit, but at the minute, this little miss hit has sent me back to GLBasic for my next game, a bit of a shame, because I like monkey! If that sounds harsh, well, I'm sorry, it isnt meant to be, but all I want is for all the official monkey/mojo stuff to work exactly the same across all supported platforms, that isnt too much to ask is it? Dabz |
| ||
HTML5 canvas doesn't support sprite tinting, so it's not in. In that respect, various channel commands dont seem to be supported on various platforms, like, ChannelState returning nothing but -1 on Android... But thats in... Under the same rule of thumb, if it doesnt work like the rest why is that in! Unless of course, Mark is intending to rejig it to suit, but at the minute, this little miss hit has sent me back to GLBasic for my next game, a bit of a shame, because I like monkey! If that sounds harsh, well, I'm sorry, it isnt meant to be, but all I want is for all the official monkey/mojo stuff to work exactly the same across all supported platforms, that isnt too much to ask is it? Dabz |
| ||
in the second AddVertex definition with verts[vertCount++].c=color; Thanks Skid. We have just confirmed this works with Android too (mojo.androidgl.java): Change Line 460 (V38): colors.put( acolor ); to colors.put( color ); This works with DrawImage and of course DrawText :) |
| ||
For Flash we had to do the following (mojo.flash.as) : New variable: class gxtkGraphics{ ... internal var alphaVal:Number; // new var In SetAlpha: internal function SetAlpha( alpha:Number ):int{ FlushGraphics(); this.alphaVal = alpha; // store alpha in the new var if( alpha!=1 ){ ... In SetColor: internal function SetColor( r:Number,g:Number,b:Number ):int{ FlushGraphics(); this.alpha=new ColorTransform( r / 255, g / 255, b / 255, this.alphaVal); // apply the colour ... |
| ||
I want to try this out. @therevills (or anyone for that matter) What are the steps for Android? I have done this... mojo.androidgl.java Change Line 460 (V38): colors.put( acolor ); to colors.put( color ); But that is all. Do I need to change anything else? I can not test it as I have no access to the computer on which I compile. So I am modifying my thumbdrive copy to try later. Can't wait to try it out. It is like Christmas every few days or so here! You guys are so awesome, Mark too. ;^) |
| ||
Also, as far as Flash is concerned: Maybe I am missing something or misunderstanding this but I do not see mojo.flash.java I do see E:\monkey\modules\mojo\native\mojo.flash.as (.as instead of .java) and for Android E:\monkey\modules\mojo\native\mojo.androidgl.java I made the changes from therevills last two posts. Is this all we have to do and are these the right files to modify for Android and Flash. Really hate that I can't test it right now. |
| ||
Yep that is the only change you need :) Opps... yes the flash file is call mojo.flash.as. Heres a guide to do it: http://www.indiecodez.com/forum/index.php/topic,149.msg4922.html#msg4922 |
| ||
Seriously? That is going to be so cool. Darn it. Won't be able to check it out for at least another 8 hours. Can I say that you all are awesome again? |
| ||
Really quickly done: https://sites.google.com/site/therevillsgames/monkey/MonkeyGame.swf |
| ||
Hi, I'm planning on adding this early next week! |
| ||
@therevills: Thanks for giving me a quick demo to play with @Mark: Yup. Like I said, Christmas. |
| ||
O.o sounds good mark. |
| ||
@Skid - Your solution is much neater :) @Mark Great news. It will be much nicer having it work just out of the box. |
| ||
That is great, I have a good usage for it. |
| ||
Nice to hear :) |
| ||
Took me awhile to figure this out, but something to be aware of. I have not fully tested this, but that seems to be my experience. *Flash builds: SetAlpha appears to erase or reset any changes you made with SetColor. *Android builds: SetColor is not affected by any call to SetAlpha. On the lighter side, my app has sickly green images with red text and yellow text in other places. God awful to look at, but that was my intention while testing SetColor. |
| ||
*Flash builds: SetAlpha appears to erase or reset any changes you made with SetColor. Yep, Ive noticed that, if you change the call order so that SetColor is after SetAlpha it works okay ;) Since Mark has said this is going to be in the offical release I havent looked at doing much more... I had a quick look at trying to get SetColor working with HTML5 with limited success: |
| ||
Any news on this? Cheers Charlie |
| ||
Hi, On it's way - performance on html5 is gonna be a bit of shocker though. |
| ||
HTML5 is kinda useless for graphics apps, it's too slow for that. Flash and WebGL are much better options. WebGL works with every FireFox4 browser on every machine. I couldn't get any other browser to work with WebGL, but it's good that FireFox4 will be the only browser in future when people need to use WebGL apps. |
| ||
@Lumooja I've been working with WebGL in Chrome for quite a while now. It's not in the stable release yet, but the beta and dev branches had it for a while :) |