本文整理汇总了C#中SFML.Graphics.RenderWindow.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.Dispose方法的具体用法?C# RenderWindow.Dispose怎么用?C# RenderWindow.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Texture textureBack = new Texture(File.ReadAllBytes(@"assets/back.png"));
textureBack.Smooth = true;
Sprite spriteBack = new Sprite(textureBack, new IntRect(0, 0, 800, 500));
Texture textureLock = new Texture(File.ReadAllBytes(@"assets/lock.png"));
textureLock.Smooth = true;
Sprite spriteLock = new Sprite(textureLock, new IntRect(0, 0, 80, 80));
spriteLock.Position = new Vector2f(76, 68);
icons = new List<Sprite>();
for (int index = 0; index < 15; index++)
{
int col = index % 5;
int row = (index - col) / 5;
Texture textureIcon = new Texture(File.ReadAllBytes(String.Format(@"assets/buttons/{0:00}.png", index + 1)));
textureIcon.Smooth = true;
Sprite spriteIcon = new Sprite(textureIcon, new IntRect(0, 0, 72, 72));
spriteIcon.Position = new Vector2f(80 + col * 72 + col * 70, 72 + row * 72 + row * 70);
icons.Add(spriteIcon);
}
ContextSettings context = new ContextSettings();
context.DepthBits = 32;
RenderWindow window = new RenderWindow(new VideoMode(800, 500), String.Empty, Styles.Default, context);
window.SetActive();
window.SetVisible(true);
window.SetKeyRepeatEnabled(true);
window.SetMouseCursorVisible(true);
window.SetVerticalSyncEnabled(false);
window.Closed += new EventHandler(
delegate(object sender, EventArgs e)
{
window.Close();
window.Dispose();
}
);
window.GainedFocus += new EventHandler(
delegate(object sender, EventArgs e)
{
}
);
window.LostFocus += new EventHandler(
delegate(object sender, EventArgs e)
{
}
);
window.KeyPressed += new EventHandler<KeyEventArgs>(
delegate(object sender, KeyEventArgs e)
{
if (e.Code == Keyboard.Key.Escape)
{
/*
sound.Stop();
sound.Dispose();
buffer.Dispose();
*/
window.Close();
window.Dispose();
}
if (e.Code == Keyboard.Key.Right)
{
if (col < 4)
{
col += 1;
}
}
//.........这里部分代码省略.........
示例2: Main
static void Main()
{
Console.Title = "Tetraquark Console";
Running = true;
const string ConfigFile = "cfg.yaml";
if (File.Exists(ConfigFile)) {
Console.WriteLine("Loading config file {0}", ConfigFile);
Settings.Load(File.ReadAllText(ConfigFile));
}
GameWatch = new Stopwatch();
GameWatch.Start();
PackMgr.Mount("Default.zip");
string[] Files = PackMgr.GetFiles();
for (int i = 0; i < Files.Length; i++) {
if (Files[i].StartsWith("resources/fonts/"))
ResourceMgr.Register<Font>(PackMgr.OpenFile(Files[i]), Path.GetFileNameWithoutExtension(Files[i]));
else if (Files[i].StartsWith("resources/textures/"))
ResourceMgr.Register<Texture>(PackMgr.OpenFile(Files[i]), Path.GetFileNameWithoutExtension(Files[i]));
}
Scales.Init(new Vector2f(ResX, ResY));
// OpenTK
ToolkitOptions TOpt = ToolkitOptions.Default;
TOpt.Backend = PlatformBackend.PreferNative;
TOpt.EnableHighResolution = true;
Toolkit.Init(TOpt);
// SFML
VideoMode VMode = new VideoMode((uint)Scales.XRes, (uint)Scales.YRes, (uint)BitsPerPixel);
ContextSettings CSet = new ContextSettings((uint)DepthBits, (uint)StencilBits);
CSet.MajorVersion = 4;
CSet.MinorVersion = 2;
CSet.AntialiasingLevel = (uint)Samples;
Styles S = Styles.None;
if (Border)
S |= Styles.Titlebar | Styles.Close;
RenderWindow RWind = new RenderWindow(VMode, "Tetraquark", S, CSet);
RWind.Closed += (Snd, E) => Running = false;
RWind.SetKeyRepeatEnabled(false);
// OpenTK
IWindowInfo WindInfo = Utilities.CreateWindowsWindowInfo(RWind.SystemHandle);
var GfxMode = new GraphicsMode(new ColorFormat(BitsPerPixel), DepthBits, StencilBits, Samples, new ColorFormat(0));
var GfxCtx = new GraphicsContext(GfxMode, WindInfo, (int)CSet.MajorVersion, (int)CSet.MinorVersion,
GfxCtxFlags.Default);
GfxCtx.MakeCurrent(WindInfo);
GfxCtx.LoadAll();
RWind.ResetGLStates();
//GL.Enable(EnableCap.FramebufferSrgb);
Renderer.Init(RWind);
Stopwatch Clock = new Stopwatch();
Clock.Start();
while (Running) {
RWind.DispatchEvents();
while (Clock.ElapsedMilliseconds < 10)
;
float Dt = (float)Clock.ElapsedMilliseconds / 1000;
Clock.Restart();
Renderer.Update(Dt);
Renderer.Draw(RWind);
RWind.Display();
}
RWind.Close();
RWind.Dispose();
Console.WriteLine("Flushing configs");
File.WriteAllText(ConfigFile, Settings.Save());
Environment.Exit(0);
}
示例3: Main
static void Main()
{
//try
{
const int width = 1024;
const int height = 768;
// Create main window
m_Window = new RenderWindow(new VideoMode(width, height), "GWEN.Net SFML test", Styles.Titlebar|Styles.Close|Styles.Resize, new ContextSettings(32, 0));
// Setup event handlers
m_Window.Closed += OnClosed;
m_Window.KeyPressed += OnKeyPressed;
m_Window.Resized += OnResized;
m_Window.KeyReleased += window_KeyReleased;
m_Window.MouseButtonPressed += window_MouseButtonPressed;
m_Window.MouseButtonReleased += window_MouseButtonReleased;
m_Window.MouseWheelMoved += window_MouseWheelMoved;
m_Window.MouseMoved += window_MouseMoved;
m_Window.TextEntered += window_TextEntered;
//m_Window.SetFramerateLimit(60);
const int fps_frames = 50;
List<long> ftime = new List<long>(fps_frames);
long lastTime = 0;
// create GWEN renderer
Renderer.SFML gwenRenderer = new Renderer.SFML(m_Window);
// Create GWEN skin
//Skin.Simple skin = new Skin.Simple(GwenRenderer);
Skin.TexturedBase skin = new Skin.TexturedBase(gwenRenderer, "DefaultSkin.png");
// set default font
Font defaultFont = new Font(gwenRenderer) {Size = 10, FaceName = "Arial Unicode MS"};
// try to load, fallback if failed
if (gwenRenderer.LoadFont(defaultFont))
{
gwenRenderer.FreeFont(defaultFont);
}
else // try another
{
defaultFont.FaceName = "Arial";
if (gwenRenderer.LoadFont(defaultFont))
{
gwenRenderer.FreeFont(defaultFont);
}
else // try default
{
defaultFont.FaceName = "OpenSans.ttf";
}
}
skin.SetDefaultFont(defaultFont.FaceName);
defaultFont.Dispose(); // skin has its own
// Create a Canvas (it's root, on which all other GWEN controls are created)
m_Canvas = new Canvas(skin);
m_Canvas.SetSize(width, height);
m_Canvas.ShouldDrawBackground = true;
m_Canvas.BackgroundColor = System.Drawing.Color.FromArgb(255, 150, 170, 170);
m_Canvas.KeyboardInputEnabled = true;
// create the unit test control
m_UnitTest = new UnitTest.UnitTest(m_Canvas);
// Create GWEN input processor
m_Input = new Input.SFML();
m_Input.Initialize(m_Canvas, m_Window);
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
while (m_Window.IsOpen())
{
m_Window.SetActive();
m_Window.DispatchEvents();
m_Window.Clear();
// Clear depth buffer
Gl.glClear(Gl.GL_DEPTH_BUFFER_BIT | Gl.GL_COLOR_BUFFER_BIT);
if (ftime.Count == fps_frames)
ftime.RemoveAt(0);
ftime.Add(stopwatch.ElapsedMilliseconds - lastTime);
lastTime = stopwatch.ElapsedMilliseconds;
if (stopwatch.ElapsedMilliseconds > 1000)
{
m_UnitTest.Fps = 1000f * ftime.Count / ftime.Sum();
stopwatch.Restart();
}
// render GWEN canvas
m_Canvas.RenderCanvas();
m_Window.Display();
}
//.........这里部分代码省略.........