mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
Fixes for texture padding
This commit is contained in:
parent
7ab42fafae
commit
17a1700b26
@ -316,15 +316,7 @@ add_render_texture(Texture *tex, RenderTextureMode mode,
|
||||
// Go ahead and tell the texture our anticipated size, even if it
|
||||
// might be inaccurate (particularly if this is a GraphicsWindow,
|
||||
// which has system-imposed restrictions on size).
|
||||
if (Texture::get_textures_power_2() != ATS_none) {
|
||||
tex->set_x_size(Texture::up_to_power_2(get_x_size()));
|
||||
tex->set_y_size(Texture::up_to_power_2(get_y_size()));
|
||||
} else {
|
||||
tex->set_x_size(get_x_size());
|
||||
tex->set_y_size(get_y_size());
|
||||
}
|
||||
tex->set_pad_size(tex->get_x_size() - get_x_size(),
|
||||
tex->get_y_size() - get_y_size());
|
||||
tex->set_size_padded(get_x_size(), get_y_size());
|
||||
|
||||
if (mode == RTM_bind_or_copy && !support_render_texture) {
|
||||
mode = RTM_copy_texture;
|
||||
|
@ -1426,8 +1426,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
||||
HRESULT hr;
|
||||
int xo, yo, w, h;
|
||||
dr->get_region_pixels_i(xo, yo, w, h);
|
||||
tex->set_x_size(Texture::up_to_power_2(w));
|
||||
tex->set_y_size(Texture::up_to_power_2(h));
|
||||
tex->set_size_padded(w, h);
|
||||
|
||||
TextureContext *tc = tex->prepare_now(get_prepared_objects(), this);
|
||||
if (tc == (TextureContext *)NULL) {
|
||||
|
@ -2029,8 +2029,7 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
||||
HRESULT hr;
|
||||
int xo, yo, w, h;
|
||||
dr->get_region_pixels_i(xo, yo, w, h);
|
||||
tex->set_x_size(Texture::up_to_power_2(w));
|
||||
tex->set_y_size(Texture::up_to_power_2(h));
|
||||
tex->set_size_padded(w, h);
|
||||
|
||||
bool use_stretch_rect;
|
||||
|
||||
|
@ -3429,13 +3429,8 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
|
||||
|
||||
int xo, yo, w, h;
|
||||
dr->get_region_pixels(xo, yo, w, h);
|
||||
if (_supports_tex_non_pow2) {
|
||||
tex->set_x_size(w);
|
||||
tex->set_y_size(h);
|
||||
} else {
|
||||
tex->set_x_size(Texture::up_to_power_2(w));
|
||||
tex->set_y_size(Texture::up_to_power_2(h));
|
||||
}
|
||||
tex->set_size_padded(w, h);
|
||||
|
||||
if (tex->get_compression() == Texture::CM_default) {
|
||||
// Unless the user explicitly turned on texture compression, turn
|
||||
// it off for the copy-to-texture case.
|
||||
|
@ -2880,6 +2880,28 @@ clear_prepared(PreparedGraphicsObjects *prepared_objects) {
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::set_size_padded
|
||||
// Description: Changes the size of the texture, padding
|
||||
// if necessary, and setting the pad region
|
||||
// as well.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void Texture::
|
||||
set_size_padded(int x, int y, int z) {
|
||||
if (get_textures_power_2() != ATS_none) {
|
||||
set_x_size(up_to_power_2(x));
|
||||
set_y_size(up_to_power_2(y));
|
||||
set_z_size(up_to_power_2(z));
|
||||
} else {
|
||||
set_x_size(x);
|
||||
set_y_size(y);
|
||||
set_z_size(z);
|
||||
}
|
||||
set_pad_size(get_x_size() - x,
|
||||
get_y_size() - y,
|
||||
get_z_size() - z);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: Texture::consider_rescale
|
||||
// Access: Private
|
||||
@ -3893,3 +3915,4 @@ operator << (ostream &out, Texture::CompressionMode cm) {
|
||||
|
||||
return out << "(**invalid Texture::CompressionMode(" << (int)cm << ")**)";
|
||||
}
|
||||
|
||||
|
@ -350,6 +350,7 @@ PUBLISHED:
|
||||
INLINE int get_pad_z_size() const;
|
||||
|
||||
INLINE void set_pad_size(int x=0, int y=0, int z=0);
|
||||
void set_size_padded(int x=1, int y=1, int z=1);
|
||||
|
||||
void set_format(Format format);
|
||||
void set_component_type(ComponentType component_type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user