1 |
package com.zoffcc.applications.zanavi;
|
2 |
|
3 |
import javax.microedition.khronos.egl.EGLConfig;
|
4 |
import javax.microedition.khronos.opengles.GL10;
|
5 |
|
6 |
import android.opengl.GLES20;
|
7 |
import android.opengl.GLSurfaceView.Renderer;
|
8 |
|
9 |
public class GlRenderer implements Renderer
|
10 |
{
|
11 |
|
12 |
@Override
|
13 |
public void onDrawFrame(GL10 gl)
|
14 |
{
|
15 |
}
|
16 |
|
17 |
@Override
|
18 |
public void onSurfaceChanged(GL10 gl, int width, int height)
|
19 |
{
|
20 |
}
|
21 |
|
22 |
@Override
|
23 |
public void onSurfaceCreated(GL10 gl, EGLConfig config)
|
24 |
{
|
25 |
}
|
26 |
|
27 |
public static int loadShader(int type, String shaderCode)
|
28 |
{
|
29 |
|
30 |
// create a vertex shader type (GLES20.GL_VERTEX_SHADER)
|
31 |
// or a fragment shader type (GLES20.GL_FRAGMENT_SHADER)
|
32 |
int shader = GLES20.glCreateShader(type);
|
33 |
|
34 |
// add the source code to the shader and compile it
|
35 |
GLES20.glShaderSource(shader, shaderCode);
|
36 |
GLES20.glCompileShader(shader);
|
37 |
|
38 |
return shader;
|
39 |
}
|
40 |
|
41 |
public static void checkGlError(String op)
|
42 |
{
|
43 |
int error;
|
44 |
while ((error = GLES20.glGetError()) != GLES20.GL_NO_ERROR)
|
45 |
{
|
46 |
System.out.println("opengl:" + op + ": glError " + error);
|
47 |
throw new RuntimeException(op + ": glError " + error);
|
48 |
}
|
49 |
}
|
50 |
}
|