void BL_print_gamedebug_line_padded(const char* text, int xco, int yco, int width, int height) { /* This is a rather important line :( The gl-mode hasn't been left * behind quite as neatly as we'd have wanted to. I don't know * what cause it, though :/ .*/ DisableForText(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, width, 0, height, -100, 100); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); /* draw in black first*/ glColor3ub(0, 0, 0); BLF_draw_default(xco+2, height-yco-2, 0.0f, (char *)text); glColor3ub(255, 255, 255); BLF_draw_default(xco, height-yco, 0.0f, (char *)text); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST); }
void BL_print_gamedebug_line(const char* text, int xco, int yco, int width, int height) { /* gl prepping */ DisableForText(); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, width, 0, height, -100, 100); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); /* the actual drawing */ glColor3ub(255, 255, 255); BLF_draw_default(xco, height-yco, 0.0f, (char *)text); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); glEnable(GL_DEPTH_TEST); }
/* draw a short status message in the top-right corner */ static void gp_draw_status_text(bGPdata *gpd, ARegion *ar) { rcti rect; /* Cannot draw any status text when drawing OpenGL Renders */ if (G.f & G_RENDER_OGL) return; /* Get bounds of region - Necessary to avoid problems with region overlap */ ED_region_visible_rect(ar, &rect); /* for now, this should only be used to indicate when we are in stroke editmode */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { const char *printable = IFACE_("GPencil Stroke Editing"); float printable_size[2]; int xco, yco; BLF_width_and_height_default(printable, BLF_DRAW_STR_DUMMY_MAX, &printable_size[0], &printable_size[1]); xco = (rect.xmax - U.widget_unit) - (int)printable_size[0]; yco = (rect.ymax - U.widget_unit); /* text label */ UI_ThemeColor(TH_TEXT_HI); #ifdef WITH_INTERNATIONAL BLF_draw_default(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX); #else BLF_draw_default_ascii(xco, yco, 0.0f, printable, BLF_DRAW_STR_DUMMY_MAX); #endif /* grease pencil icon... */ // XXX: is this too intrusive? glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); xco -= U.widget_unit; yco -= (int)printable_size[1] / 2; UI_icon_draw(xco, yco, ICON_GREASEPENCIL); glDisable(GL_BLEND); } }
void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), rcti *recti) { Scopes *scopes = (Scopes *)but->poin; rctf rect; int i, c; float w, w3, h, alpha, yofs; GLint scissor[4]; float colors[3][3] = MAT3_UNITY; float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}}; float colors_alpha[3][3], colorsycc_alpha[3][3]; /* colors pre multiplied by alpha for speed up */ float min, max; if (scopes == NULL) return; rect.xmin = (float)recti->xmin + 1; rect.xmax = (float)recti->xmax - 1; rect.ymin = (float)recti->ymin + SCOPE_RESIZE_PAD + 2; rect.ymax = (float)recti->ymax - 1; if (scopes->wavefrm_yfac < 0.5f) scopes->wavefrm_yfac = 0.98f; w = BLI_rctf_size_x(&rect) - 7; h = BLI_rctf_size_y(&rect) * scopes->wavefrm_yfac; yofs = rect.ymin + (BLI_rctf_size_y(&rect) - h) / 2.0f; w3 = w / 3.0f; /* log scale for alpha */ alpha = scopes->wavefrm_alpha * scopes->wavefrm_alpha; for (c = 0; c < 3; c++) { for (i = 0; i < 3; i++) { colors_alpha[c][i] = colors[c][i] * alpha; colorsycc_alpha[c][i] = colorsycc[c][i] * alpha; } } glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(0.f, 0.f, 0.f, 0.3f); uiSetRoundBox(UI_CNR_ALL); uiDrawBox(GL_POLYGON, rect.xmin - 1, rect.ymin - 1, rect.xmax + 1, rect.ymax + 1, 3.0f); /* need scissor test, waveform can draw outside of boundary */ glGetIntegerv(GL_VIEWPORT, scissor); glScissor(ar->winrct.xmin + (rect.xmin - 1), ar->winrct.ymin + (rect.ymin - 1), (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); glColor4f(1.f, 1.f, 1.f, 0.08f); /* draw grid lines here */ for (i = 0; i < 6; i++) { char str[4]; BLI_snprintf(str, sizeof(str), "%-3d", i * 20); str[3] = '\0'; fdrawline(rect.xmin + 22, yofs + (i / 5.f) * h, rect.xmax + 1, yofs + (i / 5.f) * h); BLF_draw_default(rect.xmin + 1, yofs - 5 + (i / 5.f) * h, 0, str, sizeof(str) - 1); /* in the loop because blf_draw reset it */ glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } /* 3 vertical separation */ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) { for (i = 1; i < 3; i++) { fdrawline(rect.xmin + i * w3, rect.ymin, rect.xmin + i * w3, rect.ymax); } } /* separate min max zone on the right */ fdrawline(rect.xmin + w, rect.ymin, rect.xmin + w, rect.ymax); /* 16-235-240 level in case of ITU-R BT601/709 */ glColor4f(1.f, 0.4f, 0.f, 0.2f); if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) { fdrawline(rect.xmin + 22, yofs + h * 16.0f / 255.0f, rect.xmax + 1, yofs + h * 16.0f / 255.0f); fdrawline(rect.xmin + 22, yofs + h * 235.0f / 255.0f, rect.xmin + w3, yofs + h * 235.0f / 255.0f); fdrawline(rect.xmin + 3 * w3, yofs + h * 235.0f / 255.0f, rect.xmax + 1, yofs + h * 235.0f / 255.0f); fdrawline(rect.xmin + w3, yofs + h * 240.0f / 255.0f, rect.xmax + 1, yofs + h * 240.0f / 255.0f); } /* 7.5 IRE black point level for NTSC */ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) fdrawline(rect.xmin, yofs + h * 0.075f, rect.xmax + 1, yofs + h * 0.075f); if (scopes->ok && scopes->waveform_1 != NULL) { /* LUMA (1 channel) */ glBlendFunc(GL_ONE, GL_ONE); glColor3f(alpha, alpha, alpha); if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { glBlendFunc(GL_ONE, GL_ONE); glPushMatrix(); glEnableClientState(GL_VERTEX_ARRAY); glTranslatef(rect.xmin, yofs, 0.f); glScalef(w, h, 0.f); glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1); glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); /* min max */ glColor3f(0.5f, 0.5f, 0.5f); min = yofs + scopes->minmax[0][0] * h; max = yofs + scopes->minmax[0][1] * h; CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); fdrawline(rect.xmax - 3, min, rect.xmax - 3, max); } /* RGB / YCC (3 channels) */ else if (ELEM4(scopes->wavefrm_mode, SCOPES_WAVEFRM_RGB, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709, SCOPES_WAVEFRM_YCC_JPEG)) { int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB); glBlendFunc(GL_ONE, GL_ONE); glPushMatrix(); glEnableClientState(GL_VERTEX_ARRAY); glTranslatef(rect.xmin, yofs, 0.f); glScalef(w3, h, 0.f); glColor3fv((rgb) ? colors_alpha[0] : colorsycc_alpha[0]); glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_1); glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); glTranslatef(1.f, 0.f, 0.f); glColor3fv((rgb) ? colors_alpha[1] : colorsycc_alpha[1]); glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_2); glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); glTranslatef(1.f, 0.f, 0.f); glColor3fv((rgb) ? colors_alpha[2] : colorsycc_alpha[2]); glVertexPointer(2, GL_FLOAT, 0, scopes->waveform_3); glDrawArrays(GL_POINTS, 0, scopes->waveform_tot); glDisableClientState(GL_VERTEX_ARRAY); glPopMatrix(); /* min max */ for (c = 0; c < 3; c++) { if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) glColor3f(colors[c][0] * 0.75f, colors[c][1] * 0.75f, colors[c][2] * 0.75f); else glColor3f(colorsycc[c][0] * 0.75f, colorsycc[c][1] * 0.75f, colorsycc[c][2] * 0.75f); min = yofs + scopes->minmax[c][0] * h; max = yofs + scopes->minmax[c][1] * h; CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); fdrawline(rect.xmin + w + 2 + c * 2, min, rect.xmin + w + 2 + c * 2, max); } } } /* outline, scale gripper */ draw_scope_end(&rect, scissor); }
void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode, const char* text, int xco, int yco, int width, int height) { /* STR_String tmpstr(text); char* s = tmpstr.Ptr(); */ // Save and change OpenGL settings int texture2D; glGetIntegerv(GL_TEXTURE_2D, (GLint*)&texture2D); glDisable(GL_TEXTURE_2D); int fog; glGetIntegerv(GL_FOG, (GLint*)&fog); glDisable(GL_FOG); int light; glGetIntegerv(GL_LIGHTING, (GLint*)&light); glDisable(GL_LIGHTING); // Set up viewing settings glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(0, width, 0, height, -1, 1); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); // Actual drawing (draw black first if padded) if (mode == RAS_IRenderTools::RAS_TEXT_PADDED) { glColor3ub(0, 0, 0); BLF_draw_default(xco+1, height-yco-1, 0.f, text, strlen(text)); } glColor3ub(255, 255, 255); BLF_draw_default(xco, height-yco, 0.f, text, strlen(text)); // Restore view settings glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glPopMatrix(); // Restore OpenGL Settings if (fog) glEnable(GL_FOG); else glDisable(GL_FOG); if (texture2D) glEnable(GL_TEXTURE_2D); else glDisable(GL_TEXTURE_2D); if (light) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); }