/// <summary> /// /// </summary> /// <see cref="http://www.opentk.com/doc/graphics/graphicscontext"/> //[HandleProcessCorruptedStateExceptions] public override void InitSynchronizedOnce() { //Memory.WriteBytesHook += OnMemoryWrite; this.ScaleViewport = PspStoredConfig.RenderScale; if (!AlreadyInitialized) { AlreadyInitialized = true; AutoResetEvent CompletedEvent = new AutoResetEvent(false); var CThread = new Thread(() => { Thread.CurrentThread.CurrentCulture = new CultureInfo(GlobalConfig.ThreadCultureName); OpenglContext = GLContextFactory.CreateWindowless(); OpenglContext.MakeCurrent(); Console.Out.WriteLineColored(ConsoleColor.White, "## OpenGL Context Version: {0}", GlGetString(GL.GL_VERSION)); Console.Out.WriteLineColored(ConsoleColor.White, "## Depth Bits: {0}", GL.glGetInteger(GL.GL_DEPTH_BITS)); Console.Out.WriteLineColored(ConsoleColor.White, "## Stencil Bits: {0}", GL.glGetInteger(GL.GL_STENCIL_BITS)); Console.Out.WriteLineColored(ConsoleColor.White, "## Color Bits: {0},{1},{2},{3}", GL.glGetInteger(GL.GL_RED_BITS), GL.glGetInteger(GL.GL_GREEN_BITS), GL.glGetInteger(GL.GL_BLUE_BITS), GL.glGetInteger(GL.GL_ALPHA_BITS)); if (GL.glGetInteger(GL.GL_STENCIL_BITS) <= 0) { Console.Error.WriteLineColored(ConsoleColor.Red, "No stencil bits available!"); } OpenglContext.ReleaseCurrent(); CompletedEvent.Set(); Console.WriteLine("OpenglGpuImpl.Init.Start()"); try { while (Running) { Thread.Sleep(10); } StopEvent.Set(); } finally { Console.WriteLine("OpenglGpuImpl.Init.End()"); } }); CThread.Name = "GpuImplEventHandling"; CThread.IsBackground = true; CThread.Start(); CompletedEvent.WaitOne(); } }
public UseOpenGLCreationContext(GraphicsDevice graphicsDevice) : this() { GL = graphicsDevice.GL; if (graphicsDevice.CurrentGraphicsContext == IntPtr.Zero) { needUnbindContext = true; useDeviceCreationContext = true; // Lock, since there is only one deviceCreationContext. // TODO: Support multiple deviceCreationContext (TLS creation of context was crashing, need to investigate why) asyncCreationLockObject = graphicsDevice.asyncCreationLockObject; Monitor.Enter(graphicsDevice.asyncCreationLockObject, ref asyncCreationLockTaken); // Bind the context deviceCreationContext = graphicsDevice.deviceCreationContext; deviceCreationContext.MakeCurrent(); } else { // TODO Hardcoded to the fact it uses only one command list, this should be fixed CommandList = graphicsDevice.InternalMainCommandList; } }