Fullscreen Managed DirectX

Hi everyone,

I'm having a problem with fullscreen mode in my managed directX application. I was wondering if someone could help me...

When my application is in fullscreen mode, I see artificats and other visual glitches such as pieces of the taskbar at the bottom of the screen. And although the screen is blue, I can still interact with the taskbar. (ie. I click the lower left hand corner and another glitch shows the start menu open momentarily). What could be causing this and how do I fix it

I'm having another problem too. Well, it's not really a problem so much as an annoyance. I've started making a game framework for my future directX games and it's been going great so far. I'm using Visual Studio C# 2005 Express, and I started my coding in an empty project. For some reason each time I start my app I get a console window as well as a normal window appearing. How do I make it disappear All I want is the normal window :P

Thanks in advance,

- Ryan



Answer this question

Fullscreen Managed DirectX

  • Savvas Christodoulou

    I took this from my own code.It sets up Direct3D in 2d for fullscreen, but it's generally the same for 3d as well. Hope it helps. 

            /// <summary>
            /// Initialize graphics here.
            /// </summary>
            public void InitializeGraphics()
            {
                // Set presentation paramters
                D3D.PresentParameters presentParams = new D3D.PresentParameters();
                presentParams.SwapEffect = D3D.SwapEffect.Discard;

                // Get the ordinal Direct3D adapter
                int adapterOrdinal = D3D.Manager.Adapters.Default.Adapter;

                // Get device caps
                D3D.Caps caps = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware);

                // Set creation flags - start with a default of software vertex processing.
                D3D.CreateFlags flags = D3D.CreateFlags.SoftwareVertexProcessing;

                // Is there support for hardware vertex processing If so, replace
                // software vertex processing.
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                    flags = D3D.CreateFlags.HardwareVertexProcessing;

                // Does the device support a pure device
                if (caps.DeviceCaps.SupportsPureDevice)
                    flags |= D3D.CreateFlags.PureDevice;

                // Get current display mode
                D3D.Format current = D3D.Manager.Adapters[0].CurrentDisplayMode.Format;

                // See if full screen can be obtained.
                if (D3D.Manager.CheckDeviceType(adapterOrdinal, D3D.DeviceType.Hardware, current,
                    current, false))
                {
                    // Full Screen can be used.
                    presentParams.Windowed = false;
                    presentParams.BackBufferCount = 1;
                    presentParams.BackBufferWidth = WIDTH;
                    presentParams.BackBufferHeight = HEIGHT;
                    presentParams.BackBufferFormat = current;
                }
                else
                {
                    // Open as a windowed application.
                    presentParams.Windowed = true;
                }
                                     
                // Create the Direct3D device.
                device = new D3D.Device(adapterOrdinal, D3D.DeviceType.Hardware, this, flags,
                    presentParams);
            }


  • Waleedmohsen

    Yay! I think I may have fixed it. I've added the following lines of code:

    // Gets rid of the window's border (and the flickering that happens when you mouse over it).
    theWindow.FormBorderStyle = FormBorderStyle.None;

    // This seems to have stopped the flickering of the task bar.
    this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

    Can anyone tell me what the last line of code is doing and why it has stopped the flickering Although the flickering does come back if the user presses Ctl-Alt-Del while it is running... but I suppose that can easily be solved by minimizing the application.

    Thanks,

    - Ryan


  • Proachbass91

    The using control styles.opaque sets form to be painted that way as it is in fact a control.

    By default in designer forms and controls are transparent capable with a transparent key (if you look towards the bottom of a form properties in designer).

    By changing the transparency to 0% you make the form opaque as your code does. (hiding glitches while onpaint happens)


  • Fullscreen Managed DirectX