mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 04:06:14 +00:00
Fix clipping when used in viewport or inside another viewport, fixes #1661
This commit is contained in:
parent
28304bc330
commit
3b434eacde
@ -7993,8 +7993,16 @@ void RasterizerGLES2::canvas_set_clip(bool p_clip, const Rect2& p_rect) {
|
|||||||
if (p_clip) {
|
if (p_clip) {
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(GL_SCISSOR_TEST);
|
||||||
glScissor(viewport.x+p_rect.pos.x,viewport.y+ (viewport.height-(p_rect.pos.y+p_rect.size.height)),
|
//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);
|
|
||||||
|
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 {
|
} else {
|
||||||
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
@ -9087,8 +9095,17 @@ void RasterizerGLES2::_canvas_item_render_commands(CanvasItem *p_item,CanvasItem
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
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)),
|
//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);
|
//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;
|
reclip=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9262,8 +9279,21 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
|
|||||||
if (current_clip) {
|
if (current_clip) {
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
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)),
|
//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);
|
//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 {
|
} else {
|
||||||
|
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(GL_SCISSOR_TEST);
|
||||||
@ -9552,8 +9582,17 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list,int p_z,const
|
|||||||
if (reclip) {
|
if (reclip) {
|
||||||
|
|
||||||
glEnable(GL_SCISSOR_TEST);
|
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)),
|
//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);
|
//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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1293,12 +1293,15 @@ bool Main::iteration() {
|
|||||||
uint64_t ticks=OS::get_singleton()->get_ticks_usec();
|
uint64_t ticks=OS::get_singleton()->get_ticks_usec();
|
||||||
uint64_t ticks_elapsed=ticks-last_ticks;
|
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;
|
frame+=ticks_elapsed;
|
||||||
|
|
||||||
last_ticks=ticks;
|
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)
|
if (step>frame_slice*8)
|
||||||
step=frame_slice*8;
|
step=frame_slice*8;
|
||||||
@ -1309,7 +1312,6 @@ bool Main::iteration() {
|
|||||||
|
|
||||||
bool exit=false;
|
bool exit=false;
|
||||||
|
|
||||||
|
|
||||||
int iters = 0;
|
int iters = 0;
|
||||||
|
|
||||||
while(time_accum>frame_slice) {
|
while(time_accum>frame_slice) {
|
||||||
|
Loading…
Reference in New Issue
Block a user