java基于OpenGL ES实现渲染实例
程序员文章站
2024-03-04 09:24:05
本文实例讲述了java基于opengl es实现渲染的方法。分享给大家供大家参考。具体如下:
1. run.java文件:
package net.obviam...
本文实例讲述了java基于opengl es实现渲染的方法。分享给大家供大家参考。具体如下:
1. run.java文件:
package net.obviam.opengl; import android.app.activity; import android.opengl.glsurfaceview; import android.os.bundle; import android.view.window; import android.view.windowmanager; public class run extends activity { /** the opengl view */ private glsurfaceview glsurfaceview; /** called when the activity is first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); // requesting to turn the title off requestwindowfeature(window.feature_no_title); // making it full screen getwindow().setflags(windowmanager.layoutparams.flag_fullscreen,windowmanager.layoutparams.flag_fullscreen); // initiate the open gl view and // create an instance with this activity glsurfaceview = new glsurfaceview(this); // set our renderer to be the main renderer with // the current activity context glsurfaceview.setrenderer(new glrenderer()); setcontentview(glsurfaceview); } /** remember to resume the glsurface */ @override protected void onresume() { super.onresume(); glsurfaceview.onresume(); } /** also pause the glsurface */ @override protected void onpause() { super.onpause(); glsurfaceview.onpause(); } }
2. glrenderer.java文件:
import javax.microedition.khronos.egl.eglconfig; import javax.microedition.khronos.opengles.gl10; import android.opengl.glsurfaceview.renderer; public class glrenderer implements renderer { @override public void ondrawframe(gl10 gl) { } @override public void onsurfacechanged(gl10 gl, int width, int height) { } @override public void onsurfacecreated(gl10 gl, eglconfig config) { } }
希望本文所述对大家的java程序设计有所帮助。