问题描述
有谁知道如何使一个的HTC Desire在OpenGL(机器人)混合。我想绘制彩色的三角形,并使用颜色缓冲的Alpha值融入他们的背景(或其他三角形)。
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).
它的工作无论是在模拟器(2.1)和一个HTC Hero的2.1却没有关于我的愿望2.2。是否有一个英雄的愿望,导致这之间的一些硬件区别?
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?
从code的主要的东西(不按顺序):
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。我可以提供更多的code。如果有人需要它...
PS. I can provide more code if someone needs it...
推荐答案
乔纳斯,你对照明的评论似乎是正确的,所以现在我认为我们有一个答案。 OpenGL ES的1.1.12规范规定 A灯光所产生的价值是与DCM
,其中,DCM是物质的漫反射颜色相关联的Alpha值。
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.
如果您已启用 COLOR_MATERIAL
,则材料漫反射颜色和材质环境颜色无一不是取自当前顶点颜色。这将意味着欲望是不正确的,仿真器是正确的。
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.
如果你禁用了 COLROR_MATERIAL
(默认状态),则漫反射颜色的材料设置与 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,ptrTo4Floats)
。这意味着,欲望是正确的,仿真器不正确。
If you have disabled COLROR_MATERIAL
(the default state), then the diffuse color material is set with glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ptrTo4Floats)
. This would imply that the Desire is correct, and the emulator is incorrect.
这篇关于为什么对OpenGL的HTC Desire的共混不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!