summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-04-14 22:05:14 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-04-14 22:05:14 -0300
commit3b434eacde58450965708c3eafb6b22eb2a99361 (patch)
tree598b4b1941f843de55cb2c5ad198e4b29ad7d3bf
parent28304bc3309eaf5d8319048de59ebf51168e24df (diff)
Fix clipping when used in viewport or inside another viewport, fixes #1661
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp55
-rw-r--r--main/main.cpp10
2 files changed, 53 insertions, 12 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index f48105e3f1..0359f5f5a0 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -7993,8 +7993,16 @@ void RasterizerGLES2::canvas_set_clip(bool p_clip, const Rect2& p_rect) {
if (p_clip) {
glEnable(GL_SCISSOR_TEST);
- glScissor(viewport.x+p_rect.pos.x,viewport.y+ (viewport.height-(p_rect.pos.y+p_rect.size.height)),
- p_rect.size.width,p_rect.size.height);
+ //glScissor(viewport.x+p_rect.pos.x,viewport.y+ (viewport.height-(p_rect.pos.y+p_rect.size.height)),
+
+ int x = p_rect.pos.x;
+ int y = window_size.height-(p_rect.pos.y+p_rect.size.y);
+ int w = p_rect.size.x;
+ int h = p_rect.size.y;
+
+ glScissor(x,y,w,h);
+
+
} else {
glDisable(GL_SCISSOR_TEST);
@@ -9087,8 +9095,17 @@ void RasterizerGLES2::_canvas_item_render_commands(CanvasItem *p_item,CanvasItem
} else {
glEnable(GL_SCISSOR_TEST);
- glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
- current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
+ //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
+ //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
+
+ int x = current_clip->final_clip_rect.pos.x;
+ int y = window_size.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y);
+ int w = current_clip->final_clip_rect.size.x;
+ int h = current_clip->final_clip_rect.size.y;
+
+ glScissor(x,y,w,h);
+
+
reclip=false;
}
}
@@ -9262,8 +9279,21 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
if (current_clip) {
glEnable(GL_SCISSOR_TEST);
- glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
- current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
+ //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
+ //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
+
+/* int x = viewport.x+current_clip->final_clip_rect.pos.x;
+ int y = window_size.height-(viewport.y+current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y);
+ int w = current_clip->final_clip_rect.size.x;
+ int h = current_clip->final_clip_rect.size.y;
+*/
+ int x = current_clip->final_clip_rect.pos.x;
+ int y = window_size.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y);
+ int w = current_clip->final_clip_rect.size.x;
+ int h = current_clip->final_clip_rect.size.y;
+
+ glScissor(x,y,w,h);
+
} else {
glDisable(GL_SCISSOR_TEST);
@@ -9552,8 +9582,17 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
if (reclip) {
glEnable(GL_SCISSOR_TEST);
- glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
- current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
+ //glScissor(viewport.x+current_clip->final_clip_rect.pos.x,viewport.y+ (viewport.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.height)),
+ //current_clip->final_clip_rect.size.width,current_clip->final_clip_rect.size.height);
+
+ int x = current_clip->final_clip_rect.pos.x;
+ int y = window_size.height-(current_clip->final_clip_rect.pos.y+current_clip->final_clip_rect.size.y);
+ int w = current_clip->final_clip_rect.size.x;
+ int h = current_clip->final_clip_rect.size.y;
+
+ glScissor(x,y,w,h);
+
+
}
diff --git a/main/main.cpp b/main/main.cpp
index 517ccaec08..dcf3c6f8d1 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1293,12 +1293,15 @@ bool Main::iteration() {
uint64_t ticks=OS::get_singleton()->get_ticks_usec();
uint64_t ticks_elapsed=ticks-last_ticks;
+ double step=(double)ticks_elapsed / 1000000.0;
+ float frame_slice=1.0/OS::get_singleton()->get_iterations_per_second();
+
+ //if (time_accum+step < frame_slice)
+ // return false;
+
frame+=ticks_elapsed;
last_ticks=ticks;
- double step=(double)ticks_elapsed / 1000000.0;
-
- float frame_slice=1.0/OS::get_singleton()->get_iterations_per_second();
if (step>frame_slice*8)
step=frame_slice*8;
@@ -1309,7 +1312,6 @@ bool Main::iteration() {
bool exit=false;
-
int iters = 0;
while(time_accum>frame_slice) {