From 96a2807e73ed595493e7ffba000d78fb9309895f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Tue, 13 Feb 2018 03:57:28 +0100 Subject: Code cleanup: remove unneeded gla* 2D drawing functions. --- source/blender/editors/screen/glutil.c | 136 --------------------------------- 1 file changed, 136 deletions(-) (limited to 'source/blender/editors/screen/glutil.c') diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 7ce16efdb97..cd53655a0bb 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -354,142 +354,6 @@ void immDrawPixelsTex_clipping(IMMDrawPixelsTexState *state, clip_min_x, clip_min_y, clip_max_x, clip_max_y, xzoom, yzoom, color); } -/* 2D Drawing Assistance */ - -void glaDefine2DArea(rcti *screen_rect) -{ - const int sc_w = BLI_rcti_size_x(screen_rect) + 1; - const int sc_h = BLI_rcti_size_y(screen_rect) + 1; - - glViewport(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); - glScissor(screen_rect->xmin, screen_rect->ymin, sc_w, sc_h); - - /* The GLA_PIXEL_OFS magic number is to shift the matrix so that - * both raster and vertex integer coordinates fall at pixel - * centers properly. For a longer discussion see the OpenGL - * Programming Guide, Appendix H, Correctness Tips. - */ - - gpuOrtho2D(GLA_PIXEL_OFS, sc_w + GLA_PIXEL_OFS, GLA_PIXEL_OFS, sc_h + GLA_PIXEL_OFS); - gpuLoadIdentity(); -} - -/* TODO(merwin): put the following 2D code to use, or build new 2D code inspired & informd by it */ - -#if 0 /* UNUSED */ - -struct gla2DDrawInfo { - int orig_vp[4], orig_sc[4]; - float orig_projmat[16], orig_viewmat[16]; - - rcti screen_rect; - rctf world_rect; - - float wo_to_sc[2]; -}; - -void gla2DGetMap(gla2DDrawInfo *di, rctf *rect) -{ - *rect = di->world_rect; -} - -void gla2DSetMap(gla2DDrawInfo *di, rctf *rect) -{ - int sc_w, sc_h; - float wo_w, wo_h; - - di->world_rect = *rect; - - sc_w = BLI_rcti_size_x(&di->screen_rect); - sc_h = BLI_rcti_size_y(&di->screen_rect); - wo_w = BLI_rcti_size_x(&di->world_rect); - wo_h = BLI_rcti_size_y(&di->world_rect); - - di->wo_to_sc[0] = sc_w / wo_w; - di->wo_to_sc[1] = sc_h / wo_h; -} - -/** Save the current OpenGL state and initialize OpenGL for 2D - * rendering. glaEnd2DDraw should be called on the returned structure - * to free it and to return OpenGL to its previous state. The - * scissor rectangle is set to match the viewport. - * - * See glaDefine2DArea for an explanation of why this function uses integers. - * - * \param screen_rect The screen rectangle to be used for 2D drawing. - * \param world_rect The world rectangle that the 2D area represented - * by \a screen_rect is supposed to represent. If NULL it is assumed the - * world has a 1 to 1 mapping to the screen. - */ -gla2DDrawInfo *glaBegin2DDraw(rcti *screen_rect, rctf *world_rect) -{ - gla2DDrawInfo *di = MEM_mallocN(sizeof(*di), "gla2DDrawInfo"); - int sc_w, sc_h; - float wo_w, wo_h; - - glGetIntegerv(GL_VIEWPORT, (GLint *)di->orig_vp); - glGetIntegerv(GL_SCISSOR_BOX, (GLint *)di->orig_sc); - gpuGetProjectionMatrix(di->orig_projmat); - gpuGetModelViewMatrix(di->orig_viewmat); - - di->screen_rect = *screen_rect; - if (world_rect) { - di->world_rect = *world_rect; - } - else { - di->world_rect.xmin = di->screen_rect.xmin; - di->world_rect.ymin = di->screen_rect.ymin; - di->world_rect.xmax = di->screen_rect.xmax; - di->world_rect.ymax = di->screen_rect.ymax; - } - - sc_w = BLI_rcti_size_x(&di->screen_rect); - sc_h = BLI_rcti_size_y(&di->screen_rect); - wo_w = BLI_rcti_size_x(&di->world_rect); - wo_h = BLI_rcti_size_y(&di->world_rect); - - di->wo_to_sc[0] = sc_w / wo_w; - di->wo_to_sc[1] = sc_h / wo_h; - - glaDefine2DArea(&di->screen_rect); - - return di; -} - -/** - * Translate the (\a wo_x, \a wo_y) point from world coordinates into screen space. - */ -void gla2DDrawTranslatePt(gla2DDrawInfo *di, float wo_x, float wo_y, int *r_sc_x, int *r_sc_y) -{ - *r_sc_x = (wo_x - di->world_rect.xmin) * di->wo_to_sc[0]; - *r_sc_y = (wo_y - di->world_rect.ymin) * di->wo_to_sc[1]; -} - -/** - * Translate the \a world point from world coordinates into screen space. - */ -void gla2DDrawTranslatePtv(gla2DDrawInfo *di, float world[2], int r_screen[2]) -{ - screen_r[0] = (world[0] - di->world_rect.xmin) * di->wo_to_sc[0]; - screen_r[1] = (world[1] - di->world_rect.ymin) * di->wo_to_sc[1]; -} - -/** - * Restores the previous OpenGL state and frees the auxiliary gla data. - */ -void glaEnd2DDraw(gla2DDrawInfo *di) -{ - glViewport(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]); - glScissor(di->orig_vp[0], di->orig_vp[1], di->orig_vp[2], di->orig_vp[3]); - gpuLoadProjectionMatrix(di->orig_projmat); - gpuLoadMatrix(di->orig_viewmat); - - MEM_freeN(di); -} - -#endif /* UNUSED */ - - /* *************** glPolygonOffset hack ************* */ /** -- cgit v1.2.3