-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtexture.cpp
45 lines (35 loc) · 815 Bytes
/
texture.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//
// texture.cpp
// MyGame
//
// Created by August Trollback on 10/9/13.
// Copyright (c) 2013 August Trollback. All rights reserved.
//
#include "texture.h"
Texture::Texture(){
mTexture = NULL;
mWidth = 0;
mHeight = 0;
}
Texture::~Texture(){
freeTex();
}
void Texture::freeTex(){
if(mTexture != NULL){
SDL_DestroyTexture(mTexture);
mTexture = NULL;
mWidth = 0;
mHeight = 0;
}
}
void Texture::render(int x, int y, SDL_Rect* clip, SDL_Renderer* renderer){
SDL_Rect renderQuad = { x, y, mWidth, mHeight };
if(clip != NULL){
renderQuad.w = clip->w;
renderQuad.h = clip->h;
}
SDL_RenderCopy(renderer, mTexture, clip, &renderQuad);
}
void Texture::setTex(SDL_Texture *newTex){
mTexture = newTex;
}