[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.2

directx CreateDevice is giving a D3DERR_INVALIDCALL help!!

Asked by Minott in 3D Game Programming

Tags: d3derr_invalidcall, createdevice

I started programming a directx 3D graphics engine that runs in full screen, a couple months ago for a game I'm trying to make. I started programming and thought I finished the engine and started on the game.  
A month ago I moved to a new apartment, so I burnt and transferred all my files to a new computer. It still compiles just fine but I get a D3DERR_INVALIDCALL when I call the CreateDevice function. At first I thought there was something wrong with my computer so I played with compiling and running some of the directx example files, but they all worked fine.  So I must be doing something wrong in my code. Here is some of my code, keep in mind that the code is in a couple of different functions so the variable names might not line up:

// here is some header info
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <mmsystem.h>

#include <d3d8.h>
#include <d3dx8.h>
#include <dinput.h>
#include <stdio.h>
// Variables
LPDIRECT3D8 g_pD3D = 0;
LPDIRECT3DSURFACE8 g_pBackSurface = 0;
LPDIRECT3DVERTEXBUFFER8 g_pVB = 0;
LPDIRECT3DDEVICE8 g_pDevice= 0;
LPDIRECT3DINDEXBUFFER8 g_pIB=0;
LPDIRECT3DTEXTURE8 g_pTexture =0;
LPDIRECTINPUT8 g_pDI =0;

// here is where I setup the window I'm going to use.
      HWND hWnd;
      WNDCLASSEX wc;
      static char strAppName[]= GAME_NAME;

      wc.cbSize = sizeof(WNDCLASSEX);
      wc.style = CS_HREDRAW | CS_VREDRAW |CS_OWNDC;
      wc.cbClsExtra = 0;
      wc.cbWndExtra = 0;
      wc.lpfnWndProc = WndProc;
      wc.hInstance = hInstance;
      wc.hbrBackground = (HBRUSH)GetStockObject( DKGRAY_BRUSH );
      wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
      wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION);
      wc.hCursor = LoadCursor( NULL, IDC_CROSS);
      wc.lpszMenuName = NULL;
      wc.lpszClassName = strAppName;
      
      RegisterClassEx( &wc);

      hWnd = CreateWindowEx(WS_EX_TOPMOST, strAppName, strAppName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 150, NULL, NULL, hInstance, NULL);
 
      hWndMain = hWnd;
            ShowWindow ( hWnd, iCmdShow);
            UpdateWindow (hWnd);
             return hWnd;
// this is my call to create the direct3d object
                g_pD3D =Direct3DCreate8( D3D_SDK_VERSION);

// and this is where I call the CreateDevice function
                                LPDIRECT3DDEVICE8 pDevice= 0;
            HRESULT r = 0;
            D3DDISPLAYMODE d3ddm;
            D3DPRESENT_PARAMETERS d3dpp;
            
            r=pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm);
            if ( FAILED(r) )
            {
                  SetError("Couldnot get display adapter information");
                  return NULL;
            }

            ZeroMemory( &d3dpp, sizeof( D3DPRESENT_PARAMETERS ) );

            d3dpp.BackBufferCount = 1;
            d3dpp.BackBufferWidth = 800;
            d3dpp.BackBufferHeight = 600;
            d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;
            d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE;
            d3dpp.SwapEffect = D3DSWAPEFFECT_COPY_VSYNC;
            d3dpp.hDeviceWindow = hWndMain;
            d3dpp.Windowed = FALSE;
            d3dpp.EnableAutoDepthStencil = TRUE;
            d3dpp.AutoDepthStencilFormat =D3DFMT_D16;
            d3dpp.FullScreen_RefreshRateInHz = 0;
            d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_ONE;
            d3dpp.Flags = D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
            
            r = pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWndMain, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &pDevice);

            if ( FAILED(r))
            {
                                            char *MyMessage;
                                            if ( r == D3DERR_INVALIDCALL)
                                            {
                                                     MyMessage =new char[]=  "INVALIDCALL";
                                            } else if ( r==D3DERR_NOTAVAILABLE) {
                                                     MyMessage =new char[]=  "NOTAVAILABLE";
                                            } else if ( r==D3DERR_OUTOFVIDEOMEMORY) {
                                                     MyMessage =new char[]=  "OUTOFVIDEOMEMORY";
                                            }
                                            MessageBox(NULL,MyMessage,"Results", MB_YESNO);
                        SetError("Could not create the render device");
                        return NULL;
            }

That's it. I don't know what I'm doing wrong. I've been working on this for a couple days now. I’ve been striping the code down and trying different screen settings, but all give the same error. Any input would be greatly appreciated.

Thanks,
Minott
 
Related Solutions
Keywords: directx CreateDevice is giving a D3DE…
 
Loading Advertisement...
 
[+][-]01/11/04 11:32 AM, ID: 10091885Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: 3D Game Programming
Tags: d3derr_invalidcall, createdevice
Sign Up Now!
Solution Provided By: Maroy
Participating Experts: 2
Solution Grade: A
 
[+][-]01/12/04 12:56 AM, ID: 10094120Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/12/04 07:45 AM, ID: 10095622Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/12/04 10:17 AM, ID: 10096673Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/13/04 12:58 AM, ID: 10102336Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]02/03/04 04:24 PM, ID: 10266829Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]02/15/04 11:28 AM, ID: 10366509Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92