protected virtual void RenderTextureStretchToScreen(GuiTexture tex)
        {
            if (tex == null)
            {
                return;
            }

            Shader.Bind();

            GL.BindVertexArray(GuiRenderer.GuiQuad.VaoID);

            Shader.UpdateGlobalUniforms();
            Shader.UpdateModelUniforms();
            Shader.UpdateInstanceUniforms(Matrix4.Identity, tex);

            GL.EnableVertexAttribArray(0);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, tex.ID);
            GL.DrawArrays(PrimitiveType.Quads, 0, 4);

            GL.DisableVertexAttribArray(0);

            Shader.Unbind();
        }
        public GuiScreen()
        {
            background_default = new GuiTexture(TextureManager.LoadTexture("gui/bg"), Vector2.Zero, Vector2.One * 16, 8);
            background         = new GuiTexture(TextureManager.LoadTexture("gui/bg_transparent"), Vector2.Zero, Vector2.One * 16, 8);
            visible            = true;

            Init();
        }
Exemple #3
0
        public GuiScreenInventory()
        {
            DoesGuiPauseGame = false;

            for (int i = 0; i < 36; i++)
            {
                buttons.Add(new GuiItemSlot(i, 0, 0, guiScale, null));
            }

            inventoryBackground = new GuiTexture(TextureManager.LoadTexture("gui/inventory_bg"), 0, 0, 318, 163, guiScale);
        }
        public GuiScreenMainMenu()
        {
            buttons.Add(new GuiButton(0, 0, -45, 2, @"\{66FF00}SINGLEPLAYER")
            {
                CenteredX = true, CenteredY = true
            });
            buttons.Add(new GuiButton(1, 0, 0, 2, @"\{FF0000}MULTIPLAYER")
            {
                CenteredX = true, CenteredY = true, Enabled = false
            });
            buttons.Add(new GuiButton(2, 0, 45, 2, @"\{FF0000}EXIT")
            {
                CenteredX = true, CenteredY = true
            });

            var titleTextgure = TextureManager.LoadTexture("gui/title");

            _titleTexture = new GuiTexture(titleTextgure, 0, 0, titleTextgure.TextureSize.Width, titleTextgure.TextureSize.Height);
        }
        protected virtual void RenderTexture(GuiTexture tex, float x, float y, bool cenetered = false)
        {
            if (tex == null)
            {
                return;
            }

            float width  = tex.Size.X * tex.Scale;
            float height = tex.Size.Y * tex.Scale;

            Vector2 ratio = new Vector2(width / SharpCraft.Instance.ClientSize.Width, height / SharpCraft.Instance.ClientSize.Height);

            Vector2 unit = new Vector2(1f / SharpCraft.Instance.ClientSize.Width, 1f / SharpCraft.Instance.ClientSize.Height);

            Vector2 pos = new Vector2(x, -y);

            if (!cenetered)
            {
                pos.X += width / 2;
                pos.Y -= height / 2;
            }

            Matrix4 mat = MatrixHelper.CreateTransformationMatrix(pos.Ceiling() * unit * 2 + Vector2.UnitY - Vector2.UnitX, ratio);

            Shader.Bind();

            GL.BindVertexArray(GuiRenderer.GuiQuad.VaoID);

            Shader.UpdateGlobalUniforms();
            Shader.UpdateModelUniforms();
            Shader.UpdateInstanceUniforms(mat, tex);

            GL.EnableVertexAttribArray(0);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, tex.ID);
            GL.DrawArrays(PrimitiveType.Quads, 0, 4);

            GL.DisableVertexAttribArray(0);

            Shader.Unbind();
        }
Exemple #6
0
        public GuiCrosshair()
        {
            Texture texture = TextureManager.LoadTexture("gui/cross");

            _texture = new GuiTexture(texture, Vector2.Zero, new Vector2(texture.TextureSize.Width, texture.TextureSize.Height), 1.4f);
        }