位置: 编程技术 - 正文

Android OpenGL ES绘图教程之五 :加入运动(android opengles2.0教程)

编辑:rootadmin
在屏幕上面绘制对象是OpenGL的一个非常好的基本功能,但是你也可以在其他的Android图形框架上面实现这些功能,比如Canvas和Drawable对象。OpenGL ES提供了额外的功能在三维坐标系里移动和变换绘制的对象或者用其他特殊的方式创建复杂的用户体验。 在本教程里,通过学习如何给图形添加旋转运动,使你对OpenGL ES有更加深入的了解。 1. 旋转图形 在OpenGL ES 2.0旋转一个绘制的对象是比较简单的。在renderer类中,创建另一个变换矩阵(旋转矩阵),然后将它与投影和相机视图矩阵结合:private float[] mRotationMatrix = new float[];public void onDrawFrame(GL gl) { float[] scratch = new float[]; ... // Create a rotation transformation for the triangle long time = SystemClock.uptimeMillis() % L; float angle = 0.f * ((int) time); Matrix.setRotateM(mRotationMatrix, 0, angle, 0, 0, -1.0f); // Combine the rotation matrix with the projection and camera view // Note that the mMVPMatrix factor *must be first* in order // for the matrix multiplication product to be correct. Matrix.multiplyMM(scratch, 0, mMVPMatrix, 0, mRotationMatrix, 0); // Draw triangle mTriangle.draw(scratch);} 如果你的三角形在添加了上述的更改后没有旋转,确保你注释掉了GLSurfaceView.RENDERMODE_WHEN_DIRTY设置,具体原因后面会讲到 2. 启用连续渲染

推荐整理分享Android OpenGL ES绘图教程之五 :加入运动(android opengles2.0教程),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:android native opengl,android native opengl,android opengl es教程,android opengl es教程,android view opengl,android opengl yuv,android opengl es教程,android opengl es教程,内容如对您有帮助,希望把文章链接给更多的朋友!

Android OpenGL ES绘图教程之五 :加入运动(android opengles2.0教程)

如果你已经努力遵守示例中的代码,确保你注释掉了设置渲染模式为有改变才绘制的那一行,否则OpenGL只会旋转图形一次,然后就会等待GLSurfaceView调用requestRender().

public MyGLSurfaceView(Context context) { ... // Render the view only when there is a change in the drawing data. // To allow the triangle to rotate automatically, this line is commented out: //setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);} 除非你需要对象在没有任何用户交互的情况下改变,将这个开关打开通常是个不错的注意。准备好取消这行代码的注释,因为下一节将会使这个调用重新可用。

Android OpenGL ES绘图教程之六 :响应触摸事件 使对象根据预设的程序进行运动,比如旋转三角形,可以吸引人的注意力。但是如果你想让用户同你的OpenGLES图形进行交互会怎么样呢?使你的OpenGLES应

VS下基于Glut OpenGL显示一些立体图形示例程序 转自:

[置顶] Bezier曲线的动态绘制 #includegl/glut.h#includemath.h#pragmacomment(linker,/subsystem:windows/entry:mainCRTStartup)intSCREEN_HEIGHT=;intNUMPOINTS=0;classPoint{public:floatx,y;voidsetxy(floatx2,floaty2){x=x2;y=y2;}};

本文链接地址:https://www.jiuchutong.com/biancheng/369574.html 转载请保留说明!

上一篇:Android OpenGL ES绘图教程之四 :投影和相机视图变换(android opengles2.0教程)

下一篇:Android OpenGL ES绘图教程之六 :响应触摸事件(opengl es api)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络