WM: Add utility wmOrtho2_*** funcs
Currently there are inconsistencies with pixel alignment. but this commit has no functional changes. - wmOrtho2_region_ui for UI/Text. - wmOrtho2_region_pixelspace for 2D drawing. - wmOrtho2_pixelspace - when the region isn't used.
This commit is contained in:
@@ -1347,8 +1347,8 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
glLoadIdentity();
|
||||
|
||||
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
|
||||
|
||||
wmOrtho2_region_ui(ar);
|
||||
|
||||
/* back */
|
||||
if (block->flag & UI_BLOCK_RADIAL)
|
||||
|
||||
@@ -1020,7 +1020,7 @@ static void ui_searchbox_region_draw_cb(const bContext *UNUSED(C), ARegion *ar)
|
||||
uiSearchboxData *data = ar->regiondata;
|
||||
|
||||
/* pixel space */
|
||||
wmOrtho2(-0.01f, ar->winx - 0.01f, -0.01f, ar->winy - 0.01f);
|
||||
wmOrtho2_region_ui(ar);
|
||||
|
||||
if (data->noback == false)
|
||||
ui_draw_search_back(NULL, NULL, &data->bbox); /* style not used yet */
|
||||
|
||||
@@ -107,10 +107,7 @@ static void region_draw_emboss(ARegion *ar, rcti *scirct)
|
||||
|
||||
void ED_region_pixelspace(ARegion *ar)
|
||||
{
|
||||
int width = BLI_rcti_size_x(&ar->winrct) + 1;
|
||||
int height = BLI_rcti_size_y(&ar->winrct) + 1;
|
||||
|
||||
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
|
||||
wmOrtho2_region_pixelspace(ar);
|
||||
glLoadIdentity();
|
||||
}
|
||||
|
||||
|
||||
@@ -3056,7 +3056,8 @@ void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, b
|
||||
|
||||
glaDefine2DArea(&ar->winrct);
|
||||
/* ortho at pixel level curarea */
|
||||
wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
|
||||
/* almost #wmOrtho2_region_pixelspace, but no +1 px */
|
||||
wmOrtho2_pixelspace(ar->winx, ar->winy);
|
||||
|
||||
x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
|
||||
y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
|
||||
|
||||
@@ -361,6 +361,10 @@ void wmSubWindowScissorSet (struct wmWindow *win, int swinid, const struct rcti
|
||||
void wmFrustum (float x1, float x2, float y1, float y2, float n, float f);
|
||||
void wmOrtho (float x1, float x2, float y1, float y2, float n, float f);
|
||||
void wmOrtho2 (float x1, float x2, float y1, float y2);
|
||||
/* use for conventions (avoid hard-coded offsets all over) */
|
||||
void wmOrtho2_region_pixelspace(const struct ARegion *ar);
|
||||
void wmOrtho2_region_ui(const struct ARegion *ar);
|
||||
void wmOrtho2_pixelspace(const float x, const float y);
|
||||
|
||||
/* utilities */
|
||||
void WM_framebuffer_index_set(int index);
|
||||
|
||||
@@ -215,7 +215,7 @@ int wm_subwindow_open(wmWindow *win, const rcti *winrct)
|
||||
|
||||
/* extra service */
|
||||
wm_swin_size_get(swin, &width, &height);
|
||||
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
|
||||
wmOrtho2_pixelspace(width, height);
|
||||
glLoadIdentity();
|
||||
|
||||
return swin->swinid;
|
||||
@@ -272,7 +272,7 @@ void wm_subwindow_position(wmWindow *win, int swinid, const rcti *winrct)
|
||||
/* extra service */
|
||||
wmSubWindowSet(win, swinid);
|
||||
wm_swin_size_get(swin, &width, &height);
|
||||
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
|
||||
wmOrtho2_pixelspace(width, height);
|
||||
}
|
||||
else {
|
||||
printf("%s: Internal error, bad winid: %d\n", __func__, swinid);
|
||||
@@ -319,7 +319,7 @@ void wmSubWindowScissorSet(wmWindow *win, int swinid, const rcti *srct, bool src
|
||||
else
|
||||
glScissor(_curswin->winrct.xmin, _curswin->winrct.ymin, width, height);
|
||||
|
||||
wmOrtho2(-GLA_PIXEL_OFS, (float)width - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, (float)height - GLA_PIXEL_OFS);
|
||||
wmOrtho2_pixelspace(width, height);
|
||||
glLoadIdentity();
|
||||
|
||||
glFlush();
|
||||
@@ -358,6 +358,35 @@ void wmOrtho2(float x1, float x2, float y1, float y2)
|
||||
wmOrtho(x1, x2, y1, y2, -100, 100);
|
||||
}
|
||||
|
||||
static void wmOrtho2_offset(const float x, const float y, const float ofs)
|
||||
{
|
||||
wmOrtho2(ofs, x + ofs, ofs, y + ofs);
|
||||
}
|
||||
|
||||
/**
|
||||
* default pixel alignment.
|
||||
*/
|
||||
void wmOrtho2_region_pixelspace(const struct ARegion *ar)
|
||||
{
|
||||
wmOrtho2_offset(ar->winx + 1, ar->winy + 1, -GLA_PIXEL_OFS);
|
||||
}
|
||||
|
||||
void wmOrtho2_pixelspace(const float x, const float y)
|
||||
{
|
||||
wmOrtho2_offset(x, y, -GLA_PIXEL_OFS);
|
||||
}
|
||||
|
||||
/**
|
||||
* use for drawing uiBlock, any UI elements and text.
|
||||
* \note prevents blurry text with multi-sample (FSAA), see T41749
|
||||
*/
|
||||
void wmOrtho2_region_ui(const ARegion *ar)
|
||||
{
|
||||
/* note, intentionally no '+ 1',
|
||||
* as with wmOrtho2_region_pixelspace */
|
||||
wmOrtho2_offset(ar->winx, ar->winy, -0.01f);
|
||||
}
|
||||
|
||||
/* *************************** Framebuffer color depth, for selection codes ********************** */
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
Reference in New Issue
Block a user