本文整理汇总了Java中android.opengl.EGLDisplay类的典型用法代码示例。如果您正苦于以下问题:Java EGLDisplay类的具体用法?Java EGLDisplay怎么用?Java EGLDisplay使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EGLDisplay类属于android.opengl包,在下文中一共展示了EGLDisplay类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newDisplay
import android.opengl.EGLDisplay; //导入依赖的package包/类
/** @return from a new EGL display connection */
@NonNull
public static EGLDisplay newDisplay() {
final EGLDisplay result = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
if (result == EGL14.EGL_NO_DISPLAY) {
logError();
throw new RuntimeException("Unable to get EGL14 display");
} else {
final int[] v = new int[2];
if (!EGL14.eglInitialize(result, v, 0, v, 1)) {
try {
logError();
throw new RuntimeException("Unable to initialize EGL14 display");
} finally {
closeDisplay(result);
}
} else {
logDebug(getDisplayString(result) + " created (EGL" + v[0] + "" + v[1] + ")");
return result;
}
}
}
示例2: testSetPresentationTime
import android.opengl.EGLDisplay; //导入依赖的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);
}
示例3: testTexture
import android.opengl.EGLDisplay; //导入依赖的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);
}
示例4: testShader
import android.opengl.EGLDisplay; //导入依赖的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);
}
示例5: getEglConfig
import android.opengl.EGLDisplay; //导入依赖的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;
}
示例6: createEglContext
import android.opengl.EGLDisplay; //导入依赖的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;
}
示例7: getEglDisplay
import android.opengl.EGLDisplay; //导入依赖的package包/类
private static EGLDisplay getEglDisplay() {
EGLDisplay eglDisplay = EGL14.eglGetDisplay(EGL14.EGL_DEFAULT_DISPLAY);
if (eglDisplay == EGL14.EGL_NO_DISPLAY) {
throw new RuntimeException(
"Unable to get EGL14 display: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
int[] version = new int[2];
if (!EGL14.eglInitialize(eglDisplay, version, 0, version, 1)) {
throw new RuntimeException(
"Unable to initialize EGL14: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
return eglDisplay;
}
示例8: createWindowSurface
import android.opengl.EGLDisplay; //导入依赖的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;
}
示例9: chooseConfig
import android.opengl.EGLDisplay; //导入依赖的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;
}
示例10: enableSecureDummySurfaceV24
import android.opengl.EGLDisplay; //导入依赖的package包/类
/**
* Returns whether use of secure dummy surfaces should be enabled.
*
* @param context Any {@link Context}.
*/
@TargetApi(24)
private static boolean enableSecureDummySurfaceV24(Context context) {
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
String eglExtensions = EGL14.eglQueryString(display, EGL10.EGL_EXTENSIONS);
if (eglExtensions == null || !eglExtensions.contains("EGL_EXT_protected_content")) {
// EGL_EXT_protected_content is required to enable secure dummy surfaces.
return false;
}
if (Util.SDK_INT == 24 && "samsung".equals(Util.MANUFACTURER)) {
// Samsung devices running API level 24 are known to be broken [Internal: b/37197802].
return false;
}
if (Util.SDK_INT < 26 && !context.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE)) {
// Pre API level 26 devices were not well tested unless they supported VR mode.
return false;
}
return true;
}
示例11: logCurrent
import android.opengl.EGLDisplay; //导入依赖的package包/类
/**
* Writes the current display, context, and surface to the log.
*/
public static void logCurrent(String msg) {
EGLDisplay display;
EGLContext context;
EGLSurface surface;
display = EGL14.eglGetCurrentDisplay();
context = EGL14.eglGetCurrentContext();
surface = EGL14.eglGetCurrentSurface(EGL14.EGL_DRAW);
Log.i(TAG, "Current EGL (" + msg + "): display=" + display + ", context=" + context +
", surface=" + surface);
}
示例12: getDisplayHandle
import android.opengl.EGLDisplay; //导入依赖的package包/类
/**
* @param display EGL display connection
* @return the EGL display handle
*/
private static long getDisplayHandle(@NonNull EGLDisplay display) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return getDisplayHandleLollipop(display);
} else {
return getDisplayHandleBase(display);
}
}
示例13: closeDisplay
import android.opengl.EGLDisplay; //导入依赖的package包/类
/**
* Close an EGL display connection.
* @param display an EGL display connection instance
*/
public static void closeDisplay(@NonNull EGLDisplay display) {
if (!EGL14.eglTerminate(display)) {
logError();
throw new RuntimeException("Unable to terminate EGL14 " + getDisplayString(display));
} else {
logDebug(getDisplayString(display) + " destroyed");
}
}
示例14: newConfig
import android.opengl.EGLDisplay; //导入依赖的package包/类
/**
* @param display an EGL display connection instance
* @param usePBuffer do not accept rendering through the native window system
* @return frame buffer configuration that defines the frame buffer resource available to the
* rendering context.
**/
@NonNull
public static EGLConfig newConfig(@NonNull EGLDisplay display, boolean usePBuffer) {
final int surfaceTypeKey = usePBuffer ? EGL14.EGL_SURFACE_TYPE : RECORDABLE_ANDROID;
final int surfaceTypeValue = usePBuffer ? EGL14.EGL_PBUFFER_BIT : 1;
final EGLConfig[] configs = new EGLConfig[1];
final int[] numConfigs = new int[1];
if (!EGL14.eglChooseConfig(display,
new int[] {
EGL14.EGL_RED_SIZE, 5,
EGL14.EGL_GREEN_SIZE, 6,
EGL14.EGL_BLUE_SIZE, 5,
/*EGL14.EGL_RED_SIZE, 8,
EGL14.EGL_GREEN_SIZE, 8,
EGL14.EGL_BLUE_SIZE, 8,
EGL14.EGL_ALPHA_SIZE, 8,*/
EGL14.EGL_RENDERABLE_TYPE,
EGL14.EGL_OPENGL_ES2_BIT,
surfaceTypeKey, surfaceTypeValue,
EGL14.EGL_NONE }, 0,
configs, 0, configs.length, numConfigs, 0) && numConfigs[0] == 1) {
logError();
throw new RuntimeException("Unable to from EGL14 config");
} else {
final EGLConfig result = configs[0];
logDebug(getConfigString(result) + " created");
return result;
}
}
示例15: newContext
import android.opengl.EGLDisplay; //导入依赖的package包/类
/**
* @param display an EGL display connection instance
* @return a new EGL rendering context
**/
@NonNull
public static EGLContext newContext(@NonNull EGLDisplay display, @NonNull EGLConfig config) {
final EGLContext result = EGL14.eglCreateContext (display, config, EGL14.EGL_NO_CONTEXT,
new int[] {EGL14.EGL_CONTEXT_CLIENT_VERSION, 2, EGL14.EGL_NONE }, 0);
if (result == EGL14.EGL_NO_CONTEXT) {
logError();
throw new RuntimeException("Unable to from EGL14 context");
} else {
logDebug(getContextString(result) + " created");
return result;
}
}