@@ -122,6 +122,7 @@ struct DrawContext {
122
122
uint32_t meshOffset = 0 ;
123
123
Geometry::Vec2i position,screenSize;
124
124
Geometry::Rect_i scissor;
125
+ Geometry::Vec2 scale;
125
126
126
127
RenderingContext* rc;
127
128
Util::Reference<Shader> shader;
@@ -149,6 +150,7 @@ struct DrawContext {
149
150
uint32_t meshOffset = 0 ;
150
151
Geometry::Vec2i position,screenSize;
151
152
Geometry::Rect_i scissor;
153
+ Geometry::Vec2 scale;
152
154
153
155
GLuint shaderProg = 0 ;
154
156
GLuint vertexBuffer = 0 ;
@@ -379,7 +381,7 @@ static bool init() {
379
381
#ifdef GUI_BACKEND_RENDERING
380
382
381
383
// ! (static)
382
- void Draw::beginDrawing (Rendering::RenderingContext& rc, const Geometry::Vec2i & screenSize) {
384
+ void Draw::beginDrawing (Rendering::RenderingContext& rc, const Geometry::Vec2i & screenSize, const Geometry::Vec2 & renderScale ) {
383
385
ctxt.rc = &rc;
384
386
385
387
static bool initialized = false ;
@@ -391,6 +393,7 @@ void Draw::beginDrawing(Rendering::RenderingContext& rc, const Geometry::Vec2i &
391
393
ctxt.position = Geometry::Vec2 (0 ,0 );
392
394
ctxt.activeTexture = nullptr ;
393
395
ctxt.screenSize = screenSize;
396
+ ctxt.scale = renderScale;
394
397
ctxt.meshOffset = 0 ;
395
398
396
399
rc.pushAndSetDepthBuffer (DepthBufferParameters (false , false , Comparison::ALWAYS));
@@ -401,7 +404,7 @@ void Draw::beginDrawing(Rendering::RenderingContext& rc, const Geometry::Vec2i &
401
404
rc.pushScissor ();
402
405
resetScissor ();
403
406
rc.pushAndSetShader (ctxt.shader .get ());
404
- ctxt.shader ->setUniform (rc, Uniform (UNIFORM_SCREEN_SCALE, Geometry::Vec2 (2 .0f /screenSize.getWidth (),-2 .0f /screenSize.getHeight ())));
407
+ ctxt.shader ->setUniform (rc, Uniform (UNIFORM_SCREEN_SCALE, Geometry::Vec2 (2 .0f /screenSize.getWidth (),-2 .0f /screenSize.getHeight ()) * ctxt. scale ));
405
408
406
409
GET_GL_ERROR ();
407
410
}
@@ -507,9 +510,11 @@ void Draw::flush() {
507
510
#ifdef GUI_BACKEND_RENDERING
508
511
BlendingParameters blending (BlendingParameters::SRC_ALPHA, BlendingParameters::ONE_MINUS_SRC_ALPHA);
509
512
ctxt.mesh ->openVertexData ().markAsChanged ();
513
+ float yOffset = static_cast <float >(ctxt.screenSize .y ()) * ctxt.scale .y () - static_cast <float >(ctxt.screenSize .getHeight ());
510
514
for (const auto & cmd : ctxt.commands ) {
511
515
ctxt.shader ->setUniform (*ctxt.rc , {UNIFORM_POS_OFFSET, cmd.offset });
512
- ctxt.rc ->setScissor (ScissorParameters (cmd.scissor ));
516
+ Geometry::Rect scissor (cmd.scissor .getX () * ctxt.scale .x (), cmd.scissor .getY () * ctxt.scale .y () - yOffset, cmd.scissor .getWidth () * ctxt.scale .x (), cmd.scissor .getHeight () * ctxt.scale .y ());
517
+ ctxt.rc ->setScissor (ScissorParameters (Geometry::Rect_i (scissor)));
513
518
if (cmd.blending )
514
519
blending.enable ();
515
520
else
0 commit comments