From 05363c5b35f32aa4037aed68594debf264cbabb4 Mon Sep 17 00:00:00 2001 From: cxgeorge <> Date: Thu, 28 Feb 2002 01:12:48 +0000 Subject: [PATCH] add more wrapmodes --- panda/src/gobj/texture.cxx | 17 +++++++++++++++++ panda/src/gobj/texture.h | 8 ++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index a1c1be621c..605a357152 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -126,6 +126,7 @@ Texture() : ImageBuffer() { _pbuffer = new PixelBuffer; _has_requested_size = false; _all_dirty_flags = 0; + memset(&_border_color,0,sizeof(Colorf)); } //////////////////////////////////////////////////////////////////// @@ -298,6 +299,16 @@ set_anisotropic_degree(int anisotropic_degree) { } } +//////////////////////////////////////////////////////////////////// +// Function: set_border_color +// Access: Published +// Description: +//////////////////////////////////////////////////////////////////// +void Texture:: +set_border_color(const Colorf &color) { + memcpy(&_border_color,&color,sizeof(Colorf)); +} + //////////////////////////////////////////////////////////////////// // Function: load // Access: Public @@ -552,6 +563,12 @@ string_wrap_mode(const string &string) { return WM_repeat; } else if (cmp_nocase_uh(string, "clamp") == 0) { return WM_clamp; + } else if (cmp_nocase_uh(string, "mirror") == 0) { + return WM_clamp; + } else if (cmp_nocase_uh(string, "mirror_once") == 0) { + return WM_clamp; + } else if (cmp_nocase_uh(string, "border_color") == 0) { + return WM_border_color; } else { return WM_invalid; } diff --git a/panda/src/gobj/texture.h b/panda/src/gobj/texture.h index 74d7727bc2..4fb8d4af20 100644 --- a/panda/src/gobj/texture.h +++ b/panda/src/gobj/texture.h @@ -70,9 +70,11 @@ PUBLISHED: }; enum WrapMode { - WM_clamp, + WM_clamp, // coords that would be outside [0-1] are clamped to 0 or 1 WM_repeat, - + WM_mirror, + WM_mirror_once, // mirror once, then clamp + WM_border_color, // coords outside [0-1] use explict border color // Returned by string_wrap_mode() for an invalid match. WM_invalid }; @@ -90,6 +92,7 @@ PUBLISHED: void set_minfilter(FilterType filter); void set_magfilter(FilterType filter); void set_anisotropic_degree(int anisotropic_degree); + void set_border_color(const Colorf &color); INLINE WrapMode get_wrapu() const; INLINE WrapMode get_wrapv() const; @@ -146,6 +149,7 @@ private: FilterType _magfilter; int _anisotropic_degree; bool _keep_ram_image; + Colorf _border_color; // A Texture keeps a list (actually, a map) of all the GSG's that it // has been prepared into. Each GSG conversely keeps a list (a set)