WebGL doesn't support query objects yet. There's not even an extension for them. It's a bit of an oversight, but stems from the fact that they aren't in OpenGL ES 2.0 (which WebGL is based on) either.
Queries are useful for a number of things. Timer queries can be used to extract detailed profiling information about your rendering. Occlusion queries can be used for culling objects before they're drawn (especially useful if you have an expensive fragment shader). And so on.
This is a nuisance for me because I was using an occlusion query to perform fast pixel-accurate collision detection for my c++ game Schroedinger's Cat. Now that I'm attempting to port the game to WebGL, I need to find an alternative approach.
Update:
I've written a follow-up to this post: OpenGL ES and occlusion queries.
Hi Vilya
ReplyDeleteWish I'd realised this sooner! I was trying to get OpenCSG ported to Javascript/WebGL https://groups.google.com/forum/?fromgroups=#!topic/emscripten-discuss/COOHsqZ6mQI
But without boolean queries, that's not possible. Did you ever find a work around?
Thanks
Marcos
I haven't been able to find a *fast* workaround, no.
DeleteFor a slow workaround, you can read back the region of the framebuffer that you drew the player sprite to & compare it pixel-by-pixel to the original (unoccluded) player sprite. That would be _very_ slow though and I doubt it would help with your OpenCSG port. Sorry!