require "import"
import "gl"
import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
import "android.opengl.*"
activity.setTitle('AndroLua')
mTriangleData ={
0.0, 0.6, 0.0,
-0.6, 0.0, 0.0,
0.6, 0.0, 0.0,
};
mTriangleColor = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
};
sr=GLSurfaceView.Renderer{
onSurfaceCreated=function(gl2, config)
gl.glDisable(gl.GL_DITHER);
gl.glHint(gl.GL_PERSPECTIVE_CORRECTION_HINT, gl.GL_FASTEST);
gl.glClearColor(0, 0, 0, 0);
gl.glShadeModel(gl.GL_SMOOTH);
gl.glClearDepth(1.0)
gl.glEnable(gl.GL_DEPTH_TEST);
gl.glDepthFunc(gl.GL_LEQUAL);
end,
onDrawFrame=function(gl2, config)
gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
gl.glMatrixMode(gl.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glRotate(0,1,1,1)
gl.glTranslate(0, 0,0);
gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
gl.glEnableClientState(gl.GL_COLOR_ARRAY);
gl.glVertexPointer(mTriangleData,3);
gl.glColorPointer(mTriangleColor,4);
gl.glDrawArrays(gl.GL_TRIANGLE_STRIP , 0, 3);
gl.glFinish();
gl.glDisableClientState(gl.GL_VERTEX_ARRAY);
gl.glDisableClientState(gl.GL_COLOR_ARRAY);
end,
onSurfaceChanged= function (gl2, w, h)
gl.glViewport(0, 0, w, h);
gl.glLoadIdentity();
ratio = w / h;
gl.glFrustum(-rautio, ratio, -1, 1, 1, 10);
end
}
glSurefaceView = GLSurfaceView(activity);
glSurefaceView.setRenderer(sr);
activity.setContentView(glSurefaceView);