root/OpenSceneGraph/trunk/src/osgPlugins/ive/Texture.cpp @ 10762

Revision 10762, 3.5 kB (checked in by robert, 4 years ago)

Converted .ive plugin from using C++ exceptions to using a local equivelant, enabling the build on embedded systems.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            Texture.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Texture in binary format to disk.
6 *
7 *    CREATED BY:        Auto generated by iveGenerated
8 *                    and later modified by Rune Schmidt Jensen.
9 *
10 *    HISTORY:        Created 20.3.2003
11 *
12 *    Copyright 2003 VR-C
13 **********************************************************************/
14
15#include "Exception.h"
16#include "Texture.h"
17#include "Object.h"
18
19using namespace ive;
20
21void Texture::write(DataOutputStream* out){
22    // Write Texture's identification.
23    out->writeInt(IVETEXTURE);
24    // If the osg class is inherited by any other class we should also write this to file.
25    osg::Object*  obj = dynamic_cast<osg::Object*>(this);
26    if(obj)
27    {
28        ((ive::Object*)(obj))->write(out);
29    }
30    else
31        out_THROW_EXCEPTION("Texture::write(): Could not cast this osg::Texture to an osg::Object.");
32
33    // Write Texture's properties.
34    out->writeInt(_wrap_s);
35    out->writeInt(_wrap_t);
36    out->writeInt(_wrap_r);
37
38    out->writeInt(_min_filter);
39    out->writeInt(_mag_filter);
40    out->writeFloat(_maxAnisotropy);
41
42    out->writeVec4(_borderColor);
43
44    out->writeInt(_internalFormatMode);
45   
46    if ( out->getVersion() >= VERSION_0008 )
47    {
48        out->writeInt(_internalFormat);
49    }
50
51    if ( out->getVersion() >= VERSION_0009 )
52    {
53        out->writeInt(_borderWidth);
54        out->writeBool(_useHardwareMipMapGeneration);
55        out->writeBool(_unrefImageDataAfterApply);
56        out->writeBool(_clientStorageHint);
57        out->writeBool(_resizeNonPowerOfTwoHint);
58    }
59   
60    if ( out->getVersion() >= VERSION_0014 )
61    {
62        out->writeInt(_sourceFormat);
63        out->writeInt(_sourceType);
64    }
65}
66
67void Texture::read(DataInputStream* in)
68{
69    // Read Texture's identification.
70    int id = in->peekInt();
71    if(id == IVETEXTURE)
72    {
73        // Read Texture's identification.
74        id = in->readInt();
75        // If the osg class is inherited by any other class we should also read this from file.
76        osg::Object*  obj = dynamic_cast<osg::Object*>(this);
77        if(obj)
78        {
79            ((ive::Object*)(obj))->read(in);
80        }
81        else
82            in_THROW_EXCEPTION("Texture::read(): Could not cast this osg::Texture to an osg::Object.");
83
84        // Read properties
85        _wrap_s = (osg::Texture::WrapMode)in->readInt();
86        _wrap_t = (osg::Texture::WrapMode)in->readInt();
87        _wrap_r = (osg::Texture::WrapMode)in->readInt();
88
89        _min_filter = (osg::Texture::FilterMode)in->readInt();
90        _mag_filter = (osg::Texture::FilterMode)in->readInt();
91        _maxAnisotropy = in->readFloat();
92
93        _borderColor = in->readVec4();
94
95        _internalFormatMode = (osg::Texture::InternalFormatMode)in->readInt();
96        if ( in->getVersion() >= VERSION_0008 )
97        {
98            _internalFormat = in->readInt();
99        }
100
101        if ( in->getVersion() >= VERSION_0009 )
102        {
103            _borderWidth = in->readInt();
104            _useHardwareMipMapGeneration = in->readBool();
105            _unrefImageDataAfterApply = in->readBool();
106            _clientStorageHint = in->readBool();
107            _resizeNonPowerOfTwoHint = in->readBool();
108        }
109
110        if ( in->getVersion() >= VERSION_0014 )
111        {
112            _sourceFormat = in->readInt();
113            _sourceType = in->readInt();
114        }
115    }
116    else
117    {
118        in_THROW_EXCEPTION("Texture::read(): Expected Texture identification.");
119    }
120}
Note: See TracBrowser for help on using the browser.