I write graphics apps for the iPhone and I'm looking to port my most recent app, 'Layers,' to the Android platform. Layers is painting app that allows users to draw on the screen and create multi-layered paintings with different brushes, colors, etc... and export to PSD. It's got desktop sync, a smudge tool, lots of good stuff... http://www.layersforiphone.com/
I started looking at the Android platform Monday and I've run into a major problem. I use OpenGL to do all the drawing because it offers the best performance. However, there are several places where I need to render into a texture and then use the texture. For example:
On the iPhone, I do this continually as the user's finger moves and I am able to achieve 12-15fps on a 1st gen iPod Touch. It's necessary because applying color and alpha to the individual sprites making up the brush stroke doesn't produce the right result (since sprites overlap and make the stroke too dark).
The android platform supports OpenGL ES 1.0 but seems to omit key functions for dealing with framebuffers. I can't find a way to bind a texture to the framebuffer and draw into it using OpenGL.
Here's how I'd normally go about it on the iPhone:
// generate a secondary framebuffer and bind it to OpenGL so we don't mess with existing output.
glGenFramebuffers(1, &compositingFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, compositingFramebuffer);
// attach a texture to the framebuffer.
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
// subsequent drawing operations are rendered into the texture
// restore the primary framebuffer and (possibly) draw the rendered texture
glBindFramebuffer(GL_FRAMEBUFFER, originalActiveFramebuffer);
Is there anything like this on the Android platform? On the iPhone, OpenGL is significantly faster than software-based drawing and is the only viable solution (trust me - I wrote a CoreGraphics painting app too...). Maybe there's another route I could take on Android? I'm willing to jump through whatever hoops are necessary, but I won't publish the app unless performance is good (10fps+ as you're drawing on the screen).
You can use the Render to Texture component to render the scene from a specific camera to a texture. You can use this feature to create rear-view mirrors, security camera screens, and draw 3D models in the viewport. To enable this component, you must enable the Render to Texture gem.
A texture is an OpenGL Object that contains one or more images that all have the same image format. A texture can be used in two ways: it can be the source of a texture access from a Shader, or it can be used as a render target.
I'm skeptical that all Android devices would support the exact same set of OpenGL ES extensions, or that they'd all support the exact same version of OpenGL ES.
Framebuffer objects (FBOs) are a part of the OpenGL ES 2.0 core specification; if your android device supports ES 2.0, then it supports FBOs.
If your android device supports ES 1.1, then check the extension string for GL_OES_framebuffer_object using glGetString(GL_EXTENSIONS).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With