mirror of
https://github.com/edubart/otclient.git
synced 2025-10-19 05:53:26 +02:00
ui and graphics changes
* implement draw clipping using opengl stencil buffers * allow to create Widgets by style name with g_ui.createWidgetByStyle * styles can now have children widgets * make proper use of the isNotPathable in pathfinding * add scrollbar skin
This commit is contained in:
@@ -49,6 +49,7 @@ void Graphics::init()
|
||||
#endif
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
m_emptyTexture = TexturePtr(new Texture);
|
||||
|
||||
@@ -113,6 +114,29 @@ void Graphics::endRender()
|
||||
{
|
||||
}
|
||||
|
||||
void Graphics::beginClipping(const Rect& clipRect)
|
||||
{
|
||||
// setup stencil buffer for writing
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
glStencilFunc(GL_ALWAYS, 1, 1);
|
||||
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
|
||||
|
||||
// draw the clipping area into the stencil buffer
|
||||
glColorMask(0, 0, 0, 0);
|
||||
g_painter.drawFilledRect(clipRect);
|
||||
|
||||
// set stencil buffer for clippig
|
||||
glColorMask(1, 1, 1, 1);
|
||||
glStencilFunc(GL_EQUAL, 1, 1);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
|
||||
}
|
||||
|
||||
void Graphics::endClipping()
|
||||
{
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
void Graphics::setViewportSize(const Size& size)
|
||||
{
|
||||
glViewport(0, 0, size.width(), size.height());
|
||||
|
@@ -44,6 +44,9 @@ public:
|
||||
void beginRender();
|
||||
void endRender();
|
||||
|
||||
void beginClipping(const Rect& clipRect);
|
||||
void endClipping();
|
||||
|
||||
void setViewportSize(const Size& size);
|
||||
|
||||
int getMaxTextureSize();
|
||||
|
Reference in New Issue
Block a user