fredsa / forplay

Automatically exported from code.google.com/p/forplay
Apache License 2.0
12 stars 4 forks source link

3D Primitives for surface #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
OpenGL triangles/polygons and lights.

Original issue reported on code.google.com by tm1r...@gmail.com on 22 May 2011 at 1:18

GoogleCodeExporter commented 9 years ago
I meant to add this as an 'enhancement' sorry. (I can't see how to change it 
now either)

Original comment by tm1r...@gmail.com on 22 May 2011 at 1:20

GoogleCodeExporter commented 9 years ago
We've definitely talked about this plenty in the past. One possible API that 
exposed GLES2 would look something like:

GlSurfaceLayer layer = graphics().createGlSurfaceLayer(width, height);
GlSurface gl = layer.surface();

gl.viewport(0, 0, width, height);
gl.clear(COLOR_BUFFER_BIT);
// etc.

This would be fairly easy to implement in the sense that it would just be a 
direct passthrough to the underlying GL calls. We'd have to think a little 
about how to advertise its presence/absence (GL won't work on some browsers, 
notably IE9, it can't realistically be implemented in Flash, and so forth), but 
that's tractable.

The bigger question is this: What happens if IE10 decides to define "WebD3D" 
instead of supporting WebGL? Or what if WinMo7 takes off, which I believe 
requires XNA or D3D? Then we have an abstraction problem on our hands. I 
strongly believe it would be better to have a slightly weaker 3D API that 
opened up broad platform support, than to offer up every detail of GLES2. 
Long-story short, I think it's best to wait a bit to see what happens with 3D 
support on IE>9 and WinMo7.

One middle-ground possibility would be to offer up an "experimental" 
direct-access GL API, which wouldn't be supported on all platforms. Then if 
circumstances change and we need to create a more abstract API, we can do so 
later. If we were to do this, I'd want to do so in a way that didn't pollute 
the ForPlay namespace -- one possibility might be:

SurfaceLayer layer = graphics().createSurfaceLayer(width, height);
Surface surf = layer.surface();
if (surf instanceof GlSurface) {
  GlSurface gl = (GlSurface) surf;
}

It's a little obscure, but gives us more leeway to change it later without 
leaving "deprecation" bombs all over the API. Thoughts?

Original comment by jgw@google.com on 28 May 2011 at 1:35

GoogleCodeExporter commented 9 years ago
Interesting: 
http://labs.adobe.com/technologies/flashplatformruntimes/incubator/features/mole
hill.html

Looks like Adobe is busily working on a D3D/GL abstraction. This could provide 
a useful way forward.

Original comment by jgw@google.com on 31 May 2011 at 8:27

GoogleCodeExporter commented 9 years ago
"One middle-ground possibility would be to offer up an "experimental" 
direct-access GL API, which wouldn't be supported on all platforms."
+1

I think a direct access OpenGL ES 2.0 API will have real benefits (Flash 11, 
WebGL, Desktop).

Original comment by consili...@gmail.com on 3 Jun 2011 at 3:08

GoogleCodeExporter commented 9 years ago
To be clear I mean a low level OpenGL ES 2 abstraction that covers Flash 11, 
Java LWJGL on the Desktop, Android OpenGL, and WebGL.

Original comment by consili...@gmail.com on 3 Jun 2011 at 3:27

GoogleCodeExporter commented 9 years ago
A link to Adobe's new Context3D API, so I don't lose it:
  http://www.matthewfabb.com/fp11incubator27_02_11/flash/display3D/package-detail.html
  (don't know why Adobe doesn't seem to have their own doc up online yet, except in a zip file)

If we were to abstract across both Flash 11 and LWJGL/GLES2/WebGL, there will 
definitely be some design work to do. The Flash 11 APIs look pretty 
straightforward, but also include yet another shader language (YASL, anyone?) 
that smells like the old-school assembly-ish shaders of days gone by. I suspect 
they did this to make it easier to abstract across GL and D3D shaders, but it's 
another kink in the works nonetheless.

Probably worth doing, regardless, but it will require some thought to get right.

Original comment by jgw@google.com on 5 Jun 2011 at 3:04

GoogleCodeExporter commented 9 years ago
Marking this "accepted". It's pretty clear we need to do this, and with Flash 
11 on the horizon, it's not as impractical as I originally thought (where I 
define "practical" as "actually possible to deploy to the vast majority of 
users").

Original comment by jgw@google.com on 5 Jun 2011 at 12:40