Hi,
I have purchased Titanium's OpenGL module and use it in my app. But I met a issue, after I finish rendering a frame, I want to read color buffer and
save data to image. But when I call your glReadPixels function, I get error msg :
[INFO] : [object TiOpenglModule] loaded
[INFO] : module is => [object TiOpenglModule]
[ERROR] : An error occurred running the iOS Simulator
[ERROR] :
[ERROR] : Project failed to build after 17s 971ms
below is my codes:
var setup = function(view) {
view.setCurrentContext();
view.glViewport(0, 0, 155, 240);
view.glMatrixMode(Opengl.GL_PROJECTION);
view.glLoadIdentity();
view.glMatrixMode(Opengl.GL_MODELVIEW);
view.glLoadIdentity();
view.glVertexPointer(2, Opengl.GL_FLOAT, 0, squareVertices);
view.glColorPointer(4, Opengl.GL_UNSIGNED_BYTE, 0, squareColors);
view.glEnableClientState(Opengl.GL_VERTEX_ARRAY);
view.glEnableClientState(Opengl.GL_COLOR_ARRAY);
};
var render = function(view) {
view.setFrameBuffer();
view.clear();
view.glLoadIdentity();
view.glTranslatef(0.0, Math.sin(transY)/2.0, 0.0);
view.glDrawArrays(Opengl.GL_TRIANGLE_STRIP, 0, 4);
view.presentFrameBuffer();
Ti.API.info('----4');
var pixels = view.glReadPixels(0, 0, 155, 240, Opengl.GL_RGBA, Opengl.GL_UNSIGNED_BYTE);
Ti.API.info('----3');
};
var doOpengl = function(e) { setup(opengl); render(opengl); };
How can I read color buffer data after I finish rendering a frame? And then save those data to a png image file.
Thanks!