Exemplo n.º 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;
 }
Exemplo n.º 2
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;
                }
            }
        }