Android Open GL
[
Front page
] [
New
|
List of pages
|
Search
|
Recent changes
|
Help
]
Start:
''[[MobileApp>Mobile Application Guide]]'' > ''[[Android>...
~
~
*Open GL [#sdd36a90]
As a superclass GL, GL10 implements the OpenGL ES 1...
In the Android, contains the primary API for OpenGL...
Android NDK corresponds to OpenGL. ~
Android NDK r3 later on, can access open gl directly.
~
~
//*描画の高速化 [#vb8aa8e7]
//
// 「2D描画で高速表示を行うにはOpenGL ESを用いるのがよく~
// 中でも『Draw Texture Extension』というOpenGLの拡張を...
//
*Step1:A OpenGL program painting the gray color to backg...
***Screen [#v6c2ac74]
#ref(test02.jpg);
~
***Sample Program [#ifb129b5]
package com.chinsanSoft;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.opengl.GLSurfaceView;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class test02 extends Activity {
private GLSurfaceView mChinSurfaceView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mChinSurfaceView = new GLSurfaceView(this);
mChinSurfaceView.setRenderer(new ChinTutorial());
setContentView(mChinSurfaceView);
}
}
class ChinTutorial implements GLSurfaceView.Renderer {
public ChinTutorial( ) {
}
public void onDrawFrame(GL10 gl){
//protected void drawFrame(GL10 gl) {
//Fill the background
gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH...
}
public void onSurfaceChanged(GL10 gl, int width, int...
}
public void onSurfaceCreated(GL10 gl, EGLConfig conf...
//Specifies the background fill color
gl.glClearColor(0.5f,0.5f,0.5f,1);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,GL...
}
}
~
~
~
*Step2:A OpenGL programs painting a square [#rd338724]
***Screen [#webdcf85]
#ref(test03.jpg);
~
***Sample Program [#g0dee929]
package com.chinsanSoft;
// A OpenGL programs painting a square
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.opengl.*;
import java.nio.*;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class test03_3d extends Activity {
private GLSurfaceView mChinSurfaceView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mChinSurfaceView = new GLSurfaceView(this);
mChinSurfaceView.setRenderer(new ChinTutorialOne(...
setContentView(mChinSurfaceView);
}
}
class ChinTutorialOne implements GLSurfaceView.Renderer {
float[] square=new float[] { // vertex
-0.25f,-0.25f,0.0f,
0.25f,-0.25f,0.0f,
-0.25f, 0.25f,0.0f,
0.25f, 0.25f,0.0f};
FloatBuffer squareBuff ; // buffer of vertex
public ChinTutorialOne(/*Context c*/) {
squareBuff=getFloatBuffer(square); // buffer of vertex
//super(c);
}
private FloatBuffer getFloatBuffer(float [] array){
FloatBuffer floatBuffer;
ByteBuffer bb = ByteBuffer.allocateDirect(array.length...
bb.order(ByteOrder.nativeOrder());
floatBuffer = bb.asFloatBuffer();
floatBuffer.put(array);
floatBuffer.position(0);
return floatBuffer;
}
public void onDrawFrame(GL10 gl){
//protected void drawFrame(GL10 gl) {
// Background fill
gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH...
// Specifying the modelview matrix
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0,0,-1); // Moving at parallel
// Specify the color
gl.glColor4f(1,0,0,0.5f);
// Specify the vertex array
gl.glVertexPointer(3,GL10.GL_FLOAT,0,squareBuff);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
// Drawing the primitives
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,4);
}
public void onSurfaceChanged(GL10 gl, int width, int...
}
public void onSurfaceCreated(GL10 gl, EGLConfig conf...
// Specify background fill color
gl.glClearColor(0.5f,0.5f,0.5f,1);
// Color and texture coordinate interpolation ac...
//gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,...
// Specifying the projection matrix
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl,0.0f,1.2f,0.0f,1.0f);
}
~
~
~
*Step3:A OpenGL program that displays the cube [#l5c1c965]
***Screen [#cdde034d]
#ref(test04.jpg);
~
***Sample Program [#vfbfb687]
~
~
Under construction
~
~
*Modeling [#beb82905]
ポリゴン表示とテクスチャ表示ができたら、次にやりたく...
http://ronor.blog81.fc2.com/blog-category-1.html
~
~
''[[Back>Introduction to Android]]''
End:
''[[MobileApp>Mobile Application Guide]]'' > ''[[Android>...
~
~
*Open GL [#sdd36a90]
As a superclass GL, GL10 implements the OpenGL ES 1...
In the Android, contains the primary API for OpenGL...
Android NDK corresponds to OpenGL. ~
Android NDK r3 later on, can access open gl directly.
~
~
//*描画の高速化 [#vb8aa8e7]
//
// 「2D描画で高速表示を行うにはOpenGL ESを用いるのがよく~
// 中でも『Draw Texture Extension』というOpenGLの拡張を...
//
*Step1:A OpenGL program painting the gray color to backg...
***Screen [#v6c2ac74]
#ref(test02.jpg);
~
***Sample Program [#ifb129b5]
package com.chinsanSoft;
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.opengl.GLSurfaceView;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class test02 extends Activity {
private GLSurfaceView mChinSurfaceView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mChinSurfaceView = new GLSurfaceView(this);
mChinSurfaceView.setRenderer(new ChinTutorial());
setContentView(mChinSurfaceView);
}
}
class ChinTutorial implements GLSurfaceView.Renderer {
public ChinTutorial( ) {
}
public void onDrawFrame(GL10 gl){
//protected void drawFrame(GL10 gl) {
//Fill the background
gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH...
}
public void onSurfaceChanged(GL10 gl, int width, int...
}
public void onSurfaceCreated(GL10 gl, EGLConfig conf...
//Specifies the background fill color
gl.glClearColor(0.5f,0.5f,0.5f,1);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,GL...
}
}
~
~
~
*Step2:A OpenGL programs painting a square [#rd338724]
***Screen [#webdcf85]
#ref(test03.jpg);
~
***Sample Program [#g0dee929]
package com.chinsanSoft;
// A OpenGL programs painting a square
import android.app.Activity;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.opengl.*;
import java.nio.*;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
public class test03_3d extends Activity {
private GLSurfaceView mChinSurfaceView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mChinSurfaceView = new GLSurfaceView(this);
mChinSurfaceView.setRenderer(new ChinTutorialOne(...
setContentView(mChinSurfaceView);
}
}
class ChinTutorialOne implements GLSurfaceView.Renderer {
float[] square=new float[] { // vertex
-0.25f,-0.25f,0.0f,
0.25f,-0.25f,0.0f,
-0.25f, 0.25f,0.0f,
0.25f, 0.25f,0.0f};
FloatBuffer squareBuff ; // buffer of vertex
public ChinTutorialOne(/*Context c*/) {
squareBuff=getFloatBuffer(square); // buffer of vertex
//super(c);
}
private FloatBuffer getFloatBuffer(float [] array){
FloatBuffer floatBuffer;
ByteBuffer bb = ByteBuffer.allocateDirect(array.length...
bb.order(ByteOrder.nativeOrder());
floatBuffer = bb.asFloatBuffer();
floatBuffer.put(array);
floatBuffer.position(0);
return floatBuffer;
}
public void onDrawFrame(GL10 gl){
//protected void drawFrame(GL10 gl) {
// Background fill
gl.glClear(GL10.GL_COLOR_BUFFER_BIT|GL10.GL_DEPTH...
// Specifying the modelview matrix
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glTranslatef(0,0,-1); // Moving at parallel
// Specify the color
gl.glColor4f(1,0,0,0.5f);
// Specify the vertex array
gl.glVertexPointer(3,GL10.GL_FLOAT,0,squareBuff);
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
// Drawing the primitives
gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP,0,4);
}
public void onSurfaceChanged(GL10 gl, int width, int...
}
public void onSurfaceCreated(GL10 gl, EGLConfig conf...
// Specify background fill color
gl.glClearColor(0.5f,0.5f,0.5f,1);
// Color and texture coordinate interpolation ac...
//gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT,...
// Specifying the projection matrix
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl,0.0f,1.2f,0.0f,1.0f);
}
~
~
~
*Step3:A OpenGL program that displays the cube [#l5c1c965]
***Screen [#cdde034d]
#ref(test04.jpg);
~
***Sample Program [#vfbfb687]
~
~
Under construction
~
~
*Modeling [#beb82905]
ポリゴン表示とテクスチャ表示ができたら、次にやりたく...
http://ronor.blog81.fc2.com/blog-category-1.html
~
~
''[[Back>Introduction to Android]]''
Page: