Android,为什么我的前景图像的颜色在 openGL ES 中发生变化?
在我的应用程序中,我使用 openGL ES。 我想在屏幕上显示两个图像。第一个用作背景(PNG 格式,32 位,1280*800),第二个用作前景(PNG 格式,32 位,64*512)。
我可以在屏幕上显示两个图像,但我不知道为什么前景图像的颜色发生了变化!这个问题的图片是: 而手的本来颜色是棕色的。在下图中,我禁用了背景图像,因此我们只能看到图像中具有原始颜色的手。
请指导我问题是什么以及为什么颜色发生变化? 非常感谢
========== 更新:
代码的某些部分:
@Override
public void onDrawFrame(GL10 gl) {
try {
Thread.sleep(ATEngine.GAME_THREAD_FPS_SLEEP);
} catch (InterruptedException e) {
e.printStackTrace();
}
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
setBackground(gl);
setHand(gl);
//All other game drawing will be called here
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE);
}
setHand方法是:
private void setHand(GL10 gl){
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glPushMatrix();
gl.glScalef(.1f, .7f, 1f);
gl.glTranslatef(4.5f, 0f, 0f);
gl.glMatrixMode(GL10.GL_TEXTURE);
gl.glLoadIdentity();
gl.glTranslatef( 0.0f, 0.0f, 0.0f);
hand.draw(gl);
gl.glPopMatrix();
gl.glLoadIdentity();
}
In my application I'm using openGL ES.
I want to show two images in the screen. The first acts as backgroung (PNG format, 32 bit, 1280*800) and second one is foreground (PNG format, 32 bit, 64*512).
I can show both image in the screen but i don't know why the color of foreground image is changed!!! the picture of this problem is:
While, the original color of hand is brown. in the following image i disabled background image, so we see just the hand with its original color in image.
please guide me what is the problem and why the color is changed?
Thanks a lot
==========
Update:
some part of code:
@Override
public void onDrawFrame(GL10 gl) {
try {
Thread.sleep(ATEngine.GAME_THREAD_FPS_SLEEP);
} catch (InterruptedException e) {
e.printStackTrace();
}
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
setBackground(gl);
setHand(gl);
//All other game drawing will be called here
gl.glEnable(GL10.GL_BLEND);
gl.glBlendFunc(GL10.GL_ONE, GL10.GL_ONE);
}
and setHand methode is:
private void setHand(GL10 gl){
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glPushMatrix();
gl.glScalef(.1f, .7f, 1f);
gl.glTranslatef(4.5f, 0f, 0f);
gl.glMatrixMode(GL10.GL_TEXTURE);
gl.glLoadIdentity();
gl.glTranslatef( 0.0f, 0.0f, 0.0f);
hand.draw(gl);
gl.glPopMatrix();
gl.glLoadIdentity();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 onDrawFrame() 函数中,我用以下行更改了最后一行。问题已解决:)
有关更多信息,请参阅我的参考:http://www. swiftless.com/tutorials/opengl/blending.html
in onDrawFrame() function I changed last line with following line. the problem solved :)
for more information, please see my reference: http://www.swiftless.com/tutorials/opengl/blending.html