Example #1
0
 public Sprite(int width, int height, int x, int y, Texture texture)
 {
     Shader = new SpriteShader();
     Shader.Texture = texture;
     Mesh = new Mesh(Shader);
     Mesh.Indices = new uint[] { 0, 1, 2, 2, 3, 1 };
     Mesh.TextureCoordinates = new float[] { 0, 0, 1, 0, 0, 1, 1, 1 };
     vertices = new float[12];
     Width = width;
     Height = height;
     X = x;
     Y = y;
     Texture = texture;
 }
Example #2
0
 public BasicTexturedShader(Texture texture)
     : base(Utility.GetSource("Dunamis.Common.Shaders.Sources.BasicTexturedVertex.txt"), Utility.GetSource("Dunamis.Common.Shaders.Sources.BasicTexturedFragment.txt"), ShaderState.Dynamic)
 {
     this.Texture = texture;
 }
Example #3
0
 protected void UpdateTexture(string identifier, Texture texture)
 {
     GL.ActiveTexture((TextureUnit)33984 + _textures[identifier]);
     GL.BindTexture(TextureTarget.Texture2D, texture.TextureId);
     GL.Uniform1(_parameters[identifier], _textures[identifier]);
 }
Example #4
0
        protected void AddTexture(string identifier, Texture texture)
        {
            int number = _textures.Count;
            int location = GL.GetUniformLocation(ShaderProgram, identifier);
            GL.ActiveTexture((TextureUnit)33984 + number);
            GL.BindTexture(TextureTarget.Texture2D, texture.TextureId);
            GL.Uniform1(location, number);

            _parameters.Add(identifier, location);
            _textures.Add(identifier, number);
        }
Example #5
0
 public Sprite(int width, int height, Texture texture)
     : this(width, height, 0, 0, texture)
 {
 }
Example #6
0
        int _width; // TODO: changable width/height

        #endregion Fields

        #region Constructors

        public RenderTexture()
        {
            GL.GenFramebuffers(1, out FrameBuffer);
            _color = new Texture();
            _depth = new Texture();
        }
Example #7
0
        public override void Run()
        {
            window = new Window(1280, 720); // Create a window with the resolution 1280x720.
            renderer = new Renderer(window, false); // Create our renderer using our window, enabling vsync.
            renderer.ClearColor = new Color3(12, 12, 12); // Set our clear color to an almost black color.

            k = window.Keyboard;

            Texture t = new Texture("Resources/Untitled.png", TextureFilter.Nearest, true);

            ourShader = new ShaderTest4(); // Create our shader.
            ourShader.Texture = t;
            xxxx = new ShaderTest4();
            // ourShader.Texture = Texture.Default;
            //cube = new Cube(ourShader); // Create our cube using our shader.
            cube = new Mesh(RenderTextureMesh.RenderTextureVertices, RenderTextureMesh.RenderTextureTextureCoordinates, new float[0],
                RenderTextureMesh.RenderTextureIndices, ourShader);
            xxxxddddd = new Mesh(Cube.CubeVertices, Cube.CubeTextureCoordinates, new float[0],
                Cube.CubeIndices, ourShader);
            sprite = new Sprite(200, 200, t);
            sprite.X = 0;
            sprite.Y = 200;
            sprite.Width = 400;

            renderer.Camera.Position = new Vector3(2, 2, 2); // Set our camera position to 2, 2, 2 (XYZ)
            renderer.Camera.Pitch = Angle.CreateDegrees(35); // Set our camera's pitch.
            renderer.Camera.Yaw = Angle.CreateDegrees(315); // Set our camera's yaw.

            //Text x = new Text("DUNAMIS", new Font("DINRg.ttf"), 24, false, false, false, Color4.White, true, 0, 0);
            //  x.String = "HELLO";

            testere = new Text("DUNAMIS hello", new Font("Resources/DINRg.ttf"));
            testere.Color = Color4.White;
            testere.Size = 54;

            while (true)
            {
                cube.Yaw += 0.0005f;
                renderer.Clear(); // Clear the screen.

                renderer.Draw(cube); // Draw our cube.
                renderer.Draw(xxxxddddd); // TODO: fix texture not switching to empty
                renderer.Draw(sprite);
                // renderer.Draw(x);
                renderer.Draw(testere);

                renderer.Display(); // Display the result.
                window.Update(); // Update window events.

                if (k.IsKeyDown(Key.Z))
                {
                    renderer.Camera.FieldOfView -= 0.05f;
                }
                if (k.IsKeyDown(Key.X))
                {
                    renderer.Camera.FieldOfView += 0.05f;
                }
                if (k.IsKeyDown(Key.A))
                {
                    renderer.Camera.Yaw -= 0.0005f;
                }
                if (k.IsKeyDown(Key.D))
                {
                    renderer.Camera.Yaw += 0.0005f;
                }
                if (k.IsKeyDown(Key.W))
                {
                    renderer.Camera.Pitch -= 0.0005f;
                }
                if (k.IsKeyDown(Key.S))
                {
                    renderer.Camera.Pitch += 0.0005f;
                }
            }
        }