本文整理汇总了Java中android.opengl.EGLConfig类的典型用法代码示例。如果您正苦于以下问题:Java EGLConfig类的具体用法?Java EGLConfig怎么用?Java EGLConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EGLConfig类属于android.opengl包,在下文中一共展示了EGLConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGLESWithSurface
import android.opengl.EGLConfig; //导入依赖的package包/类
public boolean createGLESWithSurface(EGLConfigAttrs attrs,EGLContextAttrs ctxAttrs,Object surface){
EGLConfig config=getConfig(attrs.surfaceType(EGL14.EGL_WINDOW_BIT).makeDefault(true));
if(config==null){
log("getConfig failed : "+EGL14.eglGetError());
return false;
}
mEGLContext=createContext(config,EGL14.EGL_NO_CONTEXT,ctxAttrs.makeDefault(true));
if(mEGLContext==EGL14.EGL_NO_CONTEXT){
log("createContext failed : "+EGL14.eglGetError());
return false;
}
mEGLSurface=createWindowSurface(surface);
if(mEGLSurface==EGL14.EGL_NO_SURFACE){
log("createWindowSurface failed : "+EGL14.eglGetError());
return false;
}
if(!EGL14.eglMakeCurrent(mEGLDisplay,mEGLSurface,mEGLSurface,mEGLContext)){
log("eglMakeCurrent failed : "+EGL14.eglGetError());
return false;
}
return true;
}
示例2: createGLESWithPBuffer
import android.opengl.EGLConfig; //导入依赖的package包/类
public EGLSurface createGLESWithPBuffer(EGLConfigAttrs attrs,EGLContextAttrs ctxAttrs,int width,int height){
EGLConfig config=getConfig(attrs.surfaceType(EGL14.EGL_PBUFFER_BIT));
if(config==null){
log("getConfig failed : "+EGL14.eglGetError());
return null;
}
EGLContext eglContext=createContext(config,EGL14.EGL_NO_CONTEXT,ctxAttrs);
if(eglContext==EGL14.EGL_NO_CONTEXT){
log("createContext failed : "+EGL14.eglGetError());
return null;
}
EGLSurface eglSurface=createPBufferSurface(config,width,height);
if(eglSurface==EGL14.EGL_NO_SURFACE){
log("createWindowSurface failed : "+EGL14.eglGetError());
return null;
}
if(!EGL14.eglMakeCurrent(mEGLDisplay,eglSurface,eglSurface,eglContext)){
log("eglMakeCurrent failed : "+EGL14.eglGetError());
return null;
}
return eglSurface;
}
示例3: InputSurface
import android.opengl.EGLConfig; //导入依赖的package包/类
/** Constructs a new {@link InputSurface} */
private InputSurface(@NonNull Builder builder) {
checkState();
mAutoSwap = builder.autoSwap;
mWidth = builder.width;
mHeight = builder.height;
mByteBuffer = builder.byteBuffer;
mEglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(mEglDisplay, false);
mEglContext = GLTools.newContext(mEglDisplay, eglConfig);
mEglSurface = GLTools.newSurface(mEglDisplay, eglConfig, builder.surface);
if (mAutoSwap)
GLTools.makeCurrent(mEglDisplay, mEglSurface, mEglContext);
GLTools.newShader(mShader);
mTexture = GLTools.newTexture(TEXTURE_LEVEL);
logv("Input surface created");
}
示例4: testSetPresentationTime
import android.opengl.EGLConfig; //导入依赖的package包/类
/**
* Test for {@link GLTools#setPresentationTime(EGLDisplay, EGLSurface, long)} .
* @throws Exception by some fails
*/
@Test
public final void testSetPresentationTime() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
final int txt = GLTools.newTexture(TEXTURE_LEVEL);
final SurfaceTexture surfaceTexture = new SurfaceTexture(txt, true);
final Surface surface = new Surface(surfaceTexture);
final EGLSurface window = GLTools.newSurface(eglDisplay, eglConfig, surface);
GLTools.setPresentationTime(eglDisplay, window, PRESENTATION_TIME);
GLTools.closeSurface(eglDisplay, window);
surface.release();
surfaceTexture.release();
GLTools.closeTexture(txt, TEXTURE_LEVEL);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例5: testTexture
import android.opengl.EGLConfig; //导入依赖的package包/类
/**
* Test for {@link GLTools#newTexture(int)} and {@link GLTools#closeTexture(int, int)}.
* @throws Exception by some fails
*/
@Test
public final void testTexture() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
GLTools.closeTexture(GLTools.newTexture(TEXTURE_LEVEL), TEXTURE_LEVEL);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例6: testShader
import android.opengl.EGLConfig; //导入依赖的package包/类
/**
* Test for {@link GLTools#newShader(int[])} and {@link GLTools#closeShader(int[])}.
* @throws Exception by some fails
*/
@Test
public final void testShader() throws Exception {
final EGLDisplay eglDisplay = GLTools.newDisplay();
final EGLConfig eglConfig = GLTools.newConfig(eglDisplay, true);
final EGLContext eglContext = GLTools.newContext(eglDisplay, eglConfig);
final EGLSurface eglSurface =
GLTools.newSurface(eglDisplay, eglConfig, FRAME_SIZE, FRAME_SIZE);
GLTools.makeCurrent(eglDisplay, eglSurface, eglContext);
final int[] attrs = new int[5];
GLTools.newShader(attrs);
GLTools.closeShader(attrs);
GLTools.closeSurface(eglDisplay, eglSurface);
GLTools.closeContext(eglDisplay, eglContext);
GLTools.closeDisplay(eglDisplay);
}
示例7: getEglConfig
import android.opengl.EGLConfig; //导入依赖的package包/类
private static EGLConfig getEglConfig(EGLDisplay eglDisplay, int[] configAttributes) {
EGLConfig[] configs = new EGLConfig[1];
int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(
eglDisplay, configAttributes, 0, configs, 0, configs.length, numConfigs, 0)) {
throw new RuntimeException(
"eglChooseConfig failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
if (numConfigs[0] <= 0) {
throw new RuntimeException("Unable to find any matching EGL config");
}
final EGLConfig eglConfig = configs[0];
if (eglConfig == null) {
throw new RuntimeException("eglChooseConfig returned null");
}
return eglConfig;
}
示例8: createEglContext
import android.opengl.EGLConfig; //导入依赖的package包/类
private static EGLContext createEglContext(
EglBase14.Context sharedContext, EGLDisplay eglDisplay, EGLConfig eglConfig) {
if (sharedContext != null && sharedContext.egl14Context == EGL14.EGL_NO_CONTEXT) {
throw new RuntimeException("Invalid sharedContext");
}
int[] contextAttributes = {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE};
EGLContext rootContext =
sharedContext == null ? EGL14.EGL_NO_CONTEXT : sharedContext.egl14Context;
final EGLContext eglContext;
synchronized (EglBase.lock) {
eglContext = EGL14.eglCreateContext(eglDisplay, eglConfig, rootContext, contextAttributes, 0);
}
if (eglContext == EGL14.EGL_NO_CONTEXT) {
throw new RuntimeException(
"Failed to create EGL context: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
return eglContext;
}
示例9: onSurfaceCreated
import android.opengl.EGLConfig; //导入依赖的package包/类
@Override
public void onSurfaceCreated(GL10 gl, javax.microedition.khronos.egl.EGLConfig config) {
// Set the background frame color
GLES20.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
// initialize a triangle
mAxis = new Axis(squareCoords);
mAxis2 = new Axis(squareCoords2);
mLine = new Line(new PointVector(0.0f, 0.0f, -0.5f), new PointVector(0.0f, 0.0f, 0.5f), color);
firstQuadrant = new ImportModel(new FirstQuadrantModel());
secondQuadrant = new ImportModel(new SecondQuadrantModel());
thirdQuadrant = new ImportModel(new ThirdQuadrantModel());
fourthQuadrant = new ImportModel(new FourthQuadrantModel());
}
示例10: getConfig
import android.opengl.EGLConfig; //导入依赖的package包/类
private EGLConfig getConfig(boolean with_depth_buffer) {
final int[] attribList = {
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
EGL14.EGL_RED_SIZE, 8,
EGL14.EGL_GREEN_SIZE, 8,
EGL14.EGL_BLUE_SIZE, 8,
EGL14.EGL_ALPHA_SIZE, 8,
//EGL14.EGL_STENCIL_SIZE, 8,
EGL_RECORDABLE_ANDROID, 1, // this flag need to recording of MediaCodec
with_depth_buffer ? EGL14.EGL_DEPTH_SIZE : EGL14.EGL_NONE,
with_depth_buffer ? 16 : 0,
EGL14.EGL_NONE
};
final EGLConfig[] configs = new EGLConfig[1];
final int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(mEglDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) {
// XXX it will be better to fallback to RGB565
Log.w(TAG, "unable to find RGBA8888 / " + " EGLConfig");
return null;
}
return configs[0];
}
示例11: createWindowSurface
import android.opengl.EGLConfig; //导入依赖的package包/类
public EGLSurface createWindowSurface(EGLDisplay display, EGLConfig config, Object nativeWindow)
{
EGLSurface result = null;
try
{
result = EGL14.eglCreateWindowSurface(display, config, nativeWindow, s_DEFAULT_SURFACE_ATTRIBS, 0);
}
catch (IllegalArgumentException e)
{
// This exception indicates that the surface flinger surface
// is not valid. This can happen if the surface flinger surface has
// been torn down, but the application has not yet been
// notified via SurfaceHolder.Callback.surfaceDestroyed.
// In theory the application should be notified first,
// but in practice sometimes it is not. See b/4588890
Log.e(s_TAG, "eglCreateWindowSurface", e);
}
return result;
}
示例12: chooseConfig
import android.opengl.EGLConfig; //导入依赖的package包/类
@Override
public EGLConfig chooseConfig(EGLDisplay display, EGLConfig[] configs)
{
for (EGLConfig config : configs)
{
int d = findConfigAttrib(display, config, EGL14.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(display, config, EGL14.EGL_STENCIL_SIZE, 0);
if ((d >= depthSize) && (s >= stencilSize))
{
int r = findConfigAttrib(display, config, EGL14.EGL_RED_SIZE, 0);
int g = findConfigAttrib(display, config, EGL14.EGL_GREEN_SIZE, 0);
int b = findConfigAttrib(display, config, EGL14.EGL_BLUE_SIZE, 0);
int a = findConfigAttrib(display, config, EGL14.EGL_ALPHA_SIZE, 0);
if ((r == redSize) && (g == greenSize) && (b == blueSize) && (a == alphaSize))
{
return config;
}
}
}
return null;
}
示例13: getConfig
import android.opengl.EGLConfig; //导入依赖的package包/类
public EGLConfig getConfig(EGLConfigAttrs attrs){
EGLConfig[] configs = new EGLConfig[1];
int[] configNum = new int[1];
EGL14.eglChooseConfig(mEGLDisplay,attrs.build(),0,configs,0,1,configNum,0);
//选择的过程可能出现多个,也可能一个都没有,这里只用一个
if(configNum[0]>0){
if(attrs.isDefault()){
mEGLConfig=configs[0];
}
return configs[0];
}
return null;
}
示例14: createContext
import android.opengl.EGLConfig; //导入依赖的package包/类
public EGLContext createContext(EGLConfig config,EGLContext share,EGLContextAttrs attrs){
EGLContext context= EGL14.eglCreateContext(mEGLDisplay,config,share,attrs.build(),0);
if(attrs.isDefault()){
mEGLContext=context;
}
return context;
}
示例15: getConfig
import android.opengl.EGLConfig; //导入依赖的package包/类
@SuppressWarnings("unused")
private EGLConfig getConfig(final boolean with_depth_buffer, final boolean isRecordable) {
final int[] attribList = {
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
EGL14.EGL_RED_SIZE, 8,
EGL14.EGL_GREEN_SIZE, 8,
EGL14.EGL_BLUE_SIZE, 8,
EGL14.EGL_ALPHA_SIZE, 8,
EGL14.EGL_NONE, EGL14.EGL_NONE, //EGL14.EGL_STENCIL_SIZE, 8,
EGL14.EGL_NONE, EGL14.EGL_NONE, //EGL_RECORDABLE_ANDROID, 1, // this flag need to recording of MediaCodec
EGL14.EGL_NONE, EGL14.EGL_NONE, // with_depth_buffer ? EGL14.EGL_DEPTH_SIZE : EGL14.EGL_NONE,
// with_depth_buffer ? 16 : 0,
EGL14.EGL_NONE
};
int offset = 10;
if (false) { // ステンシルバッファ(常時未使用)
attribList[offset++] = EGL14.EGL_STENCIL_SIZE;
attribList[offset++] = 8;
}
if (with_depth_buffer) { // デプスバッファ
attribList[offset++] = EGL14.EGL_DEPTH_SIZE;
attribList[offset++] = 16;
}
if (isRecordable && (Build.VERSION.SDK_INT >= 18)) {// MediaCodecの入力用Surfaceの場合
attribList[offset++] = EGL_RECORDABLE_ANDROID;
attribList[offset++] = 1;
}
for (int i = attribList.length - 1; i >= offset; i--) {
attribList[i] = EGL14.EGL_NONE;
}
final EGLConfig[] configs = new EGLConfig[1];
final int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(mEglDisplay, attribList, 0, configs, 0, configs.length, numConfigs, 0)) {
// XXX it will be better to fallback to RGB565
Log.w(TAG, "unable to find RGBA8888 / " + " EGLConfig");
return null;
}
return configs[0];
}