public bool SetHWRender(ref retro_hw_render_callback hwRenderCallback) { if (_hwRenderer != null) { _hwRenderer.Destroy(); } _glRenderContext = new DxTextureRenderContext(_device); _hwRenderer = new GLHardwareRenderer(new DefaultRenderStrategy(), _glRenderContext); if (!_maxSize.IsEmpty) { _hwRenderer.SetDimensions(_maxSize.Width, _maxSize.Height); } return(_hwRenderer.SetHWRender(ref hwRenderCallback)); }
public bool SetHWRender(ref retro_hw_render_callback hwRenderCallback) { if (_deviceContext != null) { return(false); } _deviceContext = DeviceContext.Create(); // Try and create an openGl context using the attributes specified in the callback _glContext = GlContext.TryCreate(_deviceContext, (int)hwRenderCallback.version_major, (int)hwRenderCallback.version_minor, (retro_hw_context_type)hwRenderCallback.context_type, hwRenderCallback.debug_context); // Creation might fail if the system doesn't // support the requested attributes if (_glContext == null) { return(false); } // ToDo: Some cores seem to need a separate shared context // but can't get it to work yet... if (_haveSharedContext) { _sharedGlContext = _glContext.CreateSharedContext(); } // Render context that the libretro core will render to, contains a texture buffer and an optional depth/stencil buffer. _libretroContext = new LibretroRenderContext(hwRenderCallback.depth, hwRenderCallback.stencil, hwRenderCallback.bottom_left_origin); // Get the libretro core callbacks _contextResetDlgt = hwRenderCallback.context_reset != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer <retro_hw_context_reset_t>(hwRenderCallback.context_reset) : null; _contextDestroyDlgt = hwRenderCallback.context_destroy != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer <retro_hw_context_reset_t>(hwRenderCallback.context_destroy) : null; // Pass the opengl callbacks back to the core hwRenderCallback.get_proc_address = Marshal.GetFunctionPointerForDelegate(_getProcAddressDelegate); hwRenderCallback.get_current_framebuffer = Marshal.GetFunctionPointerForDelegate(_getCurrentFramebufferDlgt); return(true); }