Public Group

# Rendering Issue

This topic is 4591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm trying to create a polygon field of sorts, 4096 polygon triangle lists (batched, of course) with 2048 textures to draw (in essence, I'm drawing 2048 textured quads) all defined in a nice 64x64 array of polygons. All the Y (height) values of the quads are 0, and each quad in the array is evenly spaced out on the X and Z axes. The problem I am encountering is that my scene is not rendering! In my renderloop, I included a few calls to Font->DrawFont to display the FPS of the scene, and while the FPS is showing up, and the scene drawing itself, the polygons themselves are not showing up at all. I took out the code segment where I loaded in the textures hoping that would solve the problem, but it didn't! Can someone help me here (code posted below)?
#define D3DFVF_D3DVertex (D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1)
// Vertex stucture.
struct Vertex
{
FLOAT x, y, z;
DWORD color;
FLOAT tu, tv;
};

void CreateMap()
// Yes, I checked - this is only called once
{
Vertex Map[64*2][64*2];
for (int x = 0; x < (64 * 2); x++)
{
for (int y = 0; y < (64*2); y++)
{
Map[x][y].color = D3DCOLOR_XRGB(255,255,255);
Map[x][y].tu = float((x/(64*64)));
Map[x][y].tv = float((y/(64*64)));
Map[x][y].x = float(x);
Map[x][y].y = 0.0f;
Map[x][y].z = float(y);
}
}
}

void RenderScene()
{
// Clear the screen.
D3D_Device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);

// Tell Direct 3D we are now going to start drawing.
D3D_Device->BeginScene();

// Set the view matrix (camera position).
SetCamera();

D3D_Device->SetTexture(0, NULL);
// Set the vertex stream that was defined at the top.
D3D_Device->SetFVF(D3DFVF_D3DVertex);

// This will bind the vertex data in the buffer to the Direct3D device.
D3D_Device->SetStreamSource(0, Object_Buffer, 0, sizeof(Vertex));

// This SHOULD draw everything in the buffer.
D3D_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);

// Now we draw the text to the screen
FontPosition.top = 25;
Font->DrawText(NULL, FrameRate, -1, &FontPosition,
DT_CENTER, 0xffffffff);

// We are done drawing.
D3D_Device->EndScene();

// Swap the old frame with the new one.
D3D_Device->Present(NULL, NULL, NULL, NULL);
}



##### Share on other sites
I don t use D3D
but I d guess the bug is somewhere in these lines
   // This will bind the vertex data in the buffer to the Direct3D device.      D3D_Device->SetStreamSource(0, Object_Buffer, 0, sizeof(Vertex));      // This SHOULD draw everything in the buffer.      D3D_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);

in the first line you specify the vertex data, ok do you need to pass the length you object_Buffer?

or do should you pass the length of the buffer to the DrawPrimitive function?

somehow it must know howmany vertices there in the buffer thus how many triangles you want to render

##### Share on other sites
D3D_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);

Third parameter in that function I believe indicates the number of triangles to be drawn. Based on that, you're telling your program to only draw one triangle. Try making that the number of triangles you are trying to render. Hope that helps.

-AJ

##### Share on other sites
Quote:
 Original post by u235D3D_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);Third parameter in that function I believe indicates the number of triangles to be drawn. Based on that, you're telling your program to only draw one triangle. Try making that the number of triangles you are trying to render. Hope that helps.-AJ

I changed the code to:

Quote:
 D3D_Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, ((64*2)*(64*2)));

And now all I get is a blank screen - not even the text is being drawn now - I think this somehow messed up my renderloop...
Any suggestions?

##### Share on other sites
That's got you telling Direct3D to render 16384 polygons because ((64*2)*(64*2)) = 1282 = 16384. I guess DirectX is getting confused and thus rendering nothing because you don't have enough vertices for 16384 triangles. At least before you had enough vertices to make the one triangle you were telling to render. Try making it 4096(the number of tris you said you're rendering) and see if anything changes.

-AJ

1. 1
2. 2
Rutin
21
3. 3
JoeJ
18
4. 4
5. 5

• 14
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631719
• Total Posts
3001886
×