[osg-users] How to render the image without reducing its size.?

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Tue Nov 22 05:11:08 PST 2016


Hi Uma,

you can use TextureRectangle instead of Texture2D. Then your UV mapping is
in the range of s:0-imageWidth, t:0-imageHeight and the image will preserve
its original size

On Tue, Nov 22, 2016 at 2:06 PM, Christian Buchner <
christian.buchner at gmail.com> wrote:

>
> Your OpenGL implementation might signal a maximum texture size of 4096.
>
> Which is why there is no alternative to downsizing it.
>
> There is also an OSG_MAX_TEXTURE_SIZE environment variable. I am not sure
> what its default value is, or if it has a default at all. Have you tried
> forcing this to 8192?
>
> Christian
>
>
>
> 2016-11-22 13:58 GMT+01:00 Uma Devi Selvaraj <umaselvam1503 at gmail.com>:
>
>> Hi,
>>
>>    I have simple code that renders image using osgviewer. I am able to
>> render the image successfully with the code. My problem now is the size of
>> the image is reduced. for example the original size of the image is 4683 *
>> 3035, the image is reduced to 4096 * 3035. Is this expected behaviour or is
>> there anything I need to add in my code. I have added my code.
>>
>>
>> //required header files
>>
>> int main(int argc,char**argv)
>> {
>>
>>         osg::ref_ptr<osg::Image> image;
>>     image = osgDB::readImageFile("C:\\Users\\mcw\\Desktop\\DemModel.tif.
>> gdal");
>>         std::cout << "Image info are " << image->s() << "\n" <<image->t()
>> <<"\n" <<image->r() << std::endl;
>>         if (!(image.valid()))
>>         {
>>                 std::cout << "Unable to read image file " << std::endl;
>>                 getchar();
>>                 return 0;
>>         }
>>
>>         osg::ref_ptr<osg::Geode> geode =(osg::createGeodeForImage(ima
>> ge));
>>
>>         osg::Texture2D *texture = new osg::Texture2D();
>>         texture->setFilter(osg::Texture::MIN_FILTER,
>> osg::Texture::LINEAR);
>>         texture->setFilter(osg::Texture::MAG_FILTER,
>> osg::Texture::LINEAR);
>>         texture->setWrap(osg::Texture::WRAP_R, osg::Texture::REPEAT);
>>         texture->setResizeNonPowerOfTwoHint(false);
>>         texture->setImage(image);
>>         texture->setBorderColor(osg::Vec4d(0.4f, 0.5f, 0.6f, 1.0f));
>>         osg::StateSet* stateset = new osg::StateSet;
>>
>>         stateset->setTextureAttributeAndModes(0, texture,
>> osg::StateAttribute::ON);
>>
>>         geode->setStateSet(stateset);
>>         osgViewer::Viewer viewer;
>>         viewer.setSceneData(geode.get());
>>         getchar();
>>         return viewer.run();
>>
>> }
>>
>> ...
>>
>> Thank you!
>>
>> Cheers,
>> Uma
>>
>> ------------------
>> Read this topic online here:
>> http://forum.openscenegraph.org/viewtopic.php?p=69470#69470
>>
>>
>>
>>
>>
>> _______________________________________________
>> osg-users mailing list
>> osg-users at lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>


-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161122/6cc2be6d/attachment-0003.htm>


More information about the osg-users mailing list