Android的GLSurfaceView的OpenGL ES具有线性渐变的背景? [英] Android GLSurfaceView OpenGL ES with linear-gradient background?

查看:543
本文介绍了Android的GLSurfaceView的OpenGL ES具有线性渐变的背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本code,我可以明确的背景和添加颜色:

with this code, I can clear the background and add a color:

gl.glEnable(GL10.GL_DEPTH_TEST);    
gl.glClearColor(0.0f, 0.25f, 0.35f, 1.0f);
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

我怎样才能改变这种具有线性渐变的背景?例如白色的顶部和蓝色底部?

How can i change this to have a linear-gradient Background? e.g. White color at the top and blue color at the bottom?

推荐答案

有没有方法来清除一个梯度,但我只是画清颜色的彩色四,而不是:

There's no method to clear to a gradient, but I'd just draw a colored quad instead of clearing the color:

void drawFrame() {
   glDisable(GL_DEPTH_TEST);
   //draw screen aligned quad with color gradient 
   //    (top two vertices white, bottom two blue)
   drawGradientQuad();

   glClear(GL_DEPTH_BUFFER_BIT); //no need to clear color

   glEnable(GL_DEPTH_TEST);
   //draw rest of scene
}

这篇关于Android的GLSurfaceView的OpenGL ES具有线性渐变的背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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