Java implementation rendering instance _java based on OpenGL ES

Source: Internet
Author: User

This article illustrates the Java rendering method based on OpenGL ES. Share to everyone for your reference. Specifically as follows:

1. Run.java Documents:

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 the activity is a.
    * * @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 the" Glsurfaceview = new Glsurfaceview (this); Set our renderer to is the main renderer with//the current Activity context glsurfaceview.setrenderer (NE
    W 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 Documents:

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 c8/>public void onsurfacechanged (GL10 gl, int width, int height) {
  }
  @Override public
  Void Onsurfacecreated (GL10 gl, eglconfig config) {
  }
}

I hope this article will help you with your Java programming.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.