Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Optimization Day!

Sign in to follow this  


And thus, henceforth this day shalt be verily named, "Optimization Day", so that coders and ye code doth speed much uppeth, and doth gain ye hard earned speed.

Or, in other words:

Map and Map-Object drawing optimizations

I learned some more Direct3D today, as I once again was forced to delve into the depths of this library I'm using ("Omega") to check out how exactly it was handling things. Open-source rocks. The more I go through the source and see how they did things, the more I'm learning. Which is uber.

Anyways, I noticed that the drawing method that was being used currently is:

1) Bind texture
2) Set vertex/texture coords
3) Lock vertices into a vertex buffer
4) Draw

Eeee. Now I realize why I was getting such low framerates in Arctic Outpost. This method seemed to be good enough for the maps that didn't have many heavily-tiled areas or large object counts, but as the maps get bigger and more complex, the framerate nose-dives from 60 to 30 on my computer. Gah. And I've got a fairly nice card, too! :P

Rather than trying to learn what the 'pros' at Microsoft's DirectX team already know, I decided to defer to the enigmatic power of the ID3DXSprite interface, which is a(n awesome!) helper library for drawing 2D sprites in D3D.

I converted my tile-drawing and map-object-drawing routines to use this, and WOW. I mean it, really. Wow. Now I'm back up to 60 FPS on the Arctic Outpost map and things are going smoothly again. Fantastic. I'll have to get some other FPS readings from other testers on lesser hardware tomorrow night when we do another testing session. [smile]

Ping optimization

For ages now latency has been really crappy. Well, sort of. After I implemented the 'ping' feature under the game listings on the master server, I realized that it's not my connection -- it's my code! Using a pure back-and-forth ping on my own system with no fancy game code going on in the background yields under 10ms every time. Hmmm. This is especially odd since when I run two clients on my computer and connect them both to a game, I get around ~100ms on average. Doh?

I don't have it perfect yet, but it's a great deal better than before. What I did was subtract the time it takes to render the game from ping calculations. Since in many situations where the framerate drops, rendering time goes up, and packets that arrive during that slow render time (or other lengthy game logic) has to sit there and wait, thus accumulating an increasingly incorrect timestamp.

Short story short, now I'm getting way more reasonable numbers on my end. I'm looking forward to stress-testing it out on tomorrow night's test.

Layering do-dads

The layering issues I mentioned in my last entry are now fixed up. Healthbars/names appear OVER all objects, while under the HUD. Also, shadows all appear UNDER all objects, while over the map tiles/ground. It both looks and feels significantly better. And people with short names can't hide beside crates anymore, either. [grin]

Also 'fixed' a handful of various bugs. Hopefully they'll stay fixed. Tomorrow night's test should be very decisive in a lot of things, it would seem. [smile]

(Oh, and I'm working on getting all/most of the text with a nice black outline so it's not vanishing on conflicting background colours like this:)

(Yay, 60FPS!)
Sign in to follow this  


Recommended Comments

Congratz on hitting 60 fps! The game is looking good as always.

Share this comment

Link to comment
Guest Anonymous Poster


Glad to hear Arctic Outpost isn't giving you anymore problems! But, is it safe for me to make another map? *Evil laughter* :D

Share this comment

Link to comment
Depending on how you render the text, you could go the cheap way and render the font 5 times (first 4 being black) - position.x - 1, position.y - 1, position.x + 1, position.y + 1, and then white at position. That was how I had it setup before I got my outlined font.

The game is looking awesome. I like the map designs (from the screenshots anyway), there seems to be a lot of detail.

Share this comment

Link to comment
@Nit: Thanks! (Update your blog more! :P)

@DarkCampainger (AP): Definitely. I really like your mapping style, and more stuff from you would be great. [smile]

@Programmer16: Yep, that's the method I'm using right now. Performance isn't exactly stellar, but it's the easiest route for sure. Since I'm using bitmap fonts I'll have to (eventually) bite the bullet and create an outlined set from the generated Win32 font. Darn. [grin] And of course, thanks for the kind words.

Share this comment

Link to comment
Guest Anonymous Poster


HopeDagger, I'm pretty good at easy tedious work, so if you could explain how, I'd be happy to add outlines to your font :)


Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!