Eyefinity

Demonstrates how to create an AMD Eyefinity desktop when programming with ADLX.

Command Prompts

Command Prompt Description
1 Display AMD Eyefinity support.
2 Create an AMD Eyefinity desktop with all the enabled displays.
3 Destroy all the AMD Eyefinity desktops.
4 Destroy the given AMD Eyefinity desktop.
M/m Display the command prompt menu.
Q/q Terminate the application.

Sample Path

/Samples/C/Desktop/Eyefinity

Code

Copied!

//
// Copyright (c) 2021 - 2025 Advanced Micro Devices, Inc. All rights reserved.
//
//-------------------------------------------------------------------------------------------------


#include "SDK/ADLXHelper/Windows/C/ADLXHelper.h"
#include "SDK/Include/IDesktops.h"
#include "SDK/Include/IDisplays.h"

// Main menu
void MainMenu();

// Menu action control
void MenuControl();

// Display Eyefinity support
void ShowEyefinitySupport();

// Create an Eyefinity desktop
void CreateEyefinityDesktop();

// Destroy all the Eyefinity desktops
void DestroyAllEyefinityDesktop();

// Destroy the given Eyefinity desktop
void DestroyGivenEyefinityDesktop();

// Wait for exit with error message
int WaitAndExit(const char* msg, const int retCode);

int main()
{
    // Define return code
    ADLX_RESULT  res = ADLX_FAIL ;

    // Initialize ADLX
    res = ADLXHelper_Initialize();
    if (ADLX_SUCCEEDED (res))
    {
        // Display main menu options
        MainMenu();
        // Get and execute the choice
        MenuControl();
    }
    else
        return WaitAndExit("\\tg_ADLXHelp initialize failed", 0);

    // Destroy ADLX
    res = ADLXHelper_Terminate();
    printf("Destroy ADLX result: %d\\n", res);

    // Pause to see the print out
    system("pause");

    return 0;
}

// main menu
void MainMenu()
{
    printf("\\tChoose one from the following options\\n");

    printf("\\t->Press 1 to display Eyefinity support\\n");
    printf("\\t->Press 2 to create an Eyefinity desktop with all the enabled displays\\n");
    printf("\\t->Press 3 to destroy all the Eyefinity desktops\\n");
    printf("\\t->Press 4 to destroy the given Eyefinity desktop\\n");

    printf("\\t->Press Q/q to terminate the application\\n");
    printf("\\t->Press M/m to display main menu options\\n");
}

// Menu action control
void MenuControl()
{
    int num = 0;
    while ((num = getchar()) != 'q' && num != 'Q')
    {
        switch (num)
        {
            // Display Eyefinity support
        case '1':
            ShowEyefinitySupport();
            break;

            // Create an Eyefinity desktop
        case '2':
            CreateEyefinityDesktop();
            break;

            // Destroy all the Eyefinity desktops
        case '3':
            DestroyAllEyefinityDesktop();
            break;

            // Destroy the given Eyefinity desktop
        case '4':
            DestroyGivenEyefinityDesktop();
            break;

            // Display main menu options
        case 'm':
        case 'M':
            MainMenu();
            break;
        default:
            break;
        }
    }
}

// Display Eyefinity support status
void ShowEyefinitySupport()
{
    // Get system services
    IADLXSystem* sys = ADLXHelper_GetSystemServices();

    IADLXDesktopServices* desktopsInfo = NULL;
    ADLX_RESULT  res = sys->pVtbl->GetDesktopsServices(sys, &desktopsInfo);
    if (ADLX_SUCCEEDED (res))
    {
        IADLXSimpleEyefinity* eyefinity = NULL;
        res = desktopsInfo->pVtbl->GetSimpleEyefinity(desktopsInfo, &eyefinity);
        if (ADLX_SUCCEEDED (res))
        {
            adlx_bool supported = 0;
            res = eyefinity->pVtbl->IsSupported(eyefinity, &supported);
            if (ADLX_SUCCEEDED (res))
                printf("\\t Eyefinity is supported on the desktop: %s\\n", supported ? "Yes" : "No");
        }
        else
            printf("\\tFailed to get simple Eyefinity\\n");

        if (eyefinity != NULL)
        {
            eyefinity->pVtbl->Release(eyefinity);
            eyefinity = NULL;
        }
    }
    else
        printf("\\tFailed to get the Desktop Services interface\\n");

    if (desktopsInfo != NULL)
    {
        desktopsInfo->pVtbl->Release(desktopsInfo);
        desktopsInfo = NULL;
    }
}

// Create an Eyefinity desktop
void CreateEyefinityDesktop()
{
    // Get system services
    IADLXSystem* sys = ADLXHelper_GetSystemServices();

    IADLXDesktopServices* desktopsInfo = NULL;
    ADLX_RESULT  res = sys->pVtbl->GetDesktopsServices(sys, &desktopsInfo);
    if (ADLX_SUCCEEDED (res))
    {
        IADLXSimpleEyefinity* eyefinity = NULL;
        res = desktopsInfo->pVtbl->GetSimpleEyefinity(desktopsInfo, &eyefinity);
        if (ADLX_SUCCEEDED (res))
        {
            IADLXEyefinityDesktop* eyefinityDesktop = NULL;
            res = eyefinity->pVtbl->Create(eyefinity, &eyefinityDesktop);
            printf("\\treturn code is: %d (0 means Success)\\n", res);
            if (eyefinityDesktop != NULL)
            {
                eyefinityDesktop->pVtbl->Release(eyefinityDesktop);
                eyefinityDesktop = NULL;
            }
        }
        else
            printf("\\tFailed to get simple Eyefinity\\n");

        if (eyefinity != NULL)
        {
            eyefinity->pVtbl->Release(eyefinity);
            eyefinity = NULL;
        }
    }
    else
        printf("\\tFailed to get the Desktop Services interface\\n");

    if (desktopsInfo != NULL)
    {
        desktopsInfo->pVtbl->Release(desktopsInfo);
        desktopsInfo = NULL;
    }
}

// Destroy all the Eyefinity desktops
void DestroyAllEyefinityDesktop()
{
    // Get system services
    IADLXSystem* sys = ADLXHelper_GetSystemServices();

    IADLXDesktopServices* desktopsInfo = NULL;
    ADLX_RESULT  res = sys->pVtbl->GetDesktopsServices(sys, &desktopsInfo);
    if (ADLX_SUCCEEDED (res))
    {
        IADLXSimpleEyefinity* eyefinity = NULL;
        res = desktopsInfo->pVtbl->GetSimpleEyefinity(desktopsInfo, &eyefinity);
        if (ADLX_SUCCEEDED (res))
        {
            res = eyefinity->pVtbl->DestroyAll(eyefinity);
            printf("\\treturn code is: %d (0 means success)\\n", res);
        }
        else
            printf("\\tFailed to get simple Eyefinity\\n");

        if (eyefinity != NULL)
        {
            eyefinity->pVtbl->Release(eyefinity);
            eyefinity = NULL;
        }
    }
    else
        printf("\\tFailed to get the Desktop Services interface\\n");

    if (desktopsInfo != NULL)
    {
        desktopsInfo->pVtbl->Release(desktopsInfo);
        desktopsInfo = NULL;
    }
}

// Destroy the given Eyefinity desktop
void DestroyGivenEyefinityDesktop()
{
    // Get system services
    IADLXSystem* sys = ADLXHelper_GetSystemServices();

    IADLXDesktopServices* desktopsInfo = NULL;
    ADLX_RESULT  res = sys->pVtbl->GetDesktopsServices(sys, &desktopsInfo);
    if (ADLX_SUCCEEDED (res))
    {
        IADLXSimpleEyefinity* eyefinity = NULL;
        res = desktopsInfo->pVtbl->GetSimpleEyefinity(desktopsInfo, &eyefinity);
        if (ADLX_SUCCEEDED (res))
        {
            IADLXDesktopList* desktops = NULL;
            res = desktopsInfo->pVtbl->GetDesktops(desktopsInfo, &desktops);
            if (ADLX_SUCCEEDED (res))
            {
                for (adlx_uint crt = desktops->pVtbl->Begin(desktops); crt != desktops->pVtbl->End(desktops); ++crt)
                {
                    IADLXDesktop* desktop = NULL;
                    res = desktops->pVtbl->At_DesktopList(desktops, crt, &desktop);
                    if (ADLX_SUCCEEDED (res))
                    {
                        IADLXEyefinityDesktop* eyefinityDesktop = NULL;
                        void* pInterf = NULL;
                        res = desktop->pVtbl->QueryInterface(desktop, IID_IADLXEyefinityDesktop(), &pInterf);
                        if (ADLX_SUCCEEDED (res))
                        {
                            eyefinityDesktop = (IADLXEyefinityDesktop*)pInterf;
                            res = eyefinity->pVtbl->Destroy(eyefinity, eyefinityDesktop);
                            printf("\\tReturn code for destroying Desktop %d is: %d (0 means Success)\\n", crt, res);
                        }
                        else
                            printf("\\tEyefinityDesktop is NULL\\n");

                        if (eyefinityDesktop != NULL)
                        {
                            eyefinityDesktop->pVtbl->Release(eyefinityDesktop);
                            eyefinityDesktop = NULL;
                        }
                    }
                    else
                        printf("\\tDesktop is NULL\\n");

                    if (desktop != NULL)
                    {
                        desktop->pVtbl->Release(desktop);
                        desktop = NULL;
                    }
                }
            }
            else
                printf("\\tFailed to get the Desktop interface\\n");

            if (desktops != NULL)
            {
                desktops->pVtbl->Release(desktops);
                desktops = NULL;
            }
        }
        else
            printf("\\t Failed to get simple Eyefinity \\n");

        if (eyefinity != NULL)
        {
            eyefinity->pVtbl->Release(eyefinity);
            eyefinity = NULL;
        }
    }
    else
        printf("\\tFailed to get the Desktop Services interface\\n");

    if (desktopsInfo != NULL)
    {
        desktopsInfo->pVtbl->Release(desktopsInfo);
        desktopsInfo = NULL;
    }
}

// Wait for exit with error message
int WaitAndExit(const char* msg, const int retCode)
{
    // Printout the message and pause to see it before returning the desired code
    if (NULL != msg)
        printf("%s\\n", msg);

    system("pause");
    return retCode;
}

Related pages

  • Visit the Adlx product page for download links and more information.

Looking for more documentation on GPUOpen?

AMD GPUOpen software blogs

Our handy software release blogs will help you make good use of our tools, SDKs, and effects, as well as sharing the latest features with new releases.

GPUOpen Manuals

Don’t miss our manual documentation! And if slide decks are what you’re after, you’ll find 100+ of our finest presentations here.

AMD GPUOpen Performance Guides

The home of great performance and optimization advice for AMD RDNA™ 2 GPUs, AMD Ryzen™ CPUs, and so much more.

Getting started: AMD GPUOpen software

New or fairly new to AMD’s tools, libraries, and effects? This is the best place to get started on GPUOpen!

AMD GPUOpen Getting Started Development and Performance

Looking for tips on getting started with developing and/or optimizing your game, whether on AMD hardware or generally? We’ve got you covered!

AMD GPUOpen Technical blogs

Browse our technical blogs, and find valuable advice on developing with AMD hardware, ray tracing, Vulkan®, DirectX®, Unreal Engine, and lots more.

Find out more about our software!

AMD GPUOpen Effects - AMD FidelityFX technologies

Create wonder. No black boxes. Meet the AMD FidelityFX SDK!

AMD GPUOpen Samples

Browse all our useful samples. Perfect for when you’re needing to get started, want to integrate one of our libraries, and much more.

AMD GPUOpen developer SDKs

Discover what our SDK technologies can offer you. Query hardware or software, manage memory, create rendering applications or machine learning, and much more!

AMD GPUOpen Developer Tools

Analyze, Optimize, Profile, Benchmark. We provide you with the developer tools you need to make sure your game is the best it can be!