protected override void Draw() { base.Draw(); if (shader == null) { shader = game.Shaders.Load(VertexShader.Colour, FragmentShader.Colour); } shader.Bind(); batch.Add(new Vertex2d() { Colour = DrawInfo.Colour, Position = screenSpaceDrawQuad.BottomLeft }); batch.Add(new Vertex2d() { Colour = DrawInfo.Colour, Position = screenSpaceDrawQuad.BottomRight }); batch.Add(new Vertex2d() { Colour = DrawInfo.Colour, Position = screenSpaceDrawQuad.TopRight }); batch.Add(new Vertex2d() { Colour = DrawInfo.Colour, Position = screenSpaceDrawQuad.TopLeft }); batch.Draw(); shader.Unbind(); }
protected override void OnRenderFrame(FrameEventArgs e) { var total = watch.Elapsed.TotalSeconds; watch.Restart(); watch.Start(); frames++; if (frames > 30) { frames = 0; Console.WriteLine($"FPS: {Math.Round(1d / total, 0)}"); } //GL.Clear(ClearBufferMask.ColorBufferBit); batch.Shader.AdditionalTransform = transform; batch.Draw(); batch2.Shader.AdditionalTransform = transform; batch2.Draw(); Context.SwapBuffers(); // Swap the front/back buffers so what we just rendered to the back buffer is displayed in the window. base.OnRenderFrame(e); }
// D R A W protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.TransparentBlack); quadBatch.Begin(tex, BlendState.NonPremultiplied); // draw character first quadBatch.Draw(pixel, screenpos - new Vector2(4, 4), new Vector2(0.5f, 0.5f), 9.5f, player_body.Rotation, Color.Red); // draw grass grassChain[0].Draw(gras1, 1.2f, 0f, 10f, 20f, rotate_base: true); grassChain[1].Draw(gras2, 1f, 0f, 0f, 30f, rotate_base: false); grassChain[2].Draw(gras3, 1.3f, 0f, 20f, 40f, rotate_base: true); // draw big grass as foreground quadBatch.Draw(BigGrass, new Vector2(300, 600 - 20), Color.White); quadBatch.End(); base.Draw(gameTime); }
protected override void PostDraw() { base.PostDraw(); frameBuffer.Unbind(); GLWrapper.PopOrtho(); GLWrapper.PopViewport(); GLWrapper.SetBlend(BlendingFactorSrc.One, BlendingFactorDest.OneMinusSrcAlpha); Rectangle textureRect = new Rectangle(0, frameBuffer.Texture.Height, frameBuffer.Texture.Width, -frameBuffer.Texture.Height); frameBuffer.Texture.Draw(screenSpaceDrawQuad, textureRect, DrawInfo.Colour, batch); // In the case of nested framebuffer containerse we need to draw to // the last framebuffer container immediately, so let's force it batch.Draw(); }
/// <summary> /// Core drawing method in OpenGL /// </summary> /// <param name="lineList">List of lines to use</param> /// <param name="globalRadius">Width of the slider</param> /// <param name="texture">Texture used for the track</param> /// <param name="prev">The last line which was rendered in the previous iteration, or null if this is the first iteration.</param> private void DrawOGL(List <Line> lineList, float globalRadius, TextureGl texture, Line prev, int lineCount) { GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.Blend); GL.Enable(EnableCap.DepthTest); GL.DepthMask(true); GL.DepthFunc(DepthFunction.Lequal); GL.Clear(ClearBufferMask.DepthBufferBit); OsuGlControl.TextureShader3D.Begin(); OsuGlControl.BindTexture(texture.TextureId); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)All.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)All.Linear); if (lineCount == -1) { lineCount = lineList.Count; } for (int x = 1; x < lineCount; x++) { DrawLineOGL(prev, lineList[x - 1], lineList[x], globalRadius); prev = lineList[x - 1]; } DrawLineOGL(prev, lineList[lineCount - 1], null, globalRadius); quadBatch.Draw(); halfCircleBatch.Draw(); OsuGlControl.TextureShader3D.End(); GL.Disable(EnableCap.DepthTest); GL.DepthMask(false); GL.Enable(EnableCap.Blend); }
internal void EndQuad() { quadBatch.Draw(); OsuGlControl.ColourShader2D.End(); }