Example #1
0
    public void LoadScene(int sceneId)
    {
        SceneData db = GameDataManage.Instance.GetDBScene(sceneId);

        Debug.Log(db.SceneName);
        switch (db.SceneType)
        {
        case ESceneType.Init:
        {
            this.NextState = GameState.Init;
        }
        break;

        case ESceneType.Login:
        {
            this.NextState = GameState.Login;
        }
        break;

        case ESceneType.Battle:
        {
            this.NextState = GameState.Battle;
        }
        break;
        }
        CurMapID = db.Id;
        GLCommand ev = new GLCommand(sceneId);

        ChangeState(GameState.Loading, ev);
    }
Example #2
0
        public void End()
        {
            var command = new GLCommand
            {
                Type = CommandType.End
            };

            _commandList.Add(command);
        }
Example #3
0
        public void SetDepthStencilState(IDepthStencilState depthStencilState)
        {
            var command = new GLCommand
            {
                Type = CommandType.SetDepthStencilState,
            };

            _commandList.Add(command);
        }
Example #4
0
        public void SetBlendState(IBlendState blendState)
        {
            var command = new GLCommand
            {
                Type = CommandType.SetBlendState,
            };

            _commandList.Add(command);
        }
Example #5
0
        private void SetProgramPipeline(GL46Pipeline pipeline)
        {
            var command = new GLCommand
            {
                Type     = CommandType.SetPipeline,
                Pipeline = pipeline
            };

            _commandList.Add(command);
        }
Example #6
0
        public void SetInputLayout(IInputLayout inputLayout)
        {
            var command = new GLCommand
            {
                Type        = CommandType.SetInputLayout,
                InputLayout = (GL46InputLayout)inputLayout
            };

            _commandList.Add(command);
        }
Example #7
0
        public void SetIndexBuffer(IIndexBuffer indexBuffer)
        {
            var command = new GLCommand
            {
                Type        = CommandType.SetIndexBuffer,
                IndexBuffer = (GL46IndexBuffer)indexBuffer
            };

            _commandList.Add(command);
        }
Example #8
0
        public void SetConstantBuffer(IConstantBuffer buffer, BufferScope bufferScope)
        {
            var command = new GLCommand
            {
                Type           = CommandType.SetConstantBuffers,
                ConstantBuffer = (GL46ConstantBuffer)buffer
            };

            _commandList.Add(command);
        }
Example #9
0
        public void SetPrimitiveTopology(PrimitiveTopology primitiveTopology)
        {
            var command = new GLCommand
            {
                Type          = CommandType.SetPrimitiveTopology,
                PrimitiveType = primitiveTopology.ToOpenTK()
            };

            _commandList.Add(command);
        }
Example #10
0
        public void SetScissorRectangle(Rectangle rectangle)
        {
            var command = new GLCommand
            {
                Type             = CommandType.SetScissor,
                ScissorRectangle = new Rectangle(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height)
            };

            _commandList.Add(command);
        }
Example #11
0
        public void ClearRenderTarget(TextureView renderTarget, Vector4 clearColor)
        {
            var command = new GLCommand
            {
                Type       = CommandType.ClearRenderTarget,
                ClearColor = new OpenTK.Graphics.Color4(clearColor.X, clearColor.Y, clearColor.Z, clearColor.W)
            };

            _commandList.Add(command);
        }
Example #12
0
    public override void Enter()
    {
        base.Enter();
        GLCommand ev = Cmd as GLCommand;

        mLoadingSceneId = ev.SceneID;
        UIManage.Instance.Clear();
        UIManage.Instance.OpenWindow(WindowID.UI_LOADING);
        mLoadingWindow = (UILoading)UIManage.Instance.GetWindow(WindowID.UI_LOADING);
    }
Example #13
0
        public void Draw(int vertexCount)
        {
            var command = new GLCommand
            {
                Type            = CommandType.Draw,
                DrawVertexCount = vertexCount
            };

            _commandList.Add(command);
        }
Example #14
0
        public void SetViewport(Viewport viewport)
        {
            var command = new GLCommand
            {
                Type     = CommandType.SetViewport,
                Viewport = viewport.ToOpenTK()
            };

            _commandList.Add(command);
        }
Example #15
0
        public void SetTexture(TextureView textureView)
        {
            var command = new GLCommand
            {
                Type        = CommandType.SetTextures,
                TextureView = ((GL46TextureView)textureView)
            };

            _commandList.Add(command);
        }
Example #16
0
        public void ClearDepthStencil(TextureView depthStencil, float clearDepth, byte stencilDepth)
        {
            var command = new GLCommand
            {
                Type         = CommandType.ClearDepthStencil,
                ClearStencil = stencilDepth,
                ClearDepth   = clearDepth
            };

            _commandList.Add(command);
        }
Example #17
0
        public void DrawIndexed(int indexCount, int indexOffset, int vertexOffset)
        {
            var command = new GLCommand
            {
                Type             = CommandType.DrawIndexed,
                DrawIndexCount   = indexCount,
                DrawIndexOffset  = indexOffset,
                DrawVertexOffset = vertexOffset,
            };

            _commandList.Add(command);
        }
Example #18
0
        public void SetVertexBuffer(IVertexBuffer vertexBuffer)
        {
            var command = new GLCommand
            {
                Type         = CommandType.SetVertexBuffer,
                InputLayout  = _currentInputLayout,
                VertexBuffer = (GL46VertexBuffer)vertexBuffer,
                VertexStride = vertexBuffer.VertexStride
            };

            _commandList.Add(command);
        }
Example #19
0
        public void Begin(string passName, IPipeline pipeline)
        {
            var command = new GLCommand
            {
                Type = CommandType.Begin,
                Name = passName
            };

            _commandList.Add(command);

            if (pipeline != null)
            {
                SetViewport(pipeline.Viewport);
                SetProgramPipeline((GL46Pipeline)pipeline);
                SetInputLayout(pipeline.InputLayout);
            }
        }
Example #20
0
        public static GLParser FromFile(string xmlFile, params string[] Api)
        {
            XDocument file = XDocument.Load(xmlFile);
            GLParser  spec = new GLParser();

            spec.HeaderComment = file.Root.Element("comment").Value;

            foreach (var feature in file.Root.Elements("feature"))
            {
                var apiName = feature.Attribute("api").Value;
                if (Api.Contains(apiName))
                {
                    var version = new GLVersion
                    {
                        Api    = feature.Attribute("api").Value.ToUpper(),
                        Number = feature.Attribute("number").Value,
                    };

                    version.Name = version.Api + version.Number.Replace(".", "");

                    // Add all enums and commands from previus versions
                    int i = spec.Versions.Count - 1;
                    if (i >= 0)
                    {
                        var previousVersion = spec.Versions[i];

                        foreach (var g in previousVersion.Groups)
                        {
                            version.Groups.Add(g.Clone());
                        }

                        foreach (var c in previousVersion.Commands)
                        {
                            version.Commands.Add(c.Clone());
                        }
                    }

                    // Include all new enums and commands
                    foreach (var require in feature.Elements("require"))
                    {
                        foreach (var enumElem in require.Elements("enum"))
                        {
                            var enumName = enumElem.Attribute("name").Value;

                            // if enum doesn't exists
                            bool exists = version.Groups.Exists(g => g.Enums.Exists(e => e.Name == enumName));

                            if (!exists)
                            {
                                // Find group
                                string groupFound = FindGroupInXML(file, enumName);

                                // The group already exists
                                GlGroup glgroup = version.Groups.Find(g => g.Name == groupFound);

                                if (glgroup == null)
                                {
                                    glgroup = new GlGroup()
                                    {
                                        Name = groupFound
                                    };
                                    version.Groups.Add(glgroup);
                                }

                                // Create new Enum
                                var glEnum = new GLEnum();
                                glEnum.Initialize(file, enumName);
                                glgroup.Enums.Add(glEnum);
                            }
                        }

                        foreach (var commandElem in require.Elements("command"))
                        {
                            var glCommand = new GLCommand()
                            {
                                Name = commandElem.Attribute("name").Value
                            };
                            if (version.Commands.Find(c => c.Name == glCommand.Name) == null)
                            {
                                // Create new command
                                glCommand.Initialize(commandElem.Document);
                                version.Commands.Add(glCommand);
                            }
                        }
                    }

                    // Add enum from commands
                    foreach (var commandElem in version.Commands)
                    {
                        // Return Type
                        if (commandElem.ReturnType.Type == "GLenum")
                        {
                            var  selectedGroup = commandElem.ReturnType.Group;
                            bool groupExists   = version.Groups.Exists(g => g.Name == selectedGroup);
                            if (!groupExists)
                            {
                                foreach (var group in file.Root.Element("groups").Elements("group"))
                                {
                                    string groupName = group.Attribute("name").Value;
                                    if (groupName == selectedGroup)
                                    {
                                        GlGroup glgroup = new GlGroup()
                                        {
                                            Name = selectedGroup
                                        };
                                        foreach (var e in group.Elements("enum"))
                                        {
                                            GLEnum glEnum   = new GLEnum();
                                            var    enumName = e.Attribute("name").Value;
                                            glEnum.Initialize(file, enumName);
                                            glgroup.Enums.Add(glEnum);
                                        }
                                        version.Groups.Add(glgroup);
                                    }
                                }
                            }
                        }

                        // Parameters
                        foreach (var param in commandElem.Parameters)
                        {
                            if (param.Type == "GLenum")
                            {
                                bool groupExists = version.Groups.Exists(g => g.Name == param.Group);
                                if (!groupExists)
                                {
                                    foreach (var group in file.Root.Element("groups").Elements("group"))
                                    {
                                        string groupName = group.Attribute("name").Value;
                                        if (groupName == param.Group)
                                        {
                                            GlGroup glgroup = new GlGroup()
                                            {
                                                Name = param.Group
                                            };
                                            foreach (var e in group.Elements("enum"))
                                            {
                                                GLEnum glEnum   = new GLEnum();
                                                var    enumName = e.Attribute("name").Value;
                                                glEnum.Initialize(file, enumName);
                                                glgroup.Enums.Add(glEnum);
                                            }
                                            version.Groups.Add(glgroup);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    // Remove any anums and commands
                    foreach (var remove in feature.Elements("remove"))
                    {
                        foreach (var e in remove.Elements("enum"))
                        {
                            foreach (var group in version.Groups)
                            {
                                var glenum = group.Enums.Find(n => n.Name == e.Attribute("name").Value);

                                if (glenum != null)
                                {
                                    group.Enums.Remove(glenum);
                                }
                            }
                        }

                        foreach (var c in remove.Elements("command"))
                        {
                            version.Commands.RemoveAll(command => command.Name == c.Attribute("name").Value);
                        }
                    }

                    // Remove all group with 0 enums
                    version.Groups.RemoveAll(g => g.Enums.Count == 0);

                    // Remove GLBoolean type
                    version.Groups.RemoveAll(g => g.Name == "Boolean");

                    spec.Versions.Add(version);
                }
            }

            return(spec);
        }
Example #21
0
        private static void BuildParameterList(GLCommand c, StringBuilder builder)
        {
            if (c.Parameters.Count > 0)
            {
                foreach (var p in c.Parameters)
                {
                    var name = p.Name;

                    // Add @ to start of any names that are C# keywords to avoid conflict
                    if (name == "params" || name == "string" || name == "ref" || name == "base")
                    {
                        name = "@" + name;
                    }

                    builder.AppendFormat("{0} {1}, ", ConvertGLType(p.Type), name);
                }
                builder.Length -= 2;
            }
        }