DrawPrimitiveUP...crashing

Started by
6 comments, last by GekkoCube 20 years, 12 months ago
Strange this problem. When i call the code i am about to post here BEFORE i draw anything else, it crashes. i tried to read the return flag, but it doesnt give. but if i call this stuff AFTER my main objects are rendered (terrain and skybox), then things are fine...although the colors eeem to be off.
  
m_Indicator[0].x     = m_Position.x;
m_Indicator[0].y     = m_Position.y;
m_Indicator[0].z     = m_Position.z;
m_Indicator[0].color = 0xffffff00;

D3DXVECTOR3 end = m_Position;
end += m_Direction * 5.0f;

// 2nd vertex

m_Indicator[1].x     = end.x;
m_Indicator[1].y     = end.y;
m_Indicator[1].z     = end.z;
m_Indicator[1].color = 0xffffff00;

// Render the single line primitive.

g_pd3dDevice->DrawPrimitiveUP( D3DPT_LINESTRIP, 1, m_Indicator,                                  m_iSizeOfInfo );
  
Im drawing a single line, so the 2nd parameter is 1. the vertex format has D3DFVF and DIFFUSE. any help will help - i am lost at this point and I hate to just rearrange the render calling to where it will work...its just weird how rearranging the rendering calls will make/break a crash!
Advertisement
check debug output, it sounds like there is a messed up state, the debug output will probably tell you whats wrong
I cannot imagine anyone, in any conceivable walk of life, ever in a million years wanting to use DrawPrimitiveUP.
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson
quote:Original post by GekkoCube

Im drawing a single line, so the 2nd parameter is 1.
the vertex format has D3DFVF and DIFFUSE.




What is D3DFVF? you need XYZ and Diffuse..maybe a typo..

What Version of DirectX are you using? I don''t see where you set the shader (DX8) or FVF (DX9).. If you are drawing D3DXMeshs, then the drawsubset would be setting the FVF, and that is why you would be able to draw but it''s messed up cause the FVF is wrong and maybe has a different stride.
Do not EVER EVER EVER use DrawPrimitiveUP.
DrawIndexedPrimitive or bust.
Ok, i am guessing that DrawPrimitiveUP is not very efficient or something....and Im guessing DrawIndexedPrimitive is.?

What about VerexBuffers?

Anyways, yes, that D3DFVF was a typo. I have a vertex format with XYZ and DIFFUSE.

i think i am drawing d3dxmeshes because i am drawing X file, copied from the tiger.x demo.
but i dont think this is the issue for this problem.

and what exactly is the stride?
any code anybody would like to see for this?
quote:Original post by GekkoCube
Ok, i am guessing that DrawPrimitiveUP is not very efficient or something....and Im guessing DrawIndexedPrimitive is.?

What about VerexBuffers?


To quote Richard Huddy (ex-NVIDIA, now ATI):

There are almost zero cases when avoiding VB’s make sense. If you think you have one of those cases then:
a) You haven’t really thought hard
b) Consult a doctor – it’s as bad as that


So DrawIndexPrimitive uses vertex buffers?
I will use it.

Also, what do you mean by debug output?
Do you mean from the error message that windows gives me, or do you mean my own debug statements?

Also, what do you mean by "messed up states" ?
do you mean renderstates or what?

My problem i am trying to find is this:
My line strips (a single line segment) is being colored by something that I dont know what. also, when i move (rotate) that line, well, it changes colors (but not any single shade, but rather multiple colors). so this makes me believe a renderstate or something is off. i tried materials and turning off textures before i draw the line. also, when i first start, the line is red. when i move, it appears rainbow-like (not a pretty rainbow).

any help, tips, ideas...i need. thanks.

This topic is closed to new replies.

Advertisement