extend GLSurfaceView and Renderer
This commit is contained in:
1 parent
70c1b327a1
commit
7f49e9fd24
4 files changed
+47
-1
No files matched your search
@@ -1,15 +1,20 @@
|
||||
package com.homelinux.holtrop.opengltest;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class MainOpenGL extends Activity
|
||||
{
|
||||
private GLSurfaceView mGLView;
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState)
|
||||
{
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
mGLView = new MyGLSurfaceView(this);
|
||||
setContentView(mGLView);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.homelinux.holtrop.opengltest;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.content.Context;
|
||||
|
||||
public class MyGLSurfaceView extends GLSurfaceView
|
||||
{
|
||||
public MyGLSurfaceView(Context context)
|
||||
{
|
||||
super(context);
|
||||
|
||||
setRenderer(new MyRenderer());
|
||||
|
||||
setEGLContextClientVersion(2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.homelinux.holtrop.opengltest;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
import android.opengl.GLES20;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
|
||||
public class MyRenderer implements GLSurfaceView.Renderer
|
||||
{
|
||||
public void onSurfaceCreated(GL10 unused, EGLConfig config)
|
||||
{
|
||||
GLES20.glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
}
|
||||
|
||||
public void onDrawFrame(GL10 unused)
|
||||
{
|
||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
public void onSurfaceChanged(GL10 unused, int width, int height)
|
||||
{
|
||||
GLES20.glViewport(0, 0, width, height);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user