我一直在为Windows 10/Windows Phone (10)开发一款UWP/UWA游戏,并一直在期待Xbox One的开发模式。今天听到dev模式的发布,我非常兴奋,迫不及待地想回家在我的Xbox上测试它。
我的应用程序/游戏运行得很好,我还没有遇到任何错误,除了被剪切的绘制区域(标题安全/电视安全区域外的外缘)。
我使用的是一个Win2D CanvasSwapChain和一个通用CoreWindow。
我觉得我可以用MyCoreWindow或MyViewSource做一些事情来缓解这个问题,但还没有找到答案。在这一点上可能是睡眠不足,但我希望一个答案或一个指向它的箭头对我自己和未来的寻求者有很大的帮助。
我不喜欢使用xaml。
这是我的视图代码。
using Windows.ApplicationModel.Core;
class MyViewSource : IFrameworkViewSource
{
public IFrameworkView CreateView()
{
return new MyCoreWindow();
}
}这是MyCoreWindow
class MyCoreWindow : IFrameworkView
{
private IGameSurface _surface;
private Engine _gameEngine;
public void Initialize(CoreApplicationView applicationView)
{
applicationView.Activated += applicationView_Activated;
CoreApplication.Suspending += CoreApplication_Suspending;
CoreApplication.Resuming += CoreApplication_Resuming;
}
private void CoreApplication_Resuming(object sender, object e)
{
_surface.Resume(sender, e);
}
private void CoreApplication_Suspending(object sender, SuspendingEventArgs e)
{
_surface.Suspend(sender, e);
}
private void applicationView_Activated(CoreApplicationView sender, IActivatedEventArgs args)
{
Windows.UI.Core.CoreWindow.GetForCurrentThread().Activate();
}
public void Load(string entryPoint)
{
_surface.Load(entryPoint);
}
public void Run()
{
while (_gameEngine.IsRunning)
{
Windows.UI.Core.CoreWindow.GetForCurrentThread().Dispatcher.ProcessEvents(CoreProcessEventsOption.ProcessAllIfPresent);
_surface.Update();
_surface.Draw();
}
}
public void SetWindow(Windows.UI.Core.CoreWindow window)
{
_surface = new Surface(window);
_surface.SetFrameRate(60);
_surface.SetUpdateRate(100);
_gameEngine = new Engine(_surface.CanvasDevice);
_surface.AddComponent(_gameEngine);
}
public void Uninitialize()
{
_surface.Unload();
}
public static void Main(string[] args)
{
CoreApplication.Run(new MyViewSource());
}
}发布于 2016-08-04 23:24:31
当您在没有XAML的情况下运行时,您的交换链是唯一呈现图形的东西,因此它总是充满整个屏幕。要将交换链缩放为仅适合标题安全区域,您需要将其作为输入提供给其他合成系统(可以是XAML或Windows.UI.Composition API),这些合成系统可以缩放和转换图像,同时使用背景色填充边框。
通过将CanvasDrawingSession.Transform设置为缩放和偏移渲染,并使用CreateLayer对其进行裁剪,您可以仅绘制到Win2D交换链的选定子集。
不过,对于游戏来说,即使在标题安全区域之外绘制也是更好的。在不同的电视上,这些空间到底有多少是可见的,这是不同的,所以如果你只是把它留为黑色,一些玩家会在你的游戏周围看到丑陋的黑色边框。你不能在这个区域绘制游戏所需的重要内容,因为其他玩家根本看不到这些东西,但通常你会希望不必要的背景图形一直延伸到屏幕的真实边缘。
(这是为电视显示器开发内容的麻烦之一)
https://stackoverflow.com/questions/38735354
复制相似问题