?
Solved

creating a device with directx C++

Posted on 2003-03-10
9
Medium Priority
?
424 Views
Last Modified: 2007-12-19
    g_pD3D = Direct3DCreate9(D3D_SDK_VERSION);
         
     g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm);    

//set present parameters
ZeroMemory( &d3dpp, sizeof(d3dpp) );
d3dpp.Windowed   = TRUE;
d3dpp.BackBufferCount=1;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.BackBufferWidth = d3ddm.Height;
d3dpp.BackBufferHeight = d3ddm.Width;
d3dpp.hDeviceWindow = hWnd;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.PresentationInterval=1;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;
d3dpp.EnableAutoDepthStencil = TRUE;

g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                     D3DCREATE_HARDWARE_VERTEXPROCESSING, &d3dpp, &d3dDevice );


the call to createdevice fails when i change the d3dpp.windowed to FALSE. anyone got a suggestion to what my problem is???
0
Comment
Question by:makkbru
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 1

Expert Comment

by:helmet275
ID: 8102016
When you switch into a full screen the handle of the window must be a top level window.  so check the setting for the variable d3dpp.hDeviceWindow
0
 
LVL 4

Expert Comment

by:joachimc
ID: 8109410
There could be two reasons.

I think you are trying to use parameters that you don't have access to in full screen.
you can not use d3ddm.Format as your parameter when you don't have them from the windows screen.

You explicitely have to set
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.BackBufferWidth = d3ddm.Height;
d3dpp.BackBufferHeight = d3ddm.Width;

d3dpp.BackBufferFormat       = D3DFMT_A8R8G8B8; //example
d3dpp.BackBufferWidth = 800;
d3dpp.BackBufferHeight = 600;

The other reason could be that you don't have a T&L graphics card so you can create the HAL device. But that seems unlikely since you can create the device in windowed mode.
0
 

Expert Comment

by:Sharathkumar
ID: 8109829
Hi makkbru,
When you want to switch to a full screen mode, you have to fully control the primary buffer and there wouldnt be any window and hence no window handler. Please check the hDeviceWindow property.
0
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
LVL 1

Author Comment

by:makkbru
ID: 8112202
hi..
I checked the format and resoulution width EnumAdapterModes(), and they worked fine....(and my graphics card rules (radeon 9700 pro)so no problem with the HAL device)
... so i guess it must be the hDeviceWindow which ****s up things....

 what do you mean by "check the setting for the variable d3dpp.hDeviceWindow"? hWnd is the window handle from the main window...:
hWnd = CreateWindow("winclass1", // class
           "3d ",      // title
           WS_POPUP | WS_VISIBLE,
           0,0,        // x,y
           WINDOW_WIDTH,  // width
           WINDOW_HEIGHT, // height
           NULL,        // handle to parent
           NULL,        // handle to menu
           GetModuleHandle(NULL),// instance
           NULL);
do i have to send my window to the top or something like that??? if so, how ???

thanks for your help! :)
0
 
LVL 4

Accepted Solution

by:
joachimc earned 180 total points
ID: 8112266
ShowWindow( D3DApp::ourHWND, SW_SHOWDEFAULT );
UpdateWindow( D3DApp::ourHWND );
0
 
LVL 1

Author Comment

by:makkbru
ID: 8125960
hmmmm... it still not working
I used the CheckDeviceFormat to check if the format was ok and it was....
CheckDeviceType did of course return D3DERR_NOTAVAILABLE...

my 3dcard supports two monitors so it should have two adapters (right?)... I have deactivated the secondary adapter in devicemanager... and GetAdapterCount() returns 1. (the odd thing is that GetAdapterCount() still returned 1 when I activated the secondary adapter in devicemanager)... could this be my problem?? if so how do i fix it???...
0
 
LVL 4

Expert Comment

by:joachimc
ID: 8125999
Try creating the device with
D3DCREATE_SOFTWARE_VERTEXPROCESSING

If you want to you can take the first DX tutorials init stuff and try if that works. If it does just clip the code from that one. Doesn't seem worth the time to search through the code anymore.
0
 
LVL 1

Author Comment

by:makkbru
ID: 8134870
thanks guys...
I'll just wait a week or so to see if somone has a bright idea, before i give away the points.
0
 
LVL 1

Author Comment

by:makkbru
ID: 8243523
well, it wasnt exactly what i was looking for.... but thanks for the help
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question