OpenGL ES color picker on iPhone

I study 3D on the iPhone, I managed to get a 3D cube on the device, but I would like to add interactivity, for example, touching one person causes a certain event, and the other person causes another event. I would rather avoid choosing a beam, as this adds extra complexity that I don't want in my application.

I read a few color selection tutorials, but there seems to be no specific tutorials for the iPhone or sample code on the Internet.

My main problem is to draw unique color objects in the back buffer and textured objects in the front buffer, never displaying unique color objects for the user, but detecting the color of the pixel touched from the back buffer.

So my question is: can someone point me towards the Objective-C tutorial or send me some sample code?

Any help or advice would be greatly appreciated.

+4
source share
1 answer

OK, so after 18 hours I finally fixed my problem. In the rendering method, all I had to do was prevent the presentRenderbuffer from being called when the render was in SELECT mode. I could hit myself right now!

 if (mode == SELECT) { glDisable(GL_DITHER); glDisable(GL_LIGHTING); glDisable(GL_LIGHT0); } // Draws the cube object, face by face and adds unique color to each face [Face1 draw]; [Face2 draw]; [Face3 draw]; [Face4 draw]; [Face5 draw]; [Face6 draw]; if (mode == SELECT) { glEnable(GL_DITHER); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); } // Wrapping presentRenderbuffer with this if statement fixed // the problem where the unique colors would appear onscreen if (mode == RENDER) { [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } 

I hope this can help someone else in the future: o)

+3
source

All Articles