This is making me very sad. Why was DirectDraw deprecated?

Here’s the situation. I’m making a tile based game in C# using MDX and Direct3D. I’m trying to achieve real time framerates and having a dismal time at it.

I have done some benchmarking with a PerformanceTimer and I’ve determined my problem is that I am calling DrawPrimative once for every visible tile. That is, to draw the map, I transform the world coordinates, call DP on a square vertex buffer, then move to the next tile. Typically I have about 1000 tiles on the screen at once. So this didn’t seem like it would be a problem, even if this is not the way to draw a 3D scene.

To draw the whole 100×100 map this way, without textures, gives 1.5 FPS. I did an experiment and made a single vertex buffer to render the whole map with one DP call (still passing in 60,000 vertices) and my FPS jumped to 40-80 (variance probably due to the presentation params and the vblank).

I now have 3 options, that I can tell, all of them unappealing.

1. Trying using the MDX Sprite class. I hear different things about it’s performance from different people.

2. Put all my textures into one big texture, put my whole map in one big vertex buffer, set all the texture coords of the individual tiles right, and blast the whole mess to the GPU with one DP call. This is not ideal since it makes updating the tilemap complicated. Especially for layers above the ground layer (critters, items, ect) that are sparse and would need constant updating. Also I would need to batch my textures if they don’t fit on a single large texture in video mem.

3. Use DirectDraw, even though it is deprecated. Or use OpenGL, which doesn’t have this problem of the DP-equivalent call costing so much. OpenGL is not natively supported by C#, so I’d rather not. There’s also stuff like SDL.Net — but it doesn’t seem I should need a 3rd party lib to draw a tilemap. I mean, come on.

So… What should I do?

Discontinuing DirectDraw was so short-sighted. D3D really isn’t a substitute. Why is the latency of DP so high? Modern GPUs had GBs of bandwidth, and I’m not close to using all mine.


Up wi King James and Donald MacGillavry!

Donald’s gane up the hill hard and hungry,
Donald comes down the hill wild and angry;
Donald will clear the gouk’s nest cleverly,
Here’s to the king and Donald Macgillavry.
Come like a weighbauk, Donald Macgillavry,
Come like a weighbauk, Donald Macgillavry,
Balance them fair, and balance them cleverly:
Off wi’the counterfeit, Donald Macgillavry.

Donald’s run o’er the hill but his tether, man,
As he were wud, or stang’d wi’ an ether, man;
When he comes back, there’s some will look merrily:
Here’s to King James and Donald Macgillavry.
Come like a weaver, Donald Macgillavry,
Come like a weaver, Donald Macgillavry,
Pack on your back, and elwand sae cleverly;
Gie them full measure, my Donald Macgillavry.

Donald has foughten wi’ rief and roguery;
Donald has dinner’d wi banes and beggary,
Better it were for Whigs and Whiggery
Meeting the devil than Donald Macgillavry.
Come like a tailor, Donald Macgillavry,
Come like a tailor, Donald Macgillavry,
Push about, in and out, thimble them cleverly,
Here’s to King James and Donald Macgillavry.

Donald’s the callan that brooks nae tangleness;
Whigging and prigging and a’newfangleness,
They maun be gane: he winna be baukit, man:
He maun hae justice, or faith he’ll tak it, man.
Come like a cobler, Donald Macgillavry,
Come like a cobler, Donald Macgillavry;
Beat them, and bore them, and lingel them cleverly,
Up wi’ King James and Donald Macgillavry.

Donald was mumpit wi mirds and mockery;
Donald was blinded wi’ blads o’ property;
Arles ran high, but makings were naething, man,
Lord, how Donald is flyting and fretting, man.
Come like the devil, Donald Macgillavry,
Come like the devil, Donald Macgillavry;
Skelp them and scaud them that proved sae unbritherly,
Up wi King James and Donald Macgillavry!

private Item[] equipped = new Item[(int)Slot.NUM_SLOTS];

Spent some time this weekend working on Witherwyn’s inventory code and GUI. However, as soon as I started adding a lot of items to the game I decided that instead of hardcoding everything, I needed to load entity data in from XML files. This will involve 3-4 hours of very tedious datafile management coding and changing the map generator and render to handle dynamically loaded tiles. I’m not really looking forward to that, so the project is on hiatus for now.

Witherwyn Google Count: about 71

eXtreme Coding…

*Announcer voice*


Our final CS143 bug fix:

Type *timmy;
Location *baseLoc = base->EmitExpr(scope_stack, gen, params, timmy);

NamedType *jimmy = dynamic_cast<NamedType *>(timmy);
Assert(jimmy); // JIMMMAAAHHH!!!!!!!!!!
// Put Jimmy to work…
ClassDecl *c = GetClassDecl(scope_stack->Nth(0), jimmy);
var = c->FindIvan(field->GetName());

Timmy has to tell Jimmy to go find Ivan in the pixel mines

Finally done all my programming projects… yay! CS143 final is going to be anti-climatic.


My project partner is really excited that we might be able to take first place at the CS223B machine vision competition tomorrow, winning us 3 laptops. I, personally, would just be satisfied with an A.

Current score on pre-competition clips: 92.78
Top score last Monday in class for said clips: 84

CS223B makes me feel so smart.