Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new WindowOptions struct.
 /// </summary>
 public WindowOptions
 (
     bool isVisible,
     bool useSingleThreadedWindow,
     Point position,
     Size size,
     double framesPerSecond,
     double updatesPerSecond,
     GraphicsAPI api,
     string title,
     WindowState windowState,
     WindowBorder windowBorder,
     VSyncMode vSync,
     int isRunningSlowlyThreshold,
     bool shouldSwapAutomatically,
     VideoMode videoMode,
     int?preferredDepthBufferBits = null
 )
 {
     IsVisible = isVisible;
     UseSingleThreadedWindow = useSingleThreadedWindow;
     Position         = position;
     Size             = size;
     FramesPerSecond  = framesPerSecond;
     UpdatesPerSecond = updatesPerSecond;
     API                      = api;
     Title                    = title;
     WindowState              = windowState;
     WindowBorder             = windowBorder;
     VSync                    = vSync;
     RunningSlowTolerance     = isRunningSlowlyThreshold;
     ShouldSwapAutomatically  = shouldSwapAutomatically;
     VideoMode                = videoMode;
     PreferredDepthBufferBits = preferredDepthBufferBits;
 }
        public X3DBrowser(VSyncMode VSync, string url, Resolution res, GraphicsMode mode) : base(res.Width, res.Height, mode)
        {
            this.VSync = VSync;
            this.URL   = url;

            app = new X3DApplication(this);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new WindowOptions struct.
 /// </summary>
 public ViewOptions
 (
     bool useSingleThreadedWindow,
     double framesPerSecond,
     double updatesPerSecond,
     GraphicsAPI api,
     VSyncMode vSync,
     int isRunningSlowlyThreshold,
     bool shouldSwapAutomatically,
     VideoMode videoMode,
     int?preferredDepthBufferBits = null,
     bool isEventDriven           = false
 )
 {
     UseSingleThreadedWindow = useSingleThreadedWindow;
     FramesPerSecond         = framesPerSecond;
     UpdatesPerSecond        = updatesPerSecond;
     API   = api;
     VSync = vSync;
     RunningSlowTolerance    = isRunningSlowlyThreshold;
     ShouldSwapAutomatically = shouldSwapAutomatically;
     VideoMode = videoMode;
     PreferredDepthBufferBits = preferredDepthBufferBits;
     IsEventDriven            = isEventDriven;
 }
Ejemplo n.º 4
0
 public EmulatorWindow(Nes nes, VSyncMode vSyncMode) :
     base(k_NesScreenWidth * k_DefaultScreenSizeMultiplier,
          k_NesScreenHeight * k_DefaultScreenSizeMultiplier,
          GraphicsMode.Default, k_Title)
 {
     VSync = vSyncMode;
     m_Nes = nes;
 }
Ejemplo n.º 5
0
        public void StartWindow(int width, int height, VSyncMode VSync)
        {
            Window mainGameWindow = new Window(width, height);

            mainGameWindow.VSync = VSync;
            mainGameWindow.Title = "Aptitude Engine";
            mainGameWindow.Run();
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates a new <see cref="WindowParameters"/> structure
 /// </summary>
 /// <param name="width">Window width in pixels</param>
 /// <param name="height">Window height in pixels</param>
 /// <param name="fullscreen">Is window must be fullscreen</param>
 /// <param name="vsync">Renderer VSync mode</param>
 /// <param name="title">Window title</param>
 public WindowParameters(int width, int height, bool fullscreen, VSyncMode vsync, string title)
 {
     Width        = width;
     Height       = height;
     IsFullscreen = fullscreen;
     VSyncMode    = vsync;
     Title        = title;
 }
        public X3DBrowser(VSyncMode VSync, SceneGraph graph, Resolution res, GraphicsMode mode) : base(res.Width, res.Height, mode)
        {
            this.VSync = VSync;
            this.URL   = string.Empty;
            this.Graph = graph;

            app = new X3DApplication(this, graph);
        }
Ejemplo n.º 8
0
 public GameContextConfig(MonitorMode pResolution, int iDepth = 24, int iStencil      = 8,
                          bool bSamples    = true, NativContextConfigTyp pGraphicType = NativContextConfigTyp.Best,
                          VSyncMode pVsync = VSyncMode.Adaptive)
 {
     m_iDepth      = iDepth;
     m_iStencil    = iStencil;
     m_pResolution = new GameResolution(pResolution);
     m_pVSync      = pVsync;
     m_pConfigTyp  = pGraphicType;
     m_pConfigInt  = 0;
     m_bSamples    = bSamples;
 }
Ejemplo n.º 9
0
        private void GameLoop()
        {
            this.Log("Create graphics context");

            context = new GraphicsContext(graphicsMode, window.WindowInfo, 4, 0, GraphicsContextFlags.Debug);

            context.MakeCurrent(window.WindowInfo);

            GraphicsContext.Assert();

            this.Log($"VSync: {Configuration.VSync}");
            VSync = Configuration.VSync;

            this.Log("Loading OpenGL entry points");
            context.LoadAll();

            batch = new SpriteBatch(this);

            this.Log("Setup OpenGL");
            SetupOpenGL();

            this.Log("Setup OpenAL");
            SetupOpenAL();
            LoadAssetProviders();

            Load();

            window.Visible = true;

            CalculateTimings();

            Time.Start();

            this.Log("Enter game loop");
            while (!Closing)
            {
                if (context.IsDisposed)
                {
                    this.Log("Context not available");
                    break;
                }

                updating = true;

                InternUpdate();
                Render(batch);

                updating = false;
            }
            this.Log("Exited game loop");

            Time.Stop();
        }
Ejemplo n.º 10
0
        public GameOptions()
        {
            ResolutionW = 1024;
            ResolutionH = 768;
            Vsync       = VSyncMode.On;
            WindowMode  = GameWindowFlags.Default;
            KeyBinding  = new KeyboardBinding(new KeyConfig());

            SoundVolume     = 100f;
            SoundSampleRate = 44100;
            SoundChannels   = 2;
        }
Ejemplo n.º 11
0
 protected void toggleMode()
 {
     if (currentMode != mode)
     {
         QualitySettings.vSyncCount = (int)mode;
         currentMode = mode;
     }
     else if ((int)currentMode != QualitySettings.vSyncCount)
     {
         mode        = (VSyncMode)QualitySettings.vSyncCount;
         currentMode = mode;
     }
 }
		protected void toggleMode()
		{
			if( currentMode != mode )
			{
				QualitySettings.vSyncCount = (int)mode;
				currentMode = mode;
			}
			else if( (int)currentMode != QualitySettings.vSyncCount )
			{
				mode = (VSyncMode)QualitySettings.vSyncCount;
				currentMode = mode;
			}
		}
        public StreetViewer3DApplication(VSyncMode VSync, Resolution res, GraphicsMode mode) : base(res.Width, res.Height, mode)
        {
            this.VSync = VSync;

            // Should really use X3D Viewpoint

            ActiveCamera              = new SceneCamera(this.Width, this.Height);
            ActiveCamera.Position     = new Vector3(-1.175851f, -0.8195555f, 3.945387f);
            ActiveCamera.Orientation  = new Quaternion(0.001025718f, 0.9989654f, -0.02997796f, -0.03418033f);
            ActiveCamera.camera_pitch = -0.0600000024f;
            ActiveCamera.camera_roll  = 0.0f;
            ActiveCamera.camera_yaw   = 3.20999742f;

            this.Keyboard.KeyUp += new EventHandler <OpenTK.Input.KeyboardKeyEventArgs>(Keyboard_KeyUp);
        }
Ejemplo n.º 14
0
        /// <summary>
        ///
        /// </summary>
        public OutputWindow(string windowTitle, Vector2i outputSize, VSyncMode vSyncMode) : base(outputSize.X, outputSize.Y, GraphicsMode.Default, windowTitle)
        {
            Keyboard.KeyDown += OnKeyDown;
            Mouse.ButtonDown += OnMouseButtonDown;
            Mouse.ButtonUp   += OnMouseButtonUp;
            Mouse.Move       += OnMouseMove;
            Closing          += OnClosing;

            OutputSize   = outputSize;
            WindowBorder = OpenTK.WindowBorder.Fixed;
            VSync        = vSyncMode;

            lastFrameDrawn = 0;

            Log.Instance.AddMsg(LogLevel.Debug, string.Format("VSync: {0}", VSync.ToString()));
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Creates a new WindowOptions struct, with sensible defaults.
 /// </summary>
 public WindowOptions(bool isVisible, bool useSingleThreadedWindow, Point position, Size size,
                      double framesPerSecond,
                      double updatesPerSecond, GraphicsAPI api, string title, WindowState windowState, WindowBorder windowBorder,
                      VSyncMode vSync, int isRunningSlowlyThreshold)
 {
     IsVisible = isVisible;
     UseSingleThreadedWindow = useSingleThreadedWindow;
     Position         = position;
     Size             = size;
     FramesPerSecond  = framesPerSecond;
     UpdatesPerSecond = updatesPerSecond;
     API                  = api;
     Title                = title;
     WindowState          = windowState;
     WindowBorder         = windowBorder;
     VSync                = vSync;
     RunningSlowTolerance = isRunningSlowlyThreshold;
 }
Ejemplo n.º 16
0
        public static void setVSync(VSyncMode v)
        {
            EnsureUndisposed();
            GraphicsContext.Assert();
            switch (v)
            {
            case VSyncMode.On:
                getContext().SwapInterval = 1;
                break;

            case VSyncMode.Off:
                getContext().SwapInterval = 0;
                break;

            case VSyncMode.Adaptive:
                getContext().SwapInterval = -1;
                break;
            }
        }
        public static async Task LoadBrowserWithURLAsync()
        {
#if VSYNC_OFF
            VSync = VSyncMode.Off;
#else
            VSync = VSyncMode.On;
#endif

            await Task.Run(() =>
            {
                browser       = new X3DBrowser(VSync, url, Resolution.Size800x600, new GraphicsMode(32, 16, 0, 4));
                browser.Title = "Initilising..";
#if VSYNC_OFF
                browser.Run();
#else
                browser.Run(60);
#endif
            });
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Create a new GlfwWindow.
        /// </summary>
        /// <param name="options">The options to use for this window.</param>
        public GlfwWindow(WindowOptions options, GlfwWindow parent, GlfwMonitor monitor)
        {
            // Title and Size must be set before the window is created.
            _title = options.Title;
            _size  = options.Size;

            _windowBorder = WindowBorder;
            _vSync        = options.VSync;

            FramesPerSecond  = options.FramesPerSecond;
            UpdatesPerSecond = options.UpdatesPerSecond;

            RunningSlowTolerance    = options.RunningSlowTolerance;
            UseSingleThreadedWindow = options.UseSingleThreadedWindow;
            ShouldSwapAutomatically = options.ShouldSwapAutomatically;

            _initialOptions = options;
            _initialMonitor = monitor;
            Parent          = (IWindowHost)parent ?? _initialMonitor;
            IsEventDriven   = options.IsEventDriven;

            GlfwProvider.GLFW.Value.GetVersion(out var major, out var minor, out _);
            if (new Version(major, minor) < new Version(3, 3))
            {
                throw new NotSupportedException("GLFW 3.3 or later is required for Silk.NET.Windowing.Desktop.");
            }

            if (options.API.API == ContextAPI.Vulkan)
            {
                VkSurface = new Surface(this);
            }
            else if (options.API.API == ContextAPI.OpenGL || options.API.API == ContextAPI.OpenGLES)
            {
                GLContext = new Context(this);
            }

            Glfw.ThrowExceptions();
        }
Ejemplo n.º 19
0
 public void SwitchVSync(VSyncMode vsync)
 {
     VSync = vsync;
 }
Ejemplo n.º 20
0
 public void SetVSyncMode(VSyncMode mode)
 {
     VSync = mode;
     Debug.Log("Enabled " + mode);
 }
 public BuilderApplication(VSyncMode VSync, Resolution res, GraphicsMode mode) : base(res.Width, res.Height, mode)
 {
     ActiveCamera = new SceneCamera(this.Width, this.Height);
 }
Ejemplo n.º 22
0
 public GameBuilder SetVSync(VSyncMode mode)
 {
     _game.VSync = mode;
     return(this);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Default Constructor. Builds a 600x800 window.
 /// </summary>
 public VideoSettings()
 {
     VSync      = VSyncMode.Off;
     Size       = new Size(800, 600);
     Fullscreen = false;
 }