NonEuclidean icon indicating copy to clipboard operation
NonEuclidean copied to clipboard

WebGL port

Open shooshx opened this issue 6 years ago • 4 comments

Hey I spent a few hours trying to come up with a quick WebGL port using emscripten I managed to get it working fine without the occlusion queries by setting engine.occlusionCullingSupported to 0 Here: take a look: https://shooshx.github.io/NonEuclidean/emscripten/page.html

That worked fine but of course the rendering was extremely slow. Trying to turn on occlusion queries didn't produce the desire result. the portals would simply render nothing. I was able to determine that the problem was the the occlusion queries simple never return "1" That's because a difference between WebGL and OpenGL which is summed in this paragraph from the WebGL2 standard:

In order to ensure consistent behavior across platforms, queries' results must only be made available when the user agent's event loop is not executing a task. In other words: A query's result must not be made available until control has returned to the user agent's main loop. Repeatedly fetching a query's QUERY_RESULT_AVAILABLE parameter in a loop, without returning control to the user agent, must always return the same value.

In your recursive code you assume that getting GL_QUERY_RESULT will flush the rendering pipeline and get the result, as OpenGL does. WebGL however does not do that until the frame code call returns control to the browser.

So what's the chance you'll want to try to restructure your code so that Render is not explicitly recursive so it would be possible to return control between queries?

Another option I was thinking about is to try to simulate occlusion queries using glReadPixels which is synchronous. I don't expect this to be very fast though.

shooshx avatar Jan 04 '19 00:01 shooshx

This project is currently idle right now. I may come back to it when I get a chance to extend it to VR, though honestly I'll first try again to do it inside a real game engine so I can make a full game more easily. If I still can't get it working then I'll be using this engine again and I could potentially look into that.

HackerPoet avatar Jan 04 '19 00:01 HackerPoet

VR you say? That sounds exciting!

casualinformee avatar May 19 '20 06:05 casualinformee

I'd vote to enforce the obliteration of that standard facet. There's no reasonable way asynchronous calls in the middle of task execution could cause different results on different platforms nowadays.

ehx-v1 avatar Jul 09 '20 11:07 ehx-v1

Where are the (.h) -- #include <GL/glew.h> and #include <Windows.h> ??????????

antoniodouglas avatar Jan 28 '23 07:01 antoniodouglas