I spoke with an employee of Microsoft who specializes in DirectX(Jesse Natalie herself) and she assured me, rather reluctantly, that DirectX9.0c is going nowhere as long as Windows exists within this decade, they're making up for graphics driver's dropping support for D3D9 with D3D9On12. I got a very, very, lucky insider's discussion with Microsoft employee's today. Was eye-opening.
Nonetheless, I'm still going at it.
Picture of a cube in GTKRadiant prior to compiling to BSP: https://cdn.discordapp.com/attachments/681620634475954196/681640530710364174/unknown.png
and the rendered result:
https://cdn.discordapp.com/attachments/681620634475954196/681640662378348549/unknown.png
What's different about this? Well, from main.cpp, to draw this, all I did was call bsp.PVS_Render().
Joe, the reason you saw so many Draw calls was due to desperation, not knowing what in the hell the Draw functions even do in DX11 or what the arguments/parameters should be, so I double/tripled up hoping for a full cube. I have yet to get one.
stBSPVertex pVB[10000];
/* pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,
m_pFaces[nFace].FirstVert,
0,
m_pFaces[nFace].NumVerts,
m_pFaces[nFace].nFirstMeshVerts,
(m_pFaces[nFace].NumMeshVerts / 3));*/
Vertex v2[10000];
for (int i = 0; i < m_nNumVerts; i++)
{
// The put the y ans z the wrong way around!
pVB[i].p.x = m_pVerts[i].vPoint[0];
pVB[i].p.y = m_pVerts[i].vPoint[1];
pVB[i].p.z = m_pVerts[i].vPoint[2];
// tv is inverted!
pVB[i].tu1 = m_pVerts[i].Tex[0];
pVB[i].tv1 = m_pVerts[i].Tex[1];
pVB[i].lu2 = m_pVerts[i].LightTexCoord[0];
pVB[i].lv2 = m_pVerts[i].LightTexCoord[1];
pVB[i].n.x = m_pVerts[i].vNormal[0];
pVB[i].n.y = m_pVerts[i].vNormal[1];
pVB[i].n.z = m_pVerts[i].vNormal[2];
// Alpha hack - so our alpha value isn't 100% anymore
pVB[i].colour = 0x10ffffff & m_pVerts->RGBA; // ARGB*/
}
for (int i = 0; i < m_nNumVerts; i++)
{
// The put the y ans z the wrong way around!
v2[i] = Vertex(pVB[i].p.x, pVB[i].p.y, pVB[i].p.z, pVB[i].tu1, pVB[i].tv1);
}
/*Vertex v[] =
{
// Front Face
Vertex(-1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
Vertex(-1.0f, 1.0f, -1.0f, 0.0f, 0.0f),
Vertex(1.0f, 1.0f, -1.0f, 1.0f, 0.0f),
Vertex(1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
// Back Face
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
Vertex(1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
Vertex(1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
Vertex(-1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
// Top Face
Vertex(-1.0f, 1.0f, -1.0f, 0.0f, 1.0f),
Vertex(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
Vertex(1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
Vertex(1.0f, 1.0f, -1.0f, 1.0f, 1.0f),
// Bottom Face
Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
Vertex(1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
Vertex(1.0f, -1.0f, 1.0f, 0.0f, 0.0f),
Vertex(-1.0f, -1.0f, 1.0f, 1.0f, 0.0f),
// Left Face
Vertex(-1.0f, -1.0f, 1.0f, 0.0f, 1.0f),
Vertex(-1.0f, 1.0f, 1.0f, 0.0f, 0.0f),
Vertex(-1.0f, 1.0f, -1.0f, 1.0f, 0.0f),
Vertex(-1.0f, -1.0f, -1.0f, 1.0f, 1.0f),
// Right Face
Vertex(1.0f, -1.0f, -1.0f, 0.0f, 1.0f),
Vertex(1.0f, 1.0f, -1.0f, 0.0f, 0.0f),
Vertex(1.0f, 1.0f, 1.0f, 1.0f, 0.0f),
Vertex(1.0f, -1.0f, 1.0f, 1.0f, 1.0f),
};
DWORD indices[] = {
// Front Face
0, 1, 2,
0, 2, 3,
// Back Face
4, 5, 6,
4, 6, 7,
// Top Face
8, 9, 10,
8, 10, 11,
// Bottom Face
12, 13, 14,
12, 14, 15,
// Left Face
16, 17, 18,
16, 18, 19,
// Right Face
20, 21, 22,
20, 22, 23
};*/
DWORD pIB[10000];
/*m_pIB->Lock(0,
m_nNumMeshIndices*sizeof(WORD),
(void**)&pIB,
0);*/
for (int i = 0; i < m_nNumMeshIndices; i++)
pIB[i] = m_pMeshIndices[i];
D3D11_BUFFER_DESC indexBufferDesc;
ZeroMemory(&indexBufferDesc, sizeof(indexBufferDesc));
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = sizeof(DWORD)* m_nNumMeshIndices;
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA iinitData;
iinitData.pSysMem = pIB;
pDevice->CreateBuffer(&indexBufferDesc, &iinitData, &squareIndexBuffer);
pDevCon->IASetIndexBuffer(squareIndexBuffer, DXGI_FORMAT_R32_UINT, 0);
D3D11_BUFFER_DESC vertexBufferDesc;
ZeroMemory(&vertexBufferDesc, sizeof(vertexBufferDesc));
vertexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
vertexBufferDesc.ByteWidth = sizeof(Vertex)* m_nNumVerts;
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = 0;
vertexBufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA vertexBufferData;
ZeroMemory(&vertexBufferData, sizeof(vertexBufferData));
vertexBufferData.pSysMem = v2;
pDevice->CreateBuffer(&vertexBufferDesc, &vertexBufferData, &squareVertBuffer);
//Set the vertex buffer
UINT stride = sizeof(Vertex);
UINT offset = 0;
pDevCon->IASetVertexBuffers(0, 1, &squareVertBuffer, &stride, &offset);
pDevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
pDevCon->DrawIndexed(m_pFaces[nFace].NumVerts, m_pFaces[nFace].nFirstMeshVerts, m_pFaces[nFace].FirstVert);
for (int i = 0; i < m_nNumFaces; i++)
{
// If its not a tri mesh
if (m_pFaces[i].nFaceType != 1) continue;
int nFirstF = m_pFaces[i].nFirstMeshVerts;
int nNumF = m_pFaces[i].NumMeshVerts;
int nFirstV = m_pFaces[i].FirstVert;
int nNumV = m_pFaces[i].NumVerts;
int nTexIndex = m_pFaces[i].nTexture;
#if(0)
pDevice->SetTexture(0,
m_pT[nTexIndex]);
#endif
int nNumTris = nNumF / 3;
m_nNumTrisDraw += nNumTris;
pDevCon->DrawIndexed(nNumTris,nFirstF,nFirstV);
pDevCon->DrawAuto();
/*pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, // Type
nFirstV, // BaseVertexIndex
0, // MinIndex
nNumV, // NumVertices
nFirstF, // StartIndex
nNumTris); // PrimitiveCount*/
}
pDevCon->DrawIndexed(m_nNumMeshIndices, 0, 0);
pDevCon->Draw(m_nNumTrisDraw, 0);
pDevCon->Draw(nNumTris, 0);
pDevCon->DrawIndexed(m_nNumVerts, 0, 0);
}
}
Again, note the multiple draw calls. It's me randomly choosing what arguments to pass in hopes of rendering what I need.
You'll note the DX9 Draw calls are commented out, I'm simply trying to mimic them. Which ones are correct and which aren't?
You'll also notice that the only thing these cubes are missing are certain tri's – there's a function in the header called RenderAll(). I've noticed it takes note of tri's – something that happens to be missing in these particular cubes.
// Renders ALL the level map
// Currently doesn't check if it renders the same face contents twice, as
// different faces can point to the same data.
void RenderAll(IDirect3DDevice9 * pDevice)
{
#if(1)
// Used for debugging
pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
pDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
#endif
pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
// pDevice->SetIndices(m_pIB);
// pDevice->SetStreamSource(0, m_pVB, 0, sizeof(stBSPVertex));
pDevice->SetFVF(m_FVF_Format);
for (int i = 0; i<m_nNumFaces; i++)
{
// If its not a tri mesh
if (m_pFaces[i].nFaceType != 1) continue;
int nFirstF = m_pFaces[i].nFirstMeshVerts;
int nNumF = m_pFaces[i].NumMeshVerts;
int nFirstV = m_pFaces[i].FirstVert;
int nNumV = m_pFaces[i].NumVerts;
int nTexIndex = m_pFaces[i].nTexture;
#if(0)
pDevice->SetTexture(0,
m_pT[nTexIndex]);
#endif
int nNumTris = nNumF / 3;
m_nNumTrisDraw += nNumTris;
pDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, // Type
nFirstV, // BaseVertexIndex
0, // MinIndex
nNumV, // NumVertices
nFirstF, // StartIndex
nNumTris); // PrimitiveCount
}
}
I don't really know the exact difference between Draw(), DrawIndexed, DrawAuto(), etc. But I do notice nNumTris--perhaps that's what's missing?
What is the DX11 equivalent of DrawIndexedPrimative with those parameterers, when it only accepts three? This is a big part of my dilemma.
Jesus, I'm so desperate it's a joke. I think I've given out at least five cries for help offering half a grand to someone who is knowledgeable in DirectX just to simply convert one header file, but no takers. Somebody please help me out here! This is torture! NikiTo is correct, I am running out of time. I am 30 years old(I look 18 years old still but whatever), and I've wasted my life on drugs. I started using right when .NET came out, until that point I was up to speed on everything, as good as the next man. I read Andre Lamonthe's Game Programming Book for DirectX 6 when I was young, and I was developing a game engine because I actually wanted to beat SEGA to their next large Sonic release, I had stolen their meshes(I was also coding botnets at the the time, when I saw housegate8.house.gov appear in my list of bots, I jumped with joy that I had unwillingly hacked into Congress). But that's all in the past; My life went downhill and yes, I'm out of time, I am choosing my hobby to be my profession until I am eligible for law school, but I was fired as a paralegal for drug use and a whole lot of life story I'm not going to get into now.
Point is, I refuse to be a drug addict anymore, I'm not going to be one of those pothead people who are content to do nothing, produce nothing. I also refuse to use Unity or any other game engine--if I didn't write it, it's not mine. This is why I'm so devoted to writing my own game engine, and having someone help convert a single header file to DX11 so I can spot all the differences, learn from them, and move on.
I feel every day that I am not successful in parsing and rendering a BSP map in a simple tutorial for DX11 that I'm closer to relapsing because my emotional state is quite low at the moment, when I was writing my game engine in DX9 it was nothing but progress but this decision to jump to DX11 has me at a stop light, and I really need the help of all of you, anyone who is reading this.
Thanks so much for your help so far, especially you Joe, you're a god/genius.