mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
publish Textures::up/down_to_power_2()
This commit is contained in:
parent
aca2606187
commit
86409f66e4
@ -1530,6 +1530,36 @@ prepare_now(PreparedGraphicsObjects *prepared_objects,
|
|||||||
return tc;
|
return tc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Texture::up_to_power_2
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Returns the smallest power of 2 greater than or equal
|
||||||
|
// to value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
int Texture::
|
||||||
|
up_to_power_2(int value) {
|
||||||
|
if (value <= 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int bit = get_next_higher_bit(((unsigned int)value) - 1);
|
||||||
|
return (1 << bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: Texture::down_to_power_2
|
||||||
|
// Access: Published, Static
|
||||||
|
// Description: Returns the largest power of 2 less than or equal
|
||||||
|
// to value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
int Texture::
|
||||||
|
down_to_power_2(int value) {
|
||||||
|
if (value <= 1) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
int bit = get_next_higher_bit(((unsigned int)value) >> 1);
|
||||||
|
return (1 << bit);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Texture::texture_uploaded
|
// Function: Texture::texture_uploaded
|
||||||
@ -1660,36 +1690,6 @@ make_texture() {
|
|||||||
return new Texture;
|
return new Texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: Texture::up_to_power_2
|
|
||||||
// Access: Public, Static
|
|
||||||
// Description: Returns the smallest power of 2 greater than or equal
|
|
||||||
// to value.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
int Texture::
|
|
||||||
up_to_power_2(int value) {
|
|
||||||
int x = 1;
|
|
||||||
while (x < value) {
|
|
||||||
x = (x << 1);
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: Texture::down_to_power_2
|
|
||||||
// Access: Public, Static
|
|
||||||
// Description: Returns the largest power of 2 less than or equal
|
|
||||||
// to value.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
int Texture::
|
|
||||||
down_to_power_2(int value) {
|
|
||||||
int x = 1;
|
|
||||||
while ((x << 1) <= value) {
|
|
||||||
x = (x << 1);
|
|
||||||
}
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: Texture::is_specific
|
// Function: Texture::is_specific
|
||||||
// Access: Public, Static
|
// Access: Public, Static
|
||||||
|
@ -424,6 +424,9 @@ PUBLISHED:
|
|||||||
TextureContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
TextureContext *prepare_now(PreparedGraphicsObjects *prepared_objects,
|
||||||
GraphicsStateGuardianBase *gsg);
|
GraphicsStateGuardianBase *gsg);
|
||||||
|
|
||||||
|
static int up_to_power_2(int value);
|
||||||
|
static int down_to_power_2(int value);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void texture_uploaded(GraphicsStateGuardianBase *gsg);
|
void texture_uploaded(GraphicsStateGuardianBase *gsg);
|
||||||
|
|
||||||
@ -436,9 +439,6 @@ public:
|
|||||||
static PT(Texture) make_texture();
|
static PT(Texture) make_texture();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static int up_to_power_2(int value);
|
|
||||||
static int down_to_power_2(int value);
|
|
||||||
|
|
||||||
static bool is_specific(CompressionMode compression);
|
static bool is_specific(CompressionMode compression);
|
||||||
static bool has_alpha(Format format);
|
static bool has_alpha(Format format);
|
||||||
static bool has_binary_alpha(Format format);
|
static bool has_binary_alpha(Format format);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user