Welcome to Dream.In.Code
Become an Expert!

Join 149,919 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,028 people online right now. Registration is fast and FREE... Join Now!




[directx9.0] Problem with GetAdapterModeCount()

 
Reply to this topicStart new topic

[directx9.0] Problem with GetAdapterModeCount(), GetAdapterModeCount() is returning zero when its suppose to return th

Zammy
3 Jun, 2008 - 04:29 PM
Post #1

New D.I.C Head
*

Joined: 21 Oct, 2006
Posts: 45


My Contributions
GetAdapterModeCount() function is returning zero. sad.gif I have about 15 modes on D3DFMT_X8R8G8B8. Some help would be great.
"This method returns the number of display modes on this adapter or zero if Adapter is greater than or equal to the number of adapters on the system."
If someone can explain me what they mean by this that would be great also.

CODE

#include <iostream>
#include <fstream>
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr9.h>


void main()
{
//getting the IDirect3D9 interface
IDirect3D9* direct3dDevice;
direct3dDevice = Direct3DCreate9(D3D_SDK_VERSION);

//getting modes
D3DDISPLAYMODE mode;
// direct3dDevice->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&mode);

//opening file
std::ofstream myfile;
myfile.open ("example.txt");

UINT adapterCount = direct3dDevice->GetAdapterCount();
for (int i=0;i< adapterCount;++i)
{
int modeCnt = direct3dDevice->GetAdapterModeCount(i ,D3DFMT_X8B8G8R8);

for(int j=0; j< modeCnt; ++j)
{
direct3dDevice->EnumAdapterModes(i,D3DFMT_X8R8G8B8,j,&mode);
myfile<< "Width= " << mode.Width << " ";
myfile<< "Height= " << mode.Height << " ";
myfile<< "Format= " << mode.Format << " ";
myfile<< "Refresh= " << mode.RefreshRate << " " << std::endl;
}
}
myfile.close();

}

User is offlineProfile CardPM
+Quote Post

Zammy
RE: [directx9.0] Problem With GetAdapterModeCount()
4 Jun, 2008 - 01:08 AM
Post #2

New D.I.C Head
*

Joined: 21 Oct, 2006
Posts: 45


My Contributions
Problem solved. Different requested modes between GetAdapterModeCount() and EnumAdapterModes().
Working code:
CODE

#include <iostream>
#include <fstream>
#include <d3d9.h>
#include <d3dx9.h>
#include <dxerr9.h>


void main()
{
    //getting the IDirect3D9 interface
    IDirect3D9* direct3dDevice;
    direct3dDevice = Direct3DCreate9(D3D_SDK_VERSION);

    //getting modes
    D3DDISPLAYMODE mode;
    //direct3dDevice->GetAdapterDisplayMode(D3DADAPTER_DEFAULT,&mode);

    //opening file
    std::ofstream myfile;
    myfile.open ("example.txt");
    
    UINT adapterCount = direct3dDevice->GetAdapterCount();
    for (int i=0;i < adapterCount;++i)
    {
        int modeCnt = direct3dDevice->GetAdapterModeCount(i ,D3DFMT_X8R8G8B8);

        for(int j=0; j< modeCnt; ++j)
        {
            direct3dDevice->EnumAdapterModes(i,D3DFMT_X8R8G8B8,j,&mode);
            myfile<< "Width= " << mode.Width << " ";
            myfile<< "Height= " << mode.Height << " ";
            myfile<< "Format= " << mode.Format << " ";
            myfile<< "Refresh= " << mode.RefreshRate << " " << std::endl;
        }
        myfile << std::endl;
        modeCnt = direct3dDevice->GetAdapterModeCount(i ,D3DFMT_R5G6B5);

        for(int j=0; j< modeCnt; ++j)
        {
            direct3dDevice->EnumAdapterModes(i,D3DFMT_R5G6B5,j,&mode);
            myfile<< "Width= " << mode.Width << " ";
            myfile<< "Height= " << mode.Height << " ";
            myfile<< "Format= " << mode.Format << " ";
            myfile<< "Refresh= " << mode.RefreshRate << " " << std::endl;
        }
    }
    myfile.close();

}


This post has been edited by Zammy: 4 Jun, 2008 - 01:15 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 02:40PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month