SlimDx 全屏切换到窗口模式的问题

发布于 2024-10-13 06:54:25 字数 954 浏览 7 评论 0原文

 // handle alt+enter ourselves
        form.KeyDown += (o, e) =>
        {
            if (e.Alt && e.KeyCode == Keys.Enter) {
                bool Full;

                Output ThisOut;
                swapChain.GetFullScreenState(out Full, out ThisOut);

                if (Full == true)
                {

                    swapChain.SetFullScreenState(false, ThisOut);

                }
                else if (Full == false)
                {

                    swapChain.SetFullScreenState(true, ThisOut);

                }
            }
           //     swapChain.IsFullScreen = !swapChain.IsFullScreen;

我正在使用 SlimDx 教程 - http://slimdx.org/tutorials/devicecreation.php并注意到交换链没有 IsFullScreen 属性。因此,我尝试使用其他可用的方法,但遇到了问题。 - 当我切换到全屏时,它按预期运行;但是,当我切换回非全屏时,我看到的只是一个不可移动的空白框。

怎么了?为什么没有像教程中那样的 isFullScreen 属性。设备是否在某处丢失?

 // handle alt+enter ourselves
        form.KeyDown += (o, e) =>
        {
            if (e.Alt && e.KeyCode == Keys.Enter) {
                bool Full;

                Output ThisOut;
                swapChain.GetFullScreenState(out Full, out ThisOut);

                if (Full == true)
                {

                    swapChain.SetFullScreenState(false, ThisOut);

                }
                else if (Full == false)
                {

                    swapChain.SetFullScreenState(true, ThisOut);

                }
            }
           //     swapChain.IsFullScreen = !swapChain.IsFullScreen;

I was using a tutorial on SlimDx - http://slimdx.org/tutorials/devicecreation.php and noticed that there wasn't a IsFullScreen property of swapchain. Therefore, I tried to use the other methods available and came across a problem.
- When I switch to full-screen, it operates as it should; but, when I switch back to non-full-screen, all I see is a blank box that is non-movable.

What is happening? and why isn't there a isFullScreen property like in the tutorial. Is the Device getting lost somewhere?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

残疾 2024-10-20 06:54:25

我是这个 slimDX 世界的新手(也在 stackoverflow 上发帖),并且基于同样的问题遇到了你的问题。我知道这是 VB,而您正在使用 C#,但我已经成功做到这一点,请注意,您将需要原始的窗口模式描述:

Private Sub Form_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    If e.Alt And e.KeyCode = Keys.Enter Then
        Dim isFull As Boolean
        swapChain.GetFullScreenState(isFull, Nothing)
        swapChain.SetFullScreenState(Not isFull, Nothing)
        swapChain.ResizeTarget(swapChainDescription.ModeDescription)
    End If
End Sub

我不是 C# 程序员,但这是我的看法:

form.KeyDown += (o, e) =>
    {
        bool Full;
        swapChain.GetFullScreenState(out Full, Null);
        swapChain.SetFullScreenState(!Full, Null);
        swapChain.ResizeTarget(swapChainDescription.ModeDescription);
    }

希望有人会如果我错了,请过来纠正我,或者你可以帮忙。

基本上,如果我理解正确的话,它并不是在寻找您已经完成的模式的描述。您已经获得了 ThisOut 并传递了 ThisOut,并且 ThisOut 包含一个全屏标志(基于 SetFullScreenState 方法的性质)。虽然它是 SlimDX,但它实际上都是 MS DX,因此参考如下:

http://msdn.microsoft.com/en-us/library/bb174579%28v=vs.85%29.aspx

点击文章内的链接了解更多信息。

请注意,如果您不全屏显示,则应该传递 Null。您传递了除 Null 之外的其他内容...确切地说是现有的渲染目标。现有渲染目标现已设置为全屏。按照函数的意图传递 Null(或 Nothing,因为它是 VB)就可以正常工作。通过采用我的原始窗口描述并重新传递窗口模式而不是全屏模式,一切都会按预期进行。

I'm new to this slimDX world (and posting on stackoverflow) as well and ran across your question based on the same problem. I know this is VB and you're using C#, but I've had success with this, note you'll need your original windowed mode description:

Private Sub Form_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
    If e.Alt And e.KeyCode = Keys.Enter Then
        Dim isFull As Boolean
        swapChain.GetFullScreenState(isFull, Nothing)
        swapChain.SetFullScreenState(Not isFull, Nothing)
        swapChain.ResizeTarget(swapChainDescription.ModeDescription)
    End If
End Sub

I'm not a C# programmer, but here's my take at it:

form.KeyDown += (o, e) =>
    {
        bool Full;
        swapChain.GetFullScreenState(out Full, Null);
        swapChain.SetFullScreenState(!Full, Null);
        swapChain.ResizeTarget(swapChainDescription.ModeDescription);
    }

Hopefully someone will come along and correct me if I'm wrong or you can help.

Basically, if I understand this correctly, it's not looking for the description of the mode it's already in, which you've done. You've gotten, ThisOut and passed ThisOut and ThisOut contains a fullscreen flag, based on the nature of the SetFullScreenState method. While it's SlimDX, it's all really MS DX, so here's the reference:

http://msdn.microsoft.com/en-us/library/bb174579%28v=vs.85%29.aspx

Follow the links inside the article to discover more.

Note that you're supposed to pass Null if you're not going fullscreen. You've passed something other than Null... the existing render target to be exact. The existing render target has now been set to fullscreen. Passing Null (or Nothing because it's VB) as the function intends works just fine. By taking my original, windowed, description and re-passing the mode, which is windowed and not fullscreen, everything works out like it should.

情话难免假 2024-10-20 06:54:25

正如该教程链接中所述,正是出于这个原因,我们向库中添加了 IsFullScreen 属性,但它目前仅存在于存储库中(尚未正式发布)。

我们将我们的版本与 DirectX 发布时间表挂钩,我们从未想过他们会花这么长时间才能发布下一个版本。他们过去每季度发布一次,但自 2010 年 6 月以来我们就没有看到过发布。

As noted in that tutorial link, we added an IsFullScreen property to the library for this very reason, but it's currently only in the repository (no official release for it yet).

We peg our releases to the DirectX release schedule, and we never imagined it would take them this long to get the next release out. They used to do once per quarter, but we haven't seen a release since June of 2010.

和影子一齐双人舞 2024-10-20 06:54:25

所以这就是我所做的:

if (e.Alt && e.KeyCode == Keys.Enter)
    {
        bool isFull = swapChain.Description.IsWindowed;
        swapChain.SetFullScreenState(isFull, null);
    }

它对我有用,并且比其他方式更干净,您甚至可以减少 1 行并将 .IsWindowed 行 a 放入 SetFullScreenState 中。

so here is what I did:

if (e.Alt && e.KeyCode == Keys.Enter)
    {
        bool isFull = swapChain.Description.IsWindowed;
        swapChain.SetFullScreenState(isFull, null);
    }

It works for me and is a bit cleaner than the other way, you could even cut down on 1 line and just put the .IsWindowed line a in the SetFullScreenState.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文