Jump to content
  • Advertisement
  • entries
    707
  • comments
    1173
  • views
    435840

OMFG!!!

Sign in to follow this  
Programmer16

152 views

I absolutely hate variable width fonts now. I started last night. First I had everything working right (or so I thought), but my frame rate would jump from 75-77-78-7 (not in that specific order, but I saw those numbers the most.) I was like wtf, 7!? So, I started profiling the code... profiling... and profiling... None of my operations in my printing function was taking more than 1ms. So, I went and started profiling my input code (since I have event based input setup, I thought maybe it was slow.) Nope, not there. So, I decide to profile the entire loop, and its only taking 13-14ms for everything. Then, I get the brilliant idea to check my text and low and behold, it was 76, not 7.

I then went on to print the entire character set in one operation (so that I could compare it to the bitmap) and I noticed that some characters weren't drawing. Fixed that easily. Then I noticed that some of the characters were being drawn twice (6 was replaced by 7). I also noticed that it was only the first character of each row after the first. So I figure my calculations were and I was right.

So, I get home today (after work) and decide, I'm going to rewrite it using a descriptor class and store the texture x/y in that at load time (I was doing the calculations at run time.) So, I started hacking away, and I was getting somewhere. But, I still had a problem - for some reason it was printing 2 spaces in in the beginning. So, I started stepping through my code over and over. Then I checked my text and boom, I had accidentally typed 2 spaces into the string to print.

Next problem was all of my lines were fine except for one, my ] character was lost somehow and my ^ character was being printed on two lines. So, I go searching through the code and found the bug (I was setting the texture x/y in the wrong order in my algorithm.)

Moving on, I come to another problem - everything except for 1 character is printing right( the 1 character was throwing off that line, but the characters on the line were rendering perfect, only 2 units pixels off.) So, again, I made the mistake of stepping through the code for about an hour when I realized that it was printing an ' instead of `, so I check my string again and I had put in an apostrophe instead of the back-quote.

The moral of the story - always check your input before stepping through the code and switching stuff around in your algorithm.

On a different note, I didn't get anything done yesterday (except for the catastrophe above), since I was very busy. My mom asked me to build her some shelves for her plants (so they can get sunlight), so I did that. Then my dad gets home and I get to change the breaks on the car, YAY!!! While doing that, the car decided to roll off of the jack and partially onto my leg (I'm not injured; I was leaning in and turning the steering wheel so that I could reach the screws to take the brakes off and the door came down on the back of my leg; it was sore, but no damage.) That took about 2 hours because I had to search for the jack (ended up using the wrong one), then for the lug-wrench, then for the right sized alan wrench, and then I had fun trying to compress the brakes so that I could put the new ones on (lets just say I'm not the strongest person in the world, but I did get it done by myself.)

The moral of that story - always use the right jack that came with the car or a bigger one, and always, ALWAYS put something behind the tire of the car so it can't roll.

And finally, my update. I removed vertex buffer, because it was kind of pointless and didn't work with my current design (since it was templated.) I have to redo part of the texture system because I didn't implement it right. I started doing a pack system, and didn't finish with that.

The pack system is pretty simple, and Raymond said that I could combine it with his dot notation addressing (thanks Raymond!):

// Pseudocode
class Texture;
class TexturePack; // has a map of texture smart ptrs, a parent pointer, and a name

pTextureManager->GetTexture("System.GUI.Skin", "GuiSkin.bmp");
pTextureManager->GetTexture("System.GUI.Cursor", "GuiCursor.bmp");
pTextureManager->GetTexture("System.CurrentMap.Player", "Player.bmp");

// The user wants to change to a different skin, so purge the GUI
// textures.
pTextureManager->Purge("System.GUI");

// The user wants to change to a different character, so purge
// the CurrentMap.Player texture.
pTextureManager->Purge("System.CurrentMap.Player");

// The user is quitting, purge all textures.
pTextureManager->Purge("System");


All the manager classes will use this, as it will ease my life majorly. I moved the terrain quad to the game side, because that I feel it will be more game specific (the regular Vertex class can be used for a lot of things, but the TerrainVertex class can only be used for terrains (well, actually it can be used for anything that is transformed, colored, and requiring 2 texture coordinate sets.) The rest of the engine code will be finished tonight, even if I have to stay up all night to do it (seriously, its only 3 classes and most of FontManager and SoundManager will be copied from TextureManager.)

Sorry for the huge update!
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!