internal Keyboard(Window window) { _downKeys = new HashSet<Key>(); window.NativeWindow.KeyDown += _KeyDown; window.NativeWindow.KeyUp += _KeyUp; window.NativeWindow.KeyPress += _KeyPress; }
internal Mouse(Window window) { _downButtons = new HashSet<Button>(); _window = window; window.NativeWindow.MouseDown += _ButtonDown; window.NativeWindow.MouseUp += _ButtonUp; window.NativeWindow.MouseWheel += WheelMove; window.NativeWindow.MouseMove += MouseMove; }
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; } } }
public Renderer(Window window, bool verticalSync) : this(window.NativeWindow.WindowInfo.Handle, window.Width, window.Height) { VerticalSync = verticalSync; }