返回顶部

收藏

java OpenGL ES 渲染示例

更多

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();
    }
}

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,OpenGL

收藏

0人收藏

支持

0

反对

0

相关聚客文章
  1. 高彬 (noreply@blogger. 发表 2014-03-28 12:39:13 jrebel 5.3.0 发布,试用
  2. passionke 发表 2014-05-27 12:43:39 如何在运行时改变 java.library.path并生效
  3. 博主 发表 2014-04-03 09:11:13 SBT管理java项目
  4. 博主 发表 2014-06-18 07:58:03 java线程:概念与原理
  5. Harrison Feng 发表 2014-06-05 22:00:00 Arrays
  6. 煎饼 发表 2015-01-15 03:27:40 debian下安装java环境
  7. Rei Dai 发表 2013-02-18 08:35:33 Sun HotSpot java 垃圾回收调优 (垃圾回收器CMS)
  8. cachetian 发表 2014-10-30 10:47:27 Java Layout汇总
  9. 博主 发表 2015-04-16 14:32:56 Java Hello World
  10. K-Res 发表 2014-12-10 09:52:59 Android Studio中项目NDK原生部分整合方式
  11. longchaoqun 发表 2015-02-05 16:18:10 Java开发人员需具备的能力
  12. chengjf 发表 2015-03-24 05:35:24 Spring初探

发表评论