diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_playanim.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 84 |
1 files changed, 49 insertions, 35 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 6bf7bcc2934..373e0bf10ad 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -58,17 +58,22 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" -#include "BKE_depsgraph.h" #include "BKE_image.h" #include "BIF_gl.h" #include "BIF_glutil.h" +#include "GPU_matrix.h" +#include "GPU_immediate.h" +#include "GPU_immediate_util.h" + #include "DNA_scene_types.h" #include "ED_datafiles.h" /* for fonts */ #include "GHOST_C-api.h" #include "BLF_api.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" /* only for WM_main_playanim */ #ifdef WITH_AUDASPACE @@ -190,10 +195,7 @@ static void playanim_window_get_size(int *r_width, int *r_height) static void playanim_gl_matrix(void) { /* unified matrix, note it affects offset for drawing */ - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f); - glMatrixMode(GL_MODELVIEW); + gpuOrtho2D(0.0f, 1.0f, 0.0f, 1.0f); } /* implementation */ @@ -308,29 +310,32 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf CLAMP(offs_x, 0.0f, 1.0f); CLAMP(offs_y, 0.0f, 1.0f); - glRasterPos2f(offs_x, offs_y); glClearColor(0.1, 0.1, 0.1, 0.0); glClear(GL_COLOR_BUFFER_BIT); - + /* checkerboard for case alpha */ if (ibuf->planes == 32) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - fdrawcheckerboard(offs_x, offs_y, offs_x + span_x, offs_y + span_y); + imm_draw_checker_box(offs_x, offs_y, offs_x + span_x, offs_y + span_y); } - glRasterPos2f(offs_x + (ps->draw_flip[0] ? span_x : 0.0f), - offs_y + (ps->draw_flip[1] ? span_y : 0.0f)); - - glPixelZoom(ps->zoom * (ps->draw_flip[0] ? -1.0f : 1.0f), - ps->zoom * (ps->draw_flip[1] ? -1.0f : 1.0f)); + IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR); - glDrawPixels(ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); + immDrawPixelsTex( + &state, + offs_x + (ps->draw_flip[0] ? span_x : 0.0f), + offs_y + (ps->draw_flip[1] ? span_y : 0.0f), + ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST, + ibuf->rect, + ((ps->draw_flip[0] ? -1.0f : 1.0f)) * (ps->zoom / (float)ps->win_x), + ((ps->draw_flip[1] ? -1.0f : 1.0f)) * (ps->zoom / (float)ps->win_y), + NULL); glDisable(GL_BLEND); - + pupdate_time(); if (picture && (g_WS.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) && (fontid != -1)) { @@ -344,6 +349,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf fsizex_inv = 1.0f / sizex; fsizey_inv = 1.0f / sizey; + BLF_color4f(fontid, 1.0, 1.0, 1.0, 1.0); BLF_enable(fontid, BLF_ASPECT); BLF_aspect(fontid, fsizex_inv, fsizey_inv, 1.0f); BLF_position(fontid, 10.0f * fsizex_inv, 10.0f * fsizey_inv, 0.0f); @@ -354,24 +360,25 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf float fac = ps->picture->frame / (double)(((PlayAnimPict *)picsbase.last)->frame - ((PlayAnimPict *)picsbase.first)->frame); fac = 2.0f * fac - 1.0f; - glMatrixMode(GL_PROJECTION); - glPushMatrix(); - glLoadIdentity(); - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glLoadIdentity(); - - glColor4f(0.0f, 1.0f, 0.0f, 1.0f); - - glBegin(GL_LINES); - glVertex2f(fac, -1.0f); - glVertex2f(fac, 1.0f); - glEnd(); - - glPopMatrix(); - glMatrixMode(GL_PROJECTION); - glPopMatrix(); - glMatrixMode(GL_MODELVIEW); + gpuPushProjectionMatrix(); + gpuLoadIdentityProjectionMatrix(); + gpuPushMatrix(); + gpuLoadIdentity(); + + unsigned int pos = VertexFormat_add_attrib(immVertexFormat(), "pos", COMP_F32, 2, KEEP_FLOAT); + + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + immUniformColor3ub(0, 255, 0); + + immBegin(PRIM_LINES, 2); + immVertex2f(pos, fac, -1.0f); + immVertex2f(pos, fac, 1.0f); + immEnd(); + + immUnbindProgram(); + + gpuPopMatrix(); + gpuPopProjectionMatrix(); } GHOST_SwapWindowBuffers(g_WS.ghost_window); @@ -1255,6 +1262,9 @@ static char *wm_main_playanim_intern(int argc, const char **argv) //GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); + /* initialize OpenGL immediate mode */ + immInit(); + /* initialize the font */ BLF_init(11, 72); ps.fontid = BLF_load_mem("monospace", (unsigned char *)datatoc_bmonofont_ttf, datatoc_bmonofont_ttf_size); @@ -1525,7 +1535,11 @@ static char *wm_main_playanim_intern(int argc, const char **argv) #endif /* we still miss freeing a lot!, * but many areas could skip initialization too for anim play */ - + + GPU_shader_free_builtin_shaders(); + + immDestroy(); + BLF_exit(); GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window); @@ -1538,7 +1552,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) IMB_exit(); BKE_images_exit(); - DAG_exit(); + DEG_free_node_types(); totblock = MEM_get_memory_blocks_in_use(); if (totblock != 0) { |