weimingtom / angel-engine

Automatically exported from code.google.com/p/angel-engine
0 stars 0 forks source link

GwenRenderer::PixelColour implimentation oversight #82

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile Angel2D under Debug
2. Run IntroGame or ClientGame debug executable alone in a folder
3. Watch Angel2D throw asserts like it's going out of style

This function was clearly written to provide some sort of default value in case 
a texture was not loaded, but due to an oversight this was never done.

In patched form, this should be something like:

Gwen::Color GwenRenderer::PixelColour( Gwen::Texture* texture, unsigned int x, 
unsigned int y, const Gwen::Color& col_default)
{
    if (texture == NULL) return col_default;

    unsigned int offset = ((texture->height - y) * texture->width) + x;
    if (offset >= _skinTexture.size() ) return col_default

    Gwen::Color c;
    c.r = (unsigned char)(_skinTexture[offset].R * 255.0f);
    c.g = (unsigned char)(_skinTexture[offset].G * 255.0f);
    c.b = (unsigned char)(_skinTexture[offset].B * 255.0f);
    c.a = (unsigned char)(_skinTexture[offset].A * 255.0f);

    return c;
}

Original issue reported on code.google.com by LoveOver...@gmail.com on 28 Sep 2013 at 1:06

GoogleCodeExporter commented 8 years ago
Another good catch; fixed in repo. 

Original comment by lieseg...@gmail.com on 28 Sep 2013 at 3:22