Пример #1
0
        public void Start()
        {
            var screenThread = new Thread(() =>
            {
                bool quit        = false;
                var eventHandler = new SDL.SDL_Event();

                SDL.SDL_SetRenderDrawColor(Renderer, 0, 0, 0, 1);

                SDL.SDL_RenderClear(Renderer);

                SDL.SDL_RenderPresent(Renderer);

                while (!quit)
                {
                    FrameHelper.NextFrame();
                    FrameCallback.Invoke();
                }
            });

            screenThread.Start();
        }
Пример #2
0
        public Screen(Action frameCallback, int scaleFactor = 1)
        {
            if (scaleFactor < 1)
            {
                throw new ArgumentOutOfRangeException("scaleFactor must not be less than 1.");
            }

            ScaleFactor   = scaleFactor;
            FrameHelper   = new FrameHelper(FrameRate);
            FrameCallback = frameCallback;

            SDL.SDL_Init(SDL.SDL_INIT_VIDEO);

            Window = IntPtr.Zero;
            Window = SDL.SDL_CreateWindow("CoreBoy",
                                          SDL.SDL_WINDOWPOS_CENTERED,
                                          SDL.SDL_WINDOWPOS_CENTERED,
                                          MinimumX * ScaleFactor,
                                          MinimumY * ScaleFactor,
                                          SDL.SDL_WindowFlags.SDL_WINDOW_SHOWN
                                          );

            Renderer = SDL.SDL_CreateRenderer(Window, -1, SDL.SDL_RendererFlags.SDL_RENDERER_ACCELERATED);
        }