Jump to content
  • Advertisement
Sign in to follow this  
Plasmarobo

Direct3DCreate9 returns null

This topic is 4143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I just got my nice new laptop a few weeks ago, and setup MSVC++ 2005 (I don't like the .net base, but I like the IDE) and MS Platform SDK Server 2003, plus DirectX 9 December SDK. Everything works. No liker errors, no sintax problems (well, not any detected anyway). When I try to call Direct3DCreate9, it decides to return null. Now, I am pretty damn sure that I have installed the SDK right. I'm thinking that it might have something to do with my OOP. (Honestly, why didn't microsoft just make nice objects to encapsulate the whole DirectX thing?) In anycase, my Windows Encapsulator works just fine, reducing about a hundred lines of code to just 3. I'll just post my code. (There is alot, so I am going to skip the windows stuff, since I know that it works.) Here's the call:
#include "stdafx.h"
#include "Foundation.h"
#include "DirectX.h"
#include <d3dx9.h>

bool Graphics::DirectX::DirectXLayer::Aquire()
{
	m_D3D = Direct3DCreate9(D3D_SDK_VERSION);
	return (m_D3D == NULL);
}


Looks alright to me. Here are the headers (probably should have lead with them)
#ifndef _DIRECT_X_H_
#define _DIRECT_X_H_
#include "stdafx.h"
#include "Foundation.h"
#include <d3dx9.h>

namespace Graphics{

	namespace DirectX{
		class DirectXLayer;
		class FormatBlock;
		//The directX layer provides a reference to directX systems
		//It's basically the foundation of directX
		class DirectXLayer
		{
		protected:
			IDirect3D9* m_D3D;
			IDirect3DDevice9* m_Device;
			

			

		public:
		D3DCAPS9 m_caps; // system capabilities
		bool Aquire();
		void GetCapsHal() { m_D3D->GetDeviceCaps(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, &m_caps); }
		bool CreateDevice(FormatBlock fmt);
		bool DefCreateDevice(HWND hWnd);
		bool CreateDevice_S(HWND hWnd);
		bool Present();
		bool GetAdapterFormat(FormatBlock fmt);


		};

I am currently linking to these files: d3d9.lib d3dx9.lib winmm.lib Am I forgetting something essential? Thanks for your help. This has been annoying for quite sometime, especially with the site down and all (who would hack it? Or was it just the RAID system? I have heard both)

Share this post


Link to post
Share on other sites
Advertisement
are you sure your DirectX SDK is ABOVE the other directories in the INCLUDE and LIB parts of the visual studio path configs? Cause visual studio already has an older version of DirectX, so you must ensure the newer version of everything is found first.

Edit: The actual rule is that you must always put items RELEASED more recently from Microsoft above items released earlier. So you might want to check the release date of the 2003 SDK too and ensure it is between the DirectX and Visual Studio entries if it was released between them in time.

Share this post


Link to post
Share on other sites
The references to DirectX are the first on the list. I don't think it has any link to an older version of direct X, but here's what it looks like:
Inc:
C:\Program Files\Microsoft DirectX SDK (December 2006)\Include



Lib:
C:\Program Files\Microsoft DirectX SDK (December 2006)\Lib\x86

EDIT:
The DirectX is dated 2006, while the platform SDK is dated 2003
DirectX is above PSDK

EDIT2:
IT works outside of the OOP shell.... which completely sucks for me.
Anyway to make it work? (Could it be a namespace problem?)

[Edited by - Plasmarobo on February 13, 2007 5:30:14 PM]

Share this post


Link to post
Share on other sites
just a thought, but when you mentioned it worked outside your wrapper i thought it might merit a post

in bool Acquire() you do

return m_D3D == NULL,

and possibly you want to

return m_D3D != NULL

so that Acquire() returns true when it succeeds... At the moment it will return true when it fails and false when it succeeds, i.e. backwards, which might be the problem you're seeing... but then i don't know how your using it. just a guess.

Share this post


Link to post
Share on other sites
If it is not the inverted logic honnyjopper mentions, then I recomend the "rebuild it piece by piece strategy" ... and I don't mean a labor intensive strategy ... I mean:

1. you say it works outside the wrapper ... so make it do so again.
2. put it inside the minimum possible wrapper, verify success.
3. copy-paste more of your other wrapper and client code into use until it fails ... this way you will know down to 1 or 2 things what is causing the breaking.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!