Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Software Development
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel excel 2003 firefox hard drive hardware hdmi internet keyboard laptop malware monitor motherboard network networking outlook problem recovery router screen slow sound spyware tdlwsp.dll trojan upgrade vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Direct3D DrawSubset error

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
andythepandy's Avatar
Member with 66 posts.
 
Join Date: Jul 2006
31-Oct-2009, 12:14 PM #1
Direct3D DrawSubset error
Hi all,
I am having a problem drawing meshing after loading them, and their materials/textures, from .X files.

Here is the code that loads the meshs:

Code:
static LPCWSTR XFileMeshes[] = {L"building1.x",L"table.x"};
static LPD3DXBUFFER MaterialBuffer[400];
static D3DXMATERIAL* TempMaterial;
static LPD3DXMESH *Meshes[2];
static int NumModels = 2;
static DWORD NumMaterials[400];
static D3DMATERIAL9* Material[400];
static LPDIRECT3DTEXTURE9* Texture[400];

static LPD3DXMESH meshTest;
static D3DMATERIAL9* meshMat;
static LPDIRECT3DTEXTURE9* meshText;
static DWORD meshNumMat;
static void LoadMeshes(LPDIRECT3DDEVICE9 d3ddev)
{
	for(int i = 0; i < NumModels; i++)
	{
		Meshes[i] = new LPD3DXMESH;
		//MessageBox(NULL, XFileMeshes[i], L"TEST", MB_OK);
		if(FAILED(D3DXLoadMeshFromX(XFileMeshes[i], D3DXMESH_SYSTEMMEM, d3ddev, NULL, &MaterialBuffer[i], NULL, &NumMaterials[i], Meshes[i])))
			MessageBox(NULL, L"Bad", L"Bad", MB_OK);
		TempMaterial = (D3DXMATERIAL*)MaterialBuffer[i]->GetBufferPointer();
		Material[i] = new D3DMATERIAL9[NumMaterials[i]];
		Texture[i] = new LPDIRECT3DTEXTURE9[NumMaterials[i]];
		for(DWORD p = 0; p < NumMaterials[i]; p++)
		{
			Material[i][p] = TempMaterial->MatD3D;
			Material[i][p].Ambient = Material[i][p].Diffuse;
			if(FAILED(D3DXCreateTextureFromFileA(d3ddev, TempMaterial[p].pTextureFilename, &Texture[i][p])))
				Texture[i][p] = NULL;
		}
	}
When I call the DrawSubset function in my RenderFrame() function:

Code:
LPD3DXMESH TempMesh = (LPD3DXMESH)Meshes;
		TempMesh[0].DrawSubset(0);
I get :
Unhandled exception at 0xabababab in Building1Explore.exe: 0xC0000005: Access violation.
I have looked and looked and am now going crazy not being able to see the problem.

Thanks very much,
Andy
Reply Bookmark and Share

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:45 PM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.