Seriously, even using dbBox to draw one rect is not worth it. It's kind of weird too, I know it uses some method of DrawPrimitive. So what makes it so slow?
Heres my test code:
Change "BoxesToDraw" to any value
F1 key to render using D3D
F2 to render using dbBox
#include "DarkGDK.h"
struct CVtx;
void DrawRect(float x, float y, float width, float height, int color);
IDirect3DDevice9 * g_pD3DDev;
bool useD3D = true;
const int BoxesToDraw = 500;
void DarkGDK(void)
{
dbSetDisplayMode(1024, 768, 32);
dbSetWindowOff();
dbSyncOn();
dbSyncRate(60);
dbMakeObjectSphere(1, 100);
g_pD3DDev = dbGetDirect3DDevice();
while(LoopGDK())
{
dbText(0,0,dbStr(dbScreenFPS()));
if(dbScanCode() == 59) useD3D = true; //F1
if(dbScanCode() == 60) useD3D = false; //F2
if(useD3D)
{
for(int i = 0; i < BoxesToDraw; i++)
{
DrawRect(
dbRND(924), //X pos on screen
dbRND(668), //Y pos on screen
100, //Width
100, //Height
dbRGB(
dbRND(255), //Red
dbRND(255), //Green
dbRND(255) //Blue
)
);
}
}
else
{
for(int i = 0; i < BoxesToDraw; i++)
{
int x = dbRND(924);
int y = dbRND(668);
int color = dbRGB(dbRND(255), dbRND(255), dbRND(255));
dbBox(x, y, x+100, y+100, color, color, color, color);
}
}
dbSync();
}
return;
}
struct CVtx
{
float x, y, z, rhw;
int color;
};
void DrawRect(float x, float y, float width, float height, int color)
{
float x1, y1, x2, y2;
CVtx p[4];
x1 = x;
y1 = y;
x2 = x+width;
y2 = y+height;
p[0].x = x2;
p[0].y = y1;
p[0].z = 0;
p[0].rhw = 1;
p[0].color = color;
p[1].x = x1;
p[1].y = y1;
p[1].z = 0;
p[1].rhw = 1;
p[1].color = color;
p[2].x = x2;
p[2].y = y2;
p[2].z = 0;
p[2].rhw = 1;
p[2].color = color;
p[3].x = x1;
p[3].y = y2;
p[3].z = 0;
p[3].rhw = 1;
p[3].color = color;
g_pD3DDev->SetRenderState(D3DRS_ZENABLE, D3DZB_FALSE);
g_pD3DDev->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
g_pD3DDev->SetFVF(D3DFVF_XYZRHW|D3DFVF_DIFFUSE);
g_pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, p, sizeof(CVtx));
}