static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FileSystem.Instance.AddWorkingDir(@".\"); FileSystem.Instance.AddWorkingDir(@"E:\Documents\ic10gd\Source\Code2015\bin\x86\Debug"); FileSystem.Instance.AddWorkingDir(@"F:\ic10gd\Source\Code2015\bin\x86\Debug"); // zou jia's res dir FileSystem.Instance.AddWorkingDir(@"D:\zonelink2"); PluginManager.Initiailze(null, null); DeviceContent dc = GraphicsAPIManager.Instance.CreateDeviceContent(); PresentParameters pm2 = new PresentParameters(); pm2.IsWindowed = true; pm2.BackBufferFormat = ImagePixelFormat.A8R8G8B8; pm2.BackBufferHeight = 600; pm2.BackBufferWidth = 800; RenderWindow wnd = (RenderWindow)dc.Create(pm2); Viewer = new RenderViewer(dc.RenderSystem); wnd.EventHandler = Viewer; Window = wnd; MainForm frm = new MainForm(dc.RenderSystem); frm.Show(); wnd.Run(); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); FileSystem.Instance.AddWorkingDir(@".\"); FileSystem.Instance.AddWorkingDir(@"E:\Documents\ic10gd\Source\Code2015\bin\x86\Debug"); // zou jia's res dir FileSystem.Instance.AddWorkingDir(@"C:\Users\penser\Documents\Visual Studio 2008\Projects\lrvbsvnicg\Source\Code2015\bin\x86\Debug"); GraphicsAPIManager.Instance.RegisterGraphicsAPI(new Apoc3D.RenderSystem.Xna.XnaGraphicsAPIFactory()); DeviceContent dc = GraphicsAPIManager.Instance.CreateDeviceContent(); PresentParameters pm2 = new PresentParameters(); pm2.IsWindowed = true; pm2.BackBufferFormat = ImagePixelFormat.A8R8G8B8; pm2.BackBufferHeight = 600; pm2.BackBufferWidth = 800; RenderWindow wnd = (RenderWindow)dc.Create(pm2); Viewer = new RenderViewer(dc.RenderSystem); wnd.EventHandler = Viewer; Window = wnd; wnd.Run(); }
public void Start(RenderWindow window, ushort numGroupsInit, ushort numGroupsLoad, float initProportion) { this.window = window; this.numGroupsInit = numGroupsInit; this.numGroupsLoad = numGroupsLoad; this.initProportion = initProportion; // We need to pre-initialise the 'Bootstrap' group so we can use // the basic contents in the loading screen ResourceGroupManager.Singleton.InitialiseResourceGroup("Bootstrap"); OverlayManager omgr = OverlayManager.Singleton; loadOverlay = omgr.GetByName("Core/LoadOverlay"); if (loadOverlay == null) System.Windows.Forms.MessageBox.Show("Cannot find loading overlay", "ExampleLoadingBar::start", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); loadOverlay.Show(); // Save links to the bar and to the loading text, for updates as we go loadingBarElement = omgr.GetOverlayElement("Core/LoadPanel/Bar/Progress"); loadingCommentElement = omgr.GetOverlayElement("Core/LoadPanel/Comment"); loadingDescriptionElement = omgr.GetOverlayElement("Core/LoadPanel/Description"); OverlayElement barContainer = omgr.GetOverlayElement("Core/LoadPanel/Bar"); progressBarMaxSize = barContainer.Width; loadingBarElement.Width = 0F; ResourceGroupManager.Singleton.ResourceGroupScriptingStarted += ResourceGroupScriptingStarted; ResourceGroupManager.Singleton.ScriptParseStarted += ScriptParseStarted; ResourceGroupManager.Singleton.ScriptParseEnded += ScriptParseEnded; ResourceGroupManager.Singleton.ResourceGroupLoadStarted += ResourceGroupLoadStarted; ResourceGroupManager.Singleton.ResourceLoadStarted += ResourceLoadStarted; ResourceGroupManager.Singleton.WorldGeometryStageStarted += WorldGeometryStageStarted; ResourceGroupManager.Singleton.WorldGeometryStageEnded += WorldGeometryStageEnded; }
RenderWindow mWindow; // This field will contain a reference to the rendering window #endregion Fields #region Constructors /// <summary> /// Constructor /// </summary> /// <param name="mSceneMgr">A reference to the scene manager</param> public Env(SceneManager mSceneMgr, RenderWindow mWindow) { this.mSceneMgr = mSceneMgr; this.mWindow = mWindow; Load(); // This method loads the environment }
//public GetValues newValues; public RenderWindowVC(RenderWindow rw) { setMove = new SetTexts(rw.setMove); setRelative = new SetTexts(rw.setRelative); setRotationSame = new SetTexts(rw.setRotationSame); setRotationLocal = new SetTexts(rw.setRotationLocal); setSelect = new SetVoid(rw.setSelect); }
public static void Update(RenderWindow Window) { myAvg.Caption = "Average FPS: " + Convert.ToString(Window.AverageFPS); myCurr.Caption = "Current FPS: " + Convert.ToString(Window.LastFPS); myBest.Caption = "Best FPS: " + Convert.ToString(Window.BestFPS); myWorst.Caption = "Worst FPS: " + Convert.ToString(Window.WorstFPS); myNumTris.Caption = "Triangle Count: " + Convert.ToString(Window.TriangleCount); myNumBatches.Caption = "Batch Count: " + Convert.ToString(Window.BatchCount); }
protected virtual bool Configure() { if (mRoot.ShowConfigDialog()) { mWindow = mRoot.Initialise(true, "TutorialApplication Render Window"); return true; } else { return false; } }
/// <summary> /// Initialzes the Game. /// </summary> /// <param name="sceneManager">The Mogre SceneManager.</param> /// <param name="camera">The game CameraMan for the MouseControl.</param> /// <param name="mWindow">The RednerWindow for sending the width and height of the window.</param> /// <param name="mouse">The Mogre Mouse for GUI.</param> /// <param name="keyboard">The Mogre Keyboard for GUI.</param> /// <returns>Returns initializes Game singleton instance.</returns> private Game(SceneManager sceneManager, CameraMan camera, RenderWindow mWindow, Mouse mouse, Keyboard keyboard) { sceneMgr = sceneManager; gameObjectMgr = GameObjectManager.GetInstance(); gameGUI = new MyGUI((int)mWindow.Width, (int)mWindow.Height, mouse, keyboard); mouseControl = MouseControl.GetInstance(camera, (int)mWindow.Width, (int)mWindow.Height); paused = true; soundPlayer = new SoundPlayer(mWindow); mission = new Mission(); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { FileSystem.Instance.AddWorkingDir(StorageContainer.TitleLocation); PluginManager.Initiailze(null, null); using (RenderWindow game = CreateRenderWindow()) { Window = game; game.Run(); } //Properties.Settings.Default.Save(); }
public void Init() { // Create root object mRoot = new Root(); // Define Resources ConfigFile cf = new ConfigFile(); cf.Load("resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); String secName, typeName, archName; while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } // Setup RenderSystem RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); // or use "OpenGL Rendering Subsystem" mRoot.RenderSystem = rs; rs.SetConfigOption("Full Screen", "No"); rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour"); // Create Render Window mRoot.Initialise(false, "Main Ogre Window"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = Handle.ToString(); mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); // Init resources TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); // Create a Simple Scene SceneManager mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC); Camera cam = mgr.CreateCamera("Camera"); cam.AutoAspectRatio = true; mWindow.AddViewport(cam); Entity ent = mgr.CreateEntity("ninja", "ninja.mesh"); mgr.RootSceneNode.CreateChildSceneNode().AttachObject(ent); cam.Position = new Vector3(0, 200, -400); cam.LookAt(ent.BoundingBox.Center); }
public DebugOverlay(RenderWindow window) { mWindow = window; var debugOverlay = OverlayManager.Singleton.GetByName("Core/DebugOverlay"); debugOverlay.Show(); mGuiAvg = OverlayManager.Singleton.GetOverlayElement("Core/AverageFps"); mGuiCurr = OverlayManager.Singleton.GetOverlayElement("Core/CurrFps"); mGuiBest = OverlayManager.Singleton.GetOverlayElement("Core/BestFps"); mGuiWorst = OverlayManager.Singleton.GetOverlayElement("Core/WorstFps"); mGuiTris = OverlayManager.Singleton.GetOverlayElement("Core/NumTris"); mModesText = OverlayManager.Singleton.GetOverlayElement("Core/NumBatches"); }
public DebugOverlay(RenderWindow window) { Window = window; Overlay debugOverlay = OverlayManager.Instance.GetByName("Core/DebugOverlay"); debugOverlay.Show(); GuiAvg = OverlayManager.Instance.GetOverlayElement("Core/AverageFps"); GuiCurr = OverlayManager.Instance.GetOverlayElement("Core/CurrFps"); GuiBest = OverlayManager.Instance.GetOverlayElement("Core/BestFps"); GuiWorst = OverlayManager.Instance.GetOverlayElement("Core/WorstFps"); GuiTris = OverlayManager.Instance.GetOverlayElement("Core/NumTris"); ModesText = OverlayManager.Instance.GetOverlayElement("Core/NumBatches"); }
/// <summary> /// set up ogre /// </summary> public Program() { root = new Root("plugins.cfg", "", "Ogre.log"); renderSystem = root.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); renderSystem.SetConfigOption("Full Screen", "No"); renderSystem.SetConfigOption("Video Mode", "1920 x 1200 @ 32-bit colour"); root.RenderSystem = renderSystem; SetupResources(); window = root.Initialise(true, "shadow test"); sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "sceneMgr"); sceneMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f); camera = sceneMgr.CreateCamera("cam"); camera.Position = new Vector3(0.8f, 0.8f, 0.8f); camera.LookAt(new Vector3(-1, 1, -1)); camera.SetAutoTracking(true, sceneMgr.RootSceneNode.CreateChildSceneNode(new Vector3(0, 0.4f, 0))); camera.NearClipDistance = 0.1f; camera.FarClipDistance = 2000; viewport = window.AddViewport(camera); viewport.BackgroundColour = ColourValue.Black; camera.AspectRatio = (float) viewport.ActualWidth / (float) viewport.ActualHeight; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); TextureManager.Singleton.DefaultNumMipmaps = 1; CreateThings(); //SetupParticles(); //SetupShadows(); SetupInput(); root.FrameStarted += FrameStarted; Console.WriteLine( @" Press 1, 2, 3, 4 to enable/disable lights, or Esc to quit. The red and blue textures have PSSM and self-shadowing enabled. The yellow one does not. You can also use WASDQE to move the camera around." ); }
public Control(RenderWindow window) { // Create input manager MOIS.ParamList pl = new MOIS.ParamList(); IntPtr windowHnd; window.GetCustomAttribute("WINDOW", out windowHnd); pl.Insert("WINDOW", windowHnd.ToString()); mInputManager = MOIS.InputManager.CreateInputSystem(pl); mKeyBoard = (MOIS.Keyboard)mInputManager.CreateInputObject(MOIS.Type.OISKeyboard, true); mMouse = (MOIS.Mouse)mInputManager.CreateInputObject(MOIS.Type.OISMouse, true); try { mJoystick = (MOIS.JoyStick)mInputManager.CreateInputObject(MOIS.Type.OISJoyStick, true); Program.Instance.gameManager.hasJoy = true; try { mFF = (MOIS.ForceFeedback)mJoystick.QueryInterface(MOIS.Interface.IType.ForceFeedback); mSupportedEffectList = mFF.GetSupportedEffects(); } catch { //Console.WriteLine("No ForceFeedback"); } } catch { //Console.WriteLine("No Joystick"); } //Callbacks for Inputs mKeyBoard.KeyPressed += new MOIS.KeyListener.KeyPressedHandler(mKeyBoard_KeyPressed); mKeyBoard.KeyReleased += new MOIS.KeyListener.KeyReleasedHandler(mKeyBoard_KeyReleased); mMouse.MouseMoved += new MOIS.MouseListener.MouseMovedHandler(mMouse_MouseMoved); mMouse.MousePressed += new MOIS.MouseListener.MousePressedHandler(mMouse_MousePressed); mMouse.MouseReleased += new MOIS.MouseListener.MouseReleasedHandler(mMouse_MouseReleased); if (mInputManager.GetNumberOfDevices(MOIS.Type.OISJoyStick) > 0) { mJoystick.ButtonPressed += new MOIS.JoyStickListener.ButtonPressedHandler(mJoystick_ButtonPressed); mJoystick.ButtonReleased += new MOIS.JoyStickListener.ButtonReleasedHandler(mJoystick_ButtonReleased); mJoystick.AxisMoved += new MOIS.JoyStickListener.AxisMovedHandler(mJoystick_AxisMoved); } }
/// <summary> /// Configures the application - returns false if the user chooses to abandon configuration. /// </summary> public virtual bool Configure() { // Show the configuration dialog and initialise the system // You can skip this and use root.restoreConfig() to load configuration // settings if you were sure there are valid ones saved in ogre.cfg if (root.ShowConfigDialog()) { // If returned true, user clicked OK so initialise // Here we choose to let the system create a default rendering window by passing 'true' window = root.Initialise(true); return true; } else { return false; } }
public MainForm() { try // can't be handled by exception manager because it doesn't exist yet { InitializeComponent(); m_GlobalModel = new GlobalStateModel(); m_Document = new DocumentModel(); m_Document.GlobalModel = m_GlobalModel; m_GlobalModel.InitEnterpriseBlocks(m_Document); } catch (Exception e) { throw e; } m_GlobalModel.ExManager.Process(() => { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; // Prevents "Normal" processes OutputWindow f1 = new OutputWindow(); f1.Show(dockPanel, DockState.DockBottom); CodeExplorer f3 = new CodeExplorer(); f3.Show(dockPanel, DockState.DockRight); RenderWindow f2 = new RenderWindow(m_Document); f2.CloseButtonVisible = false; f2.Show(dockPanel, DockState.Document); f4 = new DebugView(m_Document); f4.Show(dockPanel, DockState.DockRight); f4.Hide(); ActionView f5 = new ActionView(); f5.Show(dockPanel, DockState.DockRight); f5.Hide(); m_GlobalModel.AddOutputObserver(f1); m_GlobalModel.AddDebugMessageObserver(f4); m_Document.AddNCTextObserver(f3); m_Document.ReadConfigFile(); m_Document.AddAnimationStateObserver(this); m_GlobalModel.OutputWriter.Write("Application started" + Environment.NewLine, "Output", 0); }, "LoggingAndReplacingException"); }
public DebugOverlay(RenderWindow window) { mWindow = window; mTextManager = new TextManager(); mFPSAvg = new Text("Average FPS:") { Position = new System.Drawing.Point(10, 0) }; mFPSCurr = new Text("Current FPS:") { Position = new System.Drawing.Point(10, 15) }; mFPSBest = new Text("Best FPS:") { Position = new System.Drawing.Point(10, 30) }; mFPSWorst = new Text("Worst FPS:") { Position = new System.Drawing.Point(10, 45) }; mTris = new Text("Triangle Count:") { Position = new System.Drawing.Point(10, 60) }; mModes = new Text("???") { Position = new System.Drawing.Point(10, 75) }; mTextManager.AddText(mFPSAvg); mTextManager.AddText(mFPSCurr); mTextManager.AddText(mFPSBest); mTextManager.AddText(mFPSWorst); mTextManager.AddText(mTris); mTextManager.AddText(mModes); mTextManager.ShowAllText(); }
public void Draw(RenderWindow window) { window.Draw(sprite); }
//////////////////////////////////////////////////////////// /// <summary> /// Render the object into the given render window /// </summary> /// <param name="target">Target render window</param> /// <param name="shader">Shader to apply</param> //////////////////////////////////////////////////////////// internal abstract void Render(RenderWindow target, Shader shader);
protected virtual bool Setup() { mRoot = new Root(mPluginsCfg); RenderSystem renderSystem = null; foreach (var rs in mRoot.GetAvailableRenderers()) { if (rs.Name == "Direct3D9 Rendering Subsystem") { renderSystem = rs; break; } } renderSystem.SetConfigOption("Full Screen", "No"); renderSystem.SetConfigOption("Video Mode", "200 x 200 @ 32-bit colour"); renderSystem.SetConfigOption("FSAA", "0"); renderSystem.SetConfigOption("VSync", "No"); renderSystem.SetConfigOption("sRGB Gamma Conversion", "No"); mRoot.RenderSystem = renderSystem; mWindow = mRoot.Initialise(true, "MSpriteRenderer Preview Window"); //if(!Configure()) // return false; ChooseSceneManager(); CreateCamera(); CreateViewports(); TextureManager.Singleton.DefaultNumMipmaps = 5; CreateResourceListener(); LoadResources(); CreateScene(); CreateFrameListeners(); mDebugOverlay = new DebugOverlay(mWindow); mDebugOverlay.AdditionalInfo = "Bilinear"; return true; }
public void Game(List <string> _input) { // Find dimensions of map WIDTH = _input[0].Length; HEIGHT = _input.Count; SIZE = 1000 / WIDTH; // SFML RenderWindow window = new RenderWindow( new SFML.Window.VideoMode(1000, 1000), "Day 15"); window.SetActive(); Application.EnableVisualStyles(); // Map Tile[,] Map = new Tile[WIDTH, HEIGHT]; // Warriors List <Warrior> Warriors = new List <Warrior>(); // Fill map for (int y = 0; y < HEIGHT; y++) { char[] temp = _input[y].ToCharArray(); for (int x = 0; x < WIDTH; x++) { if (temp[x] == '#') { Map[x, y] = new Tile(x, y, Tile.Terrain.Tree); } else { Map[x, y] = new Tile(x, y, Tile.Terrain.Land); if (temp[x] == 'G') { Warriors.Add(new Goblin(x, y)); } else if (temp[x] == 'E') { Warriors.Add(new Elf(x, y)); } } } } int TotalRounds = 0; int HitPoints = 0; int Score = 0; Text RoundCount = new Text($"Round = {TotalRounds}", new Font("Input\\Venator.ttf"), (uint)SIZE / 2); RoundCount.Position = new Vector2f(0, 0) * SIZE; RoundCount.Color = new Color(0, 0, 0); bool GameRunning = true; window.Clear(); window.DispatchEvents(); for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { window.Draw(Map[x, y].rect); } } Warriors.ForEach(a => window.Draw(a.rect)); window.Draw(RoundCount); window.Display(); while (GameRunning) { Thread.Sleep(100); TotalRounds++; // First sort the warriors in order of location Warriors.Sort(); // Let every warrior take its turn in moving and then fighting for (int i = 0; i < Warriors.Count; i++) { Warriors[i].Update(Warriors, Map); } Warriors.RemoveAll(a => a.Health <= 0); window.Clear(); window.DispatchEvents(); for (int x = 0; x < WIDTH; x++) { for (int y = 0; y < HEIGHT; y++) { window.Draw(Map[x, y].rect); } } Warriors.ForEach(a => window.Draw(a.rect)); Warriors.ForEach(a => window.Draw(a.text)); RoundCount.DisplayedString = $"Round = {TotalRounds}"; window.Draw(RoundCount); window.Display(); // check if winner // Check both teams if (Warriors.Where(a => a.type == "Elf").ToList().Count() == 0) { GameRunning = false; HitPoints = (int)Warriors.Where(a => a.type == "Goblin").ToList().Sum(a => a.Health); Score = HitPoints * TotalRounds; Console.WriteLine($"Combat ends after {TotalRounds} full rounds."); Console.WriteLine($"Goblins win with {HitPoints} total hit points left."); Console.WriteLine($"Outcome: {TotalRounds} * {HitPoints} = {Score}"); break; } else if (Warriors.Where(a => a.type == "Goblin").ToList().Count() == 0) { GameRunning = false; HitPoints = (int)Warriors.Where(a => a.type == "Elf").ToList().Sum(a => a.Health); Score = HitPoints * TotalRounds; Console.WriteLine($"Combat ends after {TotalRounds} full rounds."); Console.WriteLine($"Elves win with {HitPoints} total hit points left."); Console.WriteLine($"Outcome: {TotalRounds} * {HitPoints} = {Score}"); break; } Console.ReadLine(); } }
public EventDispatcher(RenderWindow window) { this.window = window; }
public OpenGLRenderer(RenderWindow parentWindow) { GL.GetError(); // OpenTK.Toolkit.Init(); // var ctx = wglGetCurrentContext(); // var c = new OpenTK.Graphics.GraphicsContext(new OpenTK.ContextHandle(ctx), (name) => wglGetProcAddress(name), () => new OpenTK.ContextHandle(wglGetCurrentContext())); // c.MakeCurrent(new OpenTK.wparentWindow.Handle); // load extensions //_renderToTextureSupported = Gl.IsExtensionSupported("GL_ARB_framebuffer_object"); _renderToTextureSupported = false; _samplerObjectsSupported = true; // GL..arb.IsExtensionSupported("GL_ARB_sampler_objects"); _debugOutputSupported = true; // Gl.IsExtensionSupported("GL_ARB_debug_output"); _maxAnisotropy = 0; /* if (Gl.IsExtensionSupported("GL_EXT_texture_filter_anisotropic")) * { * float max; * Gl.glGetFloatv(Gl.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, out max); * * _maxAnisotropy = (int)max; * * // OpenGL considers 1.0 to be none, but we consider 0 to be none (like Direct3D does) * if (_maxAnisotropy == 1) * _maxAnisotropy = 0; * } * else * { * _maxAnisotropy = 0; * }*/ // set default render states BlendState = BlendState.Opaque; if (_debugOutputSupported) { // GL.DebugMessageCallback(glDebugLog, IntPtr.Zero); //GL.Enable(EnableCap.DebugOutputSynchronous); } _currentSamplerStates.SamplerChanged += new SamplerStateCollection.SamplerChangedHandler(samplerStateChanged); SamplerState.PointWrap = CreateSampler(new SamplerStateDesc() { AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, AddressW = TextureAddressMode.Wrap, Filter = TextureFilter.Point, MaxAnisotropy = 4 }); SamplerState.PointClamp = CreateSampler(new SamplerStateDesc() { AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, AddressW = TextureAddressMode.Clamp, Filter = TextureFilter.Point, MaxAnisotropy = 4 }); SamplerState.LinearWrap = CreateSampler(new SamplerStateDesc() { AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, AddressW = TextureAddressMode.Wrap, Filter = TextureFilter.Linear, MaxAnisotropy = 4 }); SamplerState.LinearClamp = CreateSampler(new SamplerStateDesc() { AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, AddressW = TextureAddressMode.Clamp, Filter = TextureFilter.Linear, MaxAnisotropy = 4 }); SamplerState.AnisotropicWrap = CreateSampler(new SamplerStateDesc() { AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, AddressW = TextureAddressMode.Wrap, Filter = TextureFilter.Anisoptropic, MaxAnisotropy = 4 }); SamplerState.AnisotropicClamp = CreateSampler(new SamplerStateDesc() { AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, AddressW = TextureAddressMode.Clamp, Filter = TextureFilter.Anisoptropic, MaxAnisotropy = 4 }); SamplerStates[0] = SamplerState.LinearWrap; SamplerStates[1] = SamplerState.LinearClamp; uint vao; GL.GenVertexArrays(1, out vao); GL.BindVertexArray(vao); _parentWindow = parentWindow; }
//////////////////////////////////////////////////////////// /// <summary> /// Update a texture from the contents of a render-window /// </summary> /// <param name="window">Render-window to copy to the texture</param> //////////////////////////////////////////////////////////// public void Update(RenderWindow window) { Update(window, 0, 0); }
/// <summary> /// Méthode appelée lorsque l'on souhaite faire afficher l'opponent en utilisation. /// </summary> /// <param name="window">Le renderwindow où les éléments seront afficher.</param> public void Draw(RenderWindow window) { opponentSprite.Position = new Vector2f(GetPosition().X *Game.DEFAULT_GAME_ELEMENT_WIDTH, GetPosition().Y *Game.DEFAULT_GAME_ELEMENT_HEIGHT); window.Draw(opponentSprite); }
public void Draw(RenderWindow window) { _spriteBox.Scale = new Vector2f(0.5f, 0.2f); window.Draw(_spriteBox); Console.WriteLine(_spriteBox.Position.Y); }
void ResetWindow(string title, int width, int height, bool fullscreen, bool vsync) { if (width < 0) { throw new ArgumentException("Width must be greater than 0."); } if (height < 0) { throw new ArgumentException("Height must be greater than 0."); } if (Window != null) { if (Window.IsOpen()) { Window.Close(); } } var windowStyle = Styles.Default; if (!WindowResize && WindowClose) { windowStyle = Styles.Close; } if (WindowResize && !WindowClose) { windowStyle = Styles.Resize; } if (!WindowResize && !WindowClose) { windowStyle = Styles.Titlebar; } if (!WindowBorder) { windowStyle = Styles.None; } Window = new RenderWindow(new VideoMode((uint)width, (uint)height), title, fullscreen ? Styles.Fullscreen : windowStyle); Window.Closed += new EventHandler(OnClose); Window.GainedFocus += new EventHandler(Focused); Window.LostFocus += new EventHandler(Unfocused); Window.Resized += new EventHandler <SizeEventArgs>(OnResize); if (iconImage != null) { Window.SetIcon(iconWidth, iconHeight, iconImage.Pixels); } Window.SetVerticalSyncEnabled(vsync); UpdateView(); if (Input != null) { Input.WindowInit(); } if (Debugger != null) { Debugger.WindowInit(); } }
public ControlStrategyMouse(RenderWindow window) { this.window = window; }
static void Main() { var window = new RenderWindow(new VideoMode(Configuration.WindowWidth, Configuration.WindowHeight), "Pong"); window.SetKeyRepeatEnabled(false); var ball = new Ball(new Vector2i(200, 200), new Vector2i(5, 5)); var leftPaddle = new Paddle(new Vector2i(30, 200)); var rightPaddle = new Paddle(new Vector2i(Configuration.WindowWidth - 50, 200)); var paddles = new List <Paddle> { leftPaddle, rightPaddle }; window.KeyPressed += (sender, args) => { switch (args.Code) { case Keyboard.Key.Q: leftPaddle.MoveUp(); break; case Keyboard.Key.A: leftPaddle.MoveDown(); break; } switch (args.Code) { case Keyboard.Key.O: rightPaddle.MoveUp(); break; case Keyboard.Key.L: rightPaddle.MoveDown(); break; } }; window.KeyReleased += (sender, args) => { switch (args.Code) { case Keyboard.Key.Q: leftPaddle.StopMovingUp(); break; case Keyboard.Key.A: leftPaddle.StopMovingDown(); break; } switch (args.Code) { case Keyboard.Key.O: rightPaddle.StopMovingUp(); break; case Keyboard.Key.L: rightPaddle.StopMovingDown(); break; } }; window.SetActive(); while (window.IsOpen) { window.Closed += (sender, args) => { window.Close(); }; window.Clear(); ball.CheckForCollision(paddles); ball.Update(); paddles.ForEach(p => p.Update()); window.DispatchEvents(); window.Draw(ball); paddles.ForEach(p => window.Draw(p)); window.Display(); Thread.Sleep(1000 / 60); } }
public static void Init(RenderWindow window) { _window = window; }
public void Start() { if (_running) { return; } _running = true; if (_settings.debug) { // Create debug directory if it doesn't exist if (!Directory.Exists("debug_data")) { Directory.CreateDirectory("debug_data"); } } // Create window _window = new RenderWindow(new VideoMode(1200, 800), _game.title); _window.SetFramerateLimit(60); _window.SetVerticalSyncEnabled(_settings.vsync); _window.SetMouseCursorVisible(_settings.showSystemCursor); _window.SetActive(true); UpdateRenderTarget(); _view = new View(_window.GetView()); _view.Size = _view.Size / _settings.pixelSize; _view.Center = _view.Size / 2f; _window.SetView(_view); // Statically load assets Assets.Load(); // Register input events _window.Closed += OnClosed; _window.KeyPressed += OnKeyPressed; _window.Resized += OnWindowResized; _window.MouseButtonPressed += OnMouseButtonPressed; _window.MouseButtonReleased += OnMouseButtonReleased; // Initialize game _game.Init(); _timeStepper = new TimeStepper(); _timeStepper.SetDeltaRange(_settings.minDeltaMs, _settings.maxDeltaMs); // Main loop while (_window.IsOpen() && _running) { _timeStepper.OnBeginFrame(); int timeBefore = Environment.TickCount; // Send input events _window.DispatchEvents(); UpdateGame(); Render(); _timeStepper.OnEndFrame(); } _game.Quit(); // Ensure the window is closed if (_window.IsOpen()) { _window.Close(); } _running = false; }
private bool Configure() { /* RenderSystem renderSys = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem"); renderSys.SetConfigOption("Colour Depth", "16"); renderSys.SetConfigOption("Display Frequency", "40"); renderSys.SetConfigOption("FSAA", "0"); renderSys.SetConfigOption("Full Screen", "No"); renderSys.SetConfigOption("RTT Preferred Mode", "FBO"); renderSys.SetConfigOption("VSync", "Yes"); renderSys.SetConfigOption("VSync Interval", "1"); renderSys.SetConfigOption("Video Mode", WND_SIZE.x + " x " + WND_SIZE.y); renderSys.SetConfigOption("sRGB Gamma Conversion", "No"); this.mRoot.RenderSystem = renderSys; this.mRoot.Initialise(false, "SkyLands"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = Handle.ToString(); this.mWindow = this.mRoot.CreateRenderWindow("Main RenderWindow", (uint)WND_SIZE.x, (uint)WND_SIZE.y, false, misc); return true; */ bool foundit = false; foreach (RenderSystem rs in mRoot.GetAvailableRenderers()) { mRoot.RenderSystem = rs; String rname = mRoot.RenderSystem.Name; if (rname == "Direct3D9 Rendering Subsystem") {//"OpenGL Rendering Subsystem" foundit = true; break; } } if (!foundit) return false; //we didn't find it... Raise exception? //we found it, we might as well use it! mRoot.RenderSystem.SetConfigOption("Full Screen", "No"); mRoot.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour"); mRoot.Initialise(false); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = hWnd.ToString(); mWindow = mRoot.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc); return true; }
public static void SetRenderWindow(RenderWindow _renderWindow) { Export_SetRenderWindow(_renderWindow.Name); }
private void init3D() { Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath)); // Create root object mRoot = new Root(); // Define Resources ConfigFile cf = new ConfigFile(); cf.Load("resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); String secName, typeName, archName; while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair <string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } // Setup RenderSystem RenderSystem rs = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); mRoot.RenderSystem = rs; rs.SetConfigOption("Full Screen", "No"); rs.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour"); // Create Render Window mRoot.Initialise(false, "Main Ogre Window"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = picRender.Handle.ToString(); mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); // Init resources TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); // Create a Simple Scene mgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "MainMgr"); Camera cam = mgr.CreateCamera("Camera"); //cam.PolygonMode = PolygonMode.PM_WIREFRAME; cam.AutoAspectRatio = true; mWindow.AddViewport(cam); cam.Position = new Vector3(0, 0, 200); cam.LookAt(new Vector3(0, 0, 0)); cam.ProjectionType = ProjectionType.PT_ORTHOGRAPHIC; //cam.OrthoWindowHeight = 400; cam.OrthoWindowWidth = 650; ManualObject manual = mgr.CreateManualObject("canvas"); manual.Begin("BaseWhiteNoLighting", RenderOperation.OperationTypes.OT_LINE_STRIP); manual.Position(-300.0f, -200.0f, 0.0f); // start position manual.Position(300.0f, -200.0f, 0.0f); // draw first line manual.Position(300.0f, 200.0f, 0.0f); manual.Position(-300.0f, 200.0f, 0.0f); manual.Position(-300.0f, -200.0f, 0.0f); // draw fourth line manual.End(); mgr.RootSceneNode.CreateChildSceneNode().AttachObject(manual); mWindow.GetViewport(0).BackgroundColour = new ColourValue(0.5f, 0.5f, 0.5f); }
public static void Main(string[] args) { //Console.WriteLine("Hello World!"); //byte[] loadedCode = File.ReadAllBytes("pong.rom"); byte[] loadedCode = File.ReadAllBytes("INVADERS"); //byte[] loadedCode = File.ReadAllBytes("test_opcode.ch8"); //byte[] loadedCode = File.ReadAllBytes("BC_test.ch8"); chip8 = new Chip8(loadedCode); RenderWindow app = new RenderWindow(new VideoMode(800, 600), "chip8 emu"); app.Closed += new EventHandler(OnClose); float TILESIZEX = (float)app.Size.X / 64; float TILESIZEY = (float)app.Size.Y / 32; RectangleShape shape = new RectangleShape(new Vector2f(TILESIZEX, TILESIZEY)); app.KeyPressed += OnKeyPressed; app.KeyReleased += OnKeyReleased; Font font = new Font("Arial.ttf"); Text text = new Text("", font); //app.KeyReleased += // Start the game loop //app.SetFramerateLimit(60); //app.SetVerticalSyncEnabled(true); while (app.IsOpen) { chip8.Execute(); // Process events app.DispatchEvents(); //if (chip8.displayUpdated) { // Clear screen app.Clear(); for (int y = 0; y < 32; y++) { for (int x = 0; x < 64; x++) { shape.Position = new Vector2f(x * TILESIZEX, y * TILESIZEY); if (chip8.display[x, y] == 1) { shape.FillColor = Color.Blue; } else { shape.FillColor = Color.Black; } app.Draw(shape); } //Console.WriteLine(); } List <string> lines = chip8.GetCurrentLine(); for (int i = 0; i < lines.Count; i++) { text.DisplayedString = lines[i]; text.Position = new Vector2f(0, i * 25); app.Draw(text); } for (int i = 0; i < 16; i++) { text.DisplayedString = chip8.inputs[i] ? "1" : "0"; text.Position = new Vector2f((i % 4) * 25 + 200, (i / 4) * 25); app.Draw(text); } app.Display(); chip8.displayUpdated = false; } //for (int i = 0; i < 16; i++) // chip8.inputs[i] = false; // Draw the sprite // Draw the string // Sleep to slow down emulation speed } }
public Environment(RenderWindow renderWindow) { Window = renderWindow; }
public static void Draw(RenderWindow window) { window.Draw(InfoText); window.Draw(Exit); window.Draw(ExitText); }
public void DrawCoinsText(RenderWindow window) { coinsText.DisplayedString = "Coins: " + userData.coins; window.Draw(coinsText); }
public override void Draw(RenderWindow window) { }
public override void Draw(RenderWindow window) { Display.Draw(window, Position); }
/// <summary> /// Protected constructor /// </summary> /// <param name="mSceneMgr">A reference to the scene manager</param> /// <param name="characterStat">A reference to a character stat</param> protected HMD(SceneManager mSceneMgr, RenderWindow mWindow, CharacterStats characterStat) { this.mWindow = mWindow; this.mSceneMgr = mSceneMgr; this.characterStats = characterStat; }
public DrawingSurface() { InitializeComponent(); Target = new RenderWindow(Handle); Target.SetVerticalSyncEnabled(true); }
private bool Configure() { RenderSystem renderSys = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem"); renderSys.SetConfigOption("Colour Depth", "16"); renderSys.SetConfigOption("Display Frequency", "40"); renderSys.SetConfigOption("FSAA", "0"); renderSys.SetConfigOption("Full Screen", "No"); renderSys.SetConfigOption("RTT Preferred Mode", "FBO"); renderSys.SetConfigOption("VSync", "Yes"); renderSys.SetConfigOption("VSync Interval", "1"); renderSys.SetConfigOption("Video Mode", WND_SIZE.x + " x " + WND_SIZE.y); renderSys.SetConfigOption("sRGB Gamma Conversion", "No"); this.mRoot.RenderSystem = renderSys; this.mRoot.Initialise(false, "SkyLands"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = Handle.ToString(); this.mWindow = this.mRoot.CreateRenderWindow("Main RenderWindow", (uint)WND_SIZE.x, (uint)WND_SIZE.y, false, misc); return true; }
public void draw(RenderWindow win) { //win.Draw(backGround); win.Draw(Won); }
protected virtual bool Configure() { if (Root.ShowConfigDialog()) { Window = Root.Initialize(true, "TutorialApplication Render Window"); return true; } return false; }
public void Draw(RenderWindow window) { BulletForDrawing.Position = Position; BulletForDrawing.FillColor = Color.White; window.Draw(BulletForDrawing); }
static void Main(string[] args) { //player turn? bool myturn = false; Random random = new Random(); int randomnumber = random.Next(0, 10); myturn = randomnumber > 5 ? true: false; //window size uint win_width = 300; uint win_height = 300; //game window RenderWindow window = new RenderWindow(new VideoMode(win_width, win_height), "Tic Tac Toe - G4MR", Styles.Titlebar | Styles.Close); //window events window.Closed += new EventHandler(EventClose); window.MouseButtonPressed += new EventHandler <MouseButtonEventArgs>(MouseDown); window.MouseButtonReleased += new EventHandler <MouseButtonEventArgs>(MouseUp); //setup empty 3x3 grid of the game board Pos[] board = new Pos[9]; for (int x = 0; x < 9; x++) { board[x] = new Pos(); } int count = 0; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { board[count].x = x; board[count].y = y; count++; } } //game loop while (window.IsOpen()) { window.DispatchEvents(); //clear window window.Clear(); //check the winner CheckWinner(ref board); //check if the game is tied if (CatsGame(board)) { gameover = true; catgame = true; } //lets see if the game's over if (!gameover) { //check if it's your turn if (myturn) { //check if the player clicked on the screen if (mouseState && button == "Left") { PlayerTurn(ref board); mouseState = false;//disable holding the mouse myturn = false; } } else { //let the computer do his thang myturn = true; ComputerTurn(ref board); } //draw board window.Draw(sprt_board); //draw pieces on the board for (int piece = 0; piece < board.Count(); piece++) { float x = board[piece].x * box_width; float y = board[piece].y * box_height; draw_xo(board[piece].piece, x, y, ref window); } } else { //exit the game when they click the screen if (mouseState) { window.Close(); } //you win? if (youwin && !catgame) { window.Draw(sprt_win); } //you lose? if (!youwin && !catgame) { window.Draw(sprt_lose); } //cat game? if (!youwin && catgame) { window.Draw(sprt_draw); } } //update the screen window.Display(); } }
//PĘTLA PONIŻEJ public void play() { renderWindow = new RenderWindow(videoMode, "RC", style); //renderWindow.SetMouseCursorVisible(false); renderWindow.SetVerticalSyncEnabled(false); VertexArray floor = new VertexArray(PrimitiveType.Quads, 4); floor[0] = new Vertex(new Vector2f(0, renderWindow.Size.Y / 2), Color.Black); floor[1] = new Vertex(new Vector2f(renderWindow.Size.X, renderWindow.Size.Y / 2), Color.Black); floor[2] = new Vertex(new Vector2f(renderWindow.Size.X, renderWindow.Size.Y), new Color(200, 150, 50)); floor[3] = new Vertex(new Vector2f(0, renderWindow.Size.Y), new Color(200, 150, 50)); VertexArray sky = new VertexArray(PrimitiveType.Quads, 4); sky[0] = new Vertex(new Vector2f(0, 0), new Color(50, 150, 255)); sky[1] = new Vertex(new Vector2f(renderWindow.Size.X, 0), new Color(50, 150, 255)); sky[2] = new Vertex(new Vector2f(renderWindow.Size.X, renderWindow.Size.Y / 2), Color.Black); sky[3] = new Vertex(new Vector2f(0, renderWindow.Size.Y / 2), Color.Black); //RZECZY wallsMap = new WallsMap(750, 750); player = new Player(new Vector2f(wallsMap.Size.X / 2, wallsMap.Size.Y / 2), new Vector2f(-1, 0), 90, 960); //960 renderedWalls = new VertexArray(PrimitiveType.TriangleStrip, (uint)player.numOfRays * 2); textDir = new Text(); textDir.Font = font; textDir.FillColor = Color.Green; textDir.CharacterSize = 15; textDir.Style = Text.Styles.Bold; textDir.DisplayedString = "Dir: " + Calc.angleFromVector(player.direction); textPos = new Text(); textPos.Font = font; textPos.FillColor = Color.Yellow; textPos.CharacterSize = 15; textPos.Style = Text.Styles.Bold; textPos.Position = new Vector2f(0, 30); textPos.DisplayedString = "Pos: " + player.position.X.ToString() + "\t" + player.position.Y.ToString(); //zdarzenia renderWindow.KeyPressed += RenderWindow_KeyPressed; renderWindow.MouseMoved += RenderWindow_MouseMoved; //MainLoop while (renderWindow.IsOpen == true) { //sterowanie if (Keyboard.IsKeyPressed(Keyboard.Key.W)) { player.move(1f); textPos.DisplayedString = "Pos: " + player.position.X.ToString() + "\t" + player.position.Y.ToString(); } if (Keyboard.IsKeyPressed(Keyboard.Key.S)) { player.move(-1f); textPos.DisplayedString = "Pos: " + player.position.X.ToString() + "\t" + player.position.Y.ToString(); } if (Keyboard.IsKeyPressed(Keyboard.Key.A)) { player.turn(-0.1f); textDir.DisplayedString = "Dir: " + Calc.angleFromVector(player.direction); } if (Keyboard.IsKeyPressed(Keyboard.Key.D)) { player.turn(0.1f); textDir.DisplayedString = "Dir: " + Calc.angleFromVector(player.direction); } renderWindow.DispatchEvents(); renderWindow.Clear(Color.Black); renderWindow.Draw(sky); renderWindow.Draw(floor); //niżej renderWalls(player.castRays(wallsMap.walls)); renderWindow.Draw(renderedWalls); renderWindow.Draw(textDir); renderWindow.Draw(textPos); //wyżej renderWindow.Display(); } }
//////////////////////////////////////////////////////////// /// <summary> /// Render the object into the given render window /// </summary> /// <param name="target">Target render window</param> /// <param name="shader">Shader to apply</param> //////////////////////////////////////////////////////////// internal override void Render(RenderWindow target, Shader shader) { if (shader == null) sfRenderWindow_DrawSprite(target.This, This); else sfRenderWindow_DrawSpriteWithShader(target.This, This, shader.This); }
public void InitMogre() { //----------------------------------------------------- // 1 enter ogre //----------------------------------------------------- root = new Root(); //----------------------------------------------------- // 2 configure resource paths //----------------------------------------------------- ConfigFile cf = new ConfigFile(); cf.Load("resources.cfg", "\t:=", true); // Go through all sections & settings in the file ConfigFile.SectionIterator seci = cf.GetSectionIterator(); String secName, typeName, archName; // Normally we would use the foreach syntax, which enumerates the values, but in this case we need CurrentKey too; while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } //----------------------------------------------------- // 3 Configures the application and creates the window //----------------------------------------------------- bool foundit = false; foreach (RenderSystem rs in root.GetAvailableRenderers()) { root.RenderSystem = rs; String rname = root.RenderSystem.Name; if (rname == "Direct3D9 Rendering Subsystem") { foundit = true; break; } } if (!foundit) return; //we didn't find it... Raise exception? //we found it, we might as well use it! root.RenderSystem.SetConfigOption("Full Screen", "No"); root.RenderSystem.SetConfigOption("Video Mode", "640 x 480 @ 32-bit colour"); root.Initialise(false); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = hWnd.ToString(); window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc); ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); //----------------------------------------------------- // 4 Create the SceneManager // // ST_GENERIC = octree // ST_EXTERIOR_CLOSE = simple terrain // ST_EXTERIOR_FAR = nature terrain (depreciated) // ST_EXTERIOR_REAL_FAR = paging landscape // ST_INTERIOR = Quake3 BSP //----------------------------------------------------- sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr"); sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f); //----------------------------------------------------- // 5 Create the camera //----------------------------------------------------- camera = sceneMgr.CreateCamera("SimpleCamera"); camera.Position = new Vector3(0f, 0f, 100f); // Look back along -Z camera.LookAt(new Vector3(0f, 0f, -300f)); camera.NearClipDistance = 5; viewport = window.AddViewport(camera); viewport.BackgroundColour = new ColourValue(0.0f, 0.0f, 0.0f, 1.0f); Entity ent = sceneMgr.CreateEntity("ogre", "ogrehead.mesh"); SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("ogreNode"); node.AttachObject(ent); }
// this calls the constructor of the parent class /// <summary> /// Constructor /// </summary> /// <param name="mSceneMgr">A reference of a scene manager</param> /// <param name="playerStats">A reference to a character stats</param> public GameInterface(SceneManager mSceneMgr, RenderWindow mWindow, CharacterStats playerStats) : base(mSceneMgr, mWindow, playerStats) { Load("GameInterface"); }
public void Init(String handle) { try { // Create root object mRoot = new Root(); // Define Resources ConfigFile cf = new ConfigFile(); cf.Load("./resources.cfg", "\t:=", true); ConfigFile.SectionIterator seci = cf.GetSectionIterator(); String secName, typeName, archName; while (seci.MoveNext()) { secName = seci.CurrentKey; ConfigFile.SettingsMultiMap settings = seci.Current; foreach (KeyValuePair<string, string> pair in settings) { typeName = pair.Key; archName = pair.Value; ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName); } } //Load the resources from resources.cfg and selected tab (_ConfigurationPaths) //LoadResourceLocations(_ConfigurationPaths); //example of manual add: _FileSystemPaths.Add("../../Media/models"); foreach (string foo in _ConfigurationPaths) { AddResourceLocation(foo); } // Setup RenderSystem mRSys = mRoot.GetRenderSystemByName("Direct3D9 Rendering Subsystem"); //mRSys = mRoot.GetRenderSystemByName("OpenGL Rendering Subsystem"); // or use "OpenGL Rendering Subsystem" mRoot.RenderSystem = mRSys; mRSys.SetConfigOption("Full Screen", "No"); mRSys.SetConfigOption("Video Mode", "800 x 600 @ 32-bit colour"); // Create Render Window mRoot.Initialise(false, "Main Ogre Window"); NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = handle; misc["FSAA"] = "4"; // misc["VSync"] = "True"; //not sure how to enable vsync to remove those warnings in Ogre.log mWindow = mRoot.CreateRenderWindow("Main RenderWindow", 800, 600, false, misc); // Init resources MaterialManager.Singleton.SetDefaultTextureFiltering(TextureFilterOptions.TFO_ANISOTROPIC); TextureManager.Singleton.DefaultNumMipmaps = 5; ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); // Create a Simple Scene //SceneNode node = null; // mMgr = mRoot.CreateSceneManager(SceneType.ST_GENERIC, "SceneManager"); mMgr = mRoot.CreateSceneManager(SceneType.ST_EXTERIOR_CLOSE, "SceneManager"); mMgr.AmbientLight = new ColourValue(0.8f, 0.8f, 0.8f); mCamera = mMgr.CreateCamera("Camera"); mWindow.AddViewport(mCamera); mCamera.AutoAspectRatio = true; mCamera.Viewport.SetClearEveryFrame(false); //Entity ent = mMgr.CreateEntity(displayMesh, displayMesh); //ent.SetMaterialName(displayMaterial); //node = mMgr.RootSceneNode.CreateChildSceneNode(displayMesh + "node"); //node.AttachObject(ent); mCamera.Position = new Vector3(0, 0, 0); //mCamera.Position = new Vector3(0, 0, -400); mCamera.LookAt(0, 0, 1); //Create a single point light source Light light2 = mMgr.CreateLight("MainLight"); light2.Position = new Vector3(0, 10, -25); light2.Type = Light.LightTypes.LT_POINT; light2.SetDiffuseColour(1.0f, 1.0f, 1.0f); light2.SetSpecularColour(0.1f, 0.1f, 0.1f); mWindow.WindowMovedOrResized(); IsInitialized = true; // Create the camera's top node (which will only handle position). cameraNode = mMgr.RootSceneNode.CreateChildSceneNode(); cameraNode.Position = new Vector3(0, 0, 0); //cameraNode = mMgr->getRootSceneNode()->createChildSceneNode(); //cameraNode->setPosition(0, 0, 500); // Create the camera's yaw node as a child of camera's top node. cameraYawNode = cameraNode.CreateChildSceneNode(); // Create the camera's pitch node as a child of camera's yaw node. cameraPitchNode = cameraYawNode.CreateChildSceneNode(); // Create the camera's roll node as a child of camera's pitch node // and attach the camera to it. cameraRollNode = cameraPitchNode.CreateChildSceneNode(); cameraRollNode.AttachObject(mCamera); mRaySceneQuery = mMgr.CreateRayQuery(new Ray()); } catch (Exception ex) { Console.WriteLine("[Error,OgreForm.cs]: " + ex.Message + "," + ex.StackTrace); } }
//////////////////////////////////////////////////////////// /// <summary> /// Update a texture from the contents of a render-window /// </summary> /// <param name="window">Render-window to copy to the texture</param> /// <param name="x">X offset in the texture where to copy the source pixels</param> /// <param name="y">Y offset in the texture where to copy the source pixels</param> //////////////////////////////////////////////////////////// public void Update(RenderWindow window, uint x, uint y) { sfTexture_UpdateFromRenderWindow(This, window.This, x, y); }
public void InitMogre() { //----------------------------------------------------- // 1 enter ogre //----------------------------------------------------- root = new Root(); //----------------------------------------------------- // 2 configure resource paths //----------------------------------------------------- //----------------------------------------------------- // 3 Configures the application and creates the window //----------------------------------------------------- #if DEBUG root.LoadPlugin("RenderSystem_Direct3D9_d"); #else root.LoadPlugin("RenderSystem_Direct3D9"); #endif bool foundit = false; foreach (RenderSystem rs in root.GetAvailableRenderers()) { root.RenderSystem = rs; String rname = root.RenderSystem.Name; if (rname == "Direct3D9 Rendering Subsystem") { foundit = true; break; } } if (!foundit) { return; //we didn't find it... Raise exception? } //we found it, we might as well use it! root.RenderSystem.SetConfigOption("Full Screen", "No"); root.RenderSystem.SetConfigOption("Video Mode", string.Format("{0} x {1} @ 32-bit colour", windowSize.Width, windowSize.Height)); root.Initialise(false); // other plugins #if DEBUG root.LoadPlugin("Plugin_CgProgramManager_d"); root.LoadPlugin("Plugin_OctreeSceneManager_d"); #else root.LoadPlugin("Plugin_CgProgramManager"); root.LoadPlugin("Plugin_OctreeSceneManager"); #endif NameValuePairList misc = new NameValuePairList(); misc["externalWindowHandle"] = hWnd.ToString(); window = root.CreateRenderWindow("Simple Mogre Form Window", 0, 0, false, misc); ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); //----------------------------------------------------- // 4 Create the SceneManager // // ST_GENERIC = octree // ST_EXTERIOR_CLOSE = simple terrain // ST_EXTERIOR_FAR = nature terrain (depreciated) // ST_EXTERIOR_REAL_FAR = paging landscape // ST_INTERIOR = Quake3 BSP //----------------------------------------------------- sceneMgr = root.CreateSceneManager(SceneType.ST_GENERIC, "SceneMgr"); sceneMgr.AmbientLight = new ColourValue(0.5f, 0.5f, 0.5f); //----------------------------------------------------- // 5 Create the camera //----------------------------------------------------- camera = sceneMgr.CreateCamera("SimpleCamera"); camera.NearClipDistance = 0.1f; camera.AutoAspectRatio = true; viewport = window.AddViewport(camera); viewport.BackgroundColour = new ColourValue(0.25f, 0.25f, 0.25f, 1.0f); root.FrameStarted += new FrameListener.FrameStartedHandler(MogreFrameStarted); }
//////////////////////////////////////////////////////////// /// <summary> /// Render the object into the given render window /// </summary> /// <param name="window">Target window</param> //////////////////////////////////////////////////////////// internal override void Render(RenderWindow window) { sfRenderWindow_DrawString(window.This, This); }
//close window static void EventClose(object s, EventArgs e) { RenderWindow win = (RenderWindow)s; win.Close(); }
public override void OnDraw(float deltatime, RenderWindow window) { window.Draw(canvasSprite); }
public DemoWindow(Root root, RenderWindow renderWindow) { _root = root; _window = renderWindow; }
public abstract void render(RenderWindow window);
public void Draw(RenderWindow window, Color color) { BulletForDrawing.Position = Position; BulletForDrawing.FillColor = color; window.Draw(BulletForDrawing); }