Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add actions in OpenGL ES

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces how to add actions in OpenGL ES. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Drawing objects on the screen is the most basic function of OpenGL, and you can use other Android graphics framework classes, such as Canvas and Drawable objects. OpenGLES provides some capabilities for moving and transforming painted objects in three-dimensional space, as well as other unique ways to create a good user experience.

Add a rotation action to the drawin

Rotate the graphic

It is relatively simple to use OpenGL ES 2.0 to rotate a paint object. You need to create another transformation matrix (rotation matrix) and combine it with the projection and camera transformation matrix:

Privatefloat [] mRotationMatrix = newfloat [16]; public void onDrawFrame (GL10 gl) {. / / Create a rotationtransformation for the triangle long time = SystemClock.uptimeMillis ()% 4000L; float angle = 0.090f * ((int) time); Matrix.setRotateM (mRotationMatrix, 0, angle, 0,0,-1.0f); / / Combine the rotationmatrix with the projection and camera view Matrix.multiplyMM (mMVPMatrix, 0, mRotationMatrix, 0, mMVPMatrix, 0); / / Draw triangle mTriangle.draw (mMVPMatrix);}

After making these changes, if your triangle is not rotated, make sure you have completed the GLSurfaceView.RENDERMODE_WHEN_DIRTY setting.

Enable continuous rendering

If you have been following the sample code in this article, be sure to comment out the rendering mode setting as in the following code, otherwise OpenGL will only rotate the graph once and wait for the requestRender () method from the GLSurfaceView container to be called.

PublicMyGLSurfaceView (Context context) {. / / Render the view onlywhen there is a change in the drawing data / / setRenderMode (GLSurfaceView.RENDERMODE_WHEN_DIRTY); / / comment out for auto-rotation}

Unless the change in the object has nothing to do with any user interaction, it's a good idea to set a switch flag.

On how to add actions in OpenGL ES to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report