public static extern bool GetConfigAttrib(EGLDisplay dpy, EGLConfig config, int attribute, out int value);
// called by AppThreadFunction public void ovrEgl_CreateContext(EGLContext shareEgl_Context) { // 152 ConsoleExtensions.trace("enter ovrEgl_CreateContext, eglGetDisplay"); if (this.Display != egl.EGL_NO_DISPLAY) { return; } this.Display = egl.eglGetDisplay(default(native_window.ANativeWindow)); egl.eglInitialize(this.Display, out this.MajorVersion, out this.MinorVersion); // Do NOT use eglChooseConfig, because the Android EGL code pushes in multisample // flags in eglChooseConfig if the user has selected the "force 4x MSAA" option in // settings, and that is completely wasted for our warp target. int numConfigs = 0; if (egl.eglGetConfigs(this.Display, configs, MAX_CONFIGS, out numConfigs) == false) { //ALOGE( " eglGetConfigs() failed: %s", EglErrorString( eglGetError() ) ); return; } ConsoleExtensions.tracei("ovrEgl_CreateContext numConfigs: ", numConfigs); // \VrCubeWorld.Egl.cs:95 ovrEgl_CreateContext numConfigs: 22 const int egl_EGL_OPENGL_ES3_BIT_KHR = 0x0040; this.Config = default(EGLConfig); #region numConfigs for (int i = 0; i < numConfigs; i++) { int value = 0; egl.eglGetConfigAttrib(this.Display, configs[i], egl.EGL_RENDERABLE_TYPE, out value); if ((value & egl_EGL_OPENGL_ES3_BIT_KHR) != egl_EGL_OPENGL_ES3_BIT_KHR) { continue; } // The pbuffer config also needs to be compatible with normal window rendering // so it can share textures with the window context. egl.eglGetConfigAttrib(this.Display, configs[i], egl.EGL_SURFACE_TYPE, out value); if ((value & (egl.EGL_WINDOW_BIT | egl.EGL_PBUFFER_BIT)) != (egl.EGL_WINDOW_BIT | egl.EGL_PBUFFER_BIT)) { continue; } int j = 0; for (; configAttribs[j] != egl.EGL_NONE; j += 2) { egl.eglGetConfigAttrib(this.Display, configs[i], configAttribs[j], out value); if (value != configAttribs[j + 1]) { break; } } if (configAttribs[j] == egl.EGL_NONE) { ConsoleExtensions.tracei("ovrEgl_CreateContext config found i: ", i); this.Config = configs[i]; break; } } #endregion if (this.Config == default(EGLConfig)) { ConsoleExtensions.tracei("ovrEgl_CreateContext eglChooseConfig failed"); //ALOGE( " eglChooseConfig() failed: %s", EglErrorString( eglGetError() ) ); return; } //ALOGV( " Context = eglCreateContext( Display, Config, EGL_NO_CONTEXT, contextAttribs )" ); //this.Context = egl.eglCreateContext(this.Display, this.Config, (shareEgl != NULL) ? shareEgl->Context : egl.EGL_NO_CONTEXT, contextAttribs); this.Context = egl.eglCreateContext(this.Display, this.Config, shareEgl_Context, contextAttribs); if (this.Context == egl.EGL_NO_CONTEXT) { //ALOGE( " eglCreateContext() failed: %s", EglErrorString( eglGetError() ) ); return; } //ALOGV( " TinySurface = eglCreatePbufferSurface( Display, Config, surfaceAttribs )" ); this.TinySurface = egl.eglCreatePbufferSurface(this.Display, this.Config, surfaceAttribs); if (this.TinySurface == egl.EGL_NO_SURFACE) { //ALOGE( " eglCreatePbufferSurface() failed: %s", EglErrorString( eglGetError() ) ); egl.eglDestroyContext(this.Display, this.Context); this.Context = egl.EGL_NO_CONTEXT; return; } //ALOGV( " eglMakeCurrent( Display, TinySurface, TinySurface, Context )" ); if (egl.eglMakeCurrent(this.Display, this.TinySurface, this.TinySurface, this.Context) == false) { //ALOGE( " eglMakeCurrent() failed: %s", EglErrorString( eglGetError() ) ); egl.eglDestroySurface(this.Display, this.TinySurface); egl.eglDestroyContext(this.Display, this.Context); this.Context = egl.EGL_NO_CONTEXT; return; } ConsoleExtensions.trace("exit ovrEgl_CreateContext"); }
public static extern EGLBoolean QueryContext(EGLDisplay display, IntPtr context, int attribute, ref int value);
public static extern EGLBoolean Terminate(EGLDisplay display);
public static extern EGLBoolean DestroyContext(EGLDisplay display, IntPtr ctx);
public static extern EGLBoolean GetConfigs(EGLDisplay display, [Out] EGLConfig[] configs, int config_size, out int num_config);
public static extern EGLSurface CreatePbufferFromClientBuffer(EGLDisplay dpy, int buftype, EGLClientBuffer buffer, EGLConfig config, int[] attrib_list);
public static extern bool SurfaceAttrib(EGLDisplay dpy, EGLSurface surface, int attribute, int value);
public static extern bool DestroySurface(EGLDisplay dpy, EGLSurface surface);
public static extern bool QuerySurface(EGLDisplay dpy, EGLSurface surface, int attribute, out int value);
public static extern EGLSurface CreatePixmapSurface(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, int[] attrib_list);
public static extern EGLSurface CreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list);
public static extern EGLSurface CreateWindowSurface(EGLDisplay dpy, EGLConfig config, IntPtr win, int[] attrib_list);
public static extern IntPtr CreateContext(EGLDisplay display, IntPtr config, IntPtr share_context, int[] attrib_list);
public static extern bool ReleaseTexImage(EGLDisplay dpy, EGLSurface surface, int buffer);
public static extern EGLSurface CreatePixmapSurface(EGLDisplay display, IntPtr config, IntPtr pixmap, int[] attrib_list);
public static extern bool SwapInterval(EGLDisplay dpy, int interval);
public static extern EGLBoolean GetConfigAttrib(EGLDisplay display, IntPtr config, int attribute, [Out] int[] value);
static extern IntPtr eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list);
public static extern EGLBoolean Initialize(EGLDisplay dpy, ref int major, ref int minor);
public static EGLContext CreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list) { IntPtr ptr = eglCreateContext(dpy, config, share_context, attrib_list); if (ptr == IntPtr.Zero) throw new GraphicsContextException(String.Format("Failed to create EGL context, error: {0}.", Egl.GetError())); return ptr; }
public static extern EGLBoolean QuerySurface(EGLDisplay display, EGLSurface surface, int attribute, int[] value);
public static extern bool DestroyContext(EGLDisplay dpy, EGLContext ctx);
public static extern EGLBoolean BindTexImage(EGLDisplay display, IntPtr surface, int buffer);
public static extern bool MakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
/// <summary> /// </summary> /// <param name="display"> </param> /// <param name="win"> </param> /// <returns> </returns> protected EGLSurface CreateSurfaceFromWindow(EGLDisplay display, NativeWindowType win) { throw new NotImplementedException(); }
public static extern bool QueryContext(EGLDisplay dpy, EGLContext ctx, int attribute, out int value);
public void destroyContext(IEGL10 egl, EGLDisplay display, EGLContext context) { egl.EglDestroyContext(display, context); }
public static extern bool SwapBuffers(EGLDisplay dpy, EGLSurface surface);
public static extern EGLBoolean CopyBuffers(EGLDisplay display, IntPtr surface, IntPtr target);
public static extern bool CopyBuffers(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
public static extern EGLSurface CreatePbufferSurface(EGLDisplay display, IntPtr config, int[] attrib_list);
public static bool eglInitialize(EGLDisplay dpy, out int major, out int minor) { throw null; }
public static extern EGLSurface CreateWindowSurface(EGLDisplay display, IntPtr config, IntPtr win, int[] attrib_list);
public static EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, int[] attrib_list) { throw null; }
public static extern EGLBoolean DestroySurface(EGLDisplay display, IntPtr surface);
public static EGLContext eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, int[] attrib_list) { throw null; }
public static extern EGLBoolean GetConfigAttrib(EGLDisplay display, EGLConfig config, int attribute, out int value);
public static bool eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, int attribute, out int value) { throw null; }
public static extern EGLDisplay GetDisplay(EGLDisplay display_id);
public static bool eglGetConfigs(EGLDisplay dpy, EGLConfig[] configs, int config_size, out int num_config) { throw null; }
public static extern EGLBoolean MakeCurrent(EGLDisplay display, IntPtr draw, IntPtr read, IntPtr context);
public static bool eglDestroySurface(EGLDisplay dpy, EGLSurface surface) { throw null; }
public static extern string QueryString(EGLDisplay display, int name);
public static bool eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { throw null; }
public static extern EGLBoolean SwapBuffers(EGLDisplay display, EGLSurface surface);
public static bool eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx) { throw null; }
public static extern IntPtr CreatePbufferFromClientBuffer(EGLDisplay display, uint buftype, IntPtr buffer, IntPtr config, int[] attrib_list);
public static EGLSurface eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, ScriptCoreLibNative.SystemHeaders.android.native_window.ANativeWindow win, int[] attrib_list) { throw null; }
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports recording. */ private void eglSetup() { mEGLDisplay = EGL14.EglGetDisplay(EGL14.EglDefaultDisplay); if (mEGLDisplay == EGL14.EglNoDisplay) { throw new Java.Lang.RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.EglInitialize(mEGLDisplay, version, 0, version, 1)) { throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for recording and OpenGL ES 2.0. int[] attribList; if (mEGLSharedContext == null) { attribList = new int[] { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEs2Bit, EGL14.EglNone }; } else { attribList = new int[] { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEs2Bit, EGL_RECORDABLE_ANDROID, 1, EGL14.EglNone }; } EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; EGL14.EglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.Length, numConfigs, 0); checkEglError("eglCreateContext RGB888+recordable ES2"); // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EglContextClientVersion, 2, EGL14.EglNone }; if (mEGLSharedContext == null) { mEGLContext = EGL14.EglCreateContext(mEGLDisplay, configs[0], EGL14.EglNoContext, attrib_list, 0); } else { mEGLContext = EGL14.EglCreateContext(mEGLDisplay, configs[0], mEGLSharedContext, attrib_list, 0); } checkEglError("eglCreateContext"); // Create a window surface, and attach it to the Surface we received. int[] surfaceAttribs = { EGL14.EglNone }; mEGLSurface = EGL14.EglCreateWindowSurface(mEGLDisplay, configs[0], mSurface, surfaceAttribs, 0); checkEglError("eglCreateWindowSurface"); GLES20.GlDisable(GLES20.GlDepthTest); GLES20.GlDisable(GLES20.GlCullFaceMode); }
public static bool eglTerminate(EGLDisplay dpy) { throw null; }
/** * Prepares EGL. We want a GLES 2.0 context and a surface that supports pbuffer. */ private void eglSetup() { mEGLDisplay = EGL14.EglGetDisplay(EGL14.EglDefaultDisplay); if (mEGLDisplay == EGL14.EglNoDisplay) { throw new RuntimeException("unable to get EGL14 display"); } int[] version = new int[2]; if (!EGL14.EglInitialize(mEGLDisplay, version, 0, version, 1)) { mEGLDisplay = null; throw new RuntimeException("unable to initialize EGL14"); } // Configure EGL for pbuffer and OpenGL ES 2.0, 24-bit RGB. int[] attribList = { EGL14.EglRedSize, 8, EGL14.EglGreenSize, 8, EGL14.EglBlueSize, 8, EGL14.EglAlphaSize, 8, EGL14.EglRenderableType, EGL14.EglOpenglEs2Bit, EGL14.EglSurfaceType, EGL14.EglPbufferBit, EGL14.EglNone }; EGLConfig[] configs = new EGLConfig[1]; int[] numConfigs = new int[1]; if (!EGL14.EglChooseConfig(mEGLDisplay, attribList, 0, configs, 0, configs.Length, numConfigs, 0)) { throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config"); } // Configure context for OpenGL ES 2.0. int[] attrib_list = { EGL14.EglContextClientVersion, 2, EGL14.EglNone }; mEGLContext = EGL14.EglCreateContext(mEGLDisplay, configs[0], EGL14.EglNoContext, attrib_list, 0); checkEglError("eglCreateContext"); if (mEGLContext == null) { throw new RuntimeException("null context"); } // Create a pbuffer surface. int[] surfaceAttribs = { EGL14.EglWidth, mWidth, EGL14.EglHeight, mHeight, EGL14.EglNone }; mEGLSurface = EGL14.EglCreatePbufferSurface(mEGLDisplay, configs[0], surfaceAttribs, 0); checkEglError("eglCreatePbufferSurface"); if (mEGLSurface == null) { throw new RuntimeException("surface was null"); } }
public static extern EGLBoolean SurfaceAttrib(EGLDisplay display, IntPtr surface, int attribute, int value);
// called by AppThreadFunction public void ovrEgl_DestroyContext() { // 259 if (this.Display != egl.EGL_NO_DISPLAY) { //ALOGE(" eglMakeCurrent( Display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )"); if (egl.eglMakeCurrent(this.Display, egl.EGL_NO_SURFACE, egl.EGL_NO_SURFACE, egl.EGL_NO_CONTEXT) == false) { //ALOGE(" eglMakeCurrent() failed: %s", EglErrorString(eglGetError())); } } if (this.Context != egl.EGL_NO_CONTEXT) { //ALOGE(" eglDestroyContext( Display, Context )"); if (egl.eglDestroyContext(this.Display, this.Context) == false) { //ALOGE(" eglDestroyContext() failed: %s", EglErrorString(eglGetError())); } this.Context = egl.EGL_NO_CONTEXT; } if (this.TinySurface != egl.EGL_NO_SURFACE) { //ALOGE(" eglDestroySurface( Display, TinySurface )"); if (egl.eglDestroySurface(this.Display, this.TinySurface) == false) { //ALOGE(" eglDestroySurface() failed: %s", EglErrorString(eglGetError())); } this.TinySurface = egl.EGL_NO_SURFACE; } if (this.Display != egl.EGL_NO_DISPLAY) { //ALOGE(" eglTerminate( Display )"); if (egl.eglTerminate(this.Display) == false) { //ALOGE(" eglTerminate() failed: %s", EglErrorString(eglGetError())); } this.Display = egl.EGL_NO_DISPLAY; } }
public static extern EGLBoolean SwapInterval(EGLDisplay display, int interval);
static int GetAttribute(EGLConfig config, IEGL10 egl, EGLDisplay eglDisplay, int attribute) { int[] data = new int[1]; egl.EglGetConfigAttrib(eglDisplay, config, EGL11.EglRedSize, data); return(data[0]); }
public static extern EGLBoolean ChooseConfig(EGLDisplay display, int[] attrib_list, IntPtr[] configs, int config_size, int[] num_config);
public EGLContext CreateNewContext(EGLDisplay eglDisplay, EGLConfig glconfig, EGLContext shareList) { return(IntPtr.Zero); }
public static extern bool ChooseConfig(EGLDisplay dpy, int[] attrib_list, [In, Out] EGLConfig[] configs, int config_size, out int num_config);