From ab19abe22315f2e2dcce989beef6dcabee528299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 16 Jul 2020 02:06:25 +0200 Subject: Cleanup: Port glClear calls to GPU module functions --- source/blender/draw/engines/eevee/eevee_lut_gen.c | 3 +-- source/blender/editors/gpencil/gpencil_fill.c | 4 ++-- source/blender/editors/screen/area.c | 8 ++++---- source/blender/windowmanager/intern/wm_draw.c | 8 ++++---- source/blender/windowmanager/intern/wm_playanim.c | 9 +++++---- source/blender/windowmanager/intern/wm_window.c | 4 ++-- 6 files changed, 18 insertions(+), 18 deletions(-) (limited to 'source') diff --git a/source/blender/draw/engines/eevee/eevee_lut_gen.c b/source/blender/draw/engines/eevee/eevee_lut_gen.c index 5f20d6fbfb8..1be5a1d3930 100644 --- a/source/blender/draw/engines/eevee/eevee_lut_gen.c +++ b/source/blender/draw/engines/eevee/eevee_lut_gen.c @@ -76,8 +76,7 @@ static struct GPUTexture *create_ggx_lut_texture(int UNUSED(w), int UNUSED(h)) DRW_draw_pass(pass); float *data = MEM_mallocN(sizeof(float[3]) * w * h, "lut"); - glReadBuffer(GL_COLOR_ATTACHMENT0); - glReadPixels(0, 0, w, h, GL_RGB, GL_FLOAT, data); + GPU_framebuffer_read_color(fb, 0, 0, w, h, 3, 0, data); printf("{"); for (int i = 0; i < w * h * 3; i += 3) { diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 8c901da100d..517225e5a81 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -398,8 +398,8 @@ static bool gpencil_render_offscreen(tGPDfill *tgpf) GPU_matrix_push(); GPU_matrix_identity_set(); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); + GPU_clear(GPU_COLOR_BIT | GPU_DEPTH_BIT); ED_view3d_update_viewmat( tgpf->depsgraph, tgpf->scene, tgpf->v3d, tgpf->region, NULL, winmat, NULL, true); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 3415e21c9e0..d8859ec8532 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -357,12 +357,12 @@ static void region_draw_status_text(ScrArea *area, ARegion *region) bool overlap = ED_region_is_overlap(area->spacetype, region->regiontype); if (overlap) { - GPU_clear_color(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(0.0f, 0.0f, 0.0f, 0.0f); + GPU_clear(GPU_COLOR_BIT); } else { UI_ThemeClearColor(TH_HEADER); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); } int fontid = BLF_set_default(); @@ -527,7 +527,7 @@ void ED_region_do_draw(bContext *C, ARegion *region) if (area && area_is_pseudo_minimized(area)) { UI_ThemeClearColor(TH_EDITOR_OUTLINE); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); return; } /* optional header info instead? */ diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index 2b679dfefde..c686bf3f3e1 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -736,8 +736,8 @@ static void wm_draw_window_offscreen(bContext *C, wmWindow *win, bool stereo) wm_draw_region_buffer_create(region, false, false); wm_draw_region_bind(region, 0); - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(0, 0, 0, 0); + GPU_clear(GPU_COLOR_BIT); ED_region_do_draw(C, region); wm_draw_region_unbind(region); @@ -759,8 +759,8 @@ static void wm_draw_window_onscreen(bContext *C, wmWindow *win, int view) * Actually this is only a problem when resizing the window. * If it becomes a problem we should clear only when window size changes. */ #if 0 - glClearColor(0, 0, 0, 0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(0, 0, 0, 0); + GPU_clear(GPU_COLOR_BIT); #endif /* Blit non-overlapping area regions. */ diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 37c7e802554..50d2b4dd49e 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -58,6 +58,7 @@ #include "BIF_glutil.h" #include "GPU_context.h" +#include "GPU_framebuffer.h" #include "GPU_immediate.h" #include "GPU_immediate_util.h" #include "GPU_init_exit.h" @@ -309,8 +310,8 @@ static void playanim_toscreen( CLAMP(offs_x, 0.0f, 1.0f); CLAMP(offs_y, 0.0f, 1.0f); - glClearColor(0.1, 0.1, 0.1, 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(0.1, 0.1, 0.1, 0.0); + GPU_clear(GPU_COLOR_BIT); /* checkerboard for case alpha */ if (ibuf->planes == 32) { @@ -1315,8 +1316,8 @@ static char *wm_main_playanim_intern(int argc, const char **argv) maxwiny = ibuf->y * (1 + (maxwiny / ibuf->y)); } - glClearColor(0.1, 0.1, 0.1, 0.0); - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear_color(0.1, 0.1, 0.1, 0.0); + GPU_clear(GPU_COLOR_BIT); int win_x, win_y; playanim_window_get_size(&win_x, &win_y); diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index e1b2285313c..aaf8e46b301 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -648,10 +648,10 @@ static void wm_window_ghostwindow_add(wmWindowManager *wm, } #endif /* until screens get drawn, make it nice gray */ - glClearColor(0.55, 0.55, 0.55, 0.0); + GPU_clear_color(0.55, 0.55, 0.55, 0.0); /* Crash on OSS ATI: bugs.launchpad.net/ubuntu/+source/mesa/+bug/656100 */ if (!GPU_type_matches(GPU_DEVICE_ATI, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) { - glClear(GL_COLOR_BUFFER_BIT); + GPU_clear(GPU_COLOR_BIT); } /* needed here, because it's used before it reads userdef */ -- cgit v1.2.3