diff --git a/panda/src/display/graphicsStateGuardian.I b/panda/src/display/graphicsStateGuardian.I index fbbf760cc1..b266abc397 100644 --- a/panda/src/display/graphicsStateGuardian.I +++ b/panda/src/display/graphicsStateGuardian.I @@ -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 diff --git a/panda/src/display/graphicsStateGuardian.cxx b/panda/src/display/graphicsStateGuardian.cxx index 5d2dde2a26..a4bfbe9a2f 100644 --- a/panda/src/display/graphicsStateGuardian.cxx +++ b/panda/src/display/graphicsStateGuardian.cxx @@ -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; diff --git a/panda/src/display/graphicsStateGuardian.h b/panda/src/display/graphicsStateGuardian.h index 4a20e75eb5..c24e65badc 100644 --- a/panda/src/display/graphicsStateGuardian.h +++ b/panda/src/display/graphicsStateGuardian.h @@ -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; diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index a0a0eca43f..bd330b9a39 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -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) {