Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 11th, 2014, 06:22 PM
Authorized User
Points: 79, Level: 1
Points: 79, Level: 1 Points: 79, Level: 1 Points: 79, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Dec 2013
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default Directx Initialization

I have a project that I worked on a while ago, that worked fine at that time. I decided to open it up and run it again, and its crashing and giving me an error saying that my device isn't initialize using IDirect3DDevice9*. Basically an unhandled exception of 0x0000000. According to my code I am still using the same function that I used previously to initialize the device. Here is some of my code. It crashed right were it sets the transform. Maybe its something easy that I am missing. Any help would be appreciated

	// Grab the window width and height from the HWND
	RECT r;
	GetWindowRect(hWnd, &r);
	m_nWidth = r.right - r.left;
	m_nHeight = r.bottom - r.top;

	m_bVSync = false;

	// Create the D3D Object
	Object1 = Direct3DCreate9(D3D_SDK_VERSION);

	// Create our presentation parameters for our D3D Device
	D3Dpp.hDeviceWindow = hWnd;					// Handle to the window
	D3Dpp.Windowed = bWindowed;					// Windowed or Full-screen?
	D3Dpp.BackBufferCount = 1;					// Number of back-buffers
	D3Dpp.BackBufferFormat = D3DFMT_X8R8G8B8;	// Back-buffer pixel format
	D3Dpp.BackBufferWidth = m_nWidth;			// Back-buffer width
	D3Dpp.BackBufferHeight = m_nHeight;			// Back-buffer height
	D3Dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;	// Swap effect
	D3Dpp.FullScreen_RefreshRateInHz = bWindowed ? 0 : D3DPRESENT_RATE_DEFAULT;
	D3Dpp.EnableAutoDepthStencil = TRUE;		// Enable depth and stencil buffer
	D3Dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // Depth/Stencil buffer bit format
	D3Dpp.Flags = D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL; // Discard the depth/stencil buffer upon Present()
	D3Dpp.MultiSampleQuality = 0;					// MSAA quality
	D3Dpp.MultiSampleType = D3DMULTISAMPLE_NONE;	// MSAA type

	// TODO: Determine supported vertex processing modes

	// Create D3D Device
		D3DADAPTER_DEFAULT,			// Default display adapter
		D3DDEVTYPE_HAL,				// Device type to use
		hWnd,						// Handle to our window
		&D3Dpp,						// Presentation parameters
		&Device1);				// Return a created D3D Device

	//eye position, look at position, etc for e3 image
		eyePos = D3DXVECTOR3(0, 2, -10);
		LookAt = D3DXVECTOR3(0, 0, 0);
		upVec = D3DXVECTOR3(0, 1, 0);

	//call the functions to display 3d images
		D3DXMatrixLookAtLH(&WorldMat, &eyePos, &LookAt, &upVec);
		Device1->SetTransform(D3DTS_VIEW, &WorldMat);
		D3DXMatrixPerspectiveFovLH(&ProjMat, D3DX_PI/3, float(m_nWidth)/float(m_nHeight), 1.0f, 1000.0f);
		Device1->SetTransform(D3DTS_PROJECTION, &ProjMat);
		Device1->SetRenderState(D3DRS_ZENABLE, D3DZB_TRUE); 

		// create the sprite COM object 
	D3DXCreateSprite(Device1, &Sprite1);

	//initalize the font object
	D3DXCreateFont(Device1, 30, 0, FW_BOLD, 0, true, DEFAULT_CHARSET,

Last edited by crossfire19; February 11th, 2014 at 06:50 PM..
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
about directx Innaorouk C# 2 August 27th, 2007 08:39 PM
Help. How to play media files using DirectX dextergaisie Pro VB 6 0 May 15th, 2007 06:09 AM
managed directx 9drawsubset problem? mmmobasher C# 0 December 1st, 2005 05:29 AM
How to speed up 10 times using directX? czw6296 C++ Programming 2 October 19th, 2005 10:47 PM
directx programing bcmaverik VB.NET 5 January 28th, 2004 07:07 AM

All times are GMT -4. The time now is 04:15 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.