OpenGL ES for Android(混合)

简介

在之前使用物体时没考虑过透明的情况,而混合就是除了物体透明度的一种方式。在处理物体透明时一般有两种方式,一种是直接丢弃掉透明度达到一定程度的部分;另外一种就是混合。例如一扇窗户如果是全透明的我们看到的物体就是窗口后的物体;如果它是半透明的有色玻璃时,看到的就是玻璃和窗口后物体的叠加。之前我们使用纹理的颜色都是纹理的rgb颜色,没有用到最后一个alpha(也就是透明度),alpha的范围是0到1,1表示不透明,0表示全透明。

丢弃片段

有些物体的部分,要么是全透明,要么是不透明,不存在其他的情况下,我们选择丢弃掉透明的部分来显示。例如下面这个小草的图片:

 

首先我们先用它来显示不做任何处理的情况,我们改变位置显示几个纹理,一些关键代码:

       private float[][] translate = new float[][]{
            {-1.5f, 0.0f, -0.48f},
            {1.5f, 0.0f, 0.51f},
            {0.0f, 0.0f, 0.7f},
            {-0.3f, 0.0f, -2.3f},
            {0.5f, 0.0f, -0.6f}};
    ……
    for (float[] vegetation : translate) {
   
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
In Pro OpenGL ES for Android, you'll find out how to harness the full power of OpenGL ES, and design your own 3D applications by building a fully-functional 3D solar system model using Open GL ES! OpenGL has set the standard for 3D computer graphics, and is an essential aspect of Android development. This book offers everything you need to know, from basic mathematical concepts to advanced coding techniques. You'll learn by building a fascinating 3D solar system simulator! After introducing Open GL ES, Pro OpenGL ES for Android explains the basics of 3D math and then orients you to the native Android 3D libraries you'll be using in your own 3D games and the solar system project you'll build using this book. Through the solar system example project, you'll learn how to incorporate a variety of graphic and animation techniques into your applications. You will also discover how the full spectrum of 3D development that awaits, with topics such as lighting, texture-mapping, modeling, shaders, blending modes, and several more advanced concepts. By the time you finish Pro OpenGL ES for Android, you'll have learned all the skills you'll need to build your own incredible 3D applications, based on one of the most powerful 3D libraries available. What you'll learn * The basics of 3D mathematics, and how they are applied in the OpenGL library * How to design and build your 3D worlds * To create 2D interfaces within the 3D world * To develop animation and 3D movement * How to implement 3D shading, coloring, and texturing * The differences between OpenGL and other 3D toolkits * To build a fully-functional 3D solar system simulator using OpenGL ES Who this book is for Experienced Android programmers who want to enter the 3D world of OpenGL ES programming. Table of Contents * Introduction to OpenGL ES and Our 3D Solar System Project * Generating a Basic OpenGL Program * Getting Past the 3D Math * Shading, Lighting and Colors * Materials and Textures * Animation * Creating a User Interface * Blending Modes, Buffer Objects, and Other Cool Stuff * Latest Features of OpenGL ES * Ray Tracing, Hidden Surfaces, and Other Advanced Topics Appendix A: APIs

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值