From fd016af34b03de2e0c0e890a773580af2922ddf0 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 29 Oct 2003 23:10:11 +0000 Subject: [PATCH] Added support for 565 textures to osgbluemarble. Added a osg::Image::scaleImage() version which allows the datatype to be varied. --- examples/osgbluemarble/osgbluemarble.cpp | 2 +- include/osg/Image | 5 ++++- src/osg/Image.cpp | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/osgbluemarble/osgbluemarble.cpp b/examples/osgbluemarble/osgbluemarble.cpp index 13ffc24f5..44ded5fcd 100644 --- a/examples/osgbluemarble/osgbluemarble.cpp +++ b/examples/osgbluemarble/osgbluemarble.cpp @@ -102,7 +102,7 @@ osg::Node* createTile(const std::string& filename, bool leftHemisphere, double x } else if (use565) { - image->scaleImage(image->r(),image->s(),image->t(),GL_UNSIGNED_SHORT_5_6_5); + image->scaleImage(image->s(),image->t(),image->r(),GL_UNSIGNED_SHORT_5_6_5); } diff --git a/include/osg/Image b/include/osg/Image index 45b7dd716..349ed3a4f 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -110,7 +110,10 @@ class SG_EXPORT Image : public Object /** Scale image to specified size. */ - void scaleImage(int s,int t,int r); + void scaleImage(int s,int t,int r) { scaleImage(s,t,r, getDataType()); } + + /** Scale image to specified size and with specified data type. */ + void scaleImage(int s,int t,int r, GLenum newDataType); /** Copy a source Image into a subpart of this Image at specified position. * Typically used to copy to an already allocated image, such as creating diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 9afd7a8a5..23f992beb 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -426,7 +426,7 @@ void Image::readImageFromCurrentTexture(unsigned int contextID) } -void Image::scaleImage(int s,int t,int r) +void Image::scaleImage(int s,int t,int r, GLenum newDataType) { if (_s==s && _t==t && _r==r) return; @@ -444,7 +444,7 @@ void Image::scaleImage(int s,int t,int r) - unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,_dataType,_packing)*t; + unsigned int newTotalSize = computeRowWidthInBytes(s,_pixelFormat,newDataType,_packing)*t; // need to sort out what size to really use... unsigned char* newData = new unsigned char [newTotalSize]; @@ -465,7 +465,7 @@ void Image::scaleImage(int s,int t,int r) _data, s, t, - _dataType, + newDataType, newData); if (status==0) @@ -474,6 +474,7 @@ void Image::scaleImage(int s,int t,int r) // free old image. _s = s; _t = t; + _dataType = newDataType; setData(newData,USE_NEW_DELETE); } else