为什么 OpenGL 混合在 HTC Desire 上不起作用? [英] Why does OpenGL blending not work on HTC Desire?

查看:29
本文介绍了为什么 OpenGL 混合在 HTC Desire 上不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何在 HTC Desire 上启用 OpenGL (android) 中的混合.我正在尝试绘制彩色三角形并使用颜色缓冲区的 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?

代码中的主要内容是(不按顺序):

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.如果有人需要,我可以提供更多代码...

PS. I can provide more code if someone needs it...

推荐答案

Jonas,你对照明的评论似乎是正确的,所以现在我想我们有了答案.OpenGL ES 1.1.12 规范规定光照产生的 A 值是与 dcm 相关的 alpha 值,其中 dcm 是材质漫反射颜色.

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,那么材质漫反射颜色和材质环境颜色都取自当前顶点颜色.这意味着 Desire 是不正确的,而模拟器是正确的.

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) 设置漫反射颜色材质.这意味着 Desire 是正确的,而模拟器是不正确的.

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 上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆