//
//  SDLTextureRef.h
//  Meteor
//
//  Created by Cesar Parent on 01/08/2015.
//  Copyright (c) 2015 Cesar Parent. All rights reserved.
//

#ifndef Meteor_SDLTextureRef_h
#define Meteor_SDLTextureRef_h

#include "../CPFoundation.h"
#include "../sdl_includes.h"

NS_BEGIN

class SDLTextureRef final : public CPObject {
    
public:
    
    /*!
     * @brief       Create a reference-counted pointer to an SDL_Texture struct.
     * @param       texture     Pointer to an SDL hardware structure
     */
    SDLTextureRef(SDL_Texture* texture) {
        CPNullCheck(texture);
        _texture = texture;
    }
    
    /*!
     * @brief       Frees SDL hardware texture's memory
     */
    virtual ~SDLTextureRef() {
        SDL_DestroyTexture(_texture);
    }
    
    /*!
     * @brief       Returns a pointer to the underlying SDL Texture.
     * @return      A non-null pointer to the hardawre texture.
     */
    SDL_Texture*
    raw() {
        return _texture;
    }
    
private:
    
    SDL_Texture* _texture;
};


NS_END

#endif
