Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///////////////////////////////////////////////////////////////////////////////
- void Widget::Draw(int nesting) {
- if(!mAlreadyRendered) {
- if(IsVisible()) {
- auto parent = mParent.lock();
- if(parent) {
- GLCall(glStencilFunc(GL_EQUAL, nesting, 0xFF));
- GLCall(glStencilOp(GL_KEEP, GL_KEEP, GL_INCR));
- } else {
- GLCall(glStencilFunc(GL_ALWAYS, 1, 0xFF));
- GLCall(glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE));
- }
- CalculateGlobalPosition();
- PrepareVertices();
- auto label = dynamic_pointer_cast<Label>(shared_from_this());
- if(label) {
- if(label->GetFont()) {
- GLCall(glBindTexture(GL_TEXTURE_2D, label->GetFont()->getTexture(label->GetCharacterSize()).getNativeHandle()));
- }
- } else {
- if(mTexture) {
- GLCall(glBindTexture(GL_TEXTURE_2D, mTexture->mGLTexture));
- }
- }
- if(mVertices.size()) {
- const char* data = reinterpret_cast<const char*>(&mVertices[0]);
- GLCall(glVertexPointer(2, GL_FLOAT, sizeof(sf::Vertex), data + offsetof(sf::Vertex, position)));
- GLCall(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(sf::Vertex), data + offsetof(sf::Vertex, color)));
- GLCall(glTexCoordPointer(2, GL_FLOAT, sizeof(sf::Vertex), data + offsetof(sf::Vertex, texCoords)));
- GLCall(glDrawArrays(GL_QUADS, 0, mVertices.size()));
- }
- for(auto & child : mChildren) {
- child->Draw(nesting + 1);
- }
- mAlreadyRendered = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement