void DivNode::renderOutlines(const VertexArrayPtr& pVA, Pixel32 color) { Pixel32 effColor = color; if (m_ElementOutlineColor != Pixel32(0,0,0,0)) { effColor = m_ElementOutlineColor; effColor.setA(128); } if (effColor != Pixel32(0,0,0,0)) { glm::vec2 size = getSize(); if (size == glm::vec2(DEFAULT_SIZE, DEFAULT_SIZE)) { glm::vec2 p0 = getAbsPos(glm::vec2(-4, 0.5)); glm::vec2 p1 = getAbsPos(glm::vec2(5, 0.5)); glm::vec2 p2 = getAbsPos(glm::vec2(0.5, -4)); glm::vec2 p3 = getAbsPos(glm::vec2(0.5, 5)); pVA->addLineData(effColor, p0, p1, 1); pVA->addLineData(effColor, p2, p3, 1); } else { glm::vec2 p0 = getAbsPos(glm::vec2(0.5, 0.5)); glm::vec2 p1 = getAbsPos(glm::vec2(size.x+0.5,0.5)); glm::vec2 p2 = getAbsPos(glm::vec2(size.x+0.5,size.y+0.5)); glm::vec2 p3 = getAbsPos(glm::vec2(0.5,size.y+0.5)); pVA->addLineData(effColor, p0, p1, 1); pVA->addLineData(effColor, p1, p2, 1); pVA->addLineData(effColor, p2, p3, 1); pVA->addLineData(effColor, p3, p0, 1); } } for (unsigned i = 0; i < getNumChildren(); i++) { getChild(i)->renderOutlines(pVA, effColor); } }
void PolygonNode::calcFillVertexes(const VertexDataPtr& pVertexData, Pixel32 color) { if (getNumDifferentPts(m_Pts) < 3) { return; } // Remove duplicate points vector<glm::vec2> pts; vector<unsigned int> holeIndexes; pts.reserve(m_Pts.size()); if (glm::distance2(m_Pts[0], m_Pts[m_Pts.size()-1]) > 0.1) { pts.push_back(m_Pts[0]); } for (unsigned i = 1; i < m_Pts.size(); ++i) { if (glm::distance2(m_Pts[i], m_Pts[i-1]) > 0.1) { pts.push_back(m_Pts[i]); } } if (m_Holes.size() > 0) { for (unsigned int i = 0; i < m_Holes.size(); i++) { //loop over collection holeIndexes.push_back(pts.size()); for (unsigned int j = 0; j < m_Holes[i].size(); j++) { //loop over vector pts.push_back(m_Holes[i][j]); } } } if (color.getA() > 0) { glm::vec2 minCoord = pts[0]; glm::vec2 maxCoord = pts[0]; for (unsigned i = 1; i < pts.size(); ++i) { if (pts[i].x < minCoord.x) { minCoord.x = pts[i].x; } if (pts[i].x > maxCoord.x) { maxCoord.x = pts[i].x; } if (pts[i].y < minCoord.y) { minCoord.y = pts[i].y; } if (pts[i].y > maxCoord.y) { maxCoord.y = pts[i].y; } } vector<unsigned int> triIndexes; triangulatePolygon(triIndexes, pts, holeIndexes); for (unsigned i = 0; i < pts.size(); ++i) { glm::vec2 texCoord = calcFillTexCoord(pts[i], minCoord, maxCoord); pVertexData->appendPos(pts[i], texCoord, color); } for (unsigned i = 0; i < triIndexes.size(); i+=3) { pVertexData->appendTriIndexes(triIndexes[i], triIndexes[i+1], triIndexes[i+2]); } } }
void GLShaderParamTemplate<Pixel32>::uniformSet(unsigned location, const Pixel32& val) { glproc::Uniform4f(location, val.getR()/255.f, val.getG()/255.f, val.getB()/255.f, val.getA()/255.f); }
void ColorNode::render(GLContext* pContext, const glm::mat4& transform) { glClearColor(m_Color.getR()/255.f, m_Color.getG()/255.f, m_Color.getB()/255.f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); }