Sign in to follow this  

ID3DXLine-Draw() problem!

This topic is 4652 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

I've come across a very nasty bug in my code - its blue, states that windows has decided to halt all progress and tells me to restart my PC immediately! Anyway. I know that the bug is generated by a call to ID3DXLine->Draw() ( I'm using DirectX 9, by the way...). The only thing that seems amiss is that the function asks for a pointer to a CONST D3DVECTOR2 list as its first parameter...? Now I'm a bit puzzled as I thought that having an array of const vectors is redundant as you would most likely want to change your lines during run-time - you simply wouldn't be able to do it if they are constant! The only other idea I had was to define the following... CONST D3DVECTOR2 *pointer_to_list; ...then make... D3DVECTOR2 list[10]; ...then fill up the list as in the following manor... list[0].x = 10; list[0].y = 20; ...etc,etc. Then before making the call to ->Draw()... pointer_to_list = list; ...afterall - the name of an array is actually a pointer in itself...I think! But still, even though the function accepts the parameters - it produces this serious "crash". Haven't got a clue as to what to do next...^_^

Share this post


Link to post
Share on other sites
I think you're confusing what CONST means. Here it means the Draw method promises not to alter the values in your array. You don't need to declare the array itself CONST. (You might need to do a static cast to CONST, but I doubt it.)

As for the crash, make sure the number of vertices you're passing in is copasetic with the dwVertexListCount argument to Draw.

Share this post


Link to post
Share on other sites
I still can't get this Draw function to work...has anyone else? I'm very sure I'm sending it the right parameters and using them in the proper place...I'm really stumped as to why its causing the crash...O_O

Share this post


Link to post
Share on other sites
After searching the net, I found that someone else had exactly the same problem...but apart from the basic "this is the interface and its methods" documentaion - not much else is known about this interface.

I can only assume that this was a late addition to the very last DirectX SDK update. With debugging I have found that it has a problem within the Draw() method itself.

Anyone here on the MicroSoft DirectX team? ^_^

Share this post


Link to post
Share on other sites
Show your code. Show the code where you initialize the parameters for the Draw() call and, more importantly, show the actual call. I would be very surprised if the problem was with DirectX and not with your code.

Share this post


Link to post
Share on other sites
Heres the code...

I first I create the globals...

LPD3DXLINE lpLine;
D3DXVECTOR2 D3DLine[3];

and here is how I initialise the interface after setting up Direct3D...

hr = D3DXCreateLine(lpd3ddevice, &lpLine);

if(hr != D3D_OK)
{
ERROR_add("DIRECTX9_Create_DirectGraphics: D3DXCreateLine() - FAILED\n");
return FALSE;
}

And to create my points...

D3DLine[0].x = 10;
D3DLine[0].y = 10;

D3DLine[1].x = 100;
D3DLine[1].y = 100;

D3DLine[2].x = 200;
D3DLine[2].y = 10;

...then comes the code to do all rendering...


////////////////////////////////////////////////////////////////////////////////
void API_PROCESS_DirectGraphics(void)
{
HRESULT hr;
lpd3ddevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 0);

lpd3ddevice->BeginScene();

D3D_render_3D();
D3D_render_2D();
D3D_render_lines();

lpd3ddevice->EndScene();

lpd3ddevice->Present(NULL,NULL,NULL,NULL);
}

////////////////////////////////////////////////////////////////////////////////

And the code for drawing my lines resides in the call to D3D_render_lines()...


////////////////////////////////////////////////////////////////////////////////
int D3D_render_lines(void)
{
lpLine->Begin();

lpLine->Draw(D3DLine, 3, RGB(0,255,0));

lpLine->End();
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////


...and that is the code I've used thus far.

I do appreciate your assistance. ^_^

Share this post


Link to post
Share on other sites
Re: Load_Bitmap_File.

Yeah, I thought of that too - still crashes.

Still, I came across the way to draw lines using the DrawPrimitive method in the LPDIRECT3DDEVICE9 interface! It was quite easy once I tried it. ^_^

At the moment I'm simply rewriting code that I lost two weeks ago - and improving it as I go along. I find Direct3D to be quite intimidating at first, but taking the time to understand it is well worth the late nights!

I'm thinking of writing a series of tutorials for my website for others to follow - and I think one for Direct3d would be very useful for other "lost souls" like myself...

One thing is for sure - I wouldn't have got far without the community here on Gamedev! It would be great to give something back. ^_^

Cheers.

Share this post


Link to post
Share on other sites

This topic is 4652 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this