本文整理汇总了C#中SFML.Graphics.RenderWindow.SetVerticalSyncEnabled方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.SetVerticalSyncEnabled方法的具体用法?C# RenderWindow.SetVerticalSyncEnabled怎么用?C# RenderWindow.SetVerticalSyncEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.SetVerticalSyncEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: createDisplay
public static void createDisplay(bool VSync = false,int FPSCap = 60)
{
try
{
//Configure the settings of the Window
ContextSettings settings = new ContextSettings(24, 8, 4, 3, 2);
window = new RenderWindow(new VideoMode(Convert.ToUInt32(WIDTH), Convert.ToUInt32(HEIGHT)), "OpenGL", Styles.Default, settings);
Logger.Log(window.Settings.ToString(), Logger.Symbols.Warning);
if (VSync)
{
window.SetVerticalSyncEnabled(VSync);
}else
{
window.SetFramerateLimit(Convert.ToUInt32(FPSCap));
}
//Setup EventHandler
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
window.Resized += new EventHandler<SizeEventArgs>(OnResized);
//Init OpenTK
Toolkit.Init();
OpenTK.Graphics.GraphicsContext context = new OpenTK.Graphics.GraphicsContext(new ContextHandle(IntPtr.Zero), null);
GL.Viewport(0, 0, WIDTH, HEIGHT);
}
catch (Exception e)
{
Console.Error.WriteLine(e.StackTrace);
}
}
示例2: Main
internal static void Main(string[] args)
{
shapes = new List<Shape>();
window = new RenderWindow(new VideoMode(WINDOW_SIZE.X, WINDOW_SIZE.Y), "Physics Playground", Styles.Titlebar | Styles.Close);
window.SetVerticalSyncEnabled(true);
window.SetKeyRepeatEnabled(false);
SetupEvents();
Time lastTime = clock.ElapsedTime;
while(window.IsOpen)
{
Time now = clock.ElapsedTime;
Time frame = now - lastTime;
lastTime = now;
lag += frame;
while(lag >= dt)
{
window.DispatchEvents();
if(!paused)
{
Update();
}
lag -= dt;
}
Draw();
}
}
示例3: Game
public Game(uint width = 1365, uint height = 768)
{
if (!File.Exists(IniFileName))
{
MessageBox.Show(string.Format("Brak pliku {0}!", IniFileName));
Environment.Exit(1);
}
ReadIniFile(IniFileName);
Players = new Dictionary<int, PlayerInstance>();
Width = width;
Height = height;
var settings = new ContextSettings { AntialiasingLevel = 8 };
Window = new RenderWindow(new VideoMode(Width, Height), "Nano War", Styles.Close, settings);
Window.Closed += (s, a) =>
{
GameClient.GameClient.Dispose();
Window.Close();
};
Window.SetVerticalSyncEnabled(true);
Window.SetKeyRepeatEnabled(false);
StateMachine = new StateMachine();
AudioManager = new AudioManager();
}
示例4: Main
public static void Main(string[] args)
{
window = new RenderWindow(new VideoMode(800, 600), "SFML window");
window.SetVisible(true);
window.SetVerticalSyncEnabled(true);
window.Closed += OnClosed;
window.MouseMoved += OnMouse;
window.MouseLeft += Window_MouseLeft;
window.Resized += Window_Resized;
List<Button> buttons = new List<Button>();
for (int i = 0; i < 10; i++)
{
buttons.Add(new Button(new Vector2f(i*200, 100), new Vector2f(75, 20)));
}
while (window.IsOpen)
{
window.DispatchEvents();
window.Clear(new Color(50, 50, 50));
GUIManager.GuiManager.Update(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y);
foreach (var item in buttons)
{
window.Draw(item);
}
window.Display();
}
}
示例5: initialise
public static void initialise()
{
window = new RenderWindow(new VideoMode(RESOLUTION_X, RESOLUTION_Y), "Asialaide");
// Video settings.
window.SetFramerateLimit(FRAME_LIMIT);
window.SetVerticalSyncEnabled(VSYNC);
}
示例6: SfmlControl
public SfmlControl()
{
m_renderWindow = new RenderWindow(this.Handle);
m_renderWindow.SetVerticalSyncEnabled(true);
//add resize event handler
this.Resize += SfmlControl_Resize;
SfmlControl_Resize(this, EventArgs.Empty);
}
示例7: Game
Game()
{
Window = new RenderWindow(new VideoMode(1024u, 768u), "Living Space");
Window.SetVisible(true);
Window.SetVerticalSyncEnabled(true);
Window.SetFramerateLimit(30);
Window.Closed += OnWindowClosed;
}
示例8: Run
public void Run()
{
TextureLoader.Init();
Window = new RenderWindow(videoMode, title, Styles.Close);
States = new RenderStates(RenderStates.Default);
Window.Closed += (s, e) =>
{
Console.WriteLine("Closing...");
Window.Close();
};
Window.SetVerticalSyncEnabled(true);
defaultView = Window.DefaultView;
gameView = Window.DefaultView;
gameView.Viewport = new FloatRect(0, 0, .85f, .85f);
BackgroundColor = new Color(100, 149, 237); // dat cornflower blue
Tilemap = new Tilemap(this);
SelectedTileID = 1;
var timer = new Stopwatch();
while (Window.IsOpen)
{
timer.Restart();
Window.DispatchEvents();
var mouse = Mouse.GetPosition(Window);
//if (Mouse.IsButtonPressed(Mouse.Button.Right))
// gameView.Move(new Vector2f(prevMouse.X - mouse.X, prevMouse.Y - mouse.Y));
Tilemap.Update(Frametime);
Window.Clear(BackgroundColor);
Window.SetView(gameView);
Tilemap.Draw(Window, States);
Window.SetView(defaultView);
Debug.Draw(Window);
Window.Display();
prevMouse = mouse;
timer.Stop();
Frametime = (float)timer.Elapsed.TotalMilliseconds;
Window.SetTitle($"{title} ({(1d / timer.Elapsed.TotalSeconds):0}fps)");
}
}
示例9: WindowManager
public WindowManager()
{
//Init main window shit
window = new RenderWindow(new VideoMode(640, 480), "Super cool window title!");
window.SetVerticalSyncEnabled(true);
window.SetActive(true);
window.Closed += window_Closed;
// Open gl
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glLoadIdentity();
Gl.glOrtho(0, 640, 480, 0, 0, 1);
Gl.glMatrixMode(Gl.GL_MODELVIEW);
Gl.glDisable(Gl.GL_DEPTH_TEST);
Gl.glLoadIdentity();
Gl.glTranslatef(0.375f, 0.375f, 0);
particles = new CircleShape[pcount];
for (int i = 0; i < pcount; i++)
{
particles[i] = new CircleShape(4f);
particles[i].FillColor = Color.White;
particles[i].Position = new Vector2f(0, 0);
particles[i].Radius = 4;
}
circletest = new CircleShape();
circletest.Position = new Vector2f(100, 100);
circletest.OutlineColor = Color.Red;
circletest.OutlineThickness = 1;
circletest.FillColor = Color.Black;
circletest.Radius = 100;
circletest2 = new CircleShape();
circletest2.Position = new Vector2f(200, 300);
circletest2.OutlineColor = Color.Red;
circletest2.OutlineThickness = 1;
circletest2.FillColor = Color.Black;
circletest2.Radius = 100;
mytext = new Text("test", new Font("arial.ttf"), 16);
mytext.Position = new Vector2f(4, 4);
mytext.Color = Color.White;
mytext.Style = Text.Styles.Bold;
mytextShadow = new Text("test", new Font("arial.ttf"), 16);
mytextShadow.Position = new Vector2f(6, 6);
mytextShadow.Color = Color.Black;
sim = new Simulation();
sim.InitSimulation(pcount);
}
示例10: Main
public static void Main()
{
#region Initialize Variables
window = new RenderWindow(new VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Reflexes For Friends", Styles.Default, new ContextSettings(32, 0));
timer = new Stopwatch();
world = new GameWorld(new Texture("resources/background-grass.png"));
player = new Player(new Texture("resources/player.png"));
friend = new Friend(new Texture("resources/friend.png"));
enemies = new List<Enemy>();
gameOver = false;
#endregion
#region Register Event Handlers
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
window.KeyReleased += new EventHandler<KeyEventArgs>(OnKeyReleased);
#endregion
#region Setup Modules
keyboardModule = new KeyboardModule();
#endregion
RegisterKeyBindings();
GenerateEnemies();
timer.Start();
long timeSinceLastUpdate = 0;
window.SetVerticalSyncEnabled(true);
window.SetActive();
while (window.IsOpen())
{
window.DispatchEvents();
if (!gameOver)
{
timeSinceLastUpdate += timer.ElapsedMilliseconds;
timer.Restart();
if (timeSinceLastUpdate >= UPDATE_FREQUENCY_IN_MS)
{
UpdateGame(UPDATE_FREQUENCY_IN_MS);
timeSinceLastUpdate -= UPDATE_FREQUENCY_IN_MS;
}
}
DrawGame();
window.Display();
}
timer.Stop();
}
示例11: GameWindow
public GameWindow(int mScreenWidth, int mScreenHeight, int mPixelMultiplier)
{
_stopwatch = new PerformanceStopwatch();
_width = mScreenWidth;
_height = mScreenHeight;
RenderWindow = new RenderWindow(new VideoMode((uint) _width, (uint) _height), "", Styles.Default);
RenderWindow.SetVerticalSyncEnabled(false);
if (Settings.Framerate.IsLimited) RenderWindow.SetFramerateLimit((uint) Settings.Framerate.Limit);
RenderWindow.Position = new Vector2i(400, 80);
RenderWindow.Size = new Vector2u((uint) (mScreenWidth*mPixelMultiplier), (uint) (mScreenHeight*mPixelMultiplier));
RenderWindow.GainedFocus += WindowGainedFocus;
RenderWindow.LostFocus += WindowLostFocus;
}
示例12: SetupWindow
public void SetupWindow()
{
// create window
_window = new RenderWindow (new VideoMode (1000, 800), "Equation Invasion! - Tainted Mustard", Styles.Close);
_window.SetVerticalSyncEnabled (true);
_window.SetFramerateLimit(60);
// setup SFML event handlers
_window.Closed += new EventHandler(OnClosed);
_window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
_window.KeyReleased += new EventHandler<KeyEventArgs> (OnKeyReleased);
_window.MouseButtonPressed += new EventHandler<MouseButtonEventArgs>(OnMouseClicked);
_window.TextEntered += new EventHandler<TextEventArgs>(OnTextEntered);
}
示例13: InitializeWindow
private static void InitializeWindow()
{
//Construct
window = new RenderWindow(new VideoMode(1920, 1080), "Orbs", IsFullscreen ? Styles.Fullscreen : Styles.Default);
//Set parameters
window.SetVisible(true);
window.SetMouseCursorVisible(false);
window.SetVerticalSyncEnabled(IsVSyncEnabled);
//Bind events
window.Closed += (sender, i) => window.Close();
window.KeyPressed += (sender, i) => stateManager.CurrentState?.HandleKeyPressed(i);
window.KeyPressed += (sender, i) => { if (i.Code == Keyboard.Key.F11) { window.Close(); IsFullscreen = !IsFullscreen; InitializeWindow(); } };
}
示例14: Initialize
/// <summary>
/// Initialize the game. Call once after modifying GameOptions.
/// </summary>
public static void Initialize()
{
var style = Styles.Titlebar | Styles.Close;
if (GameOptions.Resizable)
style |= Styles.Resize;
size = new Vector2f(GameOptions.Width, GameOptions.Height);
running = true;
Window = new RenderWindow(new VideoMode(GameOptions.Width, GameOptions.Height), GameOptions.Caption, style);
Window.SetFramerateLimit(GameOptions.Framerate);
Window.SetVerticalSyncEnabled(GameOptions.Vsync);
if (!string.IsNullOrWhiteSpace(GameOptions.Icon))
{
var icon = Assets.LoadTexture(GameOptions.Icon);
Window.SetIcon(icon.Size.X, icon.Size.Y, icon.CopyToImage().Pixels);
}
Framerate = GameOptions.Framerate;
#region Event Wrappers
Window.Closed += (sender, args) => Exit(true);
Window.Resized += (sender, args) => Resize(new Vector2f(args.Width, args.Height));
Window.MouseButtonPressed += (sender, args) => DispatchEvent(new MouseButtonInputArgs(args.Button, true, args.X, args.Y));
Window.MouseButtonReleased += (sender, args) => DispatchEvent(new MouseButtonInputArgs(args.Button, false, args.X, args.Y));
Window.MouseWheelMoved += (sender, args) => DispatchEvent(new MouseWheelInputArgs(args.Delta, args.X, args.Y));
Window.MouseMoved += (sender, args) => DispatchEvent(new MouseMoveInputArgs(args.X, args.Y));
Window.TextEntered += (sender, args) => DispatchEvent(new TextInputArgs(args.Unicode));
Window.KeyPressed += (sender, args) =>
{
if (args.Code == Keyboard.Key.Unknown || KeyStates[(int)args.Code]) // repeated key press
return;
KeyStates[(int)args.Code] = true;
DispatchEvent(new KeyInputArgs(args.Code, true, args.Control, args.Shift));
};
Window.KeyReleased += (sender, args) =>
{
if (args.Code != Keyboard.Key.Unknown)
KeyStates[(int)args.Code] = false;
DispatchEvent(new KeyInputArgs(args.Code, false, args.Control, args.Shift));
};
#endregion
}
示例15: Initialize
public static void Initialize()
{
var style = Styles.Titlebar | Styles.Close;
if (GameOptions.Resizable)
style |= Styles.Resize;
size = new Vector2f(GameOptions.Width, GameOptions.Height);
Window = new RenderWindow(new VideoMode(GameOptions.Width, GameOptions.Height), GameOptions.Caption, style);
Window.SetFramerateLimit(GameOptions.Framerate);
Window.SetVerticalSyncEnabled(GameOptions.Vsync);
if (GameOptions.Icon != "")
{
Texture texture = Assets.LoadTexture(GameOptions.Icon);
Window.SetIcon(texture.Size.X, texture.Size.Y, texture.CopyToImage().Pixels);
}
Window.Closed += (sender, args) => Window.Close();
Window.Resized += (sender, args) => Resize(new Vector2f(args.Width, args.Height));
Window.MouseButtonPressed += (sender, args) => DispatchEvent(new MouseButtonInputArgs(args.Button, true, args.X, args.Y));
Window.MouseButtonReleased += (sender, args) => DispatchEvent(new MouseButtonInputArgs(args.Button, false, args.X, args.Y));
Window.MouseWheelMoved += (sender, args) => DispatchEvent(new MouseWheelInputArgs(args.Delta, args.X, args.Y));
Window.MouseMoved += (sender, args) => DispatchEvent(new MouseMoveInputArgs(args.X, args.Y));
Window.TextEntered += (sender, args) => DispatchEvent(new TextInputArgs(args.Unicode));
Window.KeyPressed += (sender, args) =>
{
if (args.Code == Keyboard.Key.Unknown || keyStates[(int)args.Code]) // repeated key press
return;
keyStates[(int)args.Code] = true;
DispatchEvent(new KeyInputArgs(args.Code, true, args.Control, args.Shift));
};
Window.KeyReleased += (sender, args) =>
{
if (args.Code != Keyboard.Key.Unknown)
keyStates[(int)args.Code] = false;
DispatchEvent(new KeyInputArgs(args.Code, false, args.Control, args.Shift));
};
}