为什么 OpenGL 混合在 HTC Desire 上不起作用?
有谁知道如何在 HTC Desire 上启用 OpenGL (android) 混合。我正在尝试绘制彩色三角形并使用颜色缓冲区的 alpha 值将它们与背景(或另一个三角形)混合。
它可以在模拟器(2.1)和 htc Hero 2.1 上运行,但不能在我的 2.2 上运行。英雄和欲望之间是否存在某种硬件差异导致了这种情况?
代码中的主要内容是(不按顺序排列):
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
private final static float[] colors = {
1f, 0f, 0f, 0.5f, // point 0 red
1f, 0f, 0f, 0.5f, // point 1 red
1f, 0f, 0f, 0.5f, // point 2 red
1f, 0f, 0f, 0.5f, // point 3 red
1f, 0f, 0f, 0.5f, // point 4 red
1f, 0f, 0f, 0.5f, // point 5 red
1f, 0f, 0f, 0.5f, // point 6 red
1f, 0f, 0f, 0.5f, // point 7 red
};
PS。如果有人需要的话我可以提供更多代码......
Does anyone know how to enable blending in OpenGL (android) on a HTC Desire. I am trying to draw colored triangles and using the alpha value of the color buffer to blend them with the background (or another triangle).
It works both on the emulator (2.1) and on a htc hero 2.1 but not on my desire with 2.2. Is there some hardware difference between a hero and a desire that causes this?
The main stuff from the code is (not in order):
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
private final static float[] colors = {
1f, 0f, 0f, 0.5f, // point 0 red
1f, 0f, 0f, 0.5f, // point 1 red
1f, 0f, 0f, 0.5f, // point 2 red
1f, 0f, 0f, 0.5f, // point 3 red
1f, 0f, 0f, 0.5f, // point 4 red
1f, 0f, 0f, 0.5f, // point 5 red
1f, 0f, 0f, 0.5f, // point 6 red
1f, 0f, 0f, 0.5f, // point 7 red
};
PS. I can provide more code if someone needs it...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
乔纳斯,你对照明的评论似乎很正确,所以现在我想我们有了答案。 OpenGL ES 1.1.12 规范规定
光照产生的 A 值是与 dcm 相关的 alpha 值
,其中 dcm 是材质漫反射颜色。如果您启用了
COLOR_MATERIAL
,则材质漫反射颜色和材质环境颜色均取自当前顶点颜色。这意味着 Desire 不正确,而模拟器是正确的。如果您已禁用
COLROR_MATERIAL
(默认状态),则使用glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ptrTo4Floats)
设置漫反射颜色材质。这意味着愿望是正确的,而模拟器是不正确的。Jonas, your comment about lighting seems right on, and so now I think we have an answer. The OpenGL ES 1.1.12 Specification states
The value of A produced by lighting is the alpha value associated with dcm
, where dcm is the material diffuse color.If you have enabled
COLOR_MATERIAL
, then the material diffuse color and material ambient color both are taken from the current vertex color. This would imply the Desire is incorrect, and the emulator is correct.If you have disabled
COLROR_MATERIAL
(the default state), then the diffuse color material is set withglMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ptrTo4Floats)
. This would imply that the Desire is correct, and the emulator is incorrect.