Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGL port #2

Open
shooshx opened this issue Jan 4, 2019 · 4 comments
Open

WebGL port #2

shooshx opened this issue Jan 4, 2019 · 4 comments

Comments

@shooshx
Copy link

shooshx commented Jan 4, 2019

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.

@HackerPoet
Copy link
Owner

HackerPoet commented Jan 4, 2019

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.

@casualinformee
Copy link

VR you say? That sounds exciting!

@ehx-v1
Copy link

ehx-v1 commented Jul 9, 2020

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.

@antoniodouglas
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants