summaryrefslogtreecommitdiffstats
path: root/src/graphicsitems/nodes/qxninepatchnode.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/graphicsitems/nodes/qxninepatchnode.cpp')
-rw-r--r--src/graphicsitems/nodes/qxninepatchnode.cpp156
1 files changed, 79 insertions, 77 deletions
diff --git a/src/graphicsitems/nodes/qxninepatchnode.cpp b/src/graphicsitems/nodes/qxninepatchnode.cpp
index e7bbe11..d92cf1c 100644
--- a/src/graphicsitems/nodes/qxninepatchnode.cpp
+++ b/src/graphicsitems/nodes/qxninepatchnode.cpp
@@ -101,82 +101,84 @@ void QxNinePatchNode::setLinearFiltering(bool linearFiltering)
void QxNinePatchNode::updateGeometry()
{
- Geometry *g = geometry();
- if (g->isNull()) {
- QVector<QGLAttributeDescription> desc;
- desc << QGLAttributeDescription(QGL::Position, 2, GL_FLOAT, 5 * sizeof(float));
- desc << QGLAttributeDescription(QGL::TextureCoord0, 2, GL_FLOAT, 5 * sizeof(float));
- updateGeometryDescription(desc, GL_UNSIGNED_SHORT);
- g->setVertexCount(6 * 6); // Grid of 6x6 vertices.
- g->setIndexCount(5 * 5 * 6); // Grid of 5x5 cells, 2 triangles per cell.
- g->setDrawingMode(QGL::Triangles);
-
- ushort *indices = g->ushortIndexData();
- int count = 0;
- for (int i = 0; i < 5; ++i) {
- int i6 = i * 6;
- for (int j = 0; j < 5; ++j) {
- indices[count++] = i6 + j + 0;
- indices[count++] = i6 + j + 6;
- indices[count++] = i6 + j + 7;
- indices[count++] = i6 + j + 7;
- indices[count++] = i6 + j + 1;
- indices[count++] = i6 + j + 0;
- }
- }
- }
-
- struct V
- {
- V(float x, float y, float u, float v) : x(x), y(y), u(u), v(v) { }
- float x, y, u, v;
- };
-
- V *vertices = (V *)g->vertexData();
-
- qreal x[6], y[6], u[6], v[6];
- QRectF texRect = m_texture->textureRect();
-
- x[0] = m_targetRect.x();
- x[1] = m_targetRect.x() + m_innerRect.x();
- x[2] = x[1] + 0.5;
- x[3] = m_targetRect.x() + m_targetRect.width() -
- (texRect.width() - (m_innerRect.x() + m_innerRect.width()));
- x[4] = x[3] - 0.5;
- x[5] = m_targetRect.x() + m_targetRect.width();
-
- y[0] = m_targetRect.y();
- y[1] = m_targetRect.y() + m_innerRect.y();
- y[2] = y[1] + 0.5;
- y[3] = m_targetRect.y() + m_targetRect.height() -
- (texRect.height() - (m_innerRect.y() + m_innerRect.height()));
- y[4] = y[3] - 0.5;
- y[5] = m_targetRect.y() + m_targetRect.height();
-
- qreal pw = texRect.width();
- qreal ph = texRect.height();
-
- QRectF src = texRect;
- u[0] = src.left();
- u[1] = src.left() + m_innerRect.x() / pw * src.width();
- u[2] = u[1] + 0.5 / pw * src.width();
- u[3] = src.left() + (m_innerRect.x() + m_innerRect.width()) / pw * src.width();
- u[4] = u[3] - 0.5 / pw * src.width();
- u[5] = src.right();
-
- v[0] = src.top();
- v[1] = src.top() + m_innerRect.y() / ph * src.height();
- v[2] = v[1] + 0.5 / ph * src.height();
- v[3] = src.top() + (m_innerRect.y() + m_innerRect.height()) / ph * src.height();
- v[4] = v[3] - 0.5 / ph * src.height();
- v[5] = src.bottom();
-
- for (int i = 0; i < 6; ++i) {
- for (int j = 0; j < 6; ++j)
- vertices[i * 6 + j] = V(x[j], y[i], u[j], v[i]);
- }
-
- setBoundingRect(m_targetRect);
- markDirty(Node::DirtyGeometry);
+ // ### Gunnar: port properly
+
+// Geometry *g = geometry();
+// if (g->isNull()) {
+// QVector<QGLAttributeDescription> desc;
+// desc << QGLAttributeDescription(QGL::Position, 2, GL_FLOAT, 5 * sizeof(float));
+// desc << QGLAttributeDescription(QGL::TextureCoord0, 2, GL_FLOAT, 5 * sizeof(float));
+// updateGeometryDescription(desc, GL_UNSIGNED_SHORT);
+// g->setVertexCount(6 * 6); // Grid of 6x6 vertices.
+// g->setIndexCount(5 * 5 * 6); // Grid of 5x5 cells, 2 triangles per cell.
+// g->setDrawingMode(QGL::Triangles);
+
+// ushort *indices = g->ushortIndexData();
+// int count = 0;
+// for (int i = 0; i < 5; ++i) {
+// int i6 = i * 6;
+// for (int j = 0; j < 5; ++j) {
+// indices[count++] = i6 + j + 0;
+// indices[count++] = i6 + j + 6;
+// indices[count++] = i6 + j + 7;
+// indices[count++] = i6 + j + 7;
+// indices[count++] = i6 + j + 1;
+// indices[count++] = i6 + j + 0;
+// }
+// }
+// }
+
+// struct V
+// {
+// V(float x, float y, float u, float v) : x(x), y(y), u(u), v(v) { }
+// float x, y, u, v;
+// };
+
+// V *vertices = (V *)g->vertexData();
+
+// qreal x[6], y[6], u[6], v[6];
+// QRectF texRect = m_texture->textureRect();
+
+// x[0] = m_targetRect.x();
+// x[1] = m_targetRect.x() + m_innerRect.x();
+// x[2] = x[1] + 0.5;
+// x[3] = m_targetRect.x() + m_targetRect.width() -
+// (texRect.width() - (m_innerRect.x() + m_innerRect.width()));
+// x[4] = x[3] - 0.5;
+// x[5] = m_targetRect.x() + m_targetRect.width();
+
+// y[0] = m_targetRect.y();
+// y[1] = m_targetRect.y() + m_innerRect.y();
+// y[2] = y[1] + 0.5;
+// y[3] = m_targetRect.y() + m_targetRect.height() -
+// (texRect.height() - (m_innerRect.y() + m_innerRect.height()));
+// y[4] = y[3] - 0.5;
+// y[5] = m_targetRect.y() + m_targetRect.height();
+
+// qreal pw = texRect.width();
+// qreal ph = texRect.height();
+
+// QRectF src = texRect;
+// u[0] = src.left();
+// u[1] = src.left() + m_innerRect.x() / pw * src.width();
+// u[2] = u[1] + 0.5 / pw * src.width();
+// u[3] = src.left() + (m_innerRect.x() + m_innerRect.width()) / pw * src.width();
+// u[4] = u[3] - 0.5 / pw * src.width();
+// u[5] = src.right();
+
+// v[0] = src.top();
+// v[1] = src.top() + m_innerRect.y() / ph * src.height();
+// v[2] = v[1] + 0.5 / ph * src.height();
+// v[3] = src.top() + (m_innerRect.y() + m_innerRect.height()) / ph * src.height();
+// v[4] = v[3] - 0.5 / ph * src.height();
+// v[5] = src.bottom();
+
+// for (int i = 0; i < 6; ++i) {
+// for (int j = 0; j < 6; ++j)
+// vertices[i * 6 + j] = V(x[j], y[i], u[j], v[i]);
+// }
+
+// setBoundingRect(m_targetRect);
+// markDirty(Node::DirtyGeometry);
}