mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Added concept of a texture's Pad Region
This commit is contained in:
parent
9c32b2ec63
commit
1297993a34
@ -502,6 +502,62 @@ get_z_size() const {
|
||||
return _z_size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::get_pad_x_size
|
||||
// Access: Published
|
||||
// Description: Returns size of the pad region. See set_pad_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int Texture::
|
||||
get_pad_x_size() const {
|
||||
return _pad_x_size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::get_pad_y_size
|
||||
// Access: Published
|
||||
// Description: Returns size of the pad region. See set_pad_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int Texture::
|
||||
get_pad_y_size() const {
|
||||
return _pad_y_size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::get_pad_z_size
|
||||
// Access: Published
|
||||
// Description: Returns size of the pad region. See set_pad_size.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE int Texture::
|
||||
get_pad_z_size() const {
|
||||
return _pad_z_size;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::set_pad_size
|
||||
// Access: Published
|
||||
// Description: Sets the size of the pad region.
|
||||
//
|
||||
// Sometimes, when a video card demands power-of-two
|
||||
// textures, it is necessary to create a big texture
|
||||
// and then only use a portion of it. The pad region
|
||||
// indicates which portion of the texture is not
|
||||
// really in use. All operations use the texture
|
||||
// as a whole, including the pad region, unless they
|
||||
// explicitly state that they use only the non-pad
|
||||
// region.
|
||||
//
|
||||
// Changing the texture's size clears the pad region.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE void Texture::
|
||||
set_pad_size(int x, int y, int z) {
|
||||
if (x > _x_size) x = _x_size;
|
||||
if (y > _y_size) y = _y_size;
|
||||
if (z > _z_size) z = _z_size;
|
||||
_pad_x_size = x;
|
||||
_pad_y_size = y;
|
||||
_pad_z_size = z;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::get_num_components
|
||||
// Access: Published
|
||||
@ -1087,6 +1143,7 @@ set_x_size(int x_size) {
|
||||
_x_size = x_size;
|
||||
++_image_modified;
|
||||
clear_ram_image();
|
||||
set_pad_size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1104,6 +1161,7 @@ set_y_size(int y_size) {
|
||||
_y_size = y_size;
|
||||
++_image_modified;
|
||||
clear_ram_image();
|
||||
set_pad_size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1123,6 +1181,7 @@ set_z_size(int z_size) {
|
||||
_z_size = z_size;
|
||||
++_image_modified;
|
||||
clear_ram_image();
|
||||
set_pad_size();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,10 @@ Texture(const string &name) :
|
||||
set_format(F_rgb);
|
||||
set_component_type(T_unsigned_byte);
|
||||
|
||||
_pad_x_size = 0;
|
||||
_pad_y_size = 0;
|
||||
_pad_z_size = 0;
|
||||
|
||||
_loaded_from_image = false;
|
||||
_loaded_from_txo = false;
|
||||
_has_read_pages = false;
|
||||
@ -104,6 +108,9 @@ Texture(const Texture ©) :
|
||||
_x_size(copy._x_size),
|
||||
_y_size(copy._y_size),
|
||||
_z_size(copy._z_size),
|
||||
_pad_x_size(copy._pad_x_size),
|
||||
_pad_y_size(copy._pad_y_size),
|
||||
_pad_z_size(copy._pad_z_size),
|
||||
_num_components(copy._num_components),
|
||||
_component_width(copy._component_width),
|
||||
_texture_type(copy._texture_type),
|
||||
@ -151,6 +158,9 @@ operator = (const Texture ©) {
|
||||
_x_size = copy._x_size;
|
||||
_y_size = copy._y_size;
|
||||
_z_size = copy._z_size;
|
||||
_pad_x_size = copy._pad_x_size;
|
||||
_pad_y_size = copy._pad_y_size;
|
||||
_pad_z_size = copy._pad_z_size;
|
||||
_num_components = copy._num_components;
|
||||
_component_width = copy._component_width;
|
||||
_texture_type = copy._texture_type;
|
||||
@ -245,6 +255,7 @@ setup_texture(Texture::TextureType texture_type, int x_size, int y_size,
|
||||
set_format(format);
|
||||
|
||||
clear_ram_image();
|
||||
set_pad_size();
|
||||
_loaded_from_image = false;
|
||||
_loaded_from_txo = false;
|
||||
_has_read_pages = false;
|
||||
@ -2643,6 +2654,9 @@ reconsider_image_properties(int x_size, int y_size, int num_components,
|
||||
nassertr(x_size == y_size, false);
|
||||
}
|
||||
#endif
|
||||
if ((_x_size != x_size)||(_y_size != y_size)) {
|
||||
set_pad_size();
|
||||
}
|
||||
_x_size = x_size;
|
||||
_y_size = y_size;
|
||||
_num_components = num_components;
|
||||
@ -3541,6 +3555,7 @@ fillin(DatagramIterator &scan, BamReader *manager, bool has_rawdata) {
|
||||
_ram_images[n]._image = image;
|
||||
}
|
||||
_loaded_from_image = true;
|
||||
set_pad_size();
|
||||
++_image_modified;
|
||||
++_properties_modified;
|
||||
}
|
||||
|
@ -340,6 +340,13 @@ PUBLISHED:
|
||||
INLINE void set_x_size(int x_size);
|
||||
INLINE void set_y_size(int y_size);
|
||||
INLINE void set_z_size(int z_size);
|
||||
|
||||
INLINE int get_pad_x_size() const;
|
||||
INLINE int get_pad_y_size() const;
|
||||
INLINE int get_pad_z_size() const;
|
||||
|
||||
INLINE void set_pad_size(int x=0, int y=0, int z=0);
|
||||
|
||||
void set_format(Format format);
|
||||
void set_component_type(ComponentType component_type);
|
||||
INLINE void set_loaded_from_image();
|
||||
@ -504,6 +511,10 @@ protected:
|
||||
bool _render_to_texture;
|
||||
bool _match_framebuffer_format;
|
||||
|
||||
int _pad_x_size;
|
||||
int _pad_y_size;
|
||||
int _pad_z_size;
|
||||
|
||||
// A Texture keeps a list (actually, a map) of all the
|
||||
// PreparedGraphicsObjects tables that it has been prepared into.
|
||||
// Each PGO conversely keeps a list (a set) of all the Textures that
|
||||
|
Loading…
x
Reference in New Issue
Block a user