コード例 #1
0
        /// <summary>
        /// Subview のレイアウト時のコールバック
        ///
        /// SafeArea 周りのパラメータがこのタイミングで取得出来るようになるので
        /// ViewDidLoad() で行なっていた処理を移動
        /// </summary>
        public override void ViewWillLayoutSubviews()
        {
            DebugLogViewer.WriteLine("ViewWillLayoutSubviews()");

            base.ViewWillLayoutSubviews();
#endif

            m_Context = new EAGLContext(EAGLRenderingAPI.OpenGLES2);

            if (m_Context == null)
            {
                DebugLogViewer.WriteLine("Failed to create ES context");
            }

            var view = (GLKView)View;
            view.Context             = m_Context;
            view.DrawableColorFormat = GLKViewDrawableColorFormat.RGBA8888;
            view.DrawableDepthFormat = GLKViewDrawableDepthFormat.Format24;
            // フレームバッファがバインドされていないので、
            // フレームバッファ関連のOpenGL関数を使うにはこの方法で事前にバインドしておく
            view.BindDrawable();

            DebugLogViewer.WriteLine(string.Format("View.Drawable ({0}, {1})", view.DrawableWidth, view.DrawableHeight));
            DebugLogViewer.WriteLine(string.Format("view.Bounds {0}", view.Bounds));

            SetupGL();

            m_Activity = new GLGameTest();
            m_Activity.OnSurfaceCreated(view);

            RegisterTouchEvent(m_Activity);
        }
コード例 #2
0
        void SendHandlerOnTouchEvent(UITouch touch, UIView view, MotionEvent motion)
        {
            CGPoint point = touch.LocationInView(view);

            DebugLogViewer.WriteLine(string.Format("  Id[{0}] / Pos[{1}] / Motion[{2}]", touch.Handle, point, motion));
            m_TouchHandler.OnTouchEvent(touch.Handle, (float)point.X, (float)point.Y, motion);
        }
コード例 #3
0
        public override void Dispose()
        {
            DebugLogViewer.WriteLine("Dispose");

            //GL.DeleteBuffers(1, ref vertexBuffer);
            //GL.Oes.DeleteVertexArrays(1, ref vertexArray);
        }
コード例 #4
0
        public override void Resume()
        {
            DebugLogViewer.WriteLine("Resume");

            GL.ClearColor(0.7f, 0.83f, 0.86f, 1f);

            // ライトを設定
            float   lightAngle = 45.0f;
            Vector3 lightDir   = new Vector3((float)Math.Cos((float)lightAngle), -1.0f, (float)Math.Sin((float)lightAngle));

            lightDir.Normalize();
            GL.Uniform3(GL.GetUniformLocation(m_ProgramParam.GLProgram.Program, "lightDirection"), lightDir);

            // カメラを設定
            m_Camera.CreateViewportMatrix();
            Matrix4 viewProjectionMatrix = m_Camera.ViewProjectionMatrix;

            GL.UniformMatrix4(GL.GetUniformLocation(m_ProgramParam.GLProgram.Program, "viewProjection"),
                              false, ref viewProjectionMatrix);

            m_Texture  = new Texture(m_Game, "Images/AnimationSample.png");
            m_RegionUL = new TextureRegion(m_Texture, 0, 0, 64, 64);


            m_TextureAnimation = new Texture(m_Game, "Images/AnimationSample.png");
            m_Animation        = new Animation(0.2f, new TextureRegion[]
            {
                new TextureRegion(m_TextureAnimation, 0, 0, 64, 64),
                new TextureRegion(m_TextureAnimation, 64, 0, 64, 64),
                new TextureRegion(m_TextureAnimation, 128, 0, 64, 64),
                new TextureRegion(m_TextureAnimation, 192, 0, 64, 64),
            });
        }
コード例 #5
0
        public override void TouchesEnded(NSSet touches, UIEvent evt)
        {
            base.TouchesEnded(touches, evt);
            DebugLogViewer.WriteLine(string.Format("TouchesEnded"));

            foreach (UITouch touch in touches.ToArray <UITouch>())
            //foreach (UITouch touch in evt.AllTouches.ToArray<UITouch>())
            {
                SendHandlerOnTouchEvent(touch, View, MotionEvent.ACTION_NONE);
            }
        }
コード例 #6
0
        public override void Update(float deltaTime)
        {
            //zoom = 0.75f;

            float zoomStep = (deltaTime / 10.0f);

            zoom += zoomStep * dir;
            if (zoom < 0.5f)
            {
                dir *= -1.0f;
                zoom = 0.5f + zoomStep;
            }
            else if (zoom > 1.0f)
            {
                dir *= -1.0f;
                zoom = 1.0f - zoomStep;
            }
            else
            {
                m_Camera.SetZoom(zoom);
            }

            // カメラを設定
            m_Camera.CreateViewportMatrix();
            Matrix4 viewProjectionMatrix = m_Camera.ViewProjectionMatrix;

            GL.UniformMatrix4(GL.GetUniformLocation(m_ProgramParam.GLProgram.Program, "viewProjection"),
                              false, ref viewProjectionMatrix);


            m_AnimationSample.Update(deltaTime);

            List <TouchEvent> touchEvents = m_Game.GetInput().GetTouchEvents();

            foreach (var touchEvent in touchEvents)
            {
                m_TouchPoint.X = touchEvent.X;
                m_TouchPoint.Y = touchEvent.Y;
                m_Camera.TouchToWorld(ref m_TouchPoint);

                DebugLogViewer.WriteLine(string.Format("[{0}] : ({1})", touchEvent.Type, m_TouchPoint));

                if (DetectChecker.PointInRectangle(m_RectButtonStart, m_TouchPoint))
                {
                    DebugLogViewer.WriteLine(string.Format("Detect Start"));
                }
                if (DetectChecker.PointInRectangle(m_RectButtonEnd, m_TouchPoint))
                {
                    DebugLogViewer.WriteLine(string.Format("Detect End"));
                }
            }
        }
コード例 #7
0
        protected override void Dispose(bool disposing)
        {
            DebugLogViewer.WriteLine("Dispose() : " + disposing);

            base.Dispose(disposing);

            TearDownGL();

            if (EAGLContext.CurrentContext == m_Context)
            {
                EAGLContext.SetCurrentContext(null);
            }
        }
コード例 #8
0
        public override void Resume()
        {
            DebugLogViewer.WriteLine("Resume");

            GL.ClearColor(0.7f, 0.83f, 0.86f, 1f);

            // ライトを設定
            float   lightAngle = 45.0f;
            Vector3 lightDir   = new Vector3((float)Math.Cos((float)lightAngle), -1.0f, (float)Math.Sin((float)lightAngle));

            lightDir.Normalize();
            GL.Uniform3(GL.GetUniformLocation(m_ProgramParam.GLProgram.Program, "lightDirection"), lightDir);

#if false
            // カメラを設定
            m_Camera.CreateViewportMatrix();
            Matrix4 viewProjectionMatrix = m_Camera.ViewProjectionMatrix;
            GL.UniformMatrix4(GL.GetUniformLocation(m_ProgramParam.GLProgram.Program, "viewProjection"),
                              false, ref viewProjectionMatrix);
#else
            //// カメラを設定
            //m_Camera.CreateViewportMatrix();
            //Matrix4 viewProjectionMatrix = m_Camera.ViewProjectionMatrix;
            //GL.UniformMatrix4(GL.GetUniformLocation(m_ProgramParam.GLProgram.Program, "viewProjection"),
            //false, ref viewProjectionMatrix);
#endif

            m_Texture  = new Texture(m_Game, "Images/AnimationSample.png");
            m_RegionUL = new TextureRegion(m_Texture, 0, 0, 64, 64);


            m_TextureAnimation = new Texture(m_Game, "Images/AnimationSample.png");
            m_Animation        = new Animation(0.2f, new TextureRegion[]
            {
                new TextureRegion(m_TextureAnimation, 0, 0, 64, 64),
                new TextureRegion(m_TextureAnimation, 64, 0, 64, 64),
                new TextureRegion(m_TextureAnimation, 128, 0, 64, 64),
                new TextureRegion(m_TextureAnimation, 192, 0, 64, 64),
            });

            m_UIAtlas        = new Texture(m_Game, "Images/ui_sample.png");
            m_RgnButtonBase  = new TextureRegion(m_UIAtlas, 0, 0, 128, 32);
            m_RgnButtonStart = new TextureRegion(m_UIAtlas, 128, 0, 128, 32);
            m_RgnButtonEnd   = new TextureRegion(m_UIAtlas, 128, 32, 128, 32);


            Vector2 center = new Vector2(FRUSTRUM_WIDTH / 2.0f, FRUSTRUM_HEIGHT / 2.0f);
            float   width  = 256.0f;
            m_RectButtonStart = new CGRect((center.X - (width / 2.0f)), 860, 256.0f, 64.0f);
            m_RectButtonEnd   = new CGRect((center.X - (width / 2.0f)), 960, 256.0f, 64.0f);
        }
コード例 #9
0
        public override void LoadView()
        {
            base.LoadView();

#if DEBUG
            // デバッグログビューアーの作成
            var view           = View;
            var debugLogViewer = DebugLogViewer.CreateView(
                0, 0,
                (float)(view.Bounds.Width * DEBUG_LOG_VIEWER_WIDTH_RATIO), (float)(view.Bounds.Height * DEBUG_LOG_VIEWER_HEIGHT_RATIO),
                DEBUG_LOG_VIEWER_MAX_TEXT_COUNT,
                DEBUG_LOG_VIEWER_BACKGROUND_COLOR,
                UITextAlignment.Left);
            view.AddSubview(debugLogViewer);
#endif
        }
コード例 #10
0
        public override void ViewDidLoad()
        {
            DebugLogViewer.WriteLine("ViewDidLoad()");

            base.ViewDidLoad();
コード例 #11
0
 public override void Pause()
 {
     DebugLogViewer.WriteLine("Pause");
 }
コード例 #12
0
        public override void Update(float deltaTime)
        {
            var d = CFunctions.clib_add_internal(1, 2);

            DebugLogViewer.WriteLine("=== d = " + d);
        }
コード例 #13
0
        public override void Resume()
        {
            DebugLogViewer.WriteLine("Resume");

            GL.ClearColor(0.7f, 0.83f, 0.86f, 1f);
        }
コード例 #14
0
 public override void Dispose()
 {
     DebugLogViewer.WriteLine("Dispose");
 }