Archived

This topic is now archived and is closed to further replies.

Simple but weird triangle problem ...

This topic is 5617 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 am learning Direct3D from the NeXe website. When I try to draw a square or triangle it appears, but it has many lines through it. I tried to do a screen capture, but the square doesn''t show up in the image generated. Anyhow, please tell me why I get a lot of lines through triangles, squares, and everything else. Thanks, Matt Utley If thispost = 0 Then GoBack() Else Read() End If

Share this post


Link to post
Share on other sites
LoL! I do kind of think my computer sucks. I just wanted a simple something I could program on. I didn''t really plan on using it for gaming. Our family computer ( I''m 15, BTW ) will probably run it fine. I will try it real quick. This computer that it doesn''t work right on is a PII 350MHz, ATI 3D Rage Pro 2X AGP 16MB, and 128MB RAM.

If thispost = 0 Then
GoBack()

Else
Read()
End If

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
It gave me my error, "Failed to initialize Direct3D 8."
[\quote]
Try installing DirectX 8(.1).

Share this post


Link to post
Share on other sites
Here''s the code I use to draw the scene:


void DrawScene ()
{
///////////////////////////////////////////////
// Clear the scene to black
///////////////////////////////////////////////
d3d->g_pD3dDev->Clear (0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB (0, 0, 0), 1.0f, 0);

///////////////////////////////////////////////
// Begin the scene
///////////////////////////////////////////////
d3d->g_pD3dDev->BeginScene ();

///////////////////////////////////////////////
// Scene-Drawing functions go here
///////////////////////////////////////////////
// Matrix code
D3DXMATRIX mat;

D3DXMatrixPerspectiveFovLH(&mat, D3DX_PI/6, 640/480, 1.0, 100.0);
d3d->g_pD3dDev->SetTransform(D3DTS_PROJECTION, &(D3DMATRIX)mat);

D3DXMatrixIdentity(&mat);
d3d->g_pD3dDev->SetTransform(D3DTS_WORLD, &(D3DMATRIX)mat);

D3DXMatrixTranslation(&mat, 0, 0, 10.0);
d3d->g_pD3dDev->SetTransform(D3DTS_VIEW, &(D3DMATRIX)mat);

///////////////////////////////////////////////
// The triangle coordinates
///////////////////////////////////////////////
vtxQuad[0].Create (0, 0, 0, 0, 0, 0, 0, 0);
vtxQuad[1].Create (x1, 0, 0, 0, 0, 0, 1, 0);
vtxQuad[2].Create (0, 1, 0, 0, 0, 0, 1, 1);
vtxQuad[3].Create (1, 1, 0, 0, 0, 0, 0, 1);

///////////////////////////////////////////////
// Set the cullmode render state
///////////////////////////////////////////////
d3d->g_pD3dDev->SetRenderState (D3DRS_CULLMODE, D3DCULL_NONE);
///////////////////////////////////////////////
// Set the lighting to "off"
///////////////////////////////////////////////
d3d->g_pD3dDev->SetRenderState (D3DRS_LIGHTING, light);

///////////////////////////////////////////////
// Set the vertex shader
///////////////////////////////////////////////
d3d->g_pD3dDev->SetVertexShader (D3DFVF_CVertex);
///////////////////////////////////////////////
// Draw the quad
///////////////////////////////////////////////
d3d->g_pD3dDev->DrawPrimitiveUP (D3DPT_TRIANGLESTRIP, 2,
vtxQuad, sizeof (CVertex) );


///////////////////////////////////////////////
// End the scene
///////////////////////////////////////////////
d3d->g_pD3dDev->EndScene ();

d3d->g_pD3dDev->Present (NULL, NULL, NULL, NULL);
}
[/CODE]


The way I came up with d3d->g_pD3dDev is I made a D3D class, for initializing D3D. TFD3D* d3d = new TFD3D; Now, CVertex is the vertex class used on the NeXe website, and vtxQuad is: CVertex vtxQuad[4]. I hope you can help me with this code.


If thispost = 0 Then
GoBack()

Else
Read()
End If

Share this post


Link to post
Share on other sites
aj!
that init stuff must go into somewhere else.
DrawScene must only contain:
Clear()
Begin()
SetVertexShader()
DrawPrimitve()
End()
Present()

I think!
you should make another functin that Inits, and then load it one time before you render. And that light stuff, i dont know if you added a light thing in it, but just that code isnt enough.

Just download the source from Nexe and run it.

[edited by - pipo declown on July 25, 2002 4:31:55 PM]

Share this post


Link to post
Share on other sites