Hi Art,
On 11/27/06, Art Tevs <[EMAIL PROTECTED]> wrote:
1. OpenGL 2.0 does support Texture2D with non-power of two sizes. Does
osg::Texture2D also support this?
Yes :-)
2. Should one call something else, when creating Texture from an image, like
this:
Image* img = osgDB::readImageFile(cachename);
Texture* tex = new Texutre2D();
tex->setImage(0, img);
// this line return 1536 1536
printf("Tex loaded: %d %d\n", img->s(), img->t());
// the line returns 0 0
printf("Tex loaded: %d %d\n", tex->getTextureWidth(),
tex->getTextureHeight());
I mean, I loaded the image from a png file. img is not null, so it is valid.
But texture seems not to be created properly
The texture objects isn't built straight away - which is why the sizes
are reported as zero. The texture size will be set correctly once
texture-apply(State&) is called from a valid graphics contexts.
Another caveat is that the default osg::Texture* will resize non power
of two textures even if OpenGL 2.0 is present - this is due to only
select hardware actually accelerating non power of two textures but
many drivers reporting OpenGL 2.0...
To control the NPOT resizing there is a hint in osg::Texture :
/** Sets whether to force the texture to resize images that
have dimensions
* that are not a power of two. If enabled, NPOT images will
be resized,
* whether or not NPOT textures are supported by the
hardware. If disabled,
* NPOT images will not be resized if supported by hardware. */
inline void setResizeNonPowerOfTwoHint(bool flag) {
_resizeNonPowerOfTwoHint = flag; }
So you'd do:
texture->setResizeNonPowerOfTwoHint(false);
3. How can one retrieve the id of a texture?
Ooo do you really need to know? The OSG should handle this all for
you, most users should never need to check it. Be warned that the
texture objects are multi-buffered, so there won't be just one per
Texture, but one per graphics context. Any have a look inside
include/osg/Texture if you really really need it.
Robert.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/