public void ShouldSaveAndLoadTextureFromPng() { var color = new ColorRGB888( Color.FromArgb(unchecked ((int)0xFFC0FFEE)) ); var size = graphics.OutputSize; // Prepare a texture, draw it and save framebuffer contents var texture = graphics.CreateTexture(size.Width, size.Height); var pixels = Enumerable.Repeat(color, texture.PixelCount).ToArray(); texture.SetPixels(ref pixels); graphics.Clear(Color.Black); graphics.Draw(texture); var ms = new MemoryStream(); graphics.SaveAsPng(ms); ms.Seek(0, SeekOrigin.Begin); // Recreate same texture from framebuffer data, draw and compare var sameTexture = TextureFactory.FromStream(graphics, ms, TextureScalingQuality.Nearest, new PngDecoder()); var samePixels = new ColorRGB888[pixels.Length]; graphics.Clear(Color.Black); graphics.Draw(texture); graphics.ReadPixels(ref samePixels); samePixels.Should().Equal(pixels); }
public UIView(ICore core, UIType menuType, int width, int height, UIFlags flags, bool transparent) : base(core) { webCore = core.GetService <IUIManagerService>().GetWebCore(); this.menuType = menuType; this.width = width; this.height = height; this.flags = flags; this.isTransparent = transparent; isLoading = false; pageLoaded = false; webTextureID = TextureFactory.CreateTexture(width, height, isTransparent); hudPosX = 0; hudPosY = 0; hud = new TVScreen2DImmediate(); Keyboard = core.GetService <IKeyboardService>(); Mouse = core.GetService <IMouseService>(); JoyStick = core.GetService <IJoyStickService>(); Gamepad = core.GetService <IGamepadsService>(); CanculateHudPosition(flags); View = webCore.CreateWebView(width, height, isTransparent, true); View.OnFinishLoading += OnFinishLoading; View.OnCallback += OnCallback; View.Focus(); buttonClickSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_click.mp3")); buttonFocusSound = Core.GetService <ISoundManagerService>().Load2DSound(Path.Combine(Application.StartupPath, @"Data\Sounds\menu\button_focus.mp3")); Core.GetService <ISoundManagerService>().SetVolume(buttonClickSound, 0.5f); Core.GetService <ISoundManagerService>().SetVolume(buttonFocusSound, 0.5f); }
private void SetTexture() { if (_player.Position.Y <= _height) { IsVisible = false; } else { IsVisible = true; var alpha = (int)(_player.Position.Y - _height); if (alpha > 25) { alpha = 25; } Texture2D texture; if (!TextureCache.TryGetValue(alpha, out texture)) { texture = TextureFactory.FromColor(new Color(255, 250, 199, alpha)); TextureCache.Add(alpha, texture); } _texture = texture; } }
private ITexture loadTextureInternal(string filePath) { if (!System.IO.File.Exists(filePath)) { Console.WriteLine("Texture not found on disk: (" + filePath + ")"); return(null); } var searchTex = TextureFactory.FindTexture(delegate(ITexture tex) { var data = tex.GetCoreData(); return(data.StorageType == TextureCoreData.TextureStorageType.Disk && data.DiskFilePath == filePath); }); if (searchTex != null) { return(searchTex); } var ret = new RAMTexture(); ret.GetCoreData().StorageType = TextureCoreData.TextureStorageType.Disk; ret.GetCoreData().DiskFilePath = filePath; TextureFactory.AddTexture(ret); return(ret); }
public override void Start() { _margin = 15; _background = TextureFactory.CreateGradiant(Color.LightSteelBlue, Color.Linen, Screen.VirtualWidth, Screen.VirtualHeight); _backgroundRect = new Rectangle(0, 0, Screen.VirtualWidth, Screen.VirtualHeight); var tempVec2 = GUI.Skin.Font.MeasureString("C3DE Demos"); _titleSize = 2.5f; _titleRect = new Vector2(Screen.VirtualWidthPerTwo - tempVec2.X * _titleSize / 2, tempVec2.Y + 5); tempVec2 = GUI.Skin.Font.MeasureString("Gets the source : https://github.com/demonixis/C3DE"); _footerRect = new Vector2(Screen.VirtualWidthPerTwo - tempVec2.X / 2, Screen.VirtualHeight - tempVec2.Y - 5); _demos = new DemoWidget[Application.SceneManager.Count - 1]; for (int i = 0; i < _demos.Length; i++) { _demos[i] = new DemoWidget(Application.SceneManager[i + 1].Name, i + 1); } float x = Screen.VirtualWidthPerTwo - ButtonWidth / 2; float y = Screen.VirtualHeightPerTwo - ((ButtonHeight + _margin) * _demos.Length) / 2; for (int i = 0; i < _demos.Length; i++) { _demos[i].SetPosition(x, y + i * (ButtonHeight + _margin)); } }
void session_GamerJoined(object sender, GamerJoinedEventArgs e) { Screen playerList = allScreens["playerList"]; Texture2D newGamerImage = new TextureFactory(GraphicsDevice).CreateSquare(64, Color.Red); try { newGamerImage = Texture2D.FromStream(GraphicsDevice, e.Gamer.GetProfile().GetGamerPicture()); } catch { }; Vector2 pos = new Vector2(100, 50); foreach (Sprite s in playerList.Sprites) { pos.Y += s.Height + 5; } Sprite gamerIcon = new Sprite(newGamerImage, pos, spriteBatch); playerList.Sprites.Add(gamerIcon); TextSprite gamerName = new TextSprite(spriteBatch, new Vector2(pos.X + gamerIcon.Width + 5, pos.Y), font, e.Gamer.Gamertag); allScreens["playerList"].AdditionalSprites.Add(gamerName); if (session.AllGamers.Count >= 2 && session.IsHost) { //TODO session.StartGame(); } }
public async Task <VRMMetaObject> ReadMetaAsync(IAwaitCaller awaitCaller = null, bool createThumbnail = false) { awaitCaller = awaitCaller ?? new ImmediateCaller(); var meta = ScriptableObject.CreateInstance <VRMMetaObject>(); meta.name = "Meta"; meta.ExporterVersion = VRM.exporterVersion; var gltfMeta = VRM.meta; meta.Version = gltfMeta.version; // model version meta.Author = gltfMeta.author; meta.ContactInformation = gltfMeta.contactInformation; meta.Reference = gltfMeta.reference; meta.Title = gltfMeta.title; if (gltfMeta.texture >= 0) { var(key, param) = GltfTextureImporter.CreateSRGB(Data, gltfMeta.texture, Vector2.zero, Vector2.one); meta.Thumbnail = await TextureFactory.GetTextureAsync(param, awaitCaller) as Texture2D; } meta.AllowedUser = gltfMeta.allowedUser; meta.ViolentUssage = gltfMeta.violentUssage; meta.SexualUssage = gltfMeta.sexualUssage; meta.CommercialUssage = gltfMeta.commercialUssage; meta.OtherPermissionUrl = gltfMeta.otherPermissionUrl; meta.LicenseType = gltfMeta.licenseType; meta.OtherLicenseUrl = gltfMeta.otherLicenseUrl; return(meta); }
public async Awaitable <VRMMetaObject> ReadMetaAsync(bool createThumbnail = false) { var meta = ScriptableObject.CreateInstance <VRMMetaObject>(); meta.name = "Meta"; meta.ExporterVersion = VRM.exporterVersion; var gltfMeta = VRM.meta; meta.Version = gltfMeta.version; // model version meta.Author = gltfMeta.author; meta.ContactInformation = gltfMeta.contactInformation; meta.Reference = gltfMeta.reference; meta.Title = gltfMeta.title; meta.Thumbnail = await TextureFactory.GetTextureAsync(GLTF, GetTextureParam.Create(GLTF, gltfMeta.texture)); meta.AllowedUser = gltfMeta.allowedUser; meta.ViolentUssage = gltfMeta.violentUssage; meta.SexualUssage = gltfMeta.sexualUssage; meta.CommercialUssage = gltfMeta.commercialUssage; meta.OtherPermissionUrl = gltfMeta.otherPermissionUrl; meta.LicenseType = gltfMeta.licenseType; meta.OtherLicenseUrl = gltfMeta.otherLicenseUrl; return(meta); }
public void CreateTextureTest() { GraphicsDevice device = MockDrawable.GraphicsDevice; // TODO: Initialize to an appropriate value //Assert.Inconclusive("Write this this test method."); TextureFactory target = new TextureFactory(device); int width = 20; int height = 35; Func <Point, Color> colorDetermine = new Func <Point, Color>(CreateTexturetestDelegate); // TODO: Initialize to an appropriate value Color[] expectedData = new Color[width * height]; Texture2D actual; Color[] actualData = new Color[width * height]; actual = target.CreateTexture(width, height, colorDetermine); actual.GetData(actualData); for (int w_en = 0; w_en < width; w_en++) { for (int h_en = 0; h_en < height; h_en++) { expectedData[h_en * width + w_en] = CreateTexturetestDelegate(new Point(w_en, h_en)); } } Assert.AreEqual(expectedData.Length, actualData.Length); for (int i = 0; i < expectedData.Length; i++) { Assert.AreEqual(expectedData[i], actualData[i]); } }
public void TextureFactoryConstructorTest() { GraphicsDevice device = MockDrawable.GraphicsDevice; TextureFactory target = new TextureFactory(device); Assert.IsNotNull(target.WhitePixel); }
public static Guy Create(GraphicsDevice graphics, ContentManager content, DebugLogger logger, Vector2 position) { var physics = new GuyPhysics( position, new Vector2(0, 0), SpriteWidth, SpriteHeight, logger); var states = new GuyStates( jumping: new GuyJumpingState(new EasySprite(content.Load <Texture2D>("Guy-Jumping"))), hooray: new GuyHoorayState(new EasySprite(content.Load <Texture2D>("Guy-Hooray"))), ducking: new GuyDuckingState(new EasySprite(content.Load <Texture2D>("Guy-Ducking"))), idle: new GuyIdleState(new EasySprite(content.Load <Texture2D>("Guy-Idle"))), cannonball: new GuyCannonballState(new EasySprite(content.Load <Texture2D>("Guy-Cannonball"))), running: new GuyRunningState( new EasySpriteAnimation(content.Load <Texture2D>("Guy-Running"), 6, 2, 0.08f), new EasySprite(content.Load <Texture2D>("Guy-Sliding"))), cannonballCrash: new GuyCannonballCrashState( new EasySpriteAnimation(content.Load <Texture2D>("Guy-CannonballCrash"), 2, 1, 0.2f, canLoop: false)), cannonballCrashRecovery: new GuyCannonballCrashRecoveryState( new EasySpriteAnimation(content.Load <Texture2D>("Guy-CannonballCrashRecovery"), 6, 1, 0.08f, canLoop: false))); var boundingBox = new BoundingBox( TextureFactory.Rectangle(graphics, SpriteWidth, SpriteHeight, Color.Blue, false), content.Load <SpriteFont>("Consolas")); return(new Guy(physics, states, logger, boundingBox)); }
public override void Initialize() { base.Initialize(); // Add a camera with a FPS controller var cameraGo = AddGameObject("Camera"); GameObjectFactory.CreateCamera(new Vector3(0, 2, -10), new Vector3(0, 0, 0), Vector3.Up); var camera = cameraGo.GetComponent <Camera>(); camera.Setup(new Vector3(0, 2, 5), Vector3.Forward, Vector3.Up); camera.Far = 10000; camera.AddComponent <EditorController>(); // And a light var lightGo = AddGameObject("Directional"); lightGo.Transform.LocalPosition = new Vector3(500, 500, 0); lightGo.Transform.LocalRotation = new Vector3(MathHelper.PiOver2, -MathHelper.PiOver4, 0); var directionalLight = lightGo.GetComponent <Light>(); // Sun Flares var content = Application.Content; var glowTexture = content.Load <Texture2D>("Textures/Flares/SunGlow"); var flareTextures = new Texture2D[] { content.Load <Texture2D>("Textures/Flares/circle"), content.Load <Texture2D>("Textures/Flares/circle_sharp_1"), content.Load <Texture2D>("Textures/Flares/circle_soft_1") }; var direction = directionalLight.Direction; var sunflares = directionalLight.AddComponent <LensFlare>(); sunflares.Setup(glowTexture, flareTextures); // Skybox var blueSkybox = new string[6] { "Textures/Skybox/bluesky/px", "Textures/Skybox/bluesky/nx", "Textures/Skybox/bluesky/py", "Textures/Skybox/bluesky/ny", "Textures/Skybox/bluesky/pz", "Textures/Skybox/bluesky/nz" }; RenderSettings.Skybox.Generate(Application.GraphicsDevice, blueSkybox); // Grid var grid = new GameObject("Grid"); grid.Tag = EditorGame.EditorTag; grid.AddComponent <Grid>(); _defaultMaterial = new StandardMaterial(); _defaultMaterial.MainTexture = TextureFactory.CreateColor(Color.WhiteSmoke, 1, 1); SceneInitialized?.Invoke(new[] { cameraGo, lightGo }); }
public FrameBufferObject(int width, int height) { FrameBufferTexture = TextureFactory.Create(TextureWrapMode.ClampToEdge, width, height); FrameBufferTexture.LoadEmptyTexture(PixelInternalFormat.Rgba, PixelFormat.Bgra, true); TextureHandle = FrameBufferTexture.MyTextureHandle; Width = width; Height = height; }
public RedWarningLight(Level level, Vector3 position) : base(level) { _texture = TextureFactory.FromColor(Color.Red); _position = position; Collider = new BoxCollider(_position, new Vector3(0.75f)); }
public DifficultyState() : base() { var buttonTexture = TextureFactory.GetTexture("Controls/Button"); var buttonFont = TextureFactory.GetSpriteFont("Fonts/Font"); this.selectDifficultyTexture = TextureFactory.GetTexture("Titles/SELECT"); this.selectDifficultyTexture2 = TextureFactory.GetTexture("Titles/DIFFICULTY"); var bossButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(2, 300), Text = "Boss", }; bossButton.Click += this.BossButton_Click; var newGameEasyButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(161, 450), Text = "Easy", }; newGameEasyButton.Click += this.NewGameEasyButton_Click; var newGameNormalButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(161, 500), Text = "Normal", }; newGameNormalButton.Click += this.NewGameNormalButton_Click; var newGameHardButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(161, 550), Text = "Hard", }; newGameHardButton.Click += this.NewGameHardButton_Click; var returnButton = new Button(buttonTexture, buttonFont) { Position = new Vector2(161, 600), Text = "Main Menu", }; returnButton.Click += this.QuitGameButton_Click; this.components = new List <Component>() { newGameEasyButton, newGameNormalButton, newGameHardButton, returnButton, bossButton, }; }
public SpriteRenderer(TextureFactory textureFactory, int initialSpriteCapacity = 2048) { if (textureFactory == null) throw new ArgumentNullException(nameof(textureFactory)); this.textureFactory = textureFactory; this.CreateBuffers(initialSpriteCapacity); this.PlatformCreateBuffers(); this.PlatformCreateShaders(); }
public override void Start() { var graphics = Application.GraphicsDevice; // Setup PostProcess. AddPostProcess(new FastPostProcessing(graphics)); AddPostProcess(new FastBloom(graphics)); AddPostProcess(new Tonemapping(graphics)); AddPostProcess(new C64Filter(graphics)); AddPostProcess(new CGAFilter(graphics)); AddPostProcess(new ConvolutionFilter(graphics)); AddPostProcess(new FilmFilter(graphics)); AddPostProcess(new GrayScaleFilter(graphics)); AddPostProcess(new AverageColorFilter(graphics)); AddPostProcess(new MotionBlur(graphics)); AddPostProcess(new Vignette(graphics)); AddPostProcess(new GlobalFog(graphics)); // Setup UI var titles = new List <string>(new [] { "Fast PP", "Bloom", "Tonemapping", "C64 Filter", "CGA Filter", "Convolution", "Film", "GrayScale", "Average Color", "Motion Blur", "Vignette", "Global Fog" }); var count = titles.Count; _boxRect = new Rectangle(Screen.VirtualWidth - 220, 10, 210, 45 * count); _widgets = new Widget[count]; for (int i = 0; i < count; i++) { _widgets[i] = new Widget(); _widgets[i].Name = titles[i]; if (i == 0) { _widgets[i].Rect = new Rectangle(_boxRect.X + 10, _boxRect.Y + 30, _boxRect.Width - 20, 30); } else { _widgets[i].Rect = new Rectangle(_boxRect.X + 10, _widgets[i - 1].Rect.Y + 40, _boxRect.Width - 20, 30); } _widgets[i].RectExt = new Rectangle(_widgets[i].Rect.X - 1, _widgets[i].Rect.Y - 1, _widgets[i].Rect.Width + 1, _widgets[i].Rect.Height + 1); } _backgroundTexture = TextureFactory.CreateColor(Color.CornflowerBlue, 1, 1); var renderSettings = Scene.current.RenderSettings; renderSettings.FogDensity = 0.0085f; renderSettings.FogMode = FogMode.Linear; renderSettings.Skybox.OverrideSkyboxFog(FogMode.Exp2, 0.05f, 0, 0); }
public void Texture_OK() { //Act ITexture texture = TextureFactory.Create(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Dirt.jpg"), TextureWrapMode.ClampToEdge); //Assert Bitmap bitmap = new Bitmap(Utils.Utils.GetImageResource <ITerrain>("Landscape.Terrains.Dirt.jpg")); VerifyImage(bitmap, texture.TextureImage); }
public ClawRope(Level level, Player player) : base(level) { _player = player; _originPosition = _player.Position + GetPlayerOffset(); _yaw = _player.Yaw; _pitch = _player.Pitch; _texture = TextureFactory.FromColor(new Color(79, 64, 35)); }
public static Texture Texture(this Entity entity) { var textureId = entity.GetComponent <ImageComponent>().TextureId; if (textureId == null) { return(null); } return(TextureFactory.TryGetTexture(textureId, out var texture) ? texture : null); // todo: null object? }
public Plane(bool invertAllFaces, Vbo p1, Vbo p2, Vbo p3, Vbo p4, Image textureImage, TextureWrapMode textureWrapMode = TextureWrapMode.ClampToEdge) : this(invertAllFaces, p1, p2, p3, p4) { if (textureImage != null) { Texture1 = TextureFactory.Create(textureImage, textureWrapMode); } else { Texture1 = TextureFactory.Create(TextureWrapMode.ClampToEdge, 50, 50); } }
private void InitLoadingScreen() { /* final */ ITextureSource loadingScreenTextureSource = this.mEngineOptions.GetLoadingScreenTextureSource(); /* final */ Texture loadingScreenTexture = TextureFactory.CreateForTextureSourceSize(loadingScreenTextureSource); /* final */ TextureRegion loadingScreenTextureRegion = TextureRegionFactory.CreateFromSource(loadingScreenTexture, loadingScreenTextureSource, 0, 0); this.SetScene(new SplashScene(this.GetCamera(), loadingScreenTextureRegion)); }
private (long, GalImage, GalTextureSampler) UploadTexture(NvGpuVmm vmm, int textureHandle) { if (textureHandle == 0) { // FIXME: Some games like puyo puyo will use handles with the value 0. // This is a bug, most likely caused by sync issues. return(0, default(GalImage), default(GalTextureSampler)); } Profile.Begin(Profiles.GPU.Engine3d.UploadTexture); bool linkedTsc = ReadRegisterBool(NvGpuEngine3dReg.LinkedTsc); int ticIndex = (textureHandle >> 0) & 0xfffff; int tscIndex = linkedTsc ? ticIndex : (textureHandle >> 20) & 0xfff; long ticPosition = MakeInt64From2xInt32(NvGpuEngine3dReg.TexHeaderPoolOffset); long tscPosition = MakeInt64From2xInt32(NvGpuEngine3dReg.TexSamplerPoolOffset); ticPosition += ticIndex * 0x20; tscPosition += tscIndex * 0x20; GalImage image = TextureFactory.MakeTexture(vmm, ticPosition); GalTextureSampler sampler = TextureFactory.MakeSampler(_gpu, vmm, tscPosition); long key = vmm.ReadInt64(ticPosition + 4) & 0xffffffffffff; if (image.Layout == GalMemoryLayout.BlockLinear) { key &= ~0x1ffL; } else if (image.Layout == GalMemoryLayout.Pitch) { key &= ~0x1fL; } key = vmm.GetPhysicalAddress(key); if (key == -1) { Profile.End(Profiles.GPU.Engine3d.UploadTexture); // FIXME: Shouldn't ignore invalid addresses. return(0, default(GalImage), default(GalTextureSampler)); } _gpu.ResourceManager.SendTexture(vmm, key, image); Profile.End(Profiles.GPU.Engine3d.UploadTexture); return(key, image, sampler); }
public override void Initialize() { //http://blenderartists.org/forum/showthread.php?24038-Free-high-res-skymaps-%28Massive-07-update!%29 var textureId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, FileName)); Atmosphere.SkySphere_Enable(true); Atmosphere.SkySphere_SetTexture(textureId); Atmosphere.SkySphere_SetRotation(Rotation.x, Rotation.y, Rotation.z); Atmosphere.SkySphere_SetScale(Scale.x, Scale.y, Scale.z); Atmosphere.SkySphere_SetPolyCount(PolyCount); }
public void WhitePixelTest() { GraphicsDevice device = MockDrawable.GraphicsDevice; // TODO: Initialize to an appropriate value TextureFactory target = new TextureFactory(device); // TODO: Initialize to an appropriate value Texture2D actual; actual = target.WhitePixel; Color[] data = new Color[] { Color.Transparent }; actual.GetData(data); Assert.AreEqual(Color.White, data[0]); }
private void OnEnable() { self = target as EventInvoker; focusedBackgroundStyle = new GUIStyle { normal = { background = TextureFactory.SolidColor(new Color32(44, 93, 135, 255)) } }; selectedBackgroundStyle = new GUIStyle { normal = { background = TextureFactory.SolidColor(new Color32(77, 77, 77, 255)) } }; }
public SlamVisualizer(Game game, SpriteRenderer renderer, SlamController controller, NavigationEnvironment environment) { font = game.Content.Load <SpriteFont>("DebugFont"); var textureColor = new Color(255, 255, 255, 100); var strokeColor = new Color(0, 0, 0, 100); covarianceTexture = TextureFactory.CreateCircleTexture(game.GraphicsDevice, 1000, 20, 5, 5, textureColor, strokeColor); elements = new List <SlamElement>(); this.controller = controller; this.renderer = renderer; this.environment = environment; }
public override void Initialize() { var frontId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, FrontTexture)); var backId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, BackTexture)); var leftId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, LeftTexture)); var rightId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, RightTexture)); var topId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, TopTexture)); var bottomId = TextureFactory.LoadTexture(Path.Combine(Application.StartupPath, BottomTexture)); Atmosphere.SkyBox_Enable(true); Atmosphere.SkyBox_SetTexture(frontId, backId, leftId, rightId, topId, bottomId); }
public override void Start() { if (_borderZone == Rectangle.Empty) { _borderZone = new Rectangle(Screen.VirtualWidthPerTwo, 10, Screen.VirtualWidthPerTwo, Screen.VirtualHeight - Screen.VirtualHeight / 3); } if (_borderTexture == null) { _borderTexture = TextureFactory.CreateBorder(new Color(0.3f, 0.3f, 0.3f, 0.6f), Color.Transparent, _borderZone.Width, _borderZone.Height, 2); } }
/// <summary> /// /// </summary> public DynamicPrimitive(TextureFactory textureFactory, int initialBufferCapacity = 32, int maxBufferSizePerPrimitive = 32768) { if (textureFactory == null) { throw new ArgumentNullException(nameof(textureFactory)); } this.textureFactory = textureFactory; this.CreateBuffers(initialBufferCapacity, maxBufferSizePerPrimitive); this.CreateShaders(); this.Clear(); }
public IEnumerable <TextureImportParam> Enumerate(GltfParser parser) { for (int i = 0; i < parser.GLTF.materials.Count; ++i) { var vrmMaterial = m_vrm.materialProperties[i]; if (vrmMaterial.shader == MToon.Utils.ShaderName) { // MToon foreach (var kv in vrmMaterial.textureProperties) { // SRGB color or normalmap yield return(TextureFactory.Create(parser, kv.Value, kv.Key, default, default));
public void CreateTexture() { using (var threadWindow = Device.CreateWindow(1, 1)) using (var window = Device.CreateWindow(1, 1)) { TextureFactory factory = new TextureFactory(threadWindow.Context, new BlittableRGBA(Color.FromArgb(0, 1, 2, 3))); Thread t = new Thread(factory.Create); t.Start(); t.Join(); /////////////////////////////////////////////////////////////////// TestUtility.ValidateColor(factory.Texture, 1, 2, 3); } }
public void CreateTexturesSequential() { using (var thread0Window = Device.CreateWindow(1, 1)) using (var thread1Window = Device.CreateWindow(1, 1)) using (var window = Device.CreateWindow(1, 1)) { TextureFactory factory0 = new TextureFactory(thread0Window.Context, new BlittableRGBA(Color.FromArgb(0, 127, 0, 0))); TextureFactory factory1 = new TextureFactory(thread1Window.Context, new BlittableRGBA(Color.FromArgb(0, 0, 255, 0))); Thread t0 = new Thread(factory0.Create); t0.Start(); t0.Join(); Thread t1 = new Thread(factory1.Create); t1.Start(); t1.Join(); /////////////////////////////////////////////////////////////////// TestUtility.ValidateColor(factory0.Texture, 127, 0, 0); TestUtility.ValidateColor(factory1.Texture, 0, 255, 0); using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context)) using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), ShaderSources.MultitextureFragmentShader())) using (VertexArray va = TestUtility.CreateVertexArray(window.Context, sp.VertexAttributes["position"].Location)) { window.Context.TextureUnits[0].Texture = factory0.Texture; window.Context.TextureUnits[0].TextureSampler = Device.TextureSamplers.NearestClamp; window.Context.TextureUnits[1].Texture = factory1.Texture; window.Context.TextureUnits[1].TextureSampler = Device.TextureSamplers.NearestClamp; window.Context.Framebuffer = framebuffer; window.Context.Draw(PrimitiveType.Points, 0, 1, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState()); TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 127, 255, 0); } } }
public void Load(int rows, int cols) { bombCount = 0; camera = new Camera2D(new Rectangle(150, 0, 650, 480), new Rectangle(0,0,cols * TILE_SIZE, rows * TILE_SIZE)); this.basePosition = new Vector2(0,0); this.startupGameObject(); Explosion.Instance.Initialize(); const int TERRAIN_COUNT = 4; Texture2D[] textures = new Texture2D[TERRAIN_COUNT]; textures[(int)TerrainBehaviors.Ground] = GameResources.Content.Load<Texture2D>("Sprites/Terrain/background"); textures[(int)TerrainBehaviors.Destroyable] = GameResources.Content.Load<Texture2D>("Sprites/Terrain/wall"); textures[(int)TerrainBehaviors.Undestroyable] = GameResources.Content.Load<Texture2D>("Sprites/Terrain/hardwall"); textures[(int)TerrainBehaviors.Blowable] = GameResources.Content.Load<Texture2D>("Sprites/Terrain/barrel"); terrainFactory = new TextureFactory(textures); textures = new Texture2D[4]; textures[0] = GameResources.Content.Load<Texture2D>("Sprites/Effects/shadow_small"); textures[1] = GameResources.Content.Load<Texture2D>("Sprites/Effects/shadow_medium"); textures[2] = GameResources.Content.Load<Texture2D>("Sprites/Effects/shadow_large"); textures[3] = GameResources.Content.Load<Texture2D>("Sprites/Effects/smoke"); effectsFactory = new TextureFactory(textures); textures = new Texture2D[1]; textures[0] = GameResources.Content.Load<Texture2D>("Sprites/PowerUps/BERSERKER"); powerUpsFactory = new TextureFactory(textures,1); player = new Player(); this.rows = rows; this.cols = cols; terrainMap = new int[cols, rows]; powerUpMap = new int[cols, rows]; terrainTiles = new TerrainTile[cols,rows]; powerUpTiles = new PowerUp[cols,rows]; monsterMap = new int[cols, rows]; CollisionMap = new int[cols, rows]; }
private void Initialize() { _camera = new Camera2D(this); _camera.NearClip = -1000; _camera.FarClip = 1000; _camera.Position = new Vector2(1496, 1624); _inputService = (IInputService)Services.GetService(typeof(IInputService)); _inputService.MouseMove += _inputService_MouseMove; _inputService.KeyDown += _inputService_KeyDown; _textureFactory = new TextureFactory(this); _maps = new Maps(this); _shader = new DiffuseShader(this); _renderer = new DeferredRenderer(this); Tracer.Info("Loading Content..."); LoadContent(); }
private int time; // 時刻 #endregion Fields #region Constructors /// <summary> /// コンストラクタで、ITexture派生クラスを生成するfactoryを渡してやる。 /// /// 例) /// TextureLoader loader = new TextureLoader(delegate { /// return new GlTexture(); }); /// </summary> /// <remarks> /// ディフォルトではcache size = 64MB /// OpenGLを描画に使っている場合、テクスチャサイズは2のべき乗でalignされる。 /// たとえば、640×480の画像ならば1024×512(32bpp)になる。 /// よって、1024×512×4byte = 2097152 ≒ 2MB消費する。 /// 50MBだと640×480の画像をおおよそ25枚読み込めると考えて良いだろう。 /// </remarks> /// <param name="factory"></param> public FontRepository(TextureFactory factory) { this.factory = factory; ResizeFontCache(max); }