Exemple #1
0
 public void Init()
 {
     new Thread(
         () => {
         device = VeldridStartup.CreateGraphicsDevice(
             window,
             new GraphicsDeviceOptions {
             SyncToVerticalBlank = true
         },
             GraphicsBackend.OpenGL
             );
         Sdl2Native.SDL_GL_MakeCurrent(window.SdlWindowHandle, Sdl2Native.SDL_GL_CreateContext(window.SdlWindowHandle));
         Sdl2Native.SDL_GL_SetSwapInterval(1);
         PoolTouhou.Logger.Log($"Using : {device.BackendType}");
         GlUtil.CheckGlError();
         PoolTouhou.GameState = new LoadingMenuState();
         new Thread(UpdateLoop).Start();
         DrawLoop();
     }
         ).Start();
 }
Exemple #2
0
 private void DrawLoop()
 {
     PoolTouhou.Logger.Log("开始渲染线程循环");
     try {
         long last = 0;
         while (window.Exists && running)
         {
             long   now   = Watch.ElapsedTicks;
             double delta = Stopwatch.Frequency / (double)(now - last);
             OpenGLNative.glClearColor(0, 1, 1, 0.5f);
             OpenGLNative.glClear(ClearBufferMask.ColorBufferBit);
             PoolTouhou.GameState.Draw(delta);
             Sdl2Native.SDL_GL_SwapWindow(window.SdlWindowHandle);
             GlUtil.CheckGlError();
             last = now;
         }
     } catch (Exception e) {
         running = false;
         PoolTouhou.Logger.Log(e.Message + Environment.NewLine + e.StackTrace);
     }
 }