Alpha 通道中的测试点
在iphone上使用OpenGLES时,有没有办法检测绘制后像素的alpha是否不为0?
我想测试多个点以查看它们是否位于用户绘制的随机多边形区域内。如果您了解 Flash,那么我正在寻找类似于 BitmapData::getPixel32 的东西。
Is there a way to detect if the alpha of a pixel after drawing is not 0 when using OpenGLES on the iphone?
I would like to test multiple points to see id they are inside the area of a random polygon drawn by the user. If you know Flash, something equivalent to BitmapData::getPixel32 is what I'm looking for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
帧缓冲区由 GPU 保存,CPU 不能立即访问。我认为你最可能想要从完整的 OpenGL 中得到的东西是遮挡查询;您可以请求绘制几何图形并被告知实际绘制了多少像素。遗憾的是,这在 iPhone 上不可用。
我想你可能想要的是glReadPixels,如果你愿意,它可以用来读取单个像素,例如(写在这里,我输入,未测试)
使用glReadPixels会导致管道刷新,所以从GL中通常是一个坏主意从性能的角度来看,但它会做你想要的。与 iOS 不同,OpenGL 使用方格纸顺序来表示像素坐标,因此 (0, 0) 是左下角。
The framebuffer is kept by the GPU and is not immediately CPU accessible. I think the thing you'd most likely want from full OpenGL is the occlusion query; you can request geometry be drawn and be told how many pixels were actually plotted. Sadly that isn't available on the iPhone.
I think what you probably want is glReadPixels, which can be used to read a single pixel if you prefer, e.g. (written here, as I type, not tested)
Using glReadPixels causes a pipeline flush, so is generally a bad idea from a GL performance point of view, but it'll do what you want. Unlike iOS, OpenGL uses graph paper order for pixel coordinates, so (0, 0) is the lower left corner.