Why does OpenGL blending not work on HTC Desire?

家住魔仙堡 提交于 2019-12-01 04:05:15

问题


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...


回答1:


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 with glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, ptrTo4Floats). This would imply that the Desire is correct, and the emulator is incorrect.



来源:https://stackoverflow.com/questions/4209054/why-does-opengl-blending-not-work-on-htc-desire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!