Ejemplo n.º 1
0
        /// <summary>
        /// Sets up and initializes OpenGL ES
        /// </summary>
        void SetupGL()
        {
            // Setup the Rendering Context...
            Context = new EAGLContext(EAGLRenderingAPI.OpenGLES2);
            if (Context == null)
            {
                Console.WriteLine("Failed to create ES context");
            }

            // Initialize the Renderer...
            Renderer = new ES2Renderer();

            // Initialize the View...
            View.Context = Context;
            View.EnableSetNeedsDisplay      = true;
            View.ClearsContextBeforeDrawing = false;
            View.DrawableDepthFormat        = GLKViewDrawableDepthFormat.Format24;
            View.DrawableMultisample        = GLKViewDrawableMultisample.None;
            View.DrawInRect += Draw;

            EAGLContext.SetCurrentContext(Context);

            GL.ClearDepth(0.0f);
            GL.DepthRange(0.0f, 1.0f);
            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Equal);
            GL.DepthMask(true);

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.Dither);
            GL.Disable(EnableCap.CullFace);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Tell opengl that we want to use OpenGL ES2 capabilities.
        /// This must be done right before the frame buffer is created.
        /// </summary>
        InitializationState InitializeOpenGL()
        {
            if (m_initialized == InitializationState.Uninitialized)
            {
                Renderer = new ES2Renderer();
                Renderer.AndroidContext = App.Manager.ApplicationContext;

                // Initialize and setup some start states...
                m_initialized = InitializationState.Initialized;

                GL.ClearDepth(0.0f);
                GL.DepthRange(0.0f, 1.0f);
                GL.Enable(EnableCap.DepthTest);
                GL.DepthFunc(DepthFunction.Equal);
                GL.DepthMask(true);

                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                GL.Disable(EnableCap.Dither);
                GL.Disable(EnableCap.CullFace);
            }

            return(m_initialized);
        }