Jump to content
  • Advertisement
Sign in to follow this  
MichaelJackson

(VS 2008 C++) DirectX9 DrawPrimitiveUp problems [SOLVED]

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

This is my custom vertex - D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1 which creates struct TLVertex { float X,Y,Z,Rhw; int Colour; float tU, tV; }; TLVertex Tlv[4]; For some odd reason, this piece of code wont draw - NOTE: This code DOES NOT generate any errors! (All I'm trying to draw is a textured square!) //Do validate device routine if(ValidateDevice != S_OK) { MessageBox(0,"Problem with validating the device.","Error",0); return 0; } d3ddevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,0), 1.0f, 1 ); if FAILED(d3ddevice->BeginScene()) { MessageBox(0,"Failed to begin the scene!","Wow its your unlucky day",0); return 0; } Tlv[0].X = 0; Tlv[1].X = Tlv[0].X + 32; Tlv[2].X = Tlv[0].X; Tlv[3].X = Tlv[1].X; Tlv[0].Y = 0; Tlv[1].Y = Tlv[0].Y; Tlv[2].Y = Tlv[0].Y + 32; Tlv[3].Y = Tlv[2].Y; for(int i = 0;i<=3,++i) { Tlv.Colour = -1; Tlv.Rhw = 1; } Tlv[0].tU = 0; Tlv[0].tV = 0; Tlv[1].tU = 1; Tlv[1].tV = 0; Tlv[2].tU = 0; Tlv[2].tV = 1; Tlv[3].tU = 1; Tlv[3].tV = 1; if (TextureNo != LastTexture) { d3ddevice->SetTexture(0,(LPDIRECT3DTEXTURE9)TextureData[TextureNo]); //Since TextureData is an int pointer. LastTexture = TextureNo; } d3ddevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP,2,&Tlv[0],28); //Sizeof Tlv is 28. if FAILED(d3ddevice->EndScene()) { MessageBox(0,"EndScene failed to...end?","Error!",0); return 0; } d3ddevice->Present(NULL,NULL,NULL,NULL); return 255; *PS - whats the format code to place my code in a easy to read box? Sorry for bad wording choice* [Edited by - MichaelJackson on April 1, 2008 8:40:25 PM]

Share this post


Link to post
Share on other sites
Advertisement
There's an error-lookup app in the SDK that should be able to tell you what the error means. Like Cranny said, not setting the FVF is probably your problem.

Share this post


Link to post
Share on other sites
OK! I solved my own problem.. OOPS.

I realsied I removed a piece of code while initiziating.

@Cranny76, I do not need to constantly call up SetFVF - but it was your advice that actually helped me solve my problem. The thing is - I restructured my code, and moved the 'Render State settings' to a different routine - I forgot to call that routine when I initialised DirectX!!

God large code sucks!
Now that I have done it - it works perfectly fine!!!

Sorry for wasting your time. A stupid mistake on my behalf.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!