extend GLSurfaceView and Renderer
This commit is contained in:
parent
70c1b327a1
commit
7f49e9fd24
@ -12,4 +12,5 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
<uses-feature android:glEsVersion="0x00020000" android:required="true" />
|
||||
</manifest>
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
16
src/com/homelinux/holtrop/opengltest/MyGLSurfaceView.java
Normal file
16
src/com/homelinux/holtrop/opengltest/MyGLSurfaceView.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
24
src/com/homelinux/holtrop/opengltest/MyRenderer.java
Normal file
24
src/com/homelinux/holtrop/opengltest/MyRenderer.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user