当前位置: 首页>>代码示例>>C#>>正文


C# Gaming.GlfwWindowPtr类代码示例

本文整理汇总了C#中Pencil.Gaming.GlfwWindowPtr的典型用法代码示例。如果您正苦于以下问题:C# GlfwWindowPtr类的具体用法?C# GlfwWindowPtr怎么用?C# GlfwWindowPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GlfwWindowPtr类属于Pencil.Gaming命名空间,在下文中一共展示了GlfwWindowPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PencilGamingWindows

        public PencilGamingWindows(int width, int height, string title, bool isFullscreen, bool shouldVsync)
        {
            onWindowOpened = new Trigger<PencilGamingWindows>();
            OnWindowOpened = onWindowOpened;

            onWindowClosed = new Trigger<PencilGamingWindows>();
            OnWindowClosed = onWindowClosed;

            onWindowResized = new Trigger<PencilGamingWindows>();
            OnWindowResized = onWindowResized;

            onKeyboard = new Trigger<PencilKeyInfo>();
            OnKeyboard = onKeyboard;

            onExit = new Trigger<PencilGamingWindows>();
            OnExit = onExit;

            window = GlfwWindowPtr.Null;
            this.width = width;
            this.height = height;
            this.title = title;
            this.isFullscreen = isFullscreen;
            this.shouldVsync = shouldVsync;
            this.firstTime = true;
            if (!Glfw.Init())
            {
                Console.Error.WriteLine("ERROR: Could not initialize GLFW, shutting down.");
                Environment.Exit(1);
            }
        }
开发者ID:prepare,项目名称:three.net,代码行数:30,代码来源:PencilGamingWindows.cs

示例2: 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

示例3: GetState

		public static KeyboardState GetState(GlfwWindowPtr window) {
			KeyboardState result = new KeyboardState();

			for (int i = 0; i < allKeys.Length; ++i) {
				Key k = allKeys[i];
				result.keys[k] = Glfw.GetKey(window, k);
			}

			return result;
		}
开发者ID:nagyist,项目名称:Pencil.Gaming,代码行数:10,代码来源:Glfw3KeyboardState.cs

示例4: Initialize

        public void Initialize()
        {
            try
            {
                // Throws and Exception if GLFW cannot be initialized
                if (!Glfw.Init())
                    throw new GlfwInitException();

                // Creates the Window
                window = Glfw.CreateWindow(Width, Height, Caption, GlfwMonitorPtr.Null, GlfwWindowPtr.Null);

                // Window Hints
                Glfw.WindowHint(WindowHint.ContextVersionMajor, 3);
                Glfw.WindowHint(WindowHint.ContextVersionMinor, 0);
                Glfw.WindowHint(WindowHint.OpenGLProfile, (int)OpenGLProfile.Core);
                Glfw.WindowHint((WindowHint)WindowAttrib.Resizeable, Convert.ToInt32(false));
                Glfw.WindowHint(WindowHint.OpenGLForwardCompat, Convert.ToInt32(true)); // This is for the client to work in MacOS

                // Without this the window will not pop up
                Glfw.MakeContextCurrent(window);

                // This is shown as a false in C++ but false = 0 so that's why it's a 0
                Glfw.SwapInterval(0);

                // Set Key callback for the window
                Glfw.SetKeyCallback(window, OnKeyCallback);

                // Anything else you want to initialize should go here
                // i.e ShaderProgram if you want to use Modern openGL

                // END

                while (!Glfw.WindowShouldClose(window))
                {
                    Glfw.PollEvents();

                    // Add Anything you need to Render HERE

                    OnWindowRender();

                    // END

                    Glfw.SwapBuffers(window);
                }
            }
            catch (Exception ex)
            {

            }
            finally
            {
                Glfw.Terminate();
            }
        }
开发者ID:enguard,项目名称:Ecalia,代码行数:54,代码来源:World.cs

示例5: GetMouseState

		public static MouseState GetMouseState(GlfwWindowPtr window) {
			MouseState result = new MouseState();

			result.LeftButton = Glfw.GetMouseButton(window, MouseButton.LeftButton);
			result.MiddleButton = Glfw.GetMouseButton(window, MouseButton.MiddleButton);
			result.RightButton = Glfw.GetMouseButton(window, MouseButton.RightButton);
			int x, y;
			Glfw.GetCursorPos(window, out x, out y);
			result.X = x;
			result.Y = y;

			return result;
		}
开发者ID:AmzBee,项目名称:Pencil.Gaming,代码行数:13,代码来源:Glfw3MouseState.cs

示例6: 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

示例7: glfwGetWindowMonitor

 internal static extern GlfwMonitorPtr glfwGetWindowMonitor(GlfwWindowPtr window);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例8: glfwShowWindow

 internal static extern void glfwShowWindow(GlfwWindowPtr window);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例9: glfwHideWindow

 internal static extern void glfwHideWindow(GlfwWindowPtr window);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例10: glfwIconifyWindow

 internal static extern void glfwIconifyWindow(GlfwWindowPtr window);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例11: glfwRestoreWindow

 internal static extern void glfwRestoreWindow(GlfwWindowPtr window);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例12: 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

示例13: glfwSetFramebufferSizeCallback

 internal static extern GlfwFramebufferSizeFun glfwSetFramebufferSizeCallback(GlfwWindowPtr window, GlfwFramebufferSizeFun cbfun);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例14: glfwSetWindowTitle

 internal static extern void glfwSetWindowTitle(GlfwWindowPtr window, [MarshalAs(UnmanagedType.LPStr)] string title);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs

示例15: glfwGetClipboardString

 internal static extern sbyte* glfwGetClipboardString(GlfwWindowPtr window);
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:1,代码来源:Glfw3_32.cs


注:本文中的Pencil.Gaming.GlfwWindowPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。