3、OpenGL的API定义了若干可被客户端程序调用的函数,以及一些具名整型常量(例如,常量GL_TEXTURE_2D对应的十进制整数为3553)。虽然这些函数的定义表面上类似于C编程语言,但它们是语言独立的。因此,OpenGL有许多语言绑定,值得一提的包括:JavaScript绑定的WebGL(基于OpenGL ES 2.0在Web浏览器中的进行3D渲染的API);C绑定的WGL、GLX和CGL;iOS提供的C绑定;Android提供的Java和C绑定。
实战案例,具体代码如下: package net.obviam.opengl; import android.app.Activity; import android.opengl.GLSurfaceView; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class Run extends Activity {undefined /** The OpenGL view */ private GLSurfaceView glSurfaceView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) {undefined super.onCreate(savedInstanceState); // requesting to turn the title OFF requestWindowFeature(Window.FEATURE_NO_TITLE); // making it full screen getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); // Initiate the Open GL view and // create an instance with this activity glSurfaceView = new GLSurfaceView(this); // set our renderer to be the main renderer with // the current activity context glSurfaceView.setRenderer(new GlRenderer()); setContentView(glSurfaceView); } /** Remember to resume the glSurface */ @Override protected void onResume() {undefined super.onResume(); glSurfaceView.onResume(); } /** Also pause the glSurface */ @Override protected void onPause() {undefined super.onPause(); glSurfaceView.onPause(); } }