Mojo HTML5 GL

89 replies to this topic
Posted 1+ years ago #76
MikeHart

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

Thanks!

Let's see if that disapears again, LOL.

 
Posted 11 months ago #77
devolonter

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

Changelog:

v1.35
* 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 11 months ago #78
MikeHart

Thanks man, just tried it and it works like a charm!

 
Posted 11 months ago #79
CopperCircle

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( "http://www.monkeycoder.co.nz/img/logo/cute/monkey1.png",1,Image.MidHandle,Self )
		SetUpdateRate 60
	End
	
	Method OnUpdate()
		UpdateAsyncEvents
	End
	
	Method OnRender()
		Cls
		DrawText "Hello World!",0,0
		If image Then DrawImage image,DeviceWidth()/2,DeviceHeight()/2
	End
	
	Method OnLoadImageComplete:Void( image:Image,path:String,source:IAsyncEventSource )
		If image Then Print "OK!" Else Print "ERR"
		Self.image=image
	End

End

Function Main()
	New MyApp
End
 
Posted 11 months ago #80
devolonter

@MikeHart glad to hear it!

@CopperCircle server with files must have special headers for allowing cross-domain image loading. More info: http://en.wikipedia.org/wiki/Cross-origin_resource_sharing 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 11 months ago #81
CopperCircle

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

 
Posted 9 months ago #82
CopperCircle

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

 
Posted 9 months ago #83
devolonter

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 9 months ago #85
Shockblast

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 4 months ago #86
StoneFaceEXE

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

 
Posted 4 months ago #87
Sphinx

Great work!

@marksibly : Please have a look here!

 
Posted 2 months ago #88
devolonter

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 2 months ago #89
rIKmAN

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

Thanks devolunter.