예제 #1
0
        internal void RenderScene()
        {
            PreRender();
            if (touchFaces.Count == 0)
            {
                //Drop out early if the pre-render process reveals no available touch faces for a minor boost
                return;
            }
            renderer.ResetOpenGlState();

            fbo.Bind();

            GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            pickingShader.Activate();
            pickingShader.SetCurrentProjectionMatrix(renderer.CurrentProjectionMatrix);
            foreach (FaceState face in touchFaces)
            {
                pickingShader.SetObjectIndex(objectStates.IndexOf(face.Object) + 1);
                renderer.RenderFace(pickingShader, face);
            }
            //Must deactivate and unbind here
            pickingShader.Deactivate();
            fbo.UnBind();

            // for debug
            if (renderer.DebugTouchMode)
            {
                GL.DepthMask(false);
                GL.Disable(EnableCap.DepthTest);
                renderer.DefaultShader.Activate();
                renderer.ResetShader(renderer.DefaultShader);
                renderer.DefaultShader.SetCurrentProjectionMatrix(renderer.CurrentProjectionMatrix);
                foreach (FaceState face in touchFaces)
                {
                    renderer.RenderFace(renderer.DefaultShader, face, true);
                }
                renderer.DefaultShader.Deactivate();
            }
        }
예제 #2
0
        internal void RenderScene()
        {
            PreRender();

            renderer.ResetOpenGlState();

            fbo.Bind();

            GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            foreach (FaceState face in touchFaces)
            {
                pickingShader.Activate();
                renderer.ResetShader(pickingShader);
                pickingShader.SetObjectIndex(objectStates.IndexOf(face.Object) + 1);
                renderer.RenderFace(pickingShader, face);
                pickingShader.Deactivate();
            }

            fbo.UnBind();

            // for debug
            if (renderer.DebugTouchMode)
            {
                GL.DepthMask(false);
                GL.Disable(EnableCap.DepthTest);

                foreach (FaceState face in touchFaces)
                {
                    renderer.DefaultShader.Activate();
                    renderer.ResetShader(renderer.DefaultShader);
                    renderer.RenderFace(renderer.DefaultShader, face, true);
                    renderer.DefaultShader.Deactivate();
                }
            }
        }
예제 #3
0
파일: Touch.cs 프로젝트: zbx1425/OpenBVE
        internal void RenderScene()
        {
            PreRender();

            if (!touchableObject.Any())
            {
                //Drop out early if the pre-render process reveals no available touch faces for a minor boost
                return;
            }

            renderer.ResetOpenGlState();

            if (renderer.AvailableNewRenderer)
            {
                fbo.Bind();
                GL.ClearColor(0.0f, 0.0f, 0.0f, 0.0f);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                renderer.pickingShader.Activate();
                renderer.pickingShader.SetCurrentProjectionMatrix(renderer.CurrentProjectionMatrix);

                for (int i = 0; i < touchableObject.Count; i++)
                {
                    renderer.pickingShader.SetObjectIndex(i + 1);

                    foreach (MeshFace face in touchableObject[i].Prototype.Mesh.Faces)
                    {
                        renderer.RenderFace(renderer.pickingShader, touchableObject[i], face);
                    }
                }

                //Must deactivate and unbind here
                renderer.pickingShader.Deactivate();
                fbo.UnBind();
            }

            // for debug
            if (renderer.DebugTouchMode)
            {
                GL.DepthMask(false);
                GL.Disable(EnableCap.DepthTest);

                if (renderer.AvailableNewRenderer)
                {
                    renderer.DefaultShader.Activate();
                    renderer.ResetShader(renderer.DefaultShader);
                    renderer.DefaultShader.SetCurrentProjectionMatrix(renderer.CurrentProjectionMatrix);

                    foreach (ObjectState objectState in touchableObject)
                    {
                        foreach (MeshFace face in objectState.Prototype.Mesh.Faces)
                        {
                            renderer.RenderFace(renderer.DefaultShader, objectState, face, true);
                        }
                    }

                    renderer.DefaultShader.Deactivate();
                }
                else
                {
                    foreach (ObjectState objectState in touchableObject)
                    {
                        foreach (MeshFace face in objectState.Prototype.Mesh.Faces)
                        {
                            renderer.RenderFaceImmediateMode(objectState, face, true);
                        }
                    }
                }
            }
        }