Hi!
I would like to hide the part of the component which is outside its parent by it doesn’t work.
Here is my fragment shader code :
"#version 130
"
"uniform vec2 winSize;"
"uniform vec2 componentSize;"
"uniform vec2 componentPos;"
"void main() {"
" vec4 colors[2];"
" colors[0] = vec4(0, 0, 0, 0);"
" colors[1] = gl_Color;"
" bool b = gl_FragCoord.x >= componentPos.x"
"&& winSize.y - gl_FragCoord.y >= winSize.y - componentPos.y"
"&& gl_FragCoord.x <= componentPos.x + componentSize.x"
"&& winSize.y - gl_FragCoord.y <= winSize.y - (componentPos.y + componentSize.y);"
" gl_FragColor = colors[int(b)];"
"}"
The pixels outside the parent component are still visible.
[code=cpp]
shadScissor->setParameter(“winSize”,getWindow().getSize().x, getWindow().getSize().y);
shadScissor->setParameter(“componentPos”, getPosition().x, getPosition().y);
shadScissor->setParameter(“componentSize”,getSize().x,getSize().y);
states.shader = shadScissor.get();
onDraw(target, states);
std::multimap<int, LightComponent*, std::greater> sortedChildren;
for (unsigned int i = 0; i < children.size(); i++) {
sortedChildren.insert(std::make_pair(children[i]->getPriority(), children[i].get()));
}
std::multimap<int, LightComponent*, std::greater>::iterator it;
for (it = sortedChildren.begin(); it != sortedChildren.end(); it++) {
if (it->second->isVisible()
&& it->second->getPosition().x + it->second->getSize().x >= getPosition().x
&& it->second->getPosition().y + it->second->getSize().y >= getPosition().y
&& it->second->getPosition().x <= getPosition().x + getSize().x
&& it->second->getPosition().y <= getPosition().y + getSize().y) {
it->second->draw(target, states);
}
}
drawOn(target, states);