本文整理汇总了C#中SFML.Graphics.RenderWindow.SetActive方法的典型用法代码示例。如果您正苦于以下问题:C# RenderWindow.SetActive方法的具体用法?C# RenderWindow.SetActive怎么用?C# RenderWindow.SetActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFML.Graphics.RenderWindow
的用法示例。
在下文中一共展示了RenderWindow.SetActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
private static void Main(string[] args)
{
var contextSettings = new ContextSettings {
DepthBits = 32
};
var window = new RenderWindow(new VideoMode(640, 480), "JukeSaver spike: SFML Basic", Styles.Default, contextSettings);
window.SetActive();
window.Closed += OnClosed;
window.KeyPressed += OnKeyPressed;
int r = 0, g = 0, b = 0;
var shape = new CircleShape() {
Position = new Vector2f(320, 240),
};
while (window.IsOpen()) {
window.DispatchEvents();
window.Clear(new Color((byte)r, (byte)g, (byte)b));
shape.Radius = (float)(80.0 + GetPulse() * 40.0);
shape.Origin = new Vector2f(shape.Radius * 0.5f, shape.Radius * 0.5f);
shape.Position = new Vector2f(320 - shape.Radius * 0.5f, 240 - shape.Radius * 0.5f);
shape.FillColor = new Color(50, (byte)(160 + 80 * GetPulse()), (byte)(40 - (40 * GetPulse())));
window.Draw(shape);
window.Display();
}
}
示例2: InitializeWindow
private static void InitializeWindow()
{
Window = new RenderWindow(new VideoMode(1600, 900, 32), "Planet Simulation", Styles.Default);
//window.SetVerticalSyncEnabled(true);
Window.SetActive(false);
Window.SetVisible(true);
Window.Closed += WindowClosedEvent;
}
示例3: InitializeGameLoop
public static void InitializeGameLoop(/*Insert arguments here*/)
{
//Insert initialization here:
window = new RenderWindow(new VideoMode(800, 600), "test");
window.SetActive();
SpriteManager.Initialize();
SpriteManager.CreateCircle();
MainLoop();
}
示例4: 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);
}
示例5: 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();
}
示例6: Start
public static void Start()
{
pixels = new List<Pixel>();
window = new RenderWindow(new VideoMode((uint)Width,(uint)Height), "I Am Goc");
window.SetFramerateLimit(120);
Load();
window.MouseMoved += setMousePos;
while (window.IsOpen()){
window.SetActive();
window.DispatchEvents();
Update();
window.Display();
Count++;
}
}
示例7: Main
static void Main(string[] args)
{
var videoMode = new VideoMode(1000, 700);
var contextSettings = new ContextSettings(0, 0, 4);
RenderWindow window = new RenderWindow(videoMode, "Luda Diaria", Styles.Default, contextSettings);
window.SetActive(true);
window.Closed += (sender, e) => window.Close();
Global.Window = window;
Randomizer.Generator = new Random(42);
var input = InputManager.Instance;
input.Init();
StateManager.Instance.CurrentState = new LoadingState();
var lastTick = DateTime.Now;
const float maxTimeStep = 0.5f;
while (window.IsOpen())
{
float dt = (float)((DateTime.Now - lastTick).TotalSeconds);
lastTick = DateTime.Now;
window.DispatchEvents();
window.Clear(Color.Black);
if (input.IsKeyPressed(Keyboard.Key.Escape))
{
window.Close();
}
while (dt > 0)
{
//---UPDATE
var deltatTime = dt < maxTimeStep ? dt : maxTimeStep;
StateManager.Instance.CurrentState.Update(deltatTime);
dt -= maxTimeStep;
}
//---DRAW
StateManager.Instance.CurrentState.Draw(window, RenderStates.Default);
window.Display();
}
}
示例8: Main
private static void Main(string[] args)
{
var contextSettings = new ContextSettings { DepthBits = 32 };
var window = new RenderWindow(new VideoMode(640, 480), "SFML.Net starter kit", Styles.Default, contextSettings);
window.SetActive();
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
int r=0,g=0,b=0;
while (window.IsOpen())
{
window.DispatchEvents();
window.Clear(new Color((byte)r, (byte)g, (byte)b));
window.Display();
}
}
示例9: FboTest
public FboTest()
{
Text = new Text("", new Font("lekton.ttf"), 20)
{
Color=Color.White,
Position = new Vector2f(10,10),
};
textureOne = new SFML.Graphics.RenderTexture(32,32);
textureTwo = new SFML.Graphics.RenderTexture(640,480);
textureThree = new SFML.Graphics.RenderTexture(640,480);
shapeTwo = new RectangleShape(new Vector2f(20,20)){ FillColor = Color.Red, };
shapeThree = new RectangleShape(new Vector2f(40,40)){ FillColor = new Color(0,0,0,30), Origin = new Vector2f(20,20) };
window = new RenderWindow(new VideoMode(640, 480), "SFML.Net RenderTexture FBO bug spike", Styles.Default, new ContextSettings { DepthBits = 32 });
window.SetActive();
window.Closed += OnClosed;
window.KeyPressed += OnKeyPressed;
}
示例10: Main
public static void Main()
{
var resolution = new VideoMode(WIDTH, HEIGHT, 32);
var windowSettings = new ContextSettings(32, 0, 4);
var window = new RenderWindow(resolution, "Lockheed the Game", Styles.Close, windowSettings);
window.Closed += Events.OnClose;
window.KeyPressed += Events.OnKeyPressed;
window.KeyReleased += Events.OnKeyReleased;
window.MouseButtonPressed += Events.OnMouseButtonPressed;
window.SetActive();
Level.Level newLevel = Level.Level.GenerateSingleLevel();
Character.Character glava = new Rogue("glava");
glava.CurrentSkill = new ProjectileSkill(
"fireball", 10, 10, 10, Tier.Beginner, 5, "weapons/projectiles/fireBall.png", 5);
EntityManager.CurrentLevel = newLevel;
EntityManager.Character = glava;
DateTime lastTick = DateTime.Now;
while (window.IsOpen())
{
float dt = (float)(DateTime.Now - lastTick).TotalMilliseconds;
lastTick = DateTime.Now;
window.DispatchEvents();
while (dt > 0)
{
EntityManager.Update();
dt -= MAX_TIMESTEP;
}
window.Clear(Color.Black);
EntityManager.Draw(window);
window.Display();
}
}
示例11: Main
static void Main(string[] args)
{
Log.GlobalLevel = Log.Level.Debug;
RenderWindow app = new RenderWindow(new VideoMode(800, 600), "HP!",
Styles.Default, new ContextSettings(0, 0, 4));
app.SetFramerateLimit(60);
app.Closed += delegate { app.Close(); };
app.SetVisible(true);
app.SetActive(true);
L.I("Assuming assets in \"assets\"");
Assets assets = new Assets("assets");
LoadAnimations(assets);
Level level1 = assets.Level("level1.json");
Game game = new Game(assets, level1);
var view = new View();
int lastFrameTime = Environment.TickCount;
while (app.IsOpen) {
app.DispatchEvents();
float aspect = (float)app.Size.X / app.Size.Y;
float targetWidth = 20, targetHeight = targetWidth / aspect;
view.Reset(new FloatRect(0, 0, targetWidth, targetHeight));
app.SetView(view);
int ticks = Environment.TickCount;
float delta = (ticks - lastFrameTime) / 1000F;
lastFrameTime = ticks;
game.Update(delta);
game.Render(app);
app.Display();
}
}
示例12: 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();
}
//.........这里部分代码省略.........
示例13: OnRenderWindowChanged
/// <summary>
/// Handles the <see cref="IGameContainer.RenderWindowChanged"/> event.
/// </summary>
/// <param name="oldValue">The old value.</param>
/// <param name="newValue">The new value.</param>
protected virtual void OnRenderWindowChanged(RenderWindow oldValue, RenderWindow newValue)
{
if (newValue == null)
return;
newValue.SetMouseCursorVisible(ShowMouseCursor);
newValue.SetVerticalSyncEnabled(UseVerticalSync);
newValue.SetActive();
newValue.SetVisible(true);
}
示例14: Main
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
// Request a 32-bits depth buffer when creating the window
ContextSettings contextSettings = new ContextSettings();
contextSettings.DepthBits = 32;
// Create the main window
RenderWindow window = new RenderWindow(new VideoMode(800, 600), "SFML graphics with OpenGL", Styles.Default, contextSettings);
window.SetVerticalSyncEnabled(true);
// Make it the active window for OpenGL calls
window.SetActive();
// Setup event handlers
window.Closed += new EventHandler(OnClosed);
window.KeyPressed += new EventHandler<KeyEventArgs>(OnKeyPressed);
window.Resized += new EventHandler<SizeEventArgs>(OnResized);
// Create a sprite for the background
Sprite background = new Sprite(new Texture("resources/background.jpg"));
// Create a text to display on top of the OpenGL object
Text text = new Text("SFML / OpenGL demo", new Font("resources/sansation.ttf"));
text.Position = new Vector2f(250, 450);
text.Color = new Color(255, 255, 255, 170);
// Load an OpenGL texture.
// We could directly use a SFML.Graphics.Texture as an OpenGL texture (with its Bind() member function),
// but here we want more control on it (generate mipmaps, ...) so we create a new one
int texture = 0;
using (Image image = new Image("resources/texture.jpg"))
{
Gl.glGenTextures(1, out texture);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
Glu.gluBuild2DMipmaps(Gl.GL_TEXTURE_2D, Gl.GL_RGBA, (int)image.Size.X, (int)image.Size.Y, Gl.GL_RGBA, Gl.GL_UNSIGNED_BYTE, image.Pixels);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR);
Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR_MIPMAP_LINEAR);
}
// Enable Z-buffer read and write
Gl.glEnable(Gl.GL_DEPTH_TEST);
Gl.glDepthMask(Gl.GL_TRUE);
Gl.glClearDepth(1);
// Disable lighting
Gl.glDisable(Gl.GL_LIGHTING);
// Configure the viewport (the same size as the window)
Gl.glViewport(0, 0, (int)window.Size.X, (int)window.Size.Y);
// Setup a perspective projection
Gl.glMatrixMode(Gl.GL_PROJECTION);
Gl.glLoadIdentity();
float ratio = (float)(window.Size.X) / window.Size.Y;
Gl.glFrustum(-ratio, ratio, -1, 1, 1, 500);
// Bind the texture
Gl.glEnable(Gl.GL_TEXTURE_2D);
Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture);
// Define a 3D cube (6 faces made of 2 triangles composed by 3 vertices)
float[] cube = new float[]
{
// positions // texture coordinates
-20, -20, -20, 0, 0,
-20, 20, -20, 1, 0,
-20, -20, 20, 0, 1,
-20, -20, 20, 0, 1,
-20, 20, -20, 1, 0,
-20, 20, 20, 1, 1,
20, -20, -20, 0, 0,
20, 20, -20, 1, 0,
20, -20, 20, 0, 1,
20, -20, 20, 0, 1,
20, 20, -20, 1, 0,
20, 20, 20, 1, 1,
-20, -20, -20, 0, 0,
20, -20, -20, 1, 0,
-20, -20, 20, 0, 1,
-20, -20, 20, 0, 1,
20, -20, -20, 1, 0,
20, -20, 20, 1, 1,
-20, 20, -20, 0, 0,
20, 20, -20, 1, 0,
-20, 20, 20, 0, 1,
-20, 20, 20, 0, 1,
20, 20, -20, 1, 0,
20, 20, 20, 1, 1,
-20, -20, -20, 0, 0,
20, -20, -20, 1, 0,
-20, 20, -20, 0, 1,
-20, 20, -20, 0, 1,
20, -20, -20, 1, 0,
//.........这里部分代码省略.........
示例15: ImageViewer
public ImageViewer(string file)
{
IL.Initialize();
// Extension supported?
if (!ImageViewerUtils.IsValidExtension(file, EXTENSIONS))
return;
// Save Mouse Position -> will open image at this position
Vector2i mousePos = Mouse.GetPosition();
// Get Image
LoadImage(file);
if (Image == null)
return;
// Load Config File
Config = new Config();
Config.Load(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.txt"));
if (Config.Setting_ListenForConfigChanges)
{
ConfigFileWatcher = new FileSystemWatcher(AppDomain.CurrentDomain.BaseDirectory, "config.txt");
ConfigFileWatcher.NotifyFilter = NotifyFilters.LastWrite;
ConfigFileWatcher.Changed += new FileSystemEventHandler(OnConfigChanged);
ConfigFileWatcher.EnableRaisingEvents = true;
}
// Get/Set Folder Sorting
SortImagesBy = Config.Setting_DefaultSortBy;
SortImagesByDir = Config.Setting_DefaultSortDir;
if (SortImagesBy == SortBy.FolderDefault || SortImagesByDir == SortDirection.FolderDefault)
{
// Get parent folder name
string parentFolder = file.Substring(0, file.LastIndexOf('\\'));
parentFolder = parentFolder.Substring(parentFolder.LastIndexOf('\\') + 1, parentFolder.Length - parentFolder.LastIndexOf('\\') - 1);
// Get sort column info from window with corresponding name
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
foreach (SHDocVw.ShellBrowserWindow shellWindow in shellWindows)
{
if (shellWindow.LocationName != parentFolder)
continue;
Shell32.ShellFolderView view = (Shell32.ShellFolderView)shellWindow.Document;
string sort = view.SortColumns;
sort = sort.Substring(5, sort.Length - 5);
// Direction
if (sort[0] == '-')
{
sort = sort.Substring(1, sort.Length - 1);
if (SortImagesByDir == SortDirection.FolderDefault)
SortImagesByDir = SortDirection.Descending;
}
else if (SortImagesByDir == SortDirection.FolderDefault)
SortImagesByDir = SortDirection.Ascending;
// By
if (SortImagesBy == SortBy.FolderDefault)
{
switch (sort)
{
case "System.ItemDate;": SortImagesBy = SortBy.Date; break;
case "System.DateModified;": SortImagesBy = SortBy.DateModified; break;
case "System.DateCreated;": SortImagesBy = SortBy.DateCreated; break;
case "System.Size;": SortImagesBy = SortBy.Size; break;
default: SortImagesBy = SortBy.Name; break;
}
}
}
}
// Default sorting if folder was closed
if (SortImagesBy == SortBy.FolderDefault)
SortImagesBy = SortBy.Name;
if (SortImagesByDir == SortDirection.FolderDefault)
SortImagesByDir = SortDirection.Ascending;
// Create Context Menu
ContextMenu = new ContextMenu(this);
ContextMenu.LoadItems(Config.ContextMenu, Config.ContextMenu_Animation, Config.ContextMenu_Animation_InsertAtIndex);
ContextMenu.Setup(false);
// Create Window
Window = new RenderWindow(new VideoMode(Image.Texture.Size.X, Image.Texture.Size.Y), File + " - vimage", Styles.None);
Window.SetActive();
// Make Window Transparent (can only tell if image being viewed has transparency)
DWM_BLURBEHIND bb = new DWM_BLURBEHIND(false);
bb.dwFlags = DWM_BB.Enable;
bb.fEnable = true;
bb.hRgnBlur = new IntPtr();
DWM.DwmEnableBlurBehindWindow(Window.SystemHandle, ref bb);
bool _forceAlwaysOnTop = false;
//.........这里部分代码省略.........