Added the start of support for NPOT textures

This commit is contained in:
Josh Yelon 2006-02-18 05:25:53 +00:00
parent 4535cdfbba
commit c7853c8c71
4 changed files with 26 additions and 4 deletions

View File

@ -345,6 +345,17 @@ get_supports_cube_map() const {
return _supports_cube_map;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::get_supports_tex_non_pow2
// Access: Published
// Description: Returns true if this GSG can handle non power of two
// sized textures.
////////////////////////////////////////////////////////////////////
INLINE bool GraphicsStateGuardian::
get_supports_tex_non_pow2() const {
return _supports_tex_non_pow2;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsStateGuardian::get_max_lights
// Access: Published

View File

@ -132,7 +132,8 @@ GraphicsStateGuardian(const FrameBufferProperties &properties,
_supports_3d_texture = false;
_supports_cube_map = false;
_supports_tex_non_pow2 = false;
// Assume no limits on number of lights or clip planes.
_max_lights = -1;
_max_clip_planes = -1;

View File

@ -96,6 +96,7 @@ PUBLISHED:
INLINE bool get_supports_3d_texture() const;
INLINE bool get_supports_cube_map() const;
INLINE bool get_supports_tex_non_pow2() const;
INLINE int get_max_lights() const;
INLINE int get_max_clip_planes() const;
@ -336,6 +337,7 @@ protected:
bool _supports_3d_texture;
bool _supports_cube_map;
bool _supports_tex_non_pow2;
int _max_lights;
int _max_clip_planes;

View File

@ -472,6 +472,9 @@ reset() {
_supports_multitexture = false;
_supports_tex_non_pow2 =
has_extension("GL_ARB_texture_non_power_of_two");
if (is_at_least_version(1, 3)) {
_supports_multitexture = true;
@ -2443,9 +2446,14 @@ framebuffer_copy_to_texture(Texture *tex, int z, const DisplayRegion *dr,
int xo, yo, w, h;
dr->get_region_pixels(xo, yo, w, h);
tex->set_x_size(Texture::up_to_power_2(w));
tex->set_y_size(Texture::up_to_power_2(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));
}
// Sanity check everything.
if (z >= 0) {
if (!_supports_cube_map) {