安卓OpenGL之GLES20常用接口解析

1.glClearColor

//设置SurfaceView的背景颜色为灰色。
GLES20.glClearColor(0.5f, 0.5f, 0.5f, 0.5f);	
//native层接口原型
public static native void glClearColor(
        float red,				//范围0-1.0f
        float green,			//范围0-1.0f
        float blue,				//范围0-1.0f
        float alpha				//范围0-1.0f
);

注意:三原色RGB的范围是0-255,而glClearColor的是参数范围是0.0-1.0f,所以按照RGB颜色对照表需要做一个转换(颜色值除以255)。

RGB颜色对照表:
https://tool.oschina.net/commons?type=3

2.setLookAtM

        // Position the eye behind the origin.
        // eye point,视点,眼睛观察的位置
        final float eyeX = 0.0f;
        final float eyeY = 0.0f;
        final float eyeZ = 1.5f;	//值远大,观测的距离就越远,图形显示效果看着就越小

        // We are looking toward the distance
        final float lookX = 0.0f;
        final float lookY = 0.0f;
        final float lookZ = -5.0f;

        // Set our up vector. This is where our head would be pointing were we holding the camera.
        final float upX = 0.0f;
        final float upY = 1.0f;
        final float upZ = 0.0f;

        // Set the view matrix. This matrix can be said to represent the camera position.
        // NOTE: In OpenGL 1, a ModelView matrix is used, which is a combination of a model and
        // view matrix. In OpenGL 2, we can keep track of these matrices separately if we choose.
        // mViewMatrix是一个观察矩阵,又叫视图矩阵,以摄像机或者人眼为中心的坐标
        Matrix.setLookAtM(mViewMatrix, 0, eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ);

整理了两个函数发现了一个好用的OpenGL ES2.0的API英文手册。想要知道OpenGL的接口含义直接查看这个API就可以了。
OpenGL ES2.0的API英文手册:
https://www.khronos.org/registry/OpenGL-Refpages/es2.0/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sunxiaolin2016

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值