Skip to content

Instantly share code, notes, and snippets.

@byteandahalf
Forked from mackthehobbit/TickingTexture.h
Last active August 29, 2015 14:26

Revisions

  1. Byteandahalf revised this gist Aug 4, 2015. 1 changed file with 8 additions and 8 deletions.
    16 changes: 8 additions & 8 deletions TickingTexture.h
    Original file line number Diff line number Diff line change
    @@ -8,24 +8,24 @@ class TickingTexture {
    // this is the complete struct
    // void** vtable;
    // this seems like it determines the area of the atlas to be animated
    TextureUVCoordinateSet texture;
    TextureUVCoordinateSet atlasTemplate;

    int size;
    char *someArray;
    int arraySize;
    int framecount; // number of frames in the animation
    unsigned char *pixels; // All pixels in the image, 4 uchars for each (RGBA)
    int pixelCount;

    // disassembled this constructor for street cred
    TickingTexture(TextureUVCoordinateSet &texture, int size) {
    // I'm calling it 'size' for now - it's passed as 1 for WaterTexture and LavaTexture, 2 for WaterSideTexture, and 36 for FireTexture
    // seems like the number of frames or something similar, but the fire image has 32 frames and not 36.
    this->size = size;
    this->framecount = size;
    // 1024 could be the size in bytes of one 16x16 image, as 16*16*4 (for RGBA) = 1024
    // but why is the size parameter squared?
    arraySize = size * size * 1024;
    pixelCount = size * size * 1024;
    // arraySize *bytes* are allocated
    someArray = new char[arraySize];
    pixels = new char[pixelCount];
    // and cleared
    memset(array, 0, arraySize);
    memset(pixels, 0, pixelCount);
    }

    virtual ~TickingTexture();
  2. mackthehobbit revised this gist Aug 4, 2015. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions TickingTexture.h
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ class TickingTexture {
    TextureUVCoordinateSet texture;

    int size;
    int *someArray;
    char *someArray;
    int arraySize;

    // disassembled this constructor for street cred
    @@ -23,7 +23,7 @@ class TickingTexture {
    // but why is the size parameter squared?
    arraySize = size * size * 1024;
    // arraySize *bytes* are allocated
    someArray = new int[arraySize / 4];
    someArray = new char[arraySize];
    // and cleared
    memset(array, 0, arraySize);
    }
  3. mackthehobbit created this gist Aug 4, 2015.
    36 changes: 36 additions & 0 deletions TickingTexture.h
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #pragma once

    #include "TextureUVCoordinateSet.h"

    class TickingTexture {

    public:
    // this is the complete struct
    // void** vtable;
    // this seems like it determines the area of the atlas to be animated
    TextureUVCoordinateSet texture;

    int size;
    int *someArray;
    int arraySize;

    // disassembled this constructor for street cred
    TickingTexture(TextureUVCoordinateSet &texture, int size) {
    // I'm calling it 'size' for now - it's passed as 1 for WaterTexture and LavaTexture, 2 for WaterSideTexture, and 36 for FireTexture
    // seems like the number of frames or something similar, but the fire image has 32 frames and not 36.
    this->size = size;
    // 1024 could be the size in bytes of one 16x16 image, as 16*16*4 (for RGBA) = 1024
    // but why is the size parameter squared?
    arraySize = size * size * 1024;
    // arraySize *bytes* are allocated
    someArray = new int[arraySize / 4];
    // and cleared
    memset(array, 0, arraySize);
    }

    virtual ~TickingTexture();
    virtual void tick() = 0;
    virtual void bindTextures(Textures* textures);


    };