DrawSpline hack to draw something.

This commit is contained in:
Xele02 2013-02-13 01:03:02 +01:00
parent ca23c076a1
commit 5654a7eae5

View File

@ -149,8 +149,46 @@ void TransformDrawEngine::DrawBezier(int ucount, int vcount) {
Flush(); // as our vertex storage here is temporary, it will only survive one draw.
}
// Copy code from bezier. This is not right, but allow to display something.
void TransformDrawEngine::DrawSpline(int ucount, int vcount, int utype, int vtype) {
// TODO
u16 indices[3 * 3 * 6];
// Generate indices for a rectangular mesh.
int c = 0;
for (int y = 0; y < 3; y++) {
for (int x = 0; x < 3; x++) {
indices[c++] = y * 4 + x;
indices[c++] = y * 4 + x + 1;
indices[c++] = (y + 1) * 4 + x + 1;
indices[c++] = (y + 1) * 4 + x + 1;
indices[c++] = (y + 1) * 4 + x;
indices[c++] = y * 4 + x;
}
}
// We are free to use the "decoded" buffer here.
// Let's split it into two to get a second buffer, there's enough space.
u8 *decoded2 = decoded + 65536 * 24;
// Alright, now for the vertex data.
// For now, we will simply inject UVs.
float customUV[4 * 4 * 2];
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 4; x++) {
customUV[(y * 4 + x) * 2 + 0] = (float)x/3.0f;
customUV[(y * 4 + x) * 2 + 1] = (float)y/3.0f;
}
}
if (!(gstate.vertType & GE_VTYPE_TC_MASK)) {
dec.SetVertexType(gstate.vertType);
u32 newVertType = dec.InjectUVs(decoded2, Memory::GetPointer(gstate_c.vertexAddr), customUV, 16);
SubmitPrim(decoded2, &indices[0], GE_PRIM_TRIANGLES, c, newVertType, GE_VTYPE_IDX_16BIT, 0);
} else {
SubmitPrim(Memory::GetPointer(gstate_c.vertexAddr), &indices[0], GE_PRIM_TRIANGLES, c, gstate.vertType, GE_VTYPE_IDX_16BIT, 0);
}
Flush(); // as our vertex storage here is temporary, it will only survive one draw.
}
// Convenient way to do precomputation to save the parts of the lighting calculation