Ejemplo n.º 1
0
 public static void DisableCulling(GL gl10)
 {
     if (GLUtils.enableCulling)
     {
         GLUtils.enableCulling = false;
         gl10.GLDisable(GL.GL_CULL_FACE);
     }
 }
Ejemplo n.º 2
0
 public static void EnableVertexArray(GL gl10)
 {
     if (!GLUtils.enableVertexArray)
     {
         GLUtils.enableVertexArray = true;
         gl10.GLEnableClientState(GL.GL_VERTEX_ARRAY);
     }
 }
Ejemplo n.º 3
0
 public static void DisablecissorTest(GL gl10)
 {
     if (GLUtils.enablecissorTest)
     {
         GLUtils.enablecissorTest = false;
         gl10.GLDisable(GL.GL_SCISSOR_TEST);
     }
 }
Ejemplo n.º 4
0
 public static void DisableBlend(GL gl10)
 {
     if (GLUtils.enableBlend)
     {
         gl10.GLDisable(GL.GL_BLEND);
         GLUtils.enableBlend = false;
     }
 }
Ejemplo n.º 5
0
 public static void BindTexture(GL gl10, int hardwareTextureID)
 {
     if (GLUtils.currentHardwareTextureID != hardwareTextureID)
     {
         GLUtils.currentHardwareTextureID = hardwareTextureID;
         gl10.GLBindTexture(GL.GL_TEXTURE_2D, hardwareTextureID);
     }
 }
Ejemplo n.º 6
0
 public static void DisableDepthTest(GL gl10)
 {
     if (GLUtils.enableDepthTest)
     {
         GLUtils.enableDepthTest = false;
         gl10.GLDisable(GL.GL_DEPTH_TEST);
         gl10.GLDepthMask(false);
     }
 }
Ejemplo n.º 7
0
 public static void BlendFunction(GL gl10,
          int pSourceBlendMode, int pDestinationBlendMode)
 {
     if (GLUtils.currentSourceBlendMode != pSourceBlendMode
             || GLUtils.currentDestinationBlendMode != pDestinationBlendMode)
     {
         GLUtils.currentSourceBlendMode = pSourceBlendMode;
         GLUtils.currentDestinationBlendMode = pDestinationBlendMode;
         gl10.GLBlendFunc(pSourceBlendMode, pDestinationBlendMode);
     }
 }
Ejemplo n.º 8
0
 public static void SetColor(GL gl10, float r, float g,
          float b, float a)
 {
     if (a != GLUtils.alpha || r != GLUtils.red || g != GLUtils.green
             || b != GLUtils.blue)
     {
         GLUtils.alpha = a;
         GLUtils.red = r;
         GLUtils.green = g;
         GLUtils.blue = b;
         gl10.GLColor4f(r, g, b, a);
     }
 }
Ejemplo n.º 9
0
 public static void Reset(GL gl)
 {
     GLUtils.currentHardwareTextureID = -1;
     GLUtils.currentSourceBlendMode = -1;
     GLUtils.currentDestinationBlendMode = -1;
     GLUtils.DisableBlend(gl);
     GLUtils.DisableCulling(gl);
     GLUtils.DisableTextures(gl);
     GLUtils.DisableTexCoordArray(gl);
     GLUtils.DisableTexColorArray(gl);
     GLUtils.DisableVertexArray(gl);
     GLUtils.red = -1;
     GLUtils.green = -1;
     GLUtils.blue = -1;
     GLUtils.alpha = -1;
 }
Ejemplo n.º 10
0
        public override void Draw(GL g)
        {
            this.m_onRunning = false;
            this.m_onPause = false;
            this.m_onDestroy = false;
            this.m_onResume = false;

            lock (m_sync)
            {
                m_onRunning = LSystem.isRunning;
                m_onPause = LSystem.isPaused;
                m_onDestroy = LSystem.isDestroy;
                m_onResume = LSystem.isResume;

                if (LSystem.isResume)
                {
                    LSystem.isResume = false;
                }

                if (LSystem.isPaused)
                {
                    LSystem.isPaused = false;
                    JavaRuntime.NotifyAll(m_sync);
                }

                if (LSystem.isDestroy)
                {
                    LSystem.isDestroy = false;
                    JavaRuntime.NotifyAll(m_sync);
                }

                if (m_onResume)
                {
                    m_log.I("m_onResume");
                    timer = LSystem.GetSystemTimer();
                    lastTimeMicros = timer.GetTimeMicros();
                    elapsedTime = 0;
                    remainderMicros = 0;
                    m_process.OnResume();
                }

                if (m_onRunning)
                {
                    if (LSystem.isLogo)
                    {
                            if (logoFlag == null)
                            {
                                LSystem.isLogo = false;
                                return;
                            }
                            logoFlag.Draw(m_process.gl);
                            if (logoFlag.finish)
                            {
                                m_process.gl.SetAlpha(1.0f);
                                m_process.gl.DrawClear(LColor.black);
                                LSystem.isLogo = false;
                                logoFlag.Dispose();
                                logoFlag = null;
                                return;
                            }
                        return;
                    }

                    if (!m_process.Next())
                    {
                        return;
                    }

                    m_process.Load();

                    m_process.Calls();

                    goalTimeMicros = lastTimeMicros + 1000000L / maxFrames;
                    currTimeMicros = timer.SleepTimeMicros(goalTimeMicros);
                    elapsedTimeMicros = currTimeMicros - lastTimeMicros
                            + remainderMicros;
                    elapsedTime = MathUtils.Max(0, (elapsedTimeMicros / 1000));
                    remainderMicros = elapsedTimeMicros - elapsedTime * 1000;
                    lastTimeMicros = currTimeMicros;
                    timerContext.millisSleepTime = remainderMicros;
                    timerContext.timeSinceLastUpdate = elapsedTime;

                    ActionControl.Update(elapsedTime);

                    m_process.RunTimer(timerContext);

                    if (LSystem.AUTO_REPAINT)
                    {
                        GLEx gl = m_process.gl;

                        if (gl != null)
                        {

                            if (!m_process.Next())
                            {
                                return;
                            }

                            //�趨graphics.PreferredBackBufferWidth��graphics.PreferredBackBufferHeightʱWP���Զ����Ż��棬
                            //�˴�����������һ�Ρ�
                            /*if (LSystem.scaleWidth != 1f || LSystem.scaleHeight != 1f)
                            {
                                gl.Scale(LSystem.scaleWidth,
                                        LSystem.scaleHeight);
                            }*/

                            int repaintMode = m_process.GetRepaintMode();

                            switch (repaintMode)
                            {
                                case Screen.SCREEN_BITMAP_REPAINT:
                                    gl.Reset(true);
                                    if (m_process.GetX() == 0 && m_process.GetY() == 0)
                                    {
                                        gl.DrawTexture(m_process.GetBackground(), 0, 0);
                                    }
                                    else
                                    {
                                        gl.DrawTexture(m_process.GetBackground(), m_process.GetX(),
                                                m_process.GetY());
                                    }
                                    break;
                                case Screen.SCREEN_COLOR_REPAINT:
                                    LColor c = m_process.GetColor();
                                    if (c != null)
                                    {
                                        gl.DrawClear(c);
                                    }
                                    break;
                                case Screen.SCREEN_CANVAS_REPAINT:
                                    gl.Reset(true);
                                    break;
                                case Screen.SCREEN_NOT_REPAINT:
                                    gl.Reset(true);
                                    break;
                                default:
                                    gl.Reset(true);
                                    if (m_process.GetX() == 0 && m_process.GetY() == 0)
                                    {
                                        gl.DrawTexture(
                                                m_process.GetBackground(),
                                                repaintMode / 2
                                                        - LSystem.random.Next(repaintMode),
                                                repaintMode / 2
                                                        - LSystem.random.Next(repaintMode));
                                    }
                                    else
                                    {
                                        gl.DrawTexture(m_process.GetBackground(),
                                                m_process.GetX() + repaintMode / 2
                                                        - LSystem.random.Next(repaintMode),
                                                m_process.GetY() + repaintMode / 2
                                                        - LSystem.random.Next(repaintMode));
                                    }
                                    break;
                            }

                            m_process.Draw();

                            m_process.Drawable(elapsedTime);

                            if (isFPS)
                            {
                                this.TickFrames();
                                fpsFont.DrawString(string.Format(numformat, "FPS:{0}", frameRate), 5, 5, 0, LColor.white);
                            }

                            m_process.DrawEmulator();

                            m_process.Unload();

                            gl.Restore();

                        }

                    }

                }

            }
        }
Ejemplo n.º 11
0
 public override void InitApp(XNAContext context, GL gl)
 {
     if (m_process == null)
     {
         m_process = new LProcess(this, context._width, context._height);
     }
     m_process.Load(gl);
     Printf("initApp");
 }
Ejemplo n.º 12
0
 public void Load(GL g)
 {
     if (gl == null)
     {
         this.gl = new GLEx(g);
     }
     else
     {
         gl.Load(g);
     }
     this.gl.Update();
 }
Ejemplo n.º 13
0
 public override void CreateApp(GL gl, int width, int height)
 {
     if (LSystem.screenRect != null)
     {
         LSystem.screenRect.SetBounds(0, 0, width, height);
     }
     else
     {
         LSystem.screenRect = new RectBox(0, 0, width, height);
     }
     if (m_process == null)
     {
         m_process = new LProcess(this, width, height);
     }
     m_process.Load(gl);
     LSystem.screenProcess = m_process;
 }
Ejemplo n.º 14
0
 public override void OnSurfaceChanged(GL gl, int width, int height)
 {
     this.FreamCreate(gl, width, height);
 }
Ejemplo n.º 15
0
 public static void DisableDither(GL gl10)
 {
     if (GLUtils.enableDither)
     {
         GLUtils.enableDither = false;
         gl10.GLDisable(GL.GL_DITHER);
     }
 }
Ejemplo n.º 16
0
 public static void SetClearColor(GL gl10, LColor c)
 {
     GLUtils.SetColor(gl10, c.r, c.g, c.b, c.a);
 }
Ejemplo n.º 17
0
 protected virtual void FreamInit(GL gl)
 {
 }
Ejemplo n.º 18
0
 public static void SetHintFastest(GL gl10)
 {
     gl10.GLHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_FASTEST);
 }
Ejemplo n.º 19
0
 public static void DisableLightning(GL gl10)
 {
     if (GLUtils.enableLightning)
     {
         GLUtils.enableLightning = false;
         gl10.GLDisable(GL.GL_LIGHTING);
     }
 }
Ejemplo n.º 20
0
 public static void SetShadeModelFlat(GL gl10)
 {
     gl10.GLShadeModel(GL.GL_FLAT);
 }
Ejemplo n.º 21
0
 public static void SetShadeModelSmooth(GL gl10)
 {
     gl10.GLShadeModel(GL.GL_SMOOTH);
 }
Ejemplo n.º 22
0
 public static void EnableDepthTest(GL gl10)
 {
     if (!GLUtils.enableDepthTest)
     {
         GLUtils.enableDepthTest = true;
         gl10.GLEnable(GL.GL_DEPTH_TEST);
         gl10.GLDepthMask(true);
     }
 }
Ejemplo n.º 23
0
 protected virtual void FreamCreate(GL gl, int width, int height)
 {
 }
Ejemplo n.º 24
0
 public static void EnableLightning(GL gl10)
 {
     if (!GLUtils.enableLightning)
     {
         GLUtils.enableLightning = true;
         gl10.GLEnable(GL.GL_LIGHTING);
     }
 }
Ejemplo n.º 25
0
 protected virtual void FreamDraw(GL gl)
 {
 }
Ejemplo n.º 26
0
 public static void DisableTextures(GL gl10)
 {
     if (GLUtils.enableTextures)
     {
         GLUtils.enableTextures = false;
         gl10.GLDisable(GL.GL_TEXTURE_2D);
     }
 }
Ejemplo n.º 27
0
 public override void OnDrawFrame(GL gl)
 {
     m_drawFlag = 3;
     this.FreamDraw(gl);
     m_drawFlag = 0;
 }
Ejemplo n.º 28
0
 public static void DisableVertexArray(GL gl10)
 {
     if (GLUtils.enableVertexArray)
     {
         GLUtils.enableVertexArray = false;
         gl10.GLDisableClientState(GL.GL_VERTEX_ARRAY);
     }
 }
Ejemplo n.º 29
0
 public override void OnSurfaceCreated(GL gl)
 {
     this.FreamInit(gl);
     this.mThread = new DrawingThread(this);
     this.mThread.Start();
 }
Ejemplo n.º 30
0
 public static void EnableDither(GL gl10)
 {
     if (!GLUtils.enableDither)
     {
         GLUtils.enableDither = true;
         gl10.GLEnable(GL.GL_DITHER);
     }
 }