public StoryboardWindow(int width = 640, int height = 480) : //opentk >= 4.0.0 NOT WORK base(new GameWindowSettings { IsMultiThreaded = false }, new NativeWindowSettings { API = ContextAPI.OpenGL, APIVersion = new Version(3, 3), Flags = ContextFlags.ForwardCompatible, Profile = ContextProfile.Core, Title = "Esu!StoryboardPlayer", Size = new Vector2i(width, height) }) //opentk < 4.0.0 WORK /*base(width, height, new GraphicsMode(ColorFormat.Empty, 32), "Esu!StoryboardPlayer" * , GameWindowFlags.FixedWindow, DisplayDevice.Default, 3, 3, GraphicsContextFlags.ForwardCompatible)*/ { //VSync = VSyncMode.Off; CurrentWindow = this; RenderKernel.Init(); ApplyBorderless(PlayerSetting.EnableBorderless); SwitchFullscreen(PlayerSetting.EnableFullScreen); }
protected override void OnRenderFrame(FrameEventArgs e) { base.OnRenderFrame(e); RenderKernel.Draw(); SwapBuffers(); }
protected override async Task OnAfterRenderAsync(bool firstRender) { glContext = await RefCanvas.CreateWebGLAsync(new WebGLContextAttributes { PowerPreference = WebGLContextAttributes.POWER_PREFERENCE_HIGH_PERFORMANCE }); RenderKernel.Init(glContext, 800, 600); }
protected override void OnClosed() { base.OnClosed(); Log.User("OnClosed() was called."); RenderKernel.Clean(); MainProgram.Exit(); }
public void SwitchFullscreen() { if (!IsFullScreen) { WindowedWidth = Width; WindowedHeight = Height; WindowState = WindowState.Fullscreen; //todo Size = new Vector2i(DisplayDevice.Default.Width,DisplayDevice.Default.Height); RenderKernel.ApplyWindowRenderSize(Width, Height); } else { WindowState = WindowState.Normal; Size = new Vector2i(WindowedWidth, WindowedHeight); RenderKernel.ApplyWindowRenderSize(Width, Height); } }
public async Task PrepareRenderResource(StoryboardUpdater updater, IDirectoryReader reader) { storyboardUpdater = updater; var textureResourceMap = new Dictionary <string, TextureResource>(); foreach (var obj in updater.StoryboardObjectList) { switch (obj) { case StoryboardBackgroundObject background: var resource = await _get(obj.ImageFilePath); if (resource.IsValid) { background.AdjustScale(resource.Size.Height); } else { Log.Warn($"not found image:{obj.ImageFilePath}"); } break; case StoryboardAnimation animation: for (int index = 0; index < animation.FrameCount; index++) { string path = animation.FrameBaseImagePath + index + animation.FrameFileExtension; if (!(await _get(path)).IsValid) { Log.Warn($"not found image:{path}"); continue; } } break; default: if (!(await _get(obj.ImageFilePath)).IsValid) { Log.Warn($"not found image:{obj.ImageFilePath}"); } break; } } Console.WriteLine($"--------textureResourceMap--------"); foreach (var pair in textureResourceMap) { Console.WriteLine($"{pair.Key} \b {pair.Value.Texture.Id}"); } Console.WriteLine($"----------------------------------"); RenderKernel.ApplyRenderResource(glContext, textureResourceMap); async Task <TextureResource> _get(string image_name) { var fix_image = image_name; //for Flex if (string.IsNullOrWhiteSpace(Path.GetExtension(fix_image))) { fix_image += ".png"; } if (textureResourceMap.TryGetValue(image_name, out var resource)) { return(resource); } //load string file_path = fix_image; resource = await _load_tex(file_path); if (!resource.IsValid) { //todo: 从皮肤文件夹获取皮肤文件 file_path = Path.Combine(PlayerSetting.UserSkinPath ?? string.Empty, fix_image); /* * if (!_load_tex(file_path, out resource)) * { * if ((!image_name.EndsWith("-0")) && _get(image_name + "-0", out resource)) * return true; * }*/ } if (resource.IsValid) { textureResourceMap[image_name] = resource; Log.Debug($"Created Storyboard sprite instance from image file :{fix_image}"); } return(resource); } async Task <TextureResource> _load_tex(string file_path) { try { var stream = reader.ReadFile(file_path); if (stream is null) { return(default);
protected override void OnResize(ResizeEventArgs e) { base.OnResize(e); RenderKernel.ApplyWindowRenderSize(e.Width, e.Height); }
public void LoadStoryboardInstance(StoryboardInstance instance) { UpdateKernel.LoadStoryboardInstance(instance); RenderKernel.LoadStoryboardInstance(instance); }
public void RefreshResize() { RenderKernel.ApplyWindowRenderSize(Width, Height); }