Exemplo n.º 1
0
        public void MakeWindow()
        {
            GameWindowSettings   settings       = new GameWindowSettings();
            NativeWindowSettings nativeSettings = new NativeWindowSettings();

            using (TriangleWindow window = new TriangleWindow(settings, nativeSettings))
            {
                window.Run();
            }

            using (SquareWindow window = new SquareWindow(settings, nativeSettings))
            {
                window.Run();
            }

            using (TextureWindow window = new TextureWindow(settings, nativeSettings))
            {
                window.Run();
            }

            using (CubeWindow window = new CubeWindow(settings, nativeSettings))
            {
                window.Run();
            }
        }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Initializing");
            GameWindowSettings gws = new GameWindowSettings();

            gws.IsMultiThreaded = true;
            gws.RenderFrequency = 0.0;
            gws.UpdateFrequency = 60;

            if (args.Length > 0)
            {
                autoexit = true;
            }

            NativeWindowSettings nws = new NativeWindowSettings();

            nws.Size         = WindowSize;
            nws.Title        = "Display";
            nws.WindowBorder = WindowBorder.Fixed;

            Console.WriteLine("Creating game object");
            using (Game g = new Game(gws, nws)) {
                g.Run();
            }
        }
Exemplo n.º 3
0
        public Window(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings) : base(gameWindowSettings, nativeWindowSettings)
        {
            float x = 0.0f;
            float y = 0.0f;

            //radius lingkaran
            float radius = 0.5f;

            ////radius elips
            //float radius_x = 0.1f;
            //float radius_y = 0.2f;

            for (int i = 0; i < 360; i++)
            {
                //rumus derajat ke radian = derajat * 3.1416f / 180;
                float degInRad = i * 3.1416f / 180;

                //x
                //lingkaran
                _vertices_clock[i * 3] = x + (float)Math.Cos(degInRad) * radius;
                //elips
                //_vertices[i * 3] = x + (float)Math.Cos(degInRad) * radius_x;

                //y
                _vertices_clock[i * 3 + 1] = y + (float)Math.Sin(degInRad) * radius;
                //elips
                //_vertices[i * 3 + 1] = y + (float)Math.Sin(degInRad) * radius_y;

                //z
                _vertices_clock[i * 3 + 2] = 0;
            }
        }
Exemplo n.º 4
0
        public Window2D(Scene2D scene, GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            Scene = scene;

            eventContext = new EventContext();
        }
Exemplo n.º 5
0
 public Game(
     GameWindowSettings gameWindowSettings,
     NativeWindowSettings nativeWindowSettings)
     : base(gameWindowSettings, nativeWindowSettings)
 {
     Title = "Nile -> Ai";
 }
Exemplo n.º 6
0
        public void CreateWindow(System.Numerics.Vector2 size, bool hidden = false)
        {
            var settings = new GameWindowSettings()
            {
                IsMultiThreaded = false
            };

            var nsettings = new NativeWindowSettings()
            {
                API = ContextAPI.OpenGL,
                AutoLoadBindings = true,
                Size             = new Vector2i((int)size.X, (int)size.Y),
                Title            = "OpenH2",
                Flags            = ContextFlags.Debug,
                APIVersion       = new Version(4, 6),
                NumberOfSamples  = 8
            };

            window = new GameWindow(settings, nsettings);

            window.Resize          += this.Window_Resize;
            this.AspectRatio        = size.X / size.Y;
            this.AspectRatioChanged = true;

            window.IsVisible = !hidden;

            window.Closed += this.Window_Closed;

            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.AlphaTest);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.Enable(EnableCap.Blend);
        }
Exemplo n.º 7
0
 public Window(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings) : base(gameWindowSettings, nativeWindowSettings)
 {
     Console.WriteLine("\"Shaun the Sheep\" made by:");
     Console.WriteLine("Leonando L - C14190010");
     Console.WriteLine("Nicholas S - C14190034");
     Console.WriteLine("Jeremy H - C14190215");
     Console.WriteLine("\nControls:");
     Console.WriteLine("WASD - MOVE CAMERA");
     Console.WriteLine("LSHIFT - MOVE UP CAMERA");
     Console.WriteLine("LCTRL - MOVE DOWN CAMERA");
     Console.WriteLine("MOUSEWHEEL - ZOOM IN/OUT CAMERA");
     Console.WriteLine("R - RESET CAMERA");
     Console.WriteLine("");
     Console.WriteLine("LEFT MOUSE - HORIZONTAL SPIN");
     Console.WriteLine("RIGHT MOUSE - VERTICAL SPIN");
     Console.WriteLine("MIDDLE MOUSE - CIRCLE SPIN");
     Console.WriteLine("");
     Console.WriteLine("ARROW KEYS - MOVE LIGHT");
     Console.WriteLine("RSHIFT - MOVE UP LIGHT");
     Console.WriteLine("RCTRL - MOVE DOWN LIGHT");
     Console.WriteLine("L - RESET LIGHT");
     Console.WriteLine("");
     Console.WriteLine("F1 - SHOW HELP");
     Console.WriteLine("F7 - TOGGLE WIREFRAMES");
     Console.WriteLine("F8 - TOGGLE SOLIDS");
     Console.WriteLine("F9 - TOGGLE LIGHTBALL");
     Console.WriteLine("F10 - TOGGLE SHADOW");
     Console.WriteLine("F11 - TOGGLE FULLSCREEN");
     Console.WriteLine("F12 - TOGGLE ANIMATIONS");
     Console.WriteLine("\nActions:");
 }
Exemplo n.º 8
0
        public LightingGame(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings) : base(gameWindowSettings, nativeWindowSettings)
        {
            VSync = VSyncMode.On;

            _material = new Material(new Vector3(1.0f, 0.5f, 0.31f), new Vector3(1.0f, 0.5f, 0.31f), new Vector3(0.5f, 0.5f, 0.5f), 32.0f);
            _light    = new Light(new Vector3(1.0f, 3.0f, 3.0f), new Vector3(0.2f, 0.2f, 0.2f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(1.0f, 1.0f, 1.0f));
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            GameWindowSettings gameWinSettings = new GameWindowSettings();
            var nativeWindowSettings           = new NativeWindowSettings()
            {
                Size       = new Vector2i(800, 600),
                Title      = "Habi",
                APIVersion = new System.Version(4, 5),
                API        = ContextAPI.OpenGL,
                Flags      = ContextFlags.ForwardCompatible,
                Profile    = ContextProfile.Core,
            };

            int width, height, xpos, ypos;

            unsafe
            {
                var monitor = GLFW.GetPrimaryMonitor();
                var vidmode = GLFW.GetVideoMode(monitor);
                width  = vidmode->Width - 200;
                height = vidmode->Height - 100;
                xpos   = (vidmode->Width - width) / 2;
                ypos   = (vidmode->Height - height) / 2;
            }

            nativeWindowSettings.Size     = new Vector2i(width, height);
            nativeWindowSettings.Location = new Vector2i(xpos, ypos);

            using (var game = new Draw2DGame(gameWinSettings, nativeWindowSettings))
            {
                game.Run();
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            GameWindowSettings gwSettings = new GameWindowSettings()
            {
                //UpdateFrequency = 10,
                //RenderFrequency = 10,
            };

            NativeWindowSettings nwSettings = new NativeWindowSettings()
            {
                API              = ContextAPI.OpenGL,
                APIVersion       = new Version(3, 3),
                AutoLoadBindings = true,
                Flags            = ContextFlags.Debug | ContextFlags.ForwardCompatible,
                IsEventDriven    = false,
                Profile          = ContextProfile.Core,
                Size             = (800, 600),
                StartFocused     = true,
                StartVisible     = true,
                Title            = "Local OpenTK Test",
                WindowBorder     = WindowBorder.Resizable,
                WindowState      = WindowState.Normal,
            };

            using (Window window = new Window(gwSettings, nwSettings))
            {
                window.Run();
            }
        }
Exemplo n.º 11
0
        private void ActivateThisWindowContext(string title, uint width, uint height, bool fullscreen)
        {
            // We use OpenGL 2.0 (ie. fixed-function pipeline!)
            var settings = new GameWindowSettings();

            settings.IsMultiThreaded = false;
            var nativeSettings = new NativeWindowSettings();

            nativeSettings.Profile      = ContextProfile.Any;
            nativeSettings.WindowState  = WindowState.Normal;
            nativeSettings.API          = ContextAPI.OpenGL;
            nativeSettings.APIVersion   = new Version(2, 0);
            nativeSettings.IsFullscreen = fullscreen;

            window = new GameWindow(settings, nativeSettings)
            {
                Title = title,
                Size  = new OpenTK.Mathematics.Vector2i((int)width, (int)height)
            };

            GL.ClearDepth(1);
            GL.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);

            isRunning = true;
            window.Context.MakeCurrent();
            window.IsVisible = true;

            GL.Viewport(0, 0, window.Size.X, window.Size.Y);
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0.0, 1.0, 0.0, 1.0, 0.0, 4.0);
        }
Exemplo n.º 12
0
 //feets.bac
 public Window(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings) : base(gameWindowSettings, nativeWindowSettings)
 {
     GL.Enable(EnableCap.Multisample);
     GL.Disable(EnableCap.DepthTest);
     GL.Enable(EnableCap.Blend);
     GL.Enable(EnableCap.LineSmooth);
 }
Exemplo n.º 13
0
 public Game(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
     : base(gameWindowSettings, nativeWindowSettings)
 {
     frameCounter = 0.0f;
     sceneManager = new SceneManager(this);
     KeyDown     += sceneManager.ProcessKeyInput;
     MouseDown   += sceneManager.ProcessMouseButtonDown;
 }
Exemplo n.º 14
0
        /// <summary>
        /// Use this method to create an OpenGL context.
        /// Never use this method in your application, ONLY in unit testing.
        /// This will enable you to unit test classes which use OpenGL-dependent
        /// function calls, including `Text', `Image', and `ImageStride' classes.
        /// </summary>
        public static void CreateOpenGLContext()
        {
            var settings       = new GameWindowSettings();
            var nativeSettings = new NativeWindowSettings();

            Window._contextWin = new GameWindow(settings, nativeSettings);
            Window._contextWin.Context.MakeCurrent();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MyOTKEWindow"/> class.
        /// </summary>
        /// <param name="gameWindowSettings">The GameWindow related settings.</param>
        /// <param name="nativeWindowSettings">The NativeWindow related settings.</param>
        /// <param name="lockCursor">A value indicating whether the cursor is placed back at the center of the view during each update.</param>
        /// <param name="clearColor">The color to clear the view with on each render call.</param>
        public MyOTKEWindow(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings, bool lockCursor, Color clearColor)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            GlDebug.RegisterDebugCallback();

            this.LockCursor = lockCursor;
            this.clearColor = clearColor;
        }
Exemplo n.º 16
0
        public static AppWindow New(int width, int height)
        {
            GameWindowSettings   setting        = new GameWindowSettings();
            NativeWindowSettings nativeSettings = new NativeWindowSettings();

            nativeSettings.Size = new OpenTK.Mathematics.Vector2i(width, height);
            nativeSettings.API  = ContextAPI.OpenGL;
            return(new AppWindow(setting, nativeSettings));
        }
Exemplo n.º 17
0
        static void Main()
        {
            var gameSettings         = new GameWindowSettings();
            var nativeWindowSettings = new NativeWindowSettings();

            var program = new Program(gameSettings, nativeWindowSettings);

            program.Run();
        }
Exemplo n.º 18
0
        public static Lines2D New(int width, int height)
        {
            GameWindowSettings   setting        = new GameWindowSettings();
            NativeWindowSettings nativeSettings = new NativeWindowSettings();

            nativeSettings.Size = new Vector2i(width, height);
            nativeSettings.API  = ContextAPI.OpenGL;
            return(new Lines2D(setting, nativeSettings));
        }
Exemplo n.º 19
0
        public static Scene New(int width, int height, string title)
        {
            GameWindowSettings   setting        = new GameWindowSettings();
            NativeWindowSettings nativeSettings = new NativeWindowSettings();

            nativeSettings.Size  = new OpenTK.Mathematics.Vector2i(width, height);
            nativeSettings.Title = title;
            return(new Scene(setting, nativeSettings));
        }
Exemplo n.º 20
0
 public PolyWindow(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
     : base(gameWindowSettings, nativeWindowSettings)
 {
     Title       = "";
     updateFreq  = Convert.ToUInt64(UpdateFrequency);
     renderFreq  = Convert.ToUInt64(RenderFrequency);
     updateTimes = new double[updateFreq];
     renderTimes = new double[renderFreq];
 }
Exemplo n.º 21
0
        public MainWindow(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            Camera = new FpsCamera(Size.X, Size.Y);

            Camera.CameraPosition = new OpenToolkit.Mathematics.Vector3(0, -80, 40);
            Camera.CameraYaw      = -90;
            Camera.CameraPitch    = 90;
            Camera.RecalculateCamera(0, 0);
        }
Exemplo n.º 22
0
        /// <inheritdoc />
        public Game(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            _environment = System.Environment.Version.ToString();
            Input        = new Input(this);
            Global.Input = Input;

            DebugDrawer        = new DebugDrawer();
            Global.DebugDrawer = DebugDrawer;
        }
Exemplo n.º 23
0
        public static void Init(GameWindowSettings gws, NativeWindowSettings nws, GLRenderer renderer = null, Action initCallback = null)
        {
            _window = new GameWindow(gws, nws);

            //log basic info
            Logger.Log("Base Directory: " + AppContext.BaseDirectory, true);
            Logger.Log("Renderer: " + GL.GetString(StringName.Renderer), true);
            Logger.Log("Vendor: " + GL.GetString(StringName.Vendor), true);
            Logger.Log("Version: " + GL.GetString(StringName.Version), true);
            Logger.Log("Shading Language version: " + GL.GetString(StringName.ShadingLanguageVersion), true);

            //subscribe to window events
            MainWindow.UpdateFrame += UpdateFrame;
            MainWindow.RenderFrame += RenderFrame;

            //intialize engine
            Logger.Log("Initializing LeaderEngine...", true);
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            //init debug callbacks
            GLFW.SetErrorCallback(LogGLFWError);

            DebugProc debugProcCallback       = DebugCallback;
            GCHandle  debugProcCallbackHandle = GCHandle.Alloc(debugProcCallback);

            GL.DebugMessageCallback(debugProcCallback, IntPtr.Zero);
            GL.Enable(EnableCap.DebugOutput);
            GL.Enable(EnableCap.DebugOutputSynchronous);

            //init modules
            AssetManager.Init();
            DefaultShaders.Init();
            SpriteRenderer.Init();
            SkyboxRenderer.Init();

            _renderer = renderer ?? new ForwardRenderer();
            Renderer.Init();

            AudioManager.Init();

            Input.Init(MainWindow.KeyboardState, MainWindow.MouseState);

            //init main application
            initCallback?.Invoke();

            stopwatch.Stop();
            //print init complete msg
            Logger.Log($"LeaderEngine initialized. ({stopwatch.ElapsedMilliseconds}ms)", true);

            //open window
            MainWindow.Run();
        }
Exemplo n.º 24
0
        public static Game Initialize(int width, int height, double renderFrequency, string title)
        {
            GameWindowSettings   defaultGWS = GameWindowSettings.Default;
            NativeWindowSettings defaultNWS = NativeWindowSettings.Default;

            defaultGWS.RenderFrequency = renderFrequency;

            defaultNWS.Size  = new Vector2i(width, height);
            defaultNWS.Title = title;

            return(new Game(defaultGWS, defaultNWS));
        }
Exemplo n.º 25
0
        private App(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings) : base(gameWindowSettings, nativeWindowSettings)
        {
            // Enable things for correct texture opacity handling
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            // Window works ok if it is not fixed, but text can become bad if resized
            WindowBorder = WindowBorder.Resizable;

            VSync = VSyncMode.On;
        }
Exemplo n.º 26
0
        public RenderWindow(GameWindowSettings gameWindowSettings,
                            NativeWindowSettings nativeWindowSettings)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            Load        += MainWindowLoad;
            Resize      += MainWindowResize;
            RenderFrame += MainWindowRenderFrame;
            UpdateFrame += MainWindowUpdateFrame;

            RenderCommandUpdatesChannel = Channel.CreateUnbounded <IRenderCommand>();
            EventChannel = Channel.CreateUnbounded <IEvent>();
        }
Exemplo n.º 27
0
        public MainWindow(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings, Action initializeCallback) : base(gameWindowSettings, nativeWindowSettings)
        {
            if (instance != null)
            {
                Debug.WriteLine("Another instance is running!");
                return;
            }

            instance = this;

            this.initializeCallback = initializeCallback;
        }
Exemplo n.º 28
0
 public SDAV_Window(GameWindowSettings gameWindowSettings, NativeWindowSettings nativeWindowSettings)
     : base(gameWindowSettings, nativeWindowSettings)
 {
     originalSize = nativeWindowSettings.Size;
     if (Configuration.GetStringProperty("captureType").Equals("Microphone"))
     {
         captureType = ECaptureType.Microphone;
     }
     else
     {
         captureType = ECaptureType.Loopback;
     }
 }
Exemplo n.º 29
0
        static void Main(string[] args)
        {
            var gameWinSettings   = new GameWindowSettings();
            var nativeWinSettings = new NativeWindowSettings();

            nativeWinSettings.Size = new Vector2i(1020, 800);


            var game = new Game(gameWinSettings, nativeWinSettings);

            game.Run();

            game.Dispose();
        }
Exemplo n.º 30
0
        public BremuGbWindow(NativeWindowSettings nativeWindowSettings, GameWindowSettings gameWindowSettings, GameBoy gameBoy)
            : base(gameWindowSettings, nativeWindowSettings)
        {
            _gameBoy = gameBoy;
            _gameBoy.OutputTerminalChangedEvent += new EventHandler(OnSoundOutputTerminalChanged);
            _gameBoy.MasterVolumeChangedEvent   += new EventHandler(OnMasterVolumeChangedEvent);
            _gameBoy.NextFrameReadyEvent        += new EventHandler(OnNextFrameReady);

            _soundPlayer    = new SoundPlayer();
            _screenRenderer = new ScreenRenderer();

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
        }