當前位置: 首頁>>代碼示例>>C#>>正文


C# GlfwWindowPtr.Equals方法代碼示例

本文整理匯總了C#中Pencil.Gaming.GlfwWindowPtr.Equals方法的典型用法代碼示例。如果您正苦於以下問題:C# GlfwWindowPtr.Equals方法的具體用法?C# GlfwWindowPtr.Equals怎麽用?C# GlfwWindowPtr.Equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Pencil.Gaming.GlfwWindowPtr的用法示例。


在下文中一共展示了GlfwWindowPtr.Equals方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: create

		public static void create(int w, int h) {
			Width = w;
			Height = h;
			AspectRatio = Width / (float) Height;

			Glfw.WindowHint(WindowHint.Samples, 4);
			Glfw.WindowHint(WindowHint.ContextVersionMajor, 3);
			Glfw.WindowHint(WindowHint.ContextVersionMinor, 3);
			Glfw.WindowHint(WindowHint.OpenGLForwardCompat, GL_TRUE);
			Glfw.WindowHint(WindowHint.OpenGLProfile, OpenGLProfile.Core.GetHashCode());
			GlfwVidMode[] modes = Glfw.GetVideoModes(Glfw.GetPrimaryMonitor());

			Console.WriteLine("Displays");
			foreach (GlfwVidMode mode in modes) {
				Console.WriteLine(mode.Width + "x" + mode.Height + "\tr" + mode.RedBits + " g" + mode.GreenBits + " b" + mode.BlueBits + "\t " + mode.RefreshRate + "Hz");
			}
			GlfwVidMode defMode = Glfw.GetVideoMode(Glfw.GetPrimaryMonitor());
			Console.WriteLine("Default Display\n" + defMode.Width + "x" + defMode.Height + "\tr" + defMode.RedBits + " g" + defMode.GreenBits + " b" + defMode.BlueBits + "\t " + defMode.RefreshRate + "Hz");

			//Width = defMode.Width;
			//Height = defMode.Height;
			//window = Glfw.CreateWindow(Width, Height, title, Glfw.GetPrimaryMonitor(), GlfwWindowPtr.Null);

			window = Glfw.CreateWindow(Width, Height, title, GlfwMonitorPtr.Null, GlfwWindowPtr.Null);
			if (window.Equals(GlfwWindowPtr.Null)) {
				Glfw.Terminate();
				Console.WriteLine("Failed to create Window");
				Console.WriteLine("Press Any Key to continue ...");
				Console.ReadKey();
				Environment.Exit(1);
			}

			Glfw.MakeContextCurrent(window);

		}
開發者ID:Xenation,項目名稱:OpenGL-Tests,代碼行數:35,代碼來源:GameWindow.cs

示例2: AppMain

        // the pragram starts here
        private static void AppMain()
        {
            // initialize GLFW
            if (!Glfw.Init())
                throw new Exception("glfwInit failed");

            // open a window with GLFW
            Glfw.WindowHint(WindowHint.OpenGLProfile, (int)OpenGLProfile.Core);
            Glfw.WindowHint(WindowHint.ContextVersionMajor, 3);
            Glfw.WindowHint(WindowHint.ContextVersionMinor, 2);
            _window = Glfw.CreateWindow(ScreenSize.X, ScreenSize.Y, "", GlfwMonitorPtr.Null, GlfwWindowPtr.Null);
            if (_window.Equals(GlfwWindowPtr.Null))
                throw new Exception("glfwOpenWindow failed. Can your hardware handle OpenGL 3.2?");
            Glfw.MakeContextCurrent(_window);

            // TODO: GLEW in C#

            // print out some info about the graphics drivers
            Console.WriteLine("OpenGL version: {0}", GL.GetString(StringName.Version));
            Console.WriteLine("GLSL version: {0}", GL.GetString(StringName.ShadingLanguageVersion));
            Console.WriteLine("Vendor: {0}", GL.GetString(StringName.Vendor));
            Console.WriteLine("Renderer: {0}", GL.GetString(StringName.Renderer));

            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Less);

            // load vertex and fragment shaders into opengl
            LoadShaders();

            // load the texture
            LoadTexture();

            // create buffer and fill it with the points of the triangle
            LoadCube();

            double lastTime = Glfw.GetTime();
            // run while window is open
            while (!Glfw.WindowShouldClose(_window)) {
                // update the scene based on the time elapsed since last update
                double thisTime = Glfw.GetTime();
                Update(thisTime - lastTime);
                lastTime = thisTime;

                // draw one frame
                Render();
            }

            // clean up and exit
            Glfw.Terminate();
        }
開發者ID:remy22,項目名稱:opengl-series-csharp,代碼行數:51,代碼來源:Tutorial03.cs

示例3: AppMain

        // the pragram starts here
        private static void AppMain()
        {
            // initialize GLFW
            if (!Glfw.Init())
                throw new Exception("glfwInit failed");

            // open a window with GLFW
            Glfw.WindowHint(WindowHint.OpenGLProfile, (int)OpenGLProfile.Core);
            Glfw.WindowHint(WindowHint.ContextVersionMajor, 3);
            Glfw.WindowHint(WindowHint.ContextVersionMinor, 2);
            _window = Glfw.CreateWindow(ScreenSize.X, ScreenSize.Y, "", GlfwMonitorPtr.Null, GlfwWindowPtr.Null);
            if (_window.Equals(GlfwWindowPtr.Null))
                throw new Exception("glfwOpenWindow failed. Can your hardware handle OpenGL 3.2?");
            Glfw.MakeContextCurrent(_window);

            // GLFW settings
            Glfw.SetInputMode(_window, InputMode.CursorMode, CursorMode.CursorHidden | CursorMode.CursorCaptured);
            Glfw.SetCursorPos(_window, 0, 0);
            Glfw.SetScrollCallback(_window, new GlfwScrollFun((win, x, y) => {
                //increase or decrease field of view based on mouse wheel
                float zoomSensitivity = -0.2f;
                float fieldOfView = _gCamera.FieldOfView + zoomSensitivity * (float)y;
                if (fieldOfView < 5.0f) fieldOfView = 5.0f;
                if (fieldOfView > 130.0f) fieldOfView = 130.0f;
                _gCamera.FieldOfView = fieldOfView;
            }));

            // TODO: GLEW in C#

            // print out some info about the graphics drivers
            Console.WriteLine("OpenGL version: {0}", GL.GetString(StringName.Version));
            Console.WriteLine("GLSL version: {0}", GL.GetString(StringName.ShadingLanguageVersion));
            Console.WriteLine("Vendor: {0}", GL.GetString(StringName.Vendor));
            Console.WriteLine("Renderer: {0}", GL.GetString(StringName.Renderer));

            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Less);

            // initialise the gWoodenCrate asset
            LoadWoodenCrateAsset();

            // create all the instances in the 3D scene based on the gWoodenCrate asset
            CreateInstances();

            _gCamera.Position = new Vector3(-4, 0, 17);
            _gCamera.ViewportAspectRatio = (float)ScreenSize.X / (float)ScreenSize.Y;
            _gCamera.SetNearAndFarPlanes(0.5f, 100.0f);

            // setup light
            _gLight = new Light() {
                Position = _gCamera.Position,
                Intensities = new Vector3(1, 1, 1), // white
                Attenuation = 0.2f,
                AmbientCoefficient = 0.005f
            };

            float lastTime = (float)Glfw.GetTime();
            // run while window is open
            while (!Glfw.WindowShouldClose(_window)) {
                // update the scene based on the time elapsed since last update
                float thisTime = (float)Glfw.GetTime();
                Update(thisTime - lastTime);
                lastTime = thisTime;

                // draw one frame
                Render();
                //exit program if escape key is pressed
                if (Glfw.GetKey(_window, Key.Escape))
                    Glfw.SetWindowShouldClose(_window, true);
            }

            // clean up and exit
            Glfw.Terminate();
        }
開發者ID:remy22,項目名稱:opengl-series-csharp,代碼行數:75,代碼來源:Tutorial07.cs

示例4: AppMain

        // the pragram starts here
        private static void AppMain()
        {
            // initialize GLFW
            if (!Glfw.Init())
                throw new Exception("glfwInit failed");

            // open a window with GLFW
            Glfw.WindowHint(WindowHint.OpenGLProfile, (int)OpenGLProfile.Core);
            Glfw.WindowHint(WindowHint.ContextVersionMajor, 3);
            Glfw.WindowHint(WindowHint.ContextVersionMinor, 2);
            _window = Glfw.CreateWindow(ScreenSize.X, ScreenSize.Y, "", GlfwMonitorPtr.Null, GlfwWindowPtr.Null);
            if (_window.Equals(GlfwWindowPtr.Null))
                throw new Exception("glfwOpenWindow failed. Can your hardware handle OpenGL 3.2?");
            Glfw.MakeContextCurrent(_window);

            // GLFW settings
            Glfw.SetInputMode(_window, InputMode.CursorMode, CursorMode.CursorHidden | CursorMode.CursorCaptured);
            Glfw.SetCursorPos(_window, 0, 0);
            Glfw.SetScrollCallback(_window, new GlfwScrollFun((win, x, y) => {
                //increase or decrease field of view based on mouse wheel
                float zoomSensitivity = -0.2f;
                float fieldOfView = _gCamera.FieldOfView + zoomSensitivity * (float)y;
                if (fieldOfView < 5.0f) fieldOfView = 5.0f;
                if (fieldOfView > 130.0f) fieldOfView = 130.0f;
                _gCamera.FieldOfView = fieldOfView;
            }));

            // TODO: GLEW in C#

            // print out some info about the graphics drivers
            Console.WriteLine("OpenGL version: {0}", GL.GetString(StringName.Version));
            Console.WriteLine("GLSL version: {0}", GL.GetString(StringName.ShadingLanguageVersion));
            Console.WriteLine("Vendor: {0}", GL.GetString(StringName.Vendor));
            Console.WriteLine("Renderer: {0}", GL.GetString(StringName.Renderer));

            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Less);

            // load vertex and fragment shaders into opengl
            LoadShaders();

            // load the texture
            LoadTexture();

            // create buffer and fill it with the points of the triangle
            LoadCube();

            _gCamera.Position = new Vector3(0, 0, 4);
            _gCamera.ViewportAspectRatio = (float)ScreenSize.X / (float)ScreenSize.Y;

            double lastTime = Glfw.GetTime();
            // run while window is open
            while (!Glfw.WindowShouldClose(_window)) {
                // update the scene based on the time elapsed since last update
                double thisTime = Glfw.GetTime();
                Update(thisTime - lastTime);
                lastTime = thisTime;

                // draw one frame
                Render();
                //exit program if escape key is pressed
                if (Glfw.GetKey(_window, Key.Escape))
                    Glfw.SetWindowShouldClose(_window, true);
            }

            // clean up and exit
            Glfw.Terminate();
        }
開發者ID:remy22,項目名稱:opengl-series-csharp,代碼行數:69,代碼來源:Tutorial04.cs


注:本文中的Pencil.Gaming.GlfwWindowPtr.Equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。