Esempio n. 1
0
        protected override void OnBeforeInitalizers(object sender, EventArgs e)
        {
            _atlases = _textureBuilder.Build();

            _chunk.GenerateMeshes(_atlases);
            _boxObj.GenerateMeshes();
            _texShader = new Tex2dShader();
            _colShader = new Col2dShader();

            GL.Enable(EnableCap.DepthTest);
            GL.LineWidth(2F);

            CenterPlayer();
            base.OnBeforeInitalizers(sender, e);
        }
Esempio n. 2
0
        private void LoadTextures()
        {
            Console.WriteLine("[Client] Loading textures...");

            using (var builder = new TextureAtlasBuilder <GLTexture>(textureFactory))
            {
                var files = Directory.GetFiles("./Textures/Blocks");
                foreach (var file in files)
                {
                    var name = Path.GetFileNameWithoutExtension(file);
                    builder.AddImage(name, new Bitmap(file));
                }

                blockTextureAtlas = builder.Build();
            }

            Console.WriteLine("[Client] Loaded textures");
        }
Esempio n. 3
0
        protected override void OnBeforeInitalizers(object sender, EventArgs e)
        {
            var assets = _resource.GetAssets().Where(asset =>
                                                     asset.Type == AssetType.Texture &&
                                                     asset.NamedIdentifier.Name.StartsWith("block/") &&
                                                     asset.NamedIdentifier.Name.EndsWith(".png"));
            var textureBuilder = new TextureAtlasBuilder();
            var i = 0;

            foreach (var asset in assets)
            {
                using var stream = asset.OpenRead();
                Logger.GetLogger <MainWindow>().Info(asset.NamedIdentifier.FullName);
                var bImg     = new Image(stream);
                var isSingle = bImg.FrameCount == 1;
                var q        = 0;
                foreach (var image in bImg)
                {
                    textureBuilder.Add(isSingle ? asset.NamedIdentifier.FullName : $"{asset.NamedIdentifier.FullName}{{{q}}}", image);
                    i++;
                    q++;
                    if (i == 4096)
                    {
                        break;
                    }
                }

                if (i == 4096)
                {
                    break;
                }
            }

            _atlases = textureBuilder.Build();


            GL.ClearColor(Color4.CornflowerBlue);
            GL.Enable(EnableCap.DepthTest);
            GL.LineWidth(2F);
            base.OnBeforeInitalizers(sender, e);
        }