void InitOpenGL() { if (!OpenGLDriver.Init(width, height)) { Console.WriteLine("GLFW init error"); return; } Console.WriteLine("GLFW init OK"); }
public IOSWindow(IOSAppDelegate appDelegate) { _displaySize = new Vector2Int( (int)UIScreen.MainScreen.NativeBounds.Size.Width, (int)UIScreen.MainScreen.NativeBounds.Size.Height ); _stopwatch = new Stopwatch(); _stopwatch2 = new Stopwatch(); // Create the window Window = new UIWindow(UIScreen.MainScreen.Bounds); Window.RootViewController = new NozNavigationController(); Window.BackgroundColor = UIColor.White; Window.MakeKeyAndVisible(); appDelegate.Window = Window; // Create GL context GLContext = new EAGLContext(EAGLRenderingAPI.OpenGLES3); EAGLContext.SetCurrentContext(GLContext); // Create teh view _view = new NozView(this, Window.Bounds); _view.MultipleTouchEnabled = true; _view.UserInteractionEnabled = true; Window.AddSubview(_view); Graphics.Driver = OpenGLDriver.Create(); // Create render buffer.. _renderBufferId = GL.GenRenderBuffer(); GL.BindRenderBuffer(_renderBufferId); GLContext.RenderBufferStorage((uint)GL.Imports.GL_RENDERBUFFER, (CAEAGLLayer)_view.Layer); // Create frame buffer _frameBufferId = GL.GenFrameBuffer(); GL.BindFrameBuffer(_frameBufferId); GL.FrameBufferRenderBuffer(_renderBufferId); var link = CADisplayLink.Create(() => { Application.Step(); }); link.PreferredFramesPerSecond = 60; link.AddToRunLoop(NSRunLoop.Main, NSRunLoopMode.Default); }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.D)) { float r = Random.Range(0f, 1f); float g = Random.Range(0f, 1f); float b = Random.Range(0f, 1f); OpenGLDriver.SwapBuffers(() => DrawOpenGL(1)); } if (Input.GetKey(KeyCode.E)) { OpenGLDriver.SwapBuffers(() => DrawOpenGL(2)); } uint currentFrameBuffer = GL.GetCurrentFrameBuffer(); var texture = randomTexture2D(10, 10); _rendererComponent.material.SetTexture("_EmissionMap", texture); }
private void OnDestroy() { OpenGLDriver.DeInit(); }