root/OpenSceneGraph/trunk/src/osgPlugins/ive/Texture2D.cpp @ 13041

Revision 13041, 1.9 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/**********************************************************************
2 *
3 *    FILE:            Texture2D.cpp
4 *
5 *    DESCRIPTION:    Read/Write osg::Texture2D 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 "Texture2D.h"
17#include "Texture.h"
18#include "Image.h"
19
20using namespace ive;
21
22void Texture2D::write(DataOutputStream* out){
23    // Write Texture2D's identification.
24    out->writeInt(IVETEXTURE2D);
25    // If the osg class is inherited by any other class we should also write this to file.
26    osg::Texture*  tex = dynamic_cast<osg::Texture*>(this);
27    if(tex){
28        ((ive::Texture*)(tex))->write(out);
29    }
30    else
31        out_THROW_EXCEPTION("Texture2D::write(): Could not cast this osg::Texture2D to an osg::Texture.");
32    // Write Texture2D's properties.
33    // Write image.
34
35    // Should we include images date in stream
36    out->writeImage(getImage());
37}
38
39void Texture2D::read(DataInputStream* in){
40    // Read Texture2D's identification.
41    int id = in->peekInt();
42    if(id == IVETEXTURE2D){
43        // Code to read Texture2D's properties.
44        id = in->readInt();
45        // If the osg class is inherited by any other class we should also read this from file.
46        osg::Texture*  tex = dynamic_cast<osg::Texture*>(this);
47        if(tex){
48            ((ive::Texture*)(tex))->read(in);
49        }
50        else
51            in_THROW_EXCEPTION("Texture2D::read(): Could not cast this osg::Texture2D to an osg::Texture.");
52        // Read image.
53
54        osg::Image *image = in->readImage();
55        if(image) {
56            setImage(image);
57        }
58    }
59    else{
60        in_THROW_EXCEPTION("Texture2D::read(): Expected Texture2D identification.");
61    }
62}
Note: See TracBrowser for help on using the browser.