Пример #1
0
 public void Render(GraphicsDevice gd, CommandList cl, GraphicsSystem sc, RenderPasses renderPass)
 {
     cl.SetPipeline(_pipeline);
     cl.SetGraphicsResourceSet(0, UseTintedTexture ? sc.DuplicatorTargetSet1 : sc.DuplicatorTargetSet0);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #2
0
        public void UpdatePerFrameResources(GraphicsDevice gd, CommandList cl, GraphicsSystem sc)
        {
            WorldAndInverse wai;

            wai.World        = _transform.GetTransformMatrix();
            wai.InverseWorld = VdUtilities.CalculateInverseTranspose(ref wai.World);
            gd.UpdateBuffer(_worldAndInverseBuffer, 0, ref wai);
        }
Пример #3
0
 public void Render(GraphicsDevice gd, CommandList cl, GraphicsSystem sc, RenderPasses renderPass)
 {
     cl.SetPipeline(_pipeline);
     cl.SetGraphicsResourceSet(0, sc.MainSceneViewResourceSet);
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.DrawIndexed(6, 1, 0, 0, 0);
 }
Пример #4
0
    protected override void Init(IServiceCollection services)
    {
        _camera    = GetMutable <CameraComponent>();
        _transform = GetReadOnly <Transform3D>();
        _filter    = CreateFilter(new EntityFilterConfiguration().With <CameraComponent>().With <Transform3D>());

        _graphicsSystem = services.Get <GraphicsSystem>();
    }
Пример #5
0
 private void RenderShadowMap(CommandList cl, GraphicsSystem sc, int shadowMapIndex)
 {
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.SetPipeline(_shadowMapPipeline);
     cl.SetGraphicsResourceSet(0, _shadowMapResourceSets[shadowMapIndex * 2]);
     cl.SetGraphicsResourceSet(1, _shadowMapResourceSets[shadowMapIndex * 2 + 1]);
     cl.DrawIndexed((uint)_indexCount, 1, 0, 0, 0);
 }
        // Token: 0x0600007E RID: 126 RVA: 0x0000D42C File Offset: 0x0000B62C
        public static void DrawBlendedTextMenuEntry(TextMenu tMenu, int rowNum, int xPos, int yPos, int textHighL)
        {
            int num = tMenu.entryStart[rowNum];

            for (int i = 0; i < tMenu.entrySize[rowNum]; i++)
            {
                GraphicsSystem.DrawBlendedSprite(xPos + (i << 3), yPos, 8, 8, (int)((int)(tMenu.textData[num] & '\u000f') << 3), (int)((int)(tMenu.textData[num] >> 4) << 3) + textHighL, TextSystem.textMenuSurfaceNo);
                num++;
            }
        }
Пример #7
0
 public void CreateDeviceObjects(GraphicsDevice gd, CommandList cl, GraphicsSystem sc)
 {
     if (_imguiRenderer == null)
     {
         _imguiRenderer = new ImGuiRenderer(gd, sc.MainSceneFramebuffer.OutputDescription, _width, _height);
     }
     else
     {
         _imguiRenderer.CreateDeviceResources(gd, sc.MainSceneFramebuffer.OutputDescription);
     }
 }
Пример #8
0
 private void RenderStandard(CommandList cl, GraphicsSystem sc, bool reflectionPass)
 {
     cl.SetVertexBuffer(0, _vb);
     cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
     cl.SetPipeline(reflectionPass ? _pipelineFrontCull : _pipeline);
     cl.SetGraphicsResourceSet(0, _mainProjViewRS);
     cl.SetGraphicsResourceSet(1, _mainSharedRS);
     cl.SetGraphicsResourceSet(2, _mainPerObjectRS);
     cl.SetGraphicsResourceSet(3, reflectionPass ? _reflectionRS : _noReflectionRS);
     cl.DrawIndexed((uint)_indexCount, 1, 0, 0, 0);
 }
Пример #9
0
        public void Render(GraphicsDevice gd, CommandList cl, GraphicsSystem sc, RenderPasses renderPass)
        {
            cl.SetVertexBuffer(0, _vb);
            cl.SetIndexBuffer(_ib, IndexFormat.UInt16);
            cl.SetPipeline(renderPass == Glitch.Graphics.RenderPasses.ReflectionMap ? _reflectionPipeline : _pipeline);
            cl.SetGraphicsResourceSet(0, _resourceSet);
            float depth = gd.IsDepthRangeZeroToOne ? 0 : 1;

            cl.SetViewport(0, new Viewport(0, 0, sc.MainSceneColorTexture.Width, sc.MainSceneColorTexture.Height, depth, depth));
            cl.DrawIndexed((uint)s_indices.Length, 1, 0, 0, 0);
        }
Пример #10
0
        protected unsafe override void Start(SystemRegistry registry)
        {
            _assetSystem = registry.GetSystem <AssetSystem>();
            _sls         = registry.GetSystem <SceneLoaderSystem>();
            _gs          = registry.GetSystem <GraphicsSystem>();
            _audioSource = GameObject.GetComponent <AudioSourceComponent>();
            LoadFont();

            _gs.ImGuiRenderer.RecreateFontDeviceTexture(_gs.Context);

            _allScenes = _assetSystem.Database.GetAssetsOfType(typeof(SceneAsset));
        }
Пример #11
0
        public AxesRenderer(RenderContext rc, GraphicsSystem gs)
        {
            _gs = gs;
            _vb = rc.ResourceFactory.CreateVertexBuffer(6 * VertexPositionColor.SizeInBytes, false);

            const float opacity = 0.56f;
            RgbaFloat   red     = new RgbaFloat(1, 0, 0, opacity);
            RgbaFloat   green   = new RgbaFloat(0, 1, 0, opacity);
            RgbaFloat   blue    = new RgbaFloat(0, 0, 1, opacity);

            SetPlaneVertices(
                new Vector3(PlaneLength, 0, PlaneLength),
                new Vector3(PlaneLength, PlaneLength, 0),
                new Vector3(0, PlaneLength, PlaneLength));
            _ib = rc.ResourceFactory.CreateIndexBuffer(6 * 4, false);
            _ib.SetIndices(
                new int[]
            {
                0, 1, 2, 3, 4, 5,     // Lines
                // Planes
                6, 7, 8, 6, 8, 9,
                10, 11, 12, 10, 12, 13,
                14, 15, 16, 14, 16, 17,

                // Solid plane borders
                18, 19, 19, 20, 20, 21, 21, 18,
                22, 23, 23, 24, 24, 25, 25, 22,
                26, 27, 27, 28, 28, 29, 29, 26
            },
                0,
                0);
            _lineIndicesCount = 6;
            _material         = CreateMaterial(rc);

            _pointerVB       = ArrowPointerModel.MeshData.CreateVertexBuffer(rc.ResourceFactory);
            _pointerIB       = ArrowPointerModel.MeshData.CreateIndexBuffer(rc.ResourceFactory, out _pointerIndexCount);
            _pointerMaterial = CreatePointerMaterial(rc);
            _redTexture      = RawTextureDataArray <RgbaFloat> .FromSingleColor(RgbaFloat.Red).CreateDeviceTexture(rc.ResourceFactory);

            _greenTexture = RawTextureDataArray <RgbaFloat> .FromSingleColor(RgbaFloat.Green).CreateDeviceTexture(rc.ResourceFactory);

            _blueTexture = RawTextureDataArray <RgbaFloat> .FromSingleColor(RgbaFloat.Blue).CreateDeviceTexture(rc.ResourceFactory);

            _redBinding   = rc.ResourceFactory.CreateShaderTextureBinding(_redTexture);
            _greenBinding = rc.ResourceFactory.CreateShaderTextureBinding(_greenTexture);
            _blueBinding  = rc.ResourceFactory.CreateShaderTextureBinding(_blueTexture);

            _dss = rc.ResourceFactory.CreateDepthStencilState(false, DepthComparison.Always);
            _rs  = rc.ResourceFactory.CreateRasterizerState(FaceCullingMode.None, TriangleFillMode.Solid, true, true);
        }
Пример #12
0
        public Game(Windows.UI.Xaml.Window current)
        {
            _colliderSystem            = new ColliderSystem(_eventSystem);
            _moveSystem                = new MoveSystem();
            _physicsSystem             = new PhysicsSystem(_eventSystem);
            _inputSystem               = new InputSystem(_eventSystem);
            _graphicsSystem            = new GraphicsSystem(_eventSystem);
            _particleSystem            = new ParticleSystem();
            _playerSystem              = new PlayerSystem(_eventSystem);
            _dustParticleEmitterSystem = new DustParticleEmitterSystem(_eventSystem, _dustEntityFactory);
            _particleEmitterSystem     = new ParticleEmitterSystem(_dustEntityFactory);

            _inputSystem.Current = current;
        }
Пример #13
0
        static void Main(string[] args)
        {
            bool _isRunning     = true;
            var  graphicsSystem = new GraphicsSystem();
            var  tileMap        = new World();

            while (_isRunning)
            {
                //do stuff
                //then ...

                graphicsSystem.Display(tileMap);
            }
        }
Пример #14
0
        protected override void Start(SystemRegistry registry)
        {
            _input   = registry.GetSystem <InputSystem>();
            _goqs    = registry.GetSystem <GameObjectQuerySystem>();
            _gs      = registry.GetSystem <GraphicsSystem>();
            _physics = registry.GetSystem <PhysicsSystem>();
            _ball    = _goqs.FindByName(BallName);
            if (_ball == null)
            {
                throw new InvalidOperationException("No Ball found in scene with name " + BallName);
            }

            _ballCollider = _ball.GetComponent <Collider>();
            _ballState    = _ball.GetComponent <BallState>();
        }
Пример #15
0
 protected override void Start(SystemRegistry registry)
 {
     GameObject.RemoveComponent(this);
     _ccs = registry.GetSystem <ConsoleCommandSystem>();
     if (_ccs != null)
     {
         _ccs.Print += AddLine;
         _gs         = registry.GetSystem <GraphicsSystem>();
         _input      = registry.GetSystem <InputSystem>();
     }
     else
     {
         Enabled = false;
     }
 }
Пример #16
0
 // Token: 0x06000039 RID: 57 RVA: 0x00009A1C File Offset: 0x00007C1C
 public static void InitRenderDevice(GraphicsDevice graphicsRef)
 {
     RenderDevice.gDevice = graphicsRef;
     RenderDevice.effect  = new BasicEffect(RenderDevice.gDevice);
     RenderDevice.effect.TextureEnabled = true;
     GraphicsSystem.SetupPolygonLists();
     for (int i = 0; i < 6; i++)
     {
         RenderDevice.gfxTexture[i] = new Texture2D(RenderDevice.gDevice, 1024, 1024, false, SurfaceFormat.Bgra5551);
     }
     RenderDevice.renderTarget            = new RenderTarget2D(RenderDevice.gDevice, 400, 240, false, SurfaceFormat.Bgr565, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
     RenderDevice.rasterState.CullMode    = CullMode.None;
     RenderDevice.gDevice.RasterizerState = RenderDevice.rasterState;
     RenderDevice.gDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;
     RenderDevice.screenSprite = new SpriteBatch(RenderDevice.gDevice);
 }
Пример #17
0
 // Token: 0x0600003A RID: 58 RVA: 0x00009AD0 File Offset: 0x00007CD0
 public static void UpdateHardwareTextures()
 {
     RenderDevice.gDevice.Textures[0] = null;
     GraphicsSystem.SetActivePalette(0, 0, 240);
     GraphicsSystem.UpdateTextureBufferWithTiles();
     GraphicsSystem.UpdateTextureBufferWithSortedSprites();
     RenderDevice.gfxTexture[0].SetData <ushort>(GraphicsSystem.texBuffer);
     for (byte b = 1; b < 6; b += 1)
     {
         GraphicsSystem.SetActivePalette(b, 0, 240);
         GraphicsSystem.UpdateTextureBufferWithTiles();
         GraphicsSystem.UpdateTextureBufferWithSprites();
         RenderDevice.gfxTexture[(int)b].SetData <ushort>(GraphicsSystem.texBuffer);
     }
     GraphicsSystem.SetActivePalette(0, 0, 240);
 }
 // Token: 0x0600004B RID: 75 RVA: 0x0000B0A0 File Offset: 0x000092A0
 public static void StartupRetroEngine()
 {
     if (!EngineCallbacks.engineInit)
     {
         GlobalAppDefinitions.CalculateTrigAngles();
         GraphicsSystem.GenerateBlendLookupTable();
         if (FileIO.CheckRSDKFile())
         {
             GlobalAppDefinitions.LoadGameConfig("Data/Game/GameConfig.bin".ToCharArray());
         }
         AudioPlayback.InitAudioPlayback();
         StageSystem.InitFirstStage();
         ObjectSystem.ClearScriptData();
         EngineCallbacks.engineInit = true;
         return;
     }
     RenderDevice.UpdateHardwareTextures();
 }
Пример #19
0
        protected override void Initialize()
        {
            //pretty much self-explainatory
            //it sets screen resolution
            graphics.PreferredBackBufferHeight = Constants.SCREEN_HEIGHT;
            graphics.PreferredBackBufferWidth  = Constants.SCREEN_WIDTH;
            graphics.ApplyChanges();

            Globals._compManager    = new CompManager();
            Globals._contentManager = this.Content;
            this.gfxSystem          = new GraphicsSystem(this.GraphicsDevice);

            Globals._map  = new Map(80, 80);
            player        = new Entity(new CompPosition(10, 10), new CompGraphics('@', Color.Red));
            this.playerID = player.Id;

            base.Initialize();
        }
Пример #20
0
        protected override void OnLoad(EventArgs e)
        {
            base.WindowBorder = WindowBorder.Hidden;
            base.OnLoad(e);
            GraphicsSystem.Init();

            Title = "SageCS - BFME II";

            try
            {
                Texture t = new Texture();
                t.Load(File.Open("GermanSplash.jpg", FileMode.Open));
                Sprite sp = new Sprite(Vector2.Zero, new Vector2(800, 600), t);
                sp.Draw(GraphicsSystem.GetScreen());
            }
            catch
            {
                Texture t = new Texture();
                t.Load(File.Open("EnglishSplash.jpg", FileMode.Open));
            }

            base.SwapBuffers();

            FileSystem.Init();
            AudioSystem.Init();

            Stopwatch stopwatch = Stopwatch.StartNew();

            Texture tex  = new Texture();
            var     texS = FileSystem.Open("art\\compiledtextures\\al\\all_faction_banners.dds");

            tex.Load(texS);
            //W3DLoader.Load(FileSystem.Open("art\\w3d\\gu\\gumaarms_skn.w3d"));
            //W3DLoader.Load(FileSystem.Open("art\\w3d\\gu\\gumaarms_runa.w3d"));
            //W3DLoader.Load(FileSystem.Open("art\\w3d\\gu\\gumaarms_skl.w3d"));

            INIManager.ParseINIs();
            var   buffer    = WavLoader.Load(FileSystem.Open("data\\audio\\speech\\ucheer.wav"));
            Sound testSound = new Sound(buffer);

            testSound.Play();
            stopwatch.Stop();
            Console.WriteLine("total loading time: " + stopwatch.ElapsedMilliseconds + "ms");
        }
Пример #21
0
        public void CreateDeviceObjects(GraphicsDevice gd, CommandList cl, GraphicsSystem sc)
        {
            DisposeCollectorResourceFactory factory = new DisposeCollectorResourceFactory(gd.ResourceFactory);

            _disposeCollector = factory.DisposeCollector;

            ResourceLayout resourceLayout = factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                                             new ResourceLayoutElementDescription("SourceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment),
                                                                             new ResourceLayoutElementDescription("SourceSampler", ResourceKind.Sampler, ShaderStages.Fragment)));

            (Shader vs, Shader fs) = StaticResourceCache.GetShaders(gd, gd.ResourceFactory, "ScreenDuplicator");

            GraphicsPipelineDescription pd = new GraphicsPipelineDescription(
                new BlendStateDescription(
                    RgbaFloat.Black,
                    BlendAttachmentDescription.OverrideBlend,
                    BlendAttachmentDescription.OverrideBlend),
                gd.IsDepthRangeZeroToOne ? DepthStencilStateDescription.DepthOnlyGreaterEqual : DepthStencilStateDescription.DepthOnlyLessEqual,
                RasterizerStateDescription.Default,
                PrimitiveTopology.TriangleList,
                new ShaderSetDescription(
                    new[]
            {
                new VertexLayoutDescription(
                    new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2),
                    new VertexElementDescription("TexCoords", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2))
            },
                    new[] { vs, fs, }),
                new ResourceLayout[] { resourceLayout },
                sc.DuplicatorFramebuffer.OutputDescription);

            _pipeline = factory.CreateGraphicsPipeline(ref pd);

            float[] verts = Util.GetFullScreenQuadVerts(gd.BackendType);

            _vb = factory.CreateBuffer(new BufferDescription(verts.SizeInBytes() * sizeof(float), BufferUsage.VertexBuffer));
            cl.UpdateBuffer(_vb, 0, verts);

            _ib = factory.CreateBuffer(
                new BufferDescription((uint)s_quadIndices.Length * sizeof(ushort), BufferUsage.IndexBuffer));
            cl.UpdateBuffer(_ib, 0, s_quadIndices);
        }
Пример #22
0
        // Token: 0x0600003B RID: 59 RVA: 0x00009B58 File Offset: 0x00007D58
        public static void SetScreenDimensions(int width, int height)
        {
            InputSystem.touchWidth  = width;
            InputSystem.touchHeight = height;
            RenderDevice.viewWidth  = InputSystem.touchWidth;
            RenderDevice.viewHeight = InputSystem.touchHeight;
            float num = (float)RenderDevice.viewWidth / (float)RenderDevice.viewHeight;

            num *= 240f;
            RenderDevice.bufferWidth  = (int)num;
            RenderDevice.bufferWidth += 8;
            RenderDevice.bufferWidth  = RenderDevice.bufferWidth >> 4 << 4;
            if (RenderDevice.bufferWidth > 400)
            {
                RenderDevice.bufferWidth = 400;
            }
            RenderDevice.viewAspect = 0.75f;
            if (RenderDevice.viewHeight >= 480)
            {
                GlobalAppDefinitions.HQ3DFloorEnabled = true;
            }
            else
            {
                GlobalAppDefinitions.HQ3DFloorEnabled = false;
            }
            if (RenderDevice.viewHeight >= 480)
            {
                GraphicsSystem.SetScreenRenderSize(RenderDevice.bufferWidth, RenderDevice.bufferWidth);
                RenderDevice.bufferWidth *= 2;
                RenderDevice.bufferHeight = 480;
            }
            else
            {
                RenderDevice.bufferHeight = 240;
                GraphicsSystem.SetScreenRenderSize(RenderDevice.bufferWidth, RenderDevice.bufferWidth);
            }
            RenderDevice.orthWidth    = GlobalAppDefinitions.SCREEN_XSIZE * 16;
            RenderDevice.projection2D = Matrix.CreateOrthographicOffCenter(4f, (float)(RenderDevice.orthWidth + 4), 3844f, 4f, 0f, 100f);
            RenderDevice.projection3D = Matrix.CreatePerspectiveFieldOfView(1.8325957f, RenderDevice.viewAspect, 0.1f, 2000f) * Matrix.CreateScale(1f, -1f, 1f) * Matrix.CreateTranslation(0f, -0.045f, 0f);
            RenderDevice.screenRect   = new Rectangle(0, 0, RenderDevice.viewWidth, RenderDevice.viewHeight);
        }
Пример #23
0
        public void CreateDeviceObjects(GraphicsDevice gd, CommandList cl, GraphicsSystem sc)
        {
            DisposeCollectorResourceFactory factory = new DisposeCollectorResourceFactory(gd.ResourceFactory);

            _disposeCollector = factory.DisposeCollector;

            ResourceLayout resourceLayout = factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                                             new ResourceLayoutElementDescription("SourceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment),
                                                                             new ResourceLayoutElementDescription("SourceSampler", ResourceKind.Sampler, ShaderStages.Fragment)));

            (Shader vs, Shader fs) = StaticResourceCache.GetShaders(gd, gd.ResourceFactory, "FullScreenQuad");

            GraphicsPipelineDescription pd = new GraphicsPipelineDescription(
                new BlendStateDescription(
                    RgbaFloat.Black,
                    BlendAttachmentDescription.OverrideBlend),
                DepthStencilStateDescription.Disabled,
                new RasterizerStateDescription(FaceCullMode.Back, PolygonFillMode.Solid, FrontFace.Clockwise, true, false),
                PrimitiveTopology.TriangleList,
                new ShaderSetDescription(
                    new[]
            {
                new VertexLayoutDescription(
                    new VertexElementDescription("Position", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2),
                    new VertexElementDescription("TexCoords", VertexElementSemantic.TextureCoordinate, VertexElementFormat.Float2))
            },
                    new[] { vs, fs }),
                new ResourceLayout[] { resourceLayout },
                gd.SwapchainFramebuffer.OutputDescription);

            _pipeline = factory.CreateGraphicsPipeline(ref pd);

            float[] verts = Util.GetFullScreenQuadVerts(gd.BackendType);

            _vb = factory.CreateBuffer(new BufferDescription(verts.SizeInBytes() * sizeof(float), BufferUsage.VertexBuffer));
            cl.UpdateBuffer(_vb, 0, verts);

            _ib = factory.CreateBuffer(
                new BufferDescription(s_quadIndices.SizeInBytes(), BufferUsage.IndexBuffer));
            cl.UpdateBuffer(_ib, 0, s_quadIndices);
        }
Пример #24
0
        public void Render(GraphicsDevice gd, CommandList cl, GraphicsSystem sc, RenderPasses renderPass)
        {
            if (_materialPropsOwned)
            {
                _materialProps.FlushChanges(cl);
            }

            if ((renderPass & Glitch.Graphics.RenderPasses.AllShadowMap) != 0)
            {
                int shadowMapIndex = renderPass == Glitch.Graphics.RenderPasses.ShadowMapNear ? 0 : renderPass == Glitch.Graphics.RenderPasses.ShadowMapMid ? 1 : 2;
                RenderShadowMap(cl, sc, shadowMapIndex);
            }
            else if (renderPass == Glitch.Graphics.RenderPasses.Standard || renderPass == Glitch.Graphics.RenderPasses.AlphaBlend)
            {
                RenderStandard(cl, sc, false);
            }
            else if (renderPass == Glitch.Graphics.RenderPasses.ReflectionMap)
            {
                RenderStandard(cl, sc, true);
            }
        }
Пример #25
0
        private ResourceSet[] CreateShadowMapResourceSets(
            ResourceFactory sharedFactory,
            ResourceFactory disposeFactory,
            CommandList cl,
            GraphicsSystem sc,
            ResourceLayout projViewLayout,
            ResourceLayout worldLayout)
        {
            ResourceSet[] ret = new ResourceSet[6];

            for (int i = 0; i < 3; i++)
            {
                DeviceBuffer viewProjBuffer = i == 0 ? sc.LightViewProjectionBuffer0 : i == 1 ? sc.LightViewProjectionBuffer1 : sc.LightViewProjectionBuffer2;
                ret[i * 2] = StaticResourceCache.GetResourceSet(sharedFactory, new ResourceSetDescription(
                                                                    projViewLayout,
                                                                    viewProjBuffer));
                ResourceSet worldRS = disposeFactory.CreateResourceSet(new ResourceSetDescription(
                                                                           worldLayout,
                                                                           _worldAndInverseBuffer));
                ret[i * 2 + 1] = worldRS;
            }

            return(ret);
        }
Пример #26
0
        // Token: 0x060000B5 RID: 181 RVA: 0x00019904 File Offset: 0x00017B04
        public static void Draw3DScene(int surfaceNum)
        {
            Quad2D quad2D = new Quad2D();

            for (int i = 0; i < Scene3D.numFaces; i++)
            {
                Face3D face3D = Scene3D.indexBuffer[Scene3D.drawList[i].index];
                switch (face3D.flag)
                {
                case 0:
                    if (Scene3D.vertexBufferT[face3D.a].z > 256 && Scene3D.vertexBufferT[face3D.b].z > 256 && Scene3D.vertexBufferT[face3D.c].z > 256 && Scene3D.vertexBufferT[face3D.d].z > 256)
                    {
                        quad2D.vertex[0].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.a].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.a].z;
                        quad2D.vertex[0].y = 120 - Scene3D.vertexBufferT[face3D.a].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.a].z;
                        quad2D.vertex[1].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.b].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.b].z;
                        quad2D.vertex[1].y = 120 - Scene3D.vertexBufferT[face3D.b].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.b].z;
                        quad2D.vertex[2].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.c].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.c].z;
                        quad2D.vertex[2].y = 120 - Scene3D.vertexBufferT[face3D.c].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.c].z;
                        quad2D.vertex[3].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.d].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.d].z;
                        quad2D.vertex[3].y = 120 - Scene3D.vertexBufferT[face3D.d].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.d].z;
                        quad2D.vertex[0].u = Scene3D.vertexBuffer[face3D.a].u;
                        quad2D.vertex[0].v = Scene3D.vertexBuffer[face3D.a].v;
                        quad2D.vertex[1].u = Scene3D.vertexBuffer[face3D.b].u;
                        quad2D.vertex[1].v = Scene3D.vertexBuffer[face3D.b].v;
                        quad2D.vertex[2].u = Scene3D.vertexBuffer[face3D.c].u;
                        quad2D.vertex[2].v = Scene3D.vertexBuffer[face3D.c].v;
                        quad2D.vertex[3].u = Scene3D.vertexBuffer[face3D.d].u;
                        quad2D.vertex[3].v = Scene3D.vertexBuffer[face3D.d].v;
                        GraphicsSystem.DrawTexturedQuad(quad2D, surfaceNum);
                    }
                    break;

                case 1:
                    quad2D.vertex[0].x = Scene3D.vertexBuffer[face3D.a].x;
                    quad2D.vertex[0].y = Scene3D.vertexBuffer[face3D.a].y;
                    quad2D.vertex[1].x = Scene3D.vertexBuffer[face3D.b].x;
                    quad2D.vertex[1].y = Scene3D.vertexBuffer[face3D.b].y;
                    quad2D.vertex[2].x = Scene3D.vertexBuffer[face3D.c].x;
                    quad2D.vertex[2].y = Scene3D.vertexBuffer[face3D.c].y;
                    quad2D.vertex[3].x = Scene3D.vertexBuffer[face3D.d].x;
                    quad2D.vertex[3].y = Scene3D.vertexBuffer[face3D.d].y;
                    quad2D.vertex[0].u = Scene3D.vertexBuffer[face3D.a].u;
                    quad2D.vertex[0].v = Scene3D.vertexBuffer[face3D.a].v;
                    quad2D.vertex[1].u = Scene3D.vertexBuffer[face3D.b].u;
                    quad2D.vertex[1].v = Scene3D.vertexBuffer[face3D.b].v;
                    quad2D.vertex[2].u = Scene3D.vertexBuffer[face3D.c].u;
                    quad2D.vertex[2].v = Scene3D.vertexBuffer[face3D.c].v;
                    quad2D.vertex[3].u = Scene3D.vertexBuffer[face3D.d].u;
                    quad2D.vertex[3].v = Scene3D.vertexBuffer[face3D.d].v;
                    GraphicsSystem.DrawTexturedQuad(quad2D, surfaceNum);
                    break;

                case 2:
                    if (Scene3D.vertexBufferT[face3D.a].z > 256 && Scene3D.vertexBufferT[face3D.b].z > 256 && Scene3D.vertexBufferT[face3D.c].z > 256 && Scene3D.vertexBufferT[face3D.d].z > 256)
                    {
                        quad2D.vertex[0].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.a].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.a].z;
                        quad2D.vertex[0].y = 120 - Scene3D.vertexBufferT[face3D.a].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.a].z;
                        quad2D.vertex[1].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.b].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.b].z;
                        quad2D.vertex[1].y = 120 - Scene3D.vertexBufferT[face3D.b].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.b].z;
                        quad2D.vertex[2].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.c].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.c].z;
                        quad2D.vertex[2].y = 120 - Scene3D.vertexBufferT[face3D.c].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.c].z;
                        quad2D.vertex[3].x = GlobalAppDefinitions.SCREEN_CENTER + Scene3D.vertexBufferT[face3D.d].x * Scene3D.projectionX / Scene3D.vertexBufferT[face3D.d].z;
                        quad2D.vertex[3].y = 120 - Scene3D.vertexBufferT[face3D.d].y * Scene3D.projectionY / Scene3D.vertexBufferT[face3D.d].z;
                        GraphicsSystem.DrawQuad(quad2D, face3D.color);
                    }
                    break;

                case 3:
                    quad2D.vertex[0].x = Scene3D.vertexBuffer[face3D.a].x;
                    quad2D.vertex[0].y = Scene3D.vertexBuffer[face3D.a].y;
                    quad2D.vertex[1].x = Scene3D.vertexBuffer[face3D.b].x;
                    quad2D.vertex[1].y = Scene3D.vertexBuffer[face3D.b].y;
                    quad2D.vertex[2].x = Scene3D.vertexBuffer[face3D.c].x;
                    quad2D.vertex[2].y = Scene3D.vertexBuffer[face3D.c].y;
                    quad2D.vertex[3].x = Scene3D.vertexBuffer[face3D.d].x;
                    quad2D.vertex[3].y = Scene3D.vertexBuffer[face3D.d].y;
                    GraphicsSystem.DrawQuad(quad2D, face3D.color);
                    break;
                }
            }
        }
Пример #27
0
        public static void Main(string[] args)
        {
            CommandLineOptions commandLineOptions = new CommandLineOptions(args);
            // Force-load prefs.
            var prefs = EditorPreferences.Instance;

            OpenTKWindow window = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
                ? (OpenTKWindow)new DedicatedThreadWindow(960, 540, WindowState.Maximized)
                : new SameThreadWindow(960, 540, WindowState.Maximized);
            window.Title = "ge.Editor";
            Game game = new Game();
            GraphicsBackEndPreference backEndPref = commandLineOptions.PreferOpenGL ? GraphicsBackEndPreference.OpenGL : GraphicsBackEndPreference.None;
            GraphicsSystem gs = new GraphicsSystem(window, prefs.RenderQuality, backEndPref);
            gs.Context.ResourceFactory.AddShaderLoader(new EmbeddedResourceShaderLoader(typeof(Program).GetTypeInfo().Assembly));
            game.SystemRegistry.Register(gs);
            game.LimitFrameRate = false;

            InputSystem inputSystem = new InputSystem(window);
            inputSystem.RegisterCallback((input) =>
            {
                if (input.GetKeyDown(Key.F4) && (input.GetKey(Key.AltLeft) || input.GetKey(Key.AltRight)))
                {
                    game.Exit();
                }
            });

            game.SystemRegistry.Register(inputSystem);

            ImGuiRenderer imGuiRenderer = new ImGuiRenderer(gs.Context, window.NativeWindow, inputSystem);
            gs.SetImGuiRenderer(imGuiRenderer);

            var als = new AssemblyLoadSystem();
            game.SystemRegistry.Register(als);

            AssetSystem assetSystem = new EditorAssetSystem(Path.Combine(AppContext.BaseDirectory, "Assets"), als.Binder);
            game.SystemRegistry.Register(assetSystem);

            EditorSceneLoaderSystem esls = new EditorSceneLoaderSystem(game, game.SystemRegistry.GetSystem<GameObjectQuerySystem>());
            game.SystemRegistry.Register<SceneLoaderSystem>(esls);
            esls.AfterSceneLoaded += () => game.ResetDeltaTime();

            CommandLineOptions.AudioEnginePreference? audioPreference = commandLineOptions.AudioPreference;
            AudioEngineOptions audioEngineOptions =
                !audioPreference.HasValue ? AudioEngineOptions.Default
                : audioPreference == CommandLineOptions.AudioEnginePreference.None ? AudioEngineOptions.UseNullAudio
                : AudioEngineOptions.UseOpenAL;
            AudioSystem audioSystem = new AudioSystem(audioEngineOptions);
            game.SystemRegistry.Register(audioSystem);

            BehaviorUpdateSystem bus = new BehaviorUpdateSystem(game.SystemRegistry);
            game.SystemRegistry.Register(bus);
            bus.Register(imGuiRenderer);

            PhysicsSystem ps = new PhysicsSystem(PhysicsLayersDescription.Default);
            game.SystemRegistry.Register(ps);

            ConsoleCommandSystem ccs = new ConsoleCommandSystem(game.SystemRegistry);
            game.SystemRegistry.Register(ccs);

            game.SystemRegistry.Register(new SynchronizationHelperSystem());

            window.Closed += game.Exit;

            var editorSystem = new EditorSystem(game.SystemRegistry, commandLineOptions, imGuiRenderer);
            editorSystem.DiscoverComponentsFromAssembly(typeof(Program).GetTypeInfo().Assembly);
            // Editor system registers itself.

            game.RunMainLoop();

            window.NativeWindow.Dispose();

            EditorPreferences.Instance.Save();
        }
Пример #28
0
 public void UpdatePerFrameResources(GraphicsDevice gd, CommandList cl, GraphicsSystem sc)
 {
 }
Пример #29
0
 protected override void Start(SystemRegistry registry)
 {
     base.Start(registry);
     _gs    = registry.GetSystem <GraphicsSystem>();
     _input = registry.GetSystem <InputSystem>();
 }
Пример #30
0
        public static void Main(string[] args)
        {
            OpenTKWindow window = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? (OpenTKWindow) new DedicatedThreadWindow() : new SameThreadWindow();

            window.Title   = "ge.Main";
            window.Visible = true;
            Game           game = new Game();
            GraphicsSystem gs   = new GraphicsSystem(window);

            game.SystemRegistry.Register(gs);
            gs.AddFreeRenderItem(new ShadowMapPreview(gs.Context));

            InputSystem inputSystem = new InputSystem(window);

            inputSystem.RegisterCallback((input) =>
            {
                if (input.GetKeyDown(Key.F4) && (input.GetKey(Key.AltLeft) || input.GetKey(Key.AltRight)))
                {
                    game.Exit();
                }
                if (input.GetKeyDown(Key.F11))
                {
                    window.WindowState = window.WindowState == WindowState.Normal ? WindowState.FullScreen : WindowState.Normal;
                }
                if (input.GetKeyDown(Key.F12))
                {
                    gs.ToggleOctreeVisualizer();
                }
            });

            game.SystemRegistry.Register(inputSystem);

            ImGuiRenderer imGuiRenderer = new ImGuiRenderer(gs.Context, window.NativeWindow, inputSystem);

            gs.AddFreeRenderItem(imGuiRenderer);
            ImGuiNET.ImGui.GetIO().FontAllowUserScaling = true;

            AssetSystem assetSystem = new AssetSystem(Path.Combine(AppContext.BaseDirectory, "Assets"));

            game.SystemRegistry.Register(assetSystem);

            BehaviorUpdateSystem bus = new BehaviorUpdateSystem(game.SystemRegistry);

            game.SystemRegistry.Register(bus);
            bus.Register(imGuiRenderer);

            PhysicsSystem ps = new PhysicsSystem();

            game.SystemRegistry.Register(ps);

            ScoreSystem ss = new ScoreSystem();

            game.SystemRegistry.Register(ss);

            ConsoleCommandSystem ccs = new ConsoleCommandSystem(game.SystemRegistry);

            game.SystemRegistry.Register(ccs);

            window.Closed += game.Exit;

            LooseFileDatabase db = new LooseFileDatabase(AppContext.BaseDirectory);

            AddBinGameScene();
            SceneAsset scene = new SceneAsset();
            var        goqs  = game.SystemRegistry.GetSystem <GameObjectQuerySystem>();

            scene.GameObjects = goqs.GetAllGameObjects().Select(go => new SerializedGameObject(go)).ToArray();
            db.SaveDefinition(scene, "BINSCENE.scene");

            //var scene = db.LoadAsset<SceneAsset>("BINSCENE.scene_New");
            //scene.GenerateGameObjects();

            game.RunMainLoop();
        }