summaryrefslogtreecommitdiff
path: root/lyt/materials/texmap.cpp
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2010-10-07 15:56:13 +0200
committerTreeki <treeki@gmail.com>2010-10-07 15:56:13 +0200
commit5f6dad55d75cbe146ff7fefc899a02ccd39078ba (patch)
tree0822df14cc6d2c0329810c9ae7b4a4a638fe82b1 /lyt/materials/texmap.cpp
downloadLayoutStudio-5f6dad55d75cbe146ff7fefc899a02ccd39078ba.tar.gz
LayoutStudio-5f6dad55d75cbe146ff7fefc899a02ccd39078ba.zip
initial commit -- everything compiles except for material.cpp. the material system still needs quite a bit of work; this will come in due time
Diffstat (limited to 'lyt/materials/texmap.cpp')
-rw-r--r--lyt/materials/texmap.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/lyt/materials/texmap.cpp b/lyt/materials/texmap.cpp
new file mode 100644
index 0000000..1bb416b
--- /dev/null
+++ b/lyt/materials/texmap.cpp
@@ -0,0 +1,41 @@
+#include "texmap.h"
+#include "../layout.h"
+
+LYTTexMap::LYTTexMap() {
+}
+
+void LYTTexMap::dumpToDebug() {
+ qDebug() << "LYTTexMap @" << (void*)this << ":" << textureName;
+ qDebug() << "- wrap_s:" << wrap_s << "- wrap_t:" << wrap_t;
+ qDebug() << "- mag_filter:" << mag_filter << "- min_filter:" << min_filter;
+}
+
+
+void LYTTexMap::writeToDataStream(QDataStream &out, LYTLayout &layout) {
+ quint16 texNum = layout.m_textureRefs.indexOf(textureName);
+ out << (quint16)texNum;
+
+ quint8 var1, var2;
+ var1 = wrap_s | (((min_filter + 7) & 7) << 2);
+ var2 = wrap_t | (((mag_filter + 1) & 1) << 2);
+ out << (quint8)var1;
+ out << (quint8)var2;
+}
+
+
+void LYTTexMap::readFromDataStream(QDataStream &in, LYTLayout &layout) {
+ quint16 texNum;
+ in >> (quint16&)texNum;
+
+ textureName = layout.m_textureRefs[texNum];
+
+ quint8 var1, var2;
+ in >> (quint8&)var1;
+ in >> (quint8&)var2;
+
+ wrap_s = BitExtract(var1, 2, 30);
+ wrap_t = BitExtract(var2, 2, 30);
+
+ min_filter = (BitExtract(var1, 3, 27) + 1) & 7;
+ mag_filter = (BitExtract(var2, 1, 29) + 1) & 1;
+}