public Session(GlxContext context, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info, IDisposable @lock) { _context = context; _info = info; _lock = @lock; }
public Session(GlxContext context, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info, IDisposable clearContext) { _context = context; _info = info; _clearContext = clearContext; }
public GlxContext(GlxInterface glx, IntPtr handle, GlxDisplay display, GlxContext sharedWith, GlVersion version, int sampleCount, int stencilSize, X11Info x11, IntPtr defaultXid, bool ownsPBuffer) { Handle = handle; Glx = glx; _sharedWith = sharedWith; _x11 = x11; _defaultXid = defaultXid; _ownsPBuffer = ownsPBuffer; Display = display; Version = version; SampleCount = sampleCount; StencilSize = stencilSize; using (MakeCurrent()) GlInterface = new GlInterface(version, GlxInterface.SafeGetProcAddress); }
public RenderTarget(GlxContext context, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info) { _context = context; _info = info; }
public GlxGlPlatformSurface(GlxDisplay display, GlxContext context, EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo info) { _display = display; _context = context; _info = info; }
GlxContext CreateContext(IntPtr defaultXid, IGlContext share, int sampleCount, int stencilSize, bool ownsPBuffer) { var sharelist = ((GlxContext)share)?.Handle ?? IntPtr.Zero; IntPtr handle = default; GlxContext Create(GlVersion profile) { var profileMask = GLX_CONTEXT_CORE_PROFILE_BIT_ARB; if (profile.Type == GlProfileType.OpenGLES) { profileMask = GLX_CONTEXT_ES2_PROFILE_BIT_EXT; } var attrs = new int[] { GLX_CONTEXT_MAJOR_VERSION_ARB, profile.Major, GLX_CONTEXT_MINOR_VERSION_ARB, profile.Minor, GLX_CONTEXT_PROFILE_MASK_ARB, profileMask, 0 }; try { handle = Glx.CreateContextAttribsARB(_x11.Display, _fbconfig, sharelist, true, attrs); if (handle != IntPtr.Zero) { _version = profile; return(new GlxContext(new GlxInterface(), handle, this, (GlxContext)share, profile, sampleCount, stencilSize, _x11, defaultXid, ownsPBuffer)); } } catch { return(null); } return(null); } GlxContext rv = null; if (_version.HasValue) { rv = Create(_version.Value); } foreach (var v in _probeProfiles) { if (v.Type == GlProfileType.OpenGLES && !_displayExtensions.Contains("GLX_EXT_create_context_es2_profile")) { continue; } rv = Create(v); if (rv != null) { _version = v; break; } } if (rv != null) { return(rv); } throw new OpenGlException("Unable to create direct GLX context"); }
public GlxDisplay(X11Info x11) { _x11 = x11; var baseAttribs = new[] { GLX_X_RENDERABLE, 1, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, GLX_DOUBLEBUFFER, 1, GLX_RED_SIZE, 8, GLX_GREEN_SIZE, 8, GLX_BLUE_SIZE, 8, GLX_ALPHA_SIZE, 8, GLX_DEPTH_SIZE, 1, GLX_STENCIL_SIZE, 8, }; foreach (var attribs in new[] { //baseAttribs.Concat(multiattribs), baseAttribs, }) { var ptr = GlxChooseFBConfig(_x11.Display, x11.DefaultScreen, attribs, out var count); for (var c = 0; c < count; c++) { var visual = GlxGetVisualFromFBConfig(_x11.Display, ptr[c]); // We prefer 32 bit visuals if (_fbconfig == IntPtr.Zero || visual->depth == 32) { _fbconfig = ptr[c]; _visual = visual; if (visual->depth == 32) { break; } } } if (_fbconfig != IntPtr.Zero) { break; } } if (_fbconfig == IntPtr.Zero) { throw new OpenGlException("Unable to choose FBConfig"); } if (_visual == null) { throw new OpenGlException("Unable to get visual info from FBConfig"); } if (GlxGetFBConfigAttrib(_x11.Display, _fbconfig, GLX_SAMPLES, out var samples) == 0) { SampleCount = samples; } if (GlxGetFBConfigAttrib(_x11.Display, _fbconfig, GLX_STENCIL_SIZE, out var stencil) == 0) { StencilSize = stencil; } ImmediateContext = CreateContext(null); DeferredContext = CreateContext(ImmediateContext); ImmediateContext.MakeCurrent(); GlInterface = GlInterface.FromNativeUtf8GetProcAddress(p => GlxGetProcAddress(p)); }