/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(_background); // TODO: Add your drawing code here if (_nuklearContext.BeginTitled("demo2", "demo2", new RectangleF(50, 50, 200, 200), Nuklear.NK_WINDOW_BORDER | Nuklear.NK_WINDOW_MOVABLE | Nuklear.NK_WINDOW_SCALABLE | Nuklear.NK_WINDOW_MINIMIZABLE | Nuklear.NK_WINDOW_TITLE)) { _nuklearContext.LayoutRowStatic(30, 80, 1); _nuklearContext.LayoutRowDynamic(30, 1); _nuklearContext.ButtonText("Button"); _nuklearContext.LayoutRowDynamic(30, 2); if (_nuklearContext.OptionLabel("Tea", _isTea)) { _isTea = true; } if (_nuklearContext.OptionLabel("Coffee", !_isTea)) { _isTea = false; } _nuklearContext.ButtonColor(Color.Red); _nuklearContext.LayoutRowDynamic(30, 1); _nuklearContext.LayoutRowDynamic(30, 2); _nuklearContext.LabelColored("background", nk_text_align.NK_TEXT_LEFT, _background); if (_nuklearContext.ComboBeginColor(_background, new Vector2(_nuklearContext.WidgetWidth(), 400))) { _nuklearContext.LayoutRowDynamic(120, 1); _background = _nuklearContext.ColorPicker(_background.ToColorf(), 0).ToColor(); _nuklearContext.LayoutRowDynamic(25, 1); _background.R = (byte)_nuklearContext.Propertyi("#R", 0, _background.R, 255, 1, 1); _background.G = (byte)_nuklearContext.Propertyi("#G", 0, _background.G, 255, 1, 1); _background.B = (byte)_nuklearContext.Propertyi("#B", 0, _background.B, 255, 1, 1); _background.A = (byte)_nuklearContext.Propertyi("#A", 0, _background.A, 255, 1, 1); _nuklearContext.ComboEnd(); } _nuklearContext.LayoutRowDynamic(30, 1); _nuklearContext.LabelColored("Native Allocations: " + NativeMemory.Allocations, nk_text_align.NK_TEXT_LEFT, _background); } _nuklearContext.End(); _nuklearContext.Draw(); _perfGraph.Update(gameTime.ElapsedGameTime.TotalSeconds); _nvgContext.BeginFrame(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, 1.0f); _perfGraph.Render(_nvgContext, 5, 5); _nvgContext.EndFrame(); /* _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied); * _spriteBatch.Draw(_nuklearContext.Textures[0], Vector2.Zero, Color.White); * _spriteBatch.End();*/ base.Draw(gameTime); }
public virtual void Render(FrameEventArgs frameEventArgs) { FramebufferScene.Use(); GL.PushMatrix(); GL.ClearColor(Color.Black); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); // RenderOriginAxes(); // Set up uniforms ShaderDefault.Uniforms.SetValue("lightPos", LightPosition); ShaderDefault.Uniforms.SetValue("cameraPos", Camera.Position); ShaderDefault.Uniforms.SetValue("v", Camera.GetTransformation()); ShaderDefault.Uniforms.SetValue("p", ProjectionMatrix); GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, TextureRandom.Id); foreach (var actor in Scene.Actors) { if (!actor.RenderOutsideFrustum && !Camera.FrustumContains(actor.BoundingBox)) { continue; } var e = new ActorEventArgs(actor); ActorPreRender?.Invoke(this, e); actor.Render(this, Camera); ActorPostRender?.Invoke(this, e); } GL.PopMatrix(); FramebufferScene.Release(); FramebufferInterface.Use(); GL.ClearColor(0, 0, 0, 0); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); Nvg.BeginFrame(Window.Width, Window.Height, 1); Nvg.Save(); UserInterface.Render(this, Nvg, frameEventArgs); Nvg.Restore(); Nvg.EndFrame(); FramebufferInterface.Release(); ShaderScreen.Use(); DrawFullscreenQuad(FramebufferScene.Texture, FramebufferInterface.Texture); ShaderScreen.Release(); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(new Color(0.3f, 0.3f, 0.3f)); if (_graphics.PreferredBackBufferWidth != Window.ClientBounds.Width || _graphics.PreferredBackBufferHeight != Window.ClientBounds.Height) { _graphics.PreferredBackBufferWidth = Window.ClientBounds.Width; _graphics.PreferredBackBufferHeight = Window.ClientBounds.Height; _graphics.ApplyChanges(); } // TODO: Add your drawing code here var mouseState = Mouse.GetState(); _context.BeginFrame(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, 1.0f); var t = (float)gameTime.TotalGameTime.TotalSeconds; _demo.Render(_context, 0, 50, _graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, t); _context.FontFaceId(Blendish.DefaultFontId); _perfGraph.Render(_context, 5, 5); _context.EndFrame(); /* var texture = ((XNARenderer)_context._renderer)._textures[8]; * * _spriteBatch.Begin(); * _spriteBatch.Draw(texture, Vector2.Zero, Color.White); * _spriteBatch.End();*/ base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(new Color(0.3f, 0.3f, 0.3f)); // TODO: Add your drawing code here _contextWrapper.basic_demo(_media); _contextWrapper.button_demo(_media); _contextWrapper.grid_demo(_media); _contextWrapper.Draw(); _perfGraph.Update(gameTime.ElapsedGameTime.TotalSeconds); _nvgContext.BeginFrame(_graphics.PreferredBackBufferWidth, _graphics.PreferredBackBufferHeight, 1.0f); _perfGraph.Render(_nvgContext, 5, 5); _nvgContext.EndFrame(); /* _spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); * var texture = _media.images[3].handle; * _spriteBatch.Draw(texture, new Vector2(20, 20), Color.White); * _spriteBatch.End();*/ base.Draw(gameTime); }
public void Render(Matrix4 model, Matrix4 view, Matrix4 projection) { _framebuffer.Use(); GL.PushMatrix(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); GL.Color3(Color.White); // Set up uniforms _uTint.Value = TintColor; _uLightPos.Value = LightPosition; _uMatModel.Value = model; _uMatView.Value = view; _uMatProjection.Value = projection; _uSamples.Value = _framebuffer.Samples; _uTexRandom.Value = 1; GL.ActiveTexture(TextureUnit.Texture1); GL.BindTexture(TextureTarget.Texture2D, _texRandom); // Engage shader, render, disengage _shaderModel.Use(_uTint, _uLightPos, _uMatModel, _uMatView, _uMatProjection, _uSamples, _uTexRandom); foreach (var chunk in Chunks) { chunk?.Draw(); } _shaderScreen.Release(); // Render the ocean GL.Color3(Color.MediumBlue); var waterLevel = _generator.GetWaterLevel(); GL.MatrixMode(MatrixMode.Projection); GL.LoadMatrix(ref projection); GL.MatrixMode(MatrixMode.Modelview); var mat = view * model; GL.LoadMatrix(ref mat); GL.Begin(PrimitiveType.Quads); GL.Normal3(Vector3.UnitY); GL.Vertex3(-1, waterLevel - 0.4, -1); GL.Vertex3(SideLength * 16 - 1, waterLevel - 0.4, -1); GL.Vertex3(SideLength * 16 - 1, waterLevel - 0.4, SideLength * 16 - 1); GL.Vertex3(-1, waterLevel - 0.4, SideLength * 16 - 1); GL.End(); GL.PopMatrix(); _framebuffer.Release(); _framebufferUi.Use(); GL.ClearColor(0, 0, 0, 0); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit); _nvg.BeginFrame(_window.Width, _window.Height, 1); _nvg.Save(); _nvg.FillColor(NanoVg.Rgba(255, 255, 255, 255)); _nvg.FontFace("sans"); _nvg.FontSize(18); _nvg.TextAlign(NvgAlign.Top | NvgAlign.Left); _perfGraphFps.RenderGraph(_nvg, 4, 4); _nvg.Restore(); _ui.Render(this, _nvg); _nvg.EndFrame(); _framebufferUi.Release(); _uWidth.Value = _window.Width; _uHeight.Value = _window.Height; _uTexColor.Value = 0; _uTexUi.Value = 1; _uSamples.Value = _framebuffer.Samples; _uSamplesUi.Value = _framebufferUi.Samples; _shaderScreen.Use(_uWidth, _uHeight, _uTexColor, _uTexUi, _uSamples, _uSamplesUi); DrawFullscreenQuad(_framebuffer.TextureId, _framebufferUi.TextureId); _shaderScreen.Release(); }