Skip to content

Commit

Permalink
Functions for managing wrap modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
lipk committed Jul 7, 2014
1 parent a4b14e0 commit 74b557e
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/sdl/texture.cpp
Expand Up @@ -34,6 +34,8 @@ ttexture::ttexture(Uint16 w, Uint16 h)
, smooth_scaling_(false)
, clip_(create_gpu_rect(0, 0, w, h))
, color_mod_(create_color(0, 0, 0, 255))
, hwrap_(GPU_WRAP_NONE)
, vwrap_(GPU_WRAP_NONE)
{
image_ = GPU_CreateImage(w, h, GPU_FORMAT_RGBA);
if (image_ == NULL) {
Expand All @@ -51,6 +53,8 @@ ttexture::ttexture(const std::string &file)
, smooth_scaling_(false)
, clip_()
, color_mod_(create_color(0, 0, 0, 255))
, hwrap_(GPU_WRAP_NONE)
, vwrap_(GPU_WRAP_NONE)
{
if (image_ == NULL) {
//TODO: report error
Expand All @@ -68,6 +72,8 @@ ttexture::ttexture(const surface &source)
, smooth_scaling_(false)
, clip_()
, color_mod_(create_color(0, 0, 0, 255))
, hwrap_(GPU_WRAP_NONE)
, vwrap_(GPU_WRAP_NONE)
{
if (image_ == NULL) {
//TODO: report error
Expand All @@ -85,6 +91,8 @@ ttexture::ttexture(SDL_Surface *source)
, smooth_scaling_(false)
, clip_()
, color_mod_(create_color(0, 0, 0, 255))
, hwrap_(GPU_WRAP_NONE)
, vwrap_(GPU_WRAP_NONE)
{
if (image_ == NULL) {
//TODO: report error
Expand All @@ -102,6 +110,8 @@ ttexture::ttexture()
, smooth_scaling_(false)
, clip_(create_gpu_rect(0, 0, 0, 0))
, color_mod_(create_color(0, 0, 0, 255))
, hwrap_(GPU_WRAP_NONE)
, vwrap_(GPU_WRAP_NONE)
{
}

Expand All @@ -123,6 +133,8 @@ ttexture::ttexture(const ttexture &texture)
, smooth_scaling_(texture.smooth_scaling_)
, clip_(texture.clip_)
, color_mod_(texture.color_mod_)
, hwrap_(texture.hwrap_)
, vwrap_(texture.vwrap_)
{
if (image_ != NULL) {
image_->refcount += 1;
Expand All @@ -146,6 +158,7 @@ void ttexture::draw(GPU_Target &target, const int x, const int y)
? GPU_FILTER_LINEAR
: GPU_FILTER_NEAREST);
//GPU_SetColor(image_, &color_mod_);
GPU_SetWrapMode(image_, hwrap_, vwrap_);
GPU_BlitTransform(image_, &clip_, &target, x + width()/2,
y + height()/2, rotation_, hscale_, vscale_);
}
Expand Down Expand Up @@ -257,6 +270,32 @@ Uint8 ttexture::blue_mod() const
return color_mod_.b;
}

void ttexture::set_hwrap(GPU_WrapEnum mode)
{
hwrap_ = mode;
}

void ttexture::set_vwrap(GPU_WrapEnum mode)
{
vwrap_ = mode;
}

void ttexture::set_wrap(GPU_WrapEnum hmode, GPU_WrapEnum vmode)
{
hwrap_ = hmode;
vwrap_ = vmode;
}

GPU_WrapEnum ttexture::hwrap() const
{
return hwrap_;
}

GPU_WrapEnum ttexture::vwrap() const
{
return vwrap_;
}

bool ttexture::null() const
{
return image_ == NULL;
Expand Down
13 changes: 13 additions & 0 deletions src/sdl/texture.hpp
Expand Up @@ -88,6 +88,15 @@ class ttexture

Uint8 blue_mod() const;

void set_hwrap(GPU_WrapEnum mode);

void set_vwrap(GPU_WrapEnum mode);

void set_wrap(GPU_WrapEnum hmode, GPU_WrapEnum vmode);

GPU_WrapEnum hwrap() const;

GPU_WrapEnum vwrap( )const;

bool null() const;

Expand All @@ -105,6 +114,10 @@ class ttexture
GPU_Rect clip_;

SDL_Color color_mod_;

GPU_WrapEnum hwrap_;

GPU_WrapEnum vwrap_;
};
}
#endif
Expand Down

0 comments on commit 74b557e

Please sign in to comment.