There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop malware memory modem monitor motherboard netgear network printer problem ram registry repair router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Software & Hardware > Software Development >
Direct3D DrawSubset error

Reply  
Thread Tools
andythepandy's Avatar
Computer Specs
Member with 278 posts.
 
Join Date: Jul 2006
Location: England
Experience: Intermediate to Advanced
31-Oct-2009, 01: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

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 11:27 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.