94 replies to this topic
Posted 1+ years ago #76
M.Hartlef (MikeHart)

What the hell. This is the 3rd time I answer now.


Let's see if that disapears again, LOL.

Posted 1+ years ago #77

Sorry for delay. I’ve just released an update. All issues should be fixed.


* Added textured DrawPoly support
* Added support of async image loader
* Fixed value returned by getContext function for webgl and expreimental-webgl contexts
* Fixed issues with App.OnLoading event

Posted 1+ years ago #79

Hi, thanks for the update, I just tried with the async image loader and it does not work? it stops the image from downloading, any ideas?
(Monkey v76a)

Import mojo

Class MyApp Extends App Implements IOnLoadImageComplete

	Field image:Image

	Method OnCreate()
		LoadImageAsync( "",1,Image.MidHandle,Self )
		SetUpdateRate 60
	Method OnUpdate()
	Method OnRender()
		DrawText "Hello World!",0,0
		If image Then DrawImage image,DeviceWidth()/2,DeviceHeight()/2
	Method OnLoadImageComplete:Void( image:Image,path:String,source:IAsyncEventSource )
		If image Then Print "OK!" Else Print "ERR"


Function Main()
	New MyApp
Posted 1+ years ago #80

@MikeHart glad to hear it!

@CopperCircle server with files must have special headers for allowing cross-domain image loading. More info: Your code will work in 2d context as well, but it won’t in webgl because it requires more rights for texture binding.

Also, script may work not properly with experimental Monkey versions, because I test code only with stable builds

Posted 1+ years ago #81

Thanks for the tip, didn't realise webgl needed more rights.

Posted 1+ years ago #82

Hi, can this be made to work with WebGL in IE11?

Posted 1+ years ago #83

Hi, WebGL support in IE is slightly incomplete, but this issue can be solved. I started to work on it, but currently it is not my priority task. Sorry.

Posted 1+ years ago #85

I also noticed that this module does not work with IE11. I would also like it if IE is supported. In the mean time I use this to disable WebGL for IE11. It checks if the user agent does not have the word "trident" in it. "trident" is only used in the IE11 user agent string. So it is a temporary fix until IE11 is supported.

function init(id) {
		if (window.WebGLRenderingContext !== undefined) {
			if(navigator.userAgent.toLowerCase().indexOf('trident') === -1) {
				try {
					new WebGL2D(document.getElementById(id));
				} catch (e) { }
Posted 1+ years ago #86

Why doesn't Mark include this patch in all monkey releases again?

Posted 1+ years ago #87

Great work!

@marksibly : Please have a look here!

Posted 1+ years ago #88

This patch is deprecated!
There won’t be no updates, no bugfixes, no compatibility with new Monkey versions.

How to add WebGL support for mojo now?
I made new implementation of WebGL support for mojo in my Monkey fork - mungo. It’s a better implementation which gives ~10 time better performance than this patch and works in IE11. Here is a small demo.

Now you can use these two methods to enable WebGL acceleration for your mojo projects:

1. Download and install mungo
The fastest way to use new WebGL implementation for mojo is to download and install mungo.

2. Create custom HTML5 target
If you don’t want to use mungo you can add WebGL support for mojo by following this short manual:

1. Create a new HTML5 target based on the standard HTML5 monkey target.
2. Rename directory of the new target. For example: html5_webgl
3. There, replace files in modules/native folder by files from mungo
4. Rename new target in TARGET.MONKEY file. For example: #TARGET_NAME="Html5 WebGL Game"
5. Copy-paste code from mojo.html5.webgl.js file into template/main.js file after //${TRANSCODE_END} line
6. Add #HTML5_WEBGL_ENABLED=True in template/CONFIG.MONKEY file

Posted 1+ years ago #89

Ah excellent - I've been missing this target in newer versions as I always tested using it, and now I can again.

Thanks devolunter.

Posted 1 month ago #91

Was there ever a way to implement this now in the current version of monkey-x?

Posted 1 month ago #92

@Neuro: Not sure about this, since I think Develonter abandoned it for normal Monkey (Mungo target may still work). But, if you're interested in WebGL, this module routes calls from Mojo 1 to Mojo 2. So, you'd get Mojo 2's OpenGL (WebGL on HTML5) code backing your game's graphics. And, you could use Mojo 2 features in your game.

It's not the most efficient, but it gets the job done.

Posted 1 month ago #93
M.Hartlef (MikeHart)

@Neuro: The last time I tried Mungo, I could copy its HTML target simply over to Monkey X and it worked.

Btw, I had initial success porting fE to mojo2 (aka fantomX) and the speed increase is awesome rendering wise. You will love it. At least I do!

Posted 1 month ago #94

@immutable - thanks! Will have to check it out!

@mike - cool, is there a fork for it now that i try out??

Posted 1 month ago #95
M.Hartlef (MikeHart)

@Neuro: Sorry, not at the moment. I still need to convert a few functionalities and all the examples.