Added support for internalTextureMode

This commit is contained in:
Robert Osfield 2005-02-01 10:38:08 +00:00
parent 1cc89ba4fe
commit e668acce27
2 changed files with 67 additions and 56 deletions

View File

@ -14,13 +14,12 @@
#define VERSION_0004 4 #define VERSION_0004 4
#define VERSION_0005 5 #define VERSION_0005 5
#define VERSION_0006 6 #define VERSION_0006 6
/* Version 7 adds read/write of the DatabasePath to the
PagedLOD node (OSG 0.9.8) */
#define VERSION_0007 7 #define VERSION_0007 7
#define VERSION_0008 8
#define VERSION VERSION_0007
#define VERSION VERSION_0008
/* The BYTE_SEX tag is used to check the endian /* The BYTE_SEX tag is used to check the endian

View File

@ -1,15 +1,15 @@
/********************************************************************** /**********************************************************************
* *
* FILE: Texture.cpp * FILE: Texture.cpp
* *
* DESCRIPTION: Read/Write osg::Texture in binary format to disk. * DESCRIPTION: Read/Write osg::Texture in binary format to disk.
* *
* CREATED BY: Auto generated by iveGenerated * CREATED BY: Auto generated by iveGenerated
* and later modified by Rune Schmidt Jensen. * and later modified by Rune Schmidt Jensen.
* *
* HISTORY: Created 20.3.2003 * HISTORY: Created 20.3.2003
* *
* Copyright 2003 VR-C * Copyright 2003 VR-C
**********************************************************************/ **********************************************************************/
#include "Exception.h" #include "Exception.h"
@ -19,61 +19,73 @@
using namespace ive; using namespace ive;
void Texture::write(DataOutputStream* out){ void Texture::write(DataOutputStream* out){
// Write Texture's identification. // Write Texture's identification.
out->writeInt(IVETEXTURE); out->writeInt(IVETEXTURE);
// If the osg class is inherited by any other class we should also write this to file. // If the osg class is inherited by any other class we should also write this to file.
osg::Object* obj = dynamic_cast<osg::Object*>(this); osg::Object* obj = dynamic_cast<osg::Object*>(this);
if(obj){ if(obj)
((ive::Object*)(obj))->write(out); {
} ((ive::Object*)(obj))->write(out);
else }
throw Exception("Texture::write(): Could not cast this osg::Texture to an osg::Object."); else
// Write Texture's properties. throw Exception("Texture::write(): Could not cast this osg::Texture to an osg::Object.");
out->writeInt(_wrap_s);
out->writeInt(_wrap_t);
out->writeInt(_wrap_r);
out->writeInt(_min_filter); // Write Texture's properties.
out->writeInt(_mag_filter); out->writeInt(_wrap_s);
out->writeFloat(_maxAnisotropy); out->writeInt(_wrap_t);
out->writeInt(_wrap_r);
out->writeVec4(_borderColor); out->writeInt(_min_filter);
out->writeInt(_mag_filter);
out->writeFloat(_maxAnisotropy);
out->writeInt(_internalFormatMode); out->writeVec4(_borderColor);
// out->writeInt(_internalFormat); out->writeInt(_internalFormatMode);
if ( out->getVersion() >= VERSION_0008 )
{
out->writeInt(_internalFormat);
}
} }
void Texture::read(DataInputStream* in){ void Texture::read(DataInputStream* in)
// Read Texture's identification. {
int id = in->peekInt(); // Read Texture's identification.
if(id == IVETEXTURE){ int id = in->peekInt();
// Read Texture's identification. if(id == IVETEXTURE)
id = in->readInt(); {
// If the osg class is inherited by any other class we should also read this from file. // Read Texture's identification.
osg::Object* obj = dynamic_cast<osg::Object*>(this); id = in->readInt();
if(obj){ // If the osg class is inherited by any other class we should also read this from file.
((ive::Object*)(obj))->read(in); osg::Object* obj = dynamic_cast<osg::Object*>(this);
} if(obj)
else {
throw Exception("Texture::read(): Could not cast this osg::Texture to an osg::Object."); ((ive::Object*)(obj))->read(in);
}
else
throw Exception("Texture::read(): Could not cast this osg::Texture to an osg::Object.");
// Read properties // Read properties
_wrap_s = (osg::Texture::WrapMode)in->readInt(); _wrap_s = (osg::Texture::WrapMode)in->readInt();
_wrap_t = (osg::Texture::WrapMode)in->readInt();; _wrap_t = (osg::Texture::WrapMode)in->readInt();
_wrap_r = (osg::Texture::WrapMode)in->readInt();; _wrap_r = (osg::Texture::WrapMode)in->readInt();
_min_filter = (osg::Texture::FilterMode)in->readInt();; _min_filter = (osg::Texture::FilterMode)in->readInt();
_mag_filter = (osg::Texture::FilterMode)in->readInt();; _mag_filter = (osg::Texture::FilterMode)in->readInt();
_maxAnisotropy = in->readFloat();; _maxAnisotropy = in->readFloat();
_borderColor = in->readVec4();; _borderColor = in->readVec4();
_internalFormatMode = (osg::Texture::InternalFormatMode)in->readInt();; _internalFormatMode = (osg::Texture::InternalFormatMode)in->readInt();
// _internalFormat = in->readInt();; if ( in->getVersion() >= VERSION_0008 )
{
_internalFormat = in->readInt();
}
} }
else{ else
throw Exception("Texture::read(): Expected Texture identification."); {
} throw Exception("Texture::read(): Expected Texture identification.");
}
} }