• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Wargrave

Device Enumeration Basics

8 posts in this topic

Hello folks, I work on a small game which has to be able to list the device capabilities. I want the player to be able to choose different screen resolutions and refresh rates for instance. I've been searching for info for a while, looked in some books. But I don't know where to begin. Has anybody seen any good tutorials I can look at? Where do I begin? Thanks, Wargrave.
0

Share this post


Link to post
Share on other sites
You need to specify which version of the API and via what language you're using it [wink]

We've got 4 versions of Direct3D/X kicking around, accessible in a variety of different ways. I'm going to assume Direct3D9 and C/C++:

Create an IDirect3D9 object as usual,

Retrieve IDirect3D9::GetAdapterCount(), this represents how many adapters in your system. Usually this will only be one, but it is quite possible for people to have more in the case of multimon setups.

For each adapter:

Call IDirect3D9::GetAdapterIdentifier() - this allows you to get some "friendly" information about it. Excellent for putting in your GUI so the user knows what you're referring to (e.g. have "GeForce 6600" in the device list).

Also use IDirect3D9::GetDeviceCaps() to retrieve the device caps. Of particular interest is probably the shader model(s) supported by the device.

Next use IDirect3D9::GetAdapterModeCount() to determine how many display modes are supported. This can be quite a large list - it'll include all the resolutions and colour depths supported.

Iteratate through the actual information using IDirect3D9::EnumAdapterModes() to retrieve the information for that mode.

That should get you rolling [smile]

hth
Jack
0

Share this post


Link to post
Share on other sites
Hi again!

Thanks for the latest reply. It has helped me a lot. But I cannot find what is wrong with the following code:

#include <iostream>
#include <windows.h>
#include "d3d9.h"
#include "d3dx9.h"
using namespace std;

int main()
{
LPDIRECT3D9 g_pD3D = NULL;
if( NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
return E_FAIL;

UINT iAmountDevices = g_pD3D->GetAdapterCount();
D3DADAPTER_IDENTIFIER9* psAdapterIdentifier=new(D3DADAPTER_IDENTIFIER9[iAmountDevices]);

for(UINT n=0;n++<iAmountDevices;)
{
g_pD3D->GetAdapterIdentifier(n, 0, psAdapterIdentifier[n]);
char DeviceName[20];
cout << psAdapterIdentifier.DeviceName;
}
delete(psAdapterIdentifier);


system("PAUSE");
return 0;
}

And the compiler says:

Compiling...
EggEnum.cpp
c:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\EggEnum\EggEnum.cpp(21) : error C2664: 'IDirect3D9::GetAdapterIdentifier' : cannot convert parameter 3 from 'D3DADAPTER_IDENTIFIER9' to 'D3DADAPTER_IDENTIFIER9 *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
c:\Documents and Settings\Eddie\Mina dokument\Visual Studio Projects\EggEnum\EggEnum.cpp(23) : error C2228: left of '.DeviceName' must have class/struct/union type
type is 'D3DADAPTER_IDENTIFIER9 *'
did you intend to use '->' instead?

Thanks again,
Wargrave.
0

Share this post


Link to post
Share on other sites
This part needs editing:

for(UINT n=0;n++<iAmountDevices;)
{
// Use &psAdapterIdentifier here:
g_pD3D->GetAdapterIdentifier(n, 0, &psAdapterIdentifier[n]);

// Add [n] here:
cout << psAdapterIdentifier[n].DeviceName;
}
delete(psAdapterIdentifier);


For future reference, it's best to post code in [ source ] and [ /source ] tags to format the code a bit more nicely.
0

Share this post


Link to post
Share on other sites
GetAdapterIdentifier wants a pointer to a D3DADAPTER_IDENTIFIER9 structure.

As you have created an array of D3DADAPTER_IDENTIFIER9 structures you need to use an index to select the structure you want.

int main()
{
LPDIRECT3D9 g_pD3D = NULL;
if( NULL == (g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)))
return E_FAIL;

UINT iAmountDevices = g_pD3D->GetAdapterCount();
D3DADAPTER_IDENTIFIER9* psAdapterIdentifier=new(D3DADAPTER_IDENTIFIER9[iAmountDevices]);

for(UINT n=0;n++<iAmountDevices;)
{
g_pD3D->GetAdapterIdentifier(n, 0, &psAdapterIdentifier[n]);
char DeviceName[20];
cout << psAdapterIdentifier[n].DeviceName;
}
delete(psAdapterIdentifier);


system("PAUSE");
return 0;
}



EDIT: Evil Steve was faster
0

Share this post


Link to post
Share on other sites
Hello again!
And thank you very much for the latest replies.

I'd like to ask you for help. I sit here hour after hour compiling and looking for faults that I can't seem to find. What I'm going to ask, I'm only asking because I'm getting really desperate and because the device enumeration part of the project is taking too much time from the whole project. I also know that it probably takes less than half an hour for you guys.

My code so far is above and I need help with the following (this is the quote from the first guy who helped me):

"For each adapter:

Call IDirect3D9::GetAdapterIdentifier() - this allows you to get some "friendly" information about it. Excellent for putting in your GUI so the user knows what you're referring to (e.g. have "GeForce 6600" in the device list).

Also use IDirect3D9::GetDeviceCaps() to retrieve the device caps. Of particular interest is probably the shader model(s) supported by the device.

Next use IDirect3D9::GetAdapterModeCount() to determine how many display modes are supported. This can be quite a large list - it'll include all the resolutions and colour depths supported.

Iteratate through the actual information using IDirect3D9::EnumAdapterModes() to retrieve the information for that mode."

I would appreciate your help extremely much.
Thanks,
Wargrave.

[Edited by - Wargrave on March 25, 2006 1:53:55 PM]
0

Share this post


Link to post
Share on other sites
Hi,

Is there really no one that could help me with what I've written above. It'd be of enormous help for me. I had to go on with the sound core because my project time is limited and the device enumeration part was taking me very, very long time.

Thanks,
Wargrave
0

Share this post


Link to post
Share on other sites
If you just want to see all the resolutions for one card, you can do this:

struct ScreenMode
{
D3DDISPLAYMODE theMode;
D3DFORMAT fmt;
int nBits;
}

void GetModes(std::vector& vModes, IDirect3D9* pD3D)
{
const D3DFORMAT fmts[] =
{
D3DFMT_A1R5G5B5,
D3DFMT_A2R10G10B10,
D3DFMT_A8R8G8B8,
D3DFMT_R5G6B5,
D3DFMT_X1R5G5B5,
D3DFMT_X8R8G8B8,
};
const int nBits[] = {16, 32, 32, 16, 16, 32};
const int nNumFormats = 6;
ScreenMode theMode;

vModes.clear();
for(int i=0; i<nNumFormats; ++i)
{
UINT nCount = pD3D->GetAdapterModeCount(D3DADAPTER_DEFAULT,fmts[i]);
for(UINT j=0; j<nCount; ++j)
{
if(SUCCEEDED(pD3D->EnumAdapterModes(D3DADAPTER_DEFAULT,fmts[i],j,&theMode.theMode)))
{
theMode.fmt = fmts[i];
theMode.nBits = nBits[i];
vModes.push_back(theMode)
}
}
}
}




That function should fill a vector with all the screen modes supported by the first card on the system. If you want to support more than one card, you need to change D3DADAPTER_DEFAULT to the index of the card you want to check.

Also node that the code is untested, so there may be some bugs in it.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0