예제 #1
0
        public void Init(IntPtr windowHandle, Size size)
        {
            if (!CreateEGLContext())
            {
                Debug.WriteLine("Failed to create EGL context.");
                return;
            }

            var nativeWindow = windowHandle;

            if (!CreateEGLSurface(nativeWindow))
            {
                Debug.WriteLine("Failed to create EGL surface.");
                return;
            }

            OpenGLMaterial.InitCommonMaterials();

            // Other state
            GL.Disable(GL.GL_CULL_FACE);
            GL.Disable(GL.GL_DEPTH_TEST);
            GL.DepthFunc(GL.GL_NEVER);
            GL.Enable(GL.GL_SCISSOR_TEST);

            Utility.CheckGLESError();
        }
예제 #2
0
        public void Init(IntPtr windowHandle, Size size)
        {
            CreateOpenGLContext(windowHandle);
            OpenGLMaterial.InitCommonMaterials();
            ImGui.Development.SpecialMesh.Init();

            // Other state
            GL.Enable(GL.GL_MULTISAMPLE);
            GL.Disable(GL.GL_CULL_FACE);
            GL.Disable(GL.GL_DEPTH_TEST);
            GL.DepthFunc(GL.GL_NEVER);
            GL.Enable(GL.GL_SCISSOR_TEST);

            //set-up framebuffer
            GL.GenFramebuffers(1, framebuffers);
            GL.GenTextures(1, textures);
            framebuffer = framebuffers[0];
            framebufferColorTexture = textures[0];
            GL.BindFramebuffer(GL.GL_FRAMEBUFFER_EXT, framebuffer);

            //attach color texture to the framebuffer
            GL.BindTexture(GL.GL_TEXTURE_2D, framebufferColorTexture);
            GL.TexImage2D(GL.GL_TEXTURE_2D, 0, GL.GL_RGBA,
                (int)size.Width, (int)size.Height, 0,
                GL.GL_RGB, GL.GL_UNSIGNED_BYTE, IntPtr.Zero);
            GL.FramebufferTexture2D(GL.GL_FRAMEBUFFER_EXT, GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_TEXTURE_2D,
                framebufferColorTexture, 0);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, (int)GL.GL_CLAMP);
            GL.TexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, (int)GL.GL_CLAMP);

            GL.GetFramebufferAttachmentParameteriv(GL.GL_FRAMEBUFFER_EXT,
                GL.GL_COLOR_ATTACHMENT0_EXT, GL.GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE, IntBuffer);
            Utility.CheckGLError();
            var alphaBits = IntBuffer[0];
            if(alphaBits != 8)
            {
                throw new Exception("Framebuffer format is not R8G8B8A8.");
            }

            //check if framebuffer is complete
            if (GL.CheckFramebufferStatus(GL.GL_FRAMEBUFFER_EXT) != GL.GL_FRAMEBUFFER_COMPLETE_EXT)
            {
                throw new Exception("Framebuffer is not complete.");
            }
            GL.BindFramebuffer(GL.GL_FRAMEBUFFER_EXT, 0);

            quadMesh = new QuadMesh(size.Width, size.Height);
            Utility.CheckGLError();
        }
예제 #3
0
        public void Init(IntPtr windowHandle, Size size)
        {
            CreateOpenGLContext(windowHandle);
            OpenGLMaterial.InitCommonMaterials();
            ImGui.Development.SpecialMesh.Init();

            // Other state
            GL.Enable(GL.GL_MULTISAMPLE);
            GL.Disable(GL.GL_CULL_FACE);
            GL.Disable(GL.GL_DEPTH_TEST);
            GL.DepthFunc(GL.GL_NEVER);
            GL.Enable(GL.GL_SCISSOR_TEST);

            InitializeTextRenderResources(size);
        }