EGLHelper
[cpp]import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGL11;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSu易做图ce;
import javax.microedition.khronos.opengles.GL;
import android.view.Su易做图ceHolder;
/**
* Copyright (C) 2008 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*
* EGLHelper class extracted from GLView
*/
public class EGLHelper
{
publicEGLHelper()
{
}
/**
* Initialize EGL for a given configuration spec.
*
* @param configSpec
*/
publicvoid start(int[] configSpec)
{
/*
* Get an EGL instance
*/
mEgl =(EGL10)EGLContext.getEGL();
/*
* Get to the default display.
*/
mEglDisplay = mEgl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
/*
* We can now initialize EGL for that display
*/
int[] version= new int[2];
mEgl.eglInitialize(mEglDisplay, version);
EGLConfig[] configs= new EGLConfig[1];
int[] num_config= new int[1];
mEgl.eglChooseConfig(mEglDisplay, configSpec, configs,1, num_config);
mEglConfig = configs[0];
/*
* Create an OpenGL ES context. This must be done only once, an OpenGL
* context is a somewhat heavy object.
*/
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
EGL10.EGL_NO_CONTEXT,null);
mEglSu易做图ce =null;
}
/*
* Create and return an OpenGL su易做图ce
*/
public GL createSu易做图ce(Su易做图ceHolder holder)
{
/*
* The window size has changed, so we need to create a new su易做图ce.
*/
if(mEglSu易做图ce!=null)
{
/*
* Unbind and destroy the old EGL su易做图ce, if there is one.
*/
mEgl.eglMakeCurrent(mEglDisplay, EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT);
mEgl.eglDestroySu易做图ce(mEglDisplay, mEglSu易做图ce);
}
/*
&n
补充:软件开发 , C++ ,