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

GTL3 Testing continues

Sign in to follow this  


So, with a brief moment of calm and TF2 just not doing it for me I sat down to work out some of the bugs in GTL3 with regards to my testing.

The first problem I had was, based on commonality the PNG flips were all wrong; this was a simple coding error; I put 'false' when I meant 'true'.

The biggest issue was two of the TGA decoders not working properly; this turned out to be me being pwn'd hard by operator presidence; (row+1 * width) wasn't what I meant, ((row+1) * width) was [grin]

One last and very puzzling bug remains with the TGA RLE loaders; setting the origin to the bottom left doesn't produce the correct output.

The test image I have is 4 circles arranged thusly;

(where R = Red, G = Green, B = Blue and Y = Yellow)

Everyone else outputs
As expected.
The RLE TGA code however throw out;

This is slightly puzzling.

The TGA Image is stored as
in memory (this is the output from the 'no flip' path), so to get the correct output we need to flip it in the 'x' axis.
The decoder hits the correct code path, everything seems to setup correctly, yet for some reason the output is always;

Which is a full flip o.O

I've probably got something wrong with the maths somewhere, but I'm getting too tired to get staring at it, so I'll throw it out here, see if anyone else spots the problem before me;

const int imgsize = width * height;
while (count > 0)
int row = offset / width; // get the row we are on i.e. 12 / 10 = row 1 (check interger divsion...)
int rowRemains = width - (offset % width);
int copyAmount = (count > rowRemains) ? rowRemains : count;

forward_mem_iter src_itor(src);
forward_mem_iter end_itor(src + copyAmount);
int rowoffset = ((row+1) * width) - (width - rowRemains) - 1;
reverse_mem_iter dest_itor(dest + rowoffset );

if (repeated)

count -= copyAmount;
offset += copyAmount;
src += copyAmount;

Where 'count' is the element repeat amount or number of elements to copy.
"width" is the row width.
"height" is the image height.
"offset" is the offset in elements we are into the decoded image.
The memory iter objects are just standard iterators, with the reverse iter stepping backwards thru memory.
Dest is the START of the destination memory, this is NOT changed as the algo. progresses thus we have to workout the offset each time.

Get to end of current row, then step backwards from that position by however much we have already written into that row. The '-1' is there to ensure we stay on the correct row.

The two Copy functions call std::fill_n and std::transform respectively under the hood.

Any ideas anyone?
Sign in to follow this  

1 Comment

Recommended Comments

Could be wrong, but this line:

int rowoffset = ((row+1) * width) - (width - rowRemains) - 1;

should maybe be:

int rowoffset = (row * width) + (width - rowRemains) - 1;


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.

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!