コード例 #1
0
ファイル: KX_BlenderGL.cpp プロジェクト: 244xiao/blender
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();
	glDisable(GL_DEPTH_TEST);

	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_size(blf_mono_font, 11, 72);
	BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
	BLF_draw(blf_mono_font, (char *)text, 65535);/* XXX, use real len */
	
	glColor3ub(255, 255, 255);
	BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
	BLF_draw(blf_mono_font, (char *)text, 65535);

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glEnable(GL_DEPTH_TEST);
}
コード例 #2
0
ファイル: image_gen.c プロジェクト: DrangPo/blender
static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline)
{
	int x, y;
	int pen_x, pen_y;
	char text[3] = {'A', '1', '\0'};
	const int mono = blf_mono_font_render;

	BLF_size(mono, 54, 72); /* hard coded size! */

	/* OCIO_TODO: using NULL as display will assume using sRGB display
	 *            this is correct since currently generated images are assumed to be in sRGB space,
	 *            but this would probably needed to be fixed in some way
	 */
	BLF_buffer(mono, rect_float, rect, width, height, 4, NULL);

	for (y = 0; y < height; y += step) {
		text[1] = '1';

		for (x = 0; x < width; x += step) {
			/* hard coded offset */
			pen_x = x + 33;
			pen_y = y + 44;

			/* terribly crappy outline font! */
			BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0);

			BLF_position(mono, pen_x - outline, pen_y, 0.0);
			BLF_draw_buffer(mono, text, 2);
			BLF_position(mono, pen_x + outline, pen_y, 0.0);
			BLF_draw_buffer(mono, text, 2);
			BLF_position(mono, pen_x, pen_y - outline, 0.0);
			BLF_draw_buffer(mono, text, 2);
			BLF_position(mono, pen_x, pen_y + outline, 0.0);
			BLF_draw_buffer(mono, text, 2);

			BLF_position(mono, pen_x - outline, pen_y - outline, 0.0);
			BLF_draw_buffer(mono, text, 2);
			BLF_position(mono, pen_x + outline, pen_y + outline, 0.0);
			BLF_draw_buffer(mono, text, 2);
			BLF_position(mono, pen_x - outline, pen_y + outline, 0.0);
			BLF_draw_buffer(mono, text, 2);
			BLF_position(mono, pen_x + outline, pen_y - outline, 0.0);
			BLF_draw_buffer(mono, text, 2);

			BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0);
			BLF_position(mono, pen_x, pen_y, 0.0);
			BLF_draw_buffer(mono, text, 2);

			text[1]++;
		}
		text[0]++;
	}

	/* cleanup the buffer. */
	BLF_buffer(mono, NULL, NULL, 0, 0, 0, NULL);
}
コード例 #3
0
ファイル: image_gen.c プロジェクト: mik0001/Blender
static void checker_board_text(unsigned char *rect, float *rect_float, int width, int height, int step, int outline)
{
	int x, y;
	int pen_x, pen_y;
	char text[3]= {'A', '1', '\0'};
	const int mono= blf_mono_font;

	BLF_size(mono, 54, 72); /* hard coded size! */

	BLF_buffer(mono, rect_float, rect, width, height, 4);

	for(y= 0; y < height; y+=step)
	{
		text[1]= '1';

		for(x= 0; x < width; x+=step)
		{
			/* hard coded offset */
			pen_x = x + 33;
			pen_y = y + 44;

			/* terribly crappy outline font! */
			BLF_buffer_col(mono, 1.0, 1.0, 1.0, 1.0);

			BLF_position(mono, pen_x-outline, pen_y, 0.0);
			BLF_draw_buffer(mono, text);
			BLF_position(mono, pen_x+outline, pen_y, 0.0);
			BLF_draw_buffer(mono, text);
			BLF_position(mono, pen_x, pen_y-outline, 0.0);
			BLF_draw_buffer(mono, text);
			BLF_position(mono, pen_x, pen_y+outline, 0.0);
			BLF_draw_buffer(mono, text);

			BLF_position(mono, pen_x-outline, pen_y-outline, 0.0);
			BLF_draw_buffer(mono, text);
			BLF_position(mono, pen_x+outline, pen_y+outline, 0.0);
			BLF_draw_buffer(mono, text);
			BLF_position(mono, pen_x-outline, pen_y+outline, 0.0);
			BLF_draw_buffer(mono, text);
			BLF_position(mono, pen_x+outline, pen_y-outline, 0.0);
			BLF_draw_buffer(mono, text);

			BLF_buffer_col(mono, 0.0, 0.0, 0.0, 1.0);
			BLF_position(mono, pen_x, pen_y, 0.0);
			BLF_draw_buffer(mono, text);

			text[1]++;
		}
		text[0]++;
	}

	/* cleanup the buffer. */
	BLF_buffer(mono, NULL, NULL, 0, 0, 0);
}
コード例 #4
0
ファイル: KX_BlenderGL.cpp プロジェクト: 244xiao/blender
void BL_print_gamedebug_line(const char *text, int xco, int yco, int width, int height)
{
	/* gl prepping */
	DisableForText();
	glDisable(GL_DEPTH_TEST);

	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_size(blf_mono_font, 11, 72);
	BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
	BLF_draw(blf_mono_font, (char *)text, 65535); /* XXX, use real len */

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glEnable(GL_DEPTH_TEST);
}
コード例 #5
0
void RAS_OpenGLRasterizer::RenderText3D(
        int fontid, const char *text, int size, int dpi,
        const float color[4], const double mat[16], float aspect)
{
	/* gl prepping */
	DisableForText();

	/* the actual drawing */
	glColor4fv(color);

	/* multiply the text matrix by the object matrix */
	BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
	BLF_matrix(fontid, mat);

	/* aspect is the inverse scale that allows you to increase */
	/* your resolution without sizing the final text size      */
	/* the bigger the size, the smaller the aspect	           */
	BLF_aspect(fontid, aspect, aspect, aspect);

	BLF_size(fontid, size, dpi);
	BLF_position(fontid, 0, 0, 0);
	BLF_draw(fontid, text, 65535);

	BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
}
コード例 #6
0
ファイル: text_draw.c プロジェクト: Eibriel/kiriblender
static int text_font_draw_character(SpaceText *st, int x, int y, char c)
{
	BLF_position(mono, x, y, 0);
	BLF_draw(mono, &c, 1);

	return st->cwidth;
}
コード例 #7
0
void GPC_RenderTools::RenderText3D(	int fontid,
									const char* text,
									int size,
									int dpi,
									float* color,
									double* mat,
									float aspect)
{
	/* the actual drawing */
	glColor3fv(color);
 
	/* multiply the text matrix by the object matrix */
	BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
	BLF_matrix(fontid, mat);

	/* aspect is the inverse scale that allows you to increase */
	/* your resolution without sizing the final text size */
	/* the bigger the size, the smaller the aspect	*/
	BLF_aspect(fontid, aspect, aspect, aspect);

	BLF_size(fontid, size, dpi);
	BLF_position(fontid, 0, 0, 0);
	BLF_draw(fontid, (char *)text, strlen(text));

	BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
	glEnable(GL_DEPTH_TEST);
}
コード例 #8
0
static int text_font_draw(SpaceText *UNUSED(st), int x, int y, char *str)
{
	BLF_position(mono, x, y, 0);
	BLF_draw(mono, str, 65535); /* XXX, use real length */

	return BLF_width(mono, str);
}
コード例 #9
0
ファイル: text_draw.c プロジェクト: jonntd/blender
static int text_font_draw_character(const TextDrawContext *tdc, int x, int y, char c)
{
	BLF_position(tdc->font_id, x, y, 0);
	BLF_draw(tdc->font_id, &c, 1);

	return tdc->cwidth;
}
コード例 #10
0
ファイル: blf.c プロジェクト: RiazAhamed/NewBlender
/* same as above but call 'BLF_draw_ascii' */
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
{
	ASSERT_DEFAULT_SET;

	BLF_size(global_font_default, global_font_points, global_font_dpi);
	BLF_position(global_font_default, x, y, z);
	BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
}
コード例 #11
0
ファイル: blf.c プロジェクト: RiazAhamed/NewBlender
void BLF_draw_default(float x, float y, float z, const char *str, size_t len)
{
	ASSERT_DEFAULT_SET;

	BLF_size(global_font_default, global_font_points, global_font_dpi);
	BLF_position(global_font_default, x, y, z);
	BLF_draw(global_font_default, str, len);
}
コード例 #12
0
ファイル: text_draw.c プロジェクト: jonntd/blender
static int text_font_draw(const TextDrawContext *tdc, int x, int y, const char *str)
{
	int columns;

	BLF_position(tdc->font_id, x, y, 0);
	columns = BLF_draw_mono(tdc->font_id, str, BLF_DRAW_STR_DUMMY_MAX, tdc->cwidth);

	return tdc->cwidth * columns;
}
コード例 #13
0
ファイル: text_draw.c プロジェクト: Eibriel/kiriblender
static int text_font_draw(SpaceText *st, int x, int y, const char *str)
{
	int columns;

	BLF_position(mono, x, y, 0);
	columns = BLF_draw_mono(mono, str, BLF_DRAW_STR_DUMMY_MAX, st->cwidth);

	return st->cwidth * columns;
}
コード例 #14
0
void UI_fontstyle_draw_ex(
        const uiFontStyle *fs, const rcti *rect, const char *str,
        size_t len, float *r_xofs, float *r_yofs)
{
	int xofs = 0, yofs;
	int font_flag = BLF_CLIPPING;

	UI_fontstyle_set(fs);

	/* set the flag */
	if (fs->shadow) {
		font_flag |= BLF_SHADOW;
		const float shadow_color[4] = {fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha};
		BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
		BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
	}
	if (fs->kerning == 1) {
		font_flag |= BLF_KERNING_DEFAULT;
	}
	if (fs->word_wrap == 1) {
		font_flag |= BLF_WORD_WRAP;
	}

	BLF_enable(fs->uifont_id, font_flag);

	if (fs->word_wrap == 1) {
		/* draw from boundbox top */
		yofs = BLI_rcti_size_y(rect) - BLF_height_max(fs->uifont_id);
	}
	else {
		/* draw from boundbox center */
		yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - BLF_ascender(fs->uifont_id)));
	}

	if (fs->align == UI_STYLE_TEXT_CENTER) {
		xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));
		/* don't center text if it chops off the start of the text, 2 gives some margin */
		if (xofs < 2) {
			xofs = 2;
		}
	}
	else if (fs->align == UI_STYLE_TEXT_RIGHT) {
		xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
	}

	/* clip is very strict, so we give it some space */
	BLF_clipping(fs->uifont_id, rect->xmin - 2, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
	BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);

	BLF_draw(fs->uifont_id, str, len);

	BLF_disable(fs->uifont_id, font_flag);

	*r_xofs = xofs;
	*r_yofs = yofs;
}
コード例 #15
0
ファイル: text_draw.c プロジェクト: Eibriel/kiriblender
static int text_font_draw_character_utf8(SpaceText *st, int x, int y, const char *c)
{
	int columns;

	const size_t len = BLI_str_utf8_size_safe(c);
	BLF_position(mono, x, y, 0);
	columns = BLF_draw_mono(mono, c, len, st->cwidth);

	return st->cwidth * columns;
}
コード例 #16
0
ファイル: text_draw.c プロジェクト: jonntd/blender
static int text_font_draw_character_utf8(const TextDrawContext *tdc, int x, int y, const char *c)
{
	int columns;

	const size_t len = BLI_str_utf8_size_safe(c);
	BLF_position(tdc->font_id, x, y, 0);
	columns = BLF_draw_mono(tdc->font_id, c, len, tdc->cwidth);

	return tdc->cwidth * columns;
}
コード例 #17
0
void RAS_OpenGLRasterizer::RenderText2D(
        RAS_TEXT_RENDER_MODE mode,
        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();
	glDisable(GL_DEPTH_TEST);

	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();

	glOrtho(0, width, 0, height, -100, 100);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();

	if (mode == RAS_TEXT_PADDED) {
		/* draw in black first*/
		glColor3ub(0, 0, 0);
		BLF_size(blf_mono_font, 11, 72);
		BLF_position(blf_mono_font, (float)xco+1, (float)(height-yco-1), 0.0f);
		BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */
	}

	/* the actual drawing */
	glColor3ub(255, 255, 255);
	BLF_size(blf_mono_font, 11, 72);
	BLF_position(blf_mono_font, (float)xco, (float)(height-yco), 0.0f);
	BLF_draw(blf_mono_font, text, 65535); /* XXX, use real len */

	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glEnable(GL_DEPTH_TEST);
}
コード例 #18
0
static int text_font_draw_character(SpaceText *st, int x, int y, char c)
{
	char str[2];
	str[0]= c;
	str[1]= '\0';

	BLF_position(mono, x, y, 0);
	BLF_draw(mono, str, 1);

	return st->cwidth;
}
コード例 #19
0
static PyObject *py_blf_position(PyObject *UNUSED(self), PyObject *args)
{
	int fontid;
	float x, y, z;

	if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z))
		return NULL;

	BLF_position(fontid, x, y, z);

	Py_RETURN_NONE;
}
コード例 #20
0
/**
 * Similar to #UI_fontstyle_draw
 * but ignore alignment, shadow & no clipping rect.
 *
 * For drawing on-screen labels.
 */
void UI_fontstyle_draw_simple(const uiFontStyle *fs, float x, float y, const char *str)
{
	if (fs->kerning == 1)
		BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);

	UI_fontstyle_set(fs);
	BLF_position(fs->uifont_id, x, y, 0.0f);
	BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);

	if (fs->kerning == 1)
		BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
コード例 #21
0
/* drawn same as above, but at 90 degree angle */
void UI_fontstyle_draw_rotated(const uiFontStyle *fs, const rcti *rect, const char *str)
{
	float height;
	int xofs, yofs;
	float angle;
	rcti txtrect;

	UI_fontstyle_set(fs);

	height = BLF_ascender(fs->uifont_id);
	/* becomes x-offset when rotated */
	xofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));

	/* ignore UI_STYLE, always aligned to top */

	/* rotate counter-clockwise for now (assumes left-to-right language)*/
	xofs += height;
	yofs = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX) + 5;
	angle = M_PI_2;

	/* translate rect to vertical */
	txtrect.xmin = rect->xmin - BLI_rcti_size_y(rect);
	txtrect.ymin = rect->ymin - BLI_rcti_size_x(rect);
	txtrect.xmax = rect->xmin;
	txtrect.ymax = rect->ymin;

	/* clip is very strict, so we give it some space */
	/* clipping is done without rotation, so make rect big enough to contain both positions */
	BLF_clipping(fs->uifont_id, txtrect.xmin - 1, txtrect.ymin - yofs - xofs - 4, rect->xmax + 1, rect->ymax + 4);
	BLF_enable(fs->uifont_id, BLF_CLIPPING);
	BLF_position(fs->uifont_id, txtrect.xmin + xofs, txtrect.ymax - yofs, 0.0f);

	BLF_enable(fs->uifont_id, BLF_ROTATION);
	BLF_rotation(fs->uifont_id, angle);

	if (fs->shadow) {
		BLF_enable(fs->uifont_id, BLF_SHADOW);
		const float shadow_color[4] = {fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha};
		BLF_shadow(fs->uifont_id, fs->shadow, shadow_color);
		BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
	}

	if (fs->kerning == 1)
		BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);

	BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
	BLF_disable(fs->uifont_id, BLF_ROTATION);
	BLF_disable(fs->uifont_id, BLF_CLIPPING);
	if (fs->shadow)
		BLF_disable(fs->uifont_id, BLF_SHADOW);
	if (fs->kerning == 1)
		BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
コード例 #22
0
ファイル: interface_style.c プロジェクト: OldBrunet/BGERTPS
/* drawn same as above, but at 90 degree angle */
void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
{
	float height;
	int xofs, yofs;
	float angle;
	rcti txtrect;

	uiStyleFontSet(fs);

	height= BLF_ascender(fs->uifont_id);
	/* becomes x-offset when rotated */
	xofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));

	/* ignore UI_STYLE, always aligned to top */

	/* rotate counter-clockwise for now (assumes left-to-right language)*/
	xofs+= height;
	yofs= BLF_width(fs->uifont_id, str) + 5;
	angle= 90.0f;

	/* translate rect to vertical */
	txtrect.xmin= rect->xmin - (rect->ymax - rect->ymin);
	txtrect.ymin= rect->ymin - (rect->xmax - rect->xmin);
	txtrect.xmax= rect->xmin;
	txtrect.ymax= rect->ymin;

	/* clip is very strict, so we give it some space */
	/* clipping is done without rotation, so make rect big enough to contain both positions */
	BLF_clipping(fs->uifont_id, txtrect.xmin-1, txtrect.ymin-yofs-xofs-4, rect->xmax+1, rect->ymax+4);
	BLF_enable(fs->uifont_id, BLF_CLIPPING);
	BLF_position(fs->uifont_id, txtrect.xmin+xofs, txtrect.ymax-yofs, 0.0f);

	BLF_enable(fs->uifont_id, BLF_ROTATION);
	BLF_rotation(fs->uifont_id, angle);

	if (fs->shadow) {
		BLF_enable(fs->uifont_id, BLF_SHADOW);
		BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
		BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
	}

	if (fs->kerning == 1)
		BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);

	BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
	BLF_disable(fs->uifont_id, BLF_ROTATION);
	BLF_disable(fs->uifont_id, BLF_CLIPPING);
	if (fs->shadow)
		BLF_disable(fs->uifont_id, BLF_SHADOW);
	if (fs->kerning == 1)
		BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
}
コード例 #23
0
ファイル: interface_style.c プロジェクト: OldBrunet/BGERTPS
/* temporarily, does widget font */
void UI_DrawString(float x, float y, const char *str)
{
	uiStyle *style= U.uistyles.first;
	
	if (style->widget.kerning == 1)
		BLF_enable(style->widget.uifont_id, BLF_KERNING_DEFAULT);

	uiStyleFontSet(&style->widget);
	BLF_position(style->widget.uifont_id, x, y, 0.0f);
	BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */

	if (style->widget.kerning == 1)
		BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
}
コード例 #24
0
void GPC_RenderTools::RenderText3D(	int fontid,
									const char* text,
									int size,
									int dpi,
									float* color,
									double* mat,
									float aspect)
{
	if(GLEW_ARB_multitexture) {
		for(int i=0; i<MAXTEX; i++) {
			glActiveTextureARB(GL_TEXTURE0_ARB+i);

			if(GLEW_ARB_texture_cube_map)
				if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
					glDisable(GL_TEXTURE_CUBE_MAP_ARB);

			if(glIsEnabled(GL_TEXTURE_2D))
				glDisable(GL_TEXTURE_2D);
		}

		glActiveTextureARB(GL_TEXTURE0_ARB);
	}
	else {
		if(GLEW_ARB_texture_cube_map)
			if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
				glDisable(GL_TEXTURE_CUBE_MAP_ARB);

		if(glIsEnabled(GL_TEXTURE_2D))
			glDisable(GL_TEXTURE_2D);
	}

	/* the actual drawing */
	glColor4fv(color);
 
	/* multiply the text matrix by the object matrix */
	BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
	BLF_matrix(fontid, mat);

	/* aspect is the inverse scale that allows you to increase */
	/* your resolution without sizing the final text size */
	/* the bigger the size, the smaller the aspect	*/
	BLF_aspect(fontid, aspect, aspect, aspect);

	BLF_size(fontid, size, dpi);
	BLF_position(fontid, 0, 0, 0);
	BLF_draw(fontid, text, 65535);

	BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
	glEnable(GL_DEPTH_TEST);
}
コード例 #25
0
void UI_fontstyle_draw_ex(
        const uiFontStyle *fs, const rcti *rect, const char *str,
        size_t len, float *r_xofs, float *r_yofs)
{
	float height;
	int xofs = 0, yofs;
	
	UI_fontstyle_set(fs);

	height = BLF_ascender(fs->uifont_id);
	yofs = ceil(0.5f * (BLI_rcti_size_y(rect) - height));

	if (fs->align == UI_STYLE_TEXT_CENTER) {
		xofs = floor(0.5f * (BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len)));
		/* don't center text if it chops off the start of the text, 2 gives some margin */
		if (xofs < 2) {
			xofs = 2;
		}
	}
	else if (fs->align == UI_STYLE_TEXT_RIGHT) {
		xofs = BLI_rcti_size_x(rect) - BLF_width(fs->uifont_id, str, len) - 0.1f * U.widget_unit;
	}
	
	/* clip is very strict, so we give it some space */
	BLF_clipping(fs->uifont_id, rect->xmin - 2, rect->ymin - 4, rect->xmax + 1, rect->ymax + 4);
	BLF_enable(fs->uifont_id, BLF_CLIPPING);
	BLF_position(fs->uifont_id, rect->xmin + xofs, rect->ymin + yofs, 0.0f);

	if (fs->shadow) {
		BLF_enable(fs->uifont_id, BLF_SHADOW);
		BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
		BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
	}

	if (fs->kerning == 1)
		BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);

	BLF_draw(fs->uifont_id, str, len);
	BLF_disable(fs->uifont_id, BLF_CLIPPING);
	if (fs->shadow)
		BLF_disable(fs->uifont_id, BLF_SHADOW);
	if (fs->kerning == 1)
		BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);

	*r_xofs = xofs;
	*r_yofs = yofs;
}
コード例 #26
0
ファイル: blf.c プロジェクト: OldBrunet/BGERTPS
/* same as above but call 'BLF_draw_ascii' */
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len)
{
	if (!str)
		return;

	if (global_font_default == -1)
		global_font_default= blf_search("default");

	if (global_font_default == -1) {
		printf("Warning: Can't found default font!!\n");
		return;
	}

	BLF_size(global_font_default, global_font_points, global_font_dpi);
	BLF_position(global_font_default, x, y, z);
	BLF_draw_ascii(global_font_default, str, len); /* XXX, use real length */
}
コード例 #27
0
ファイル: interface_style.c プロジェクト: OldBrunet/BGERTPS
void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
	float *r_xofs, float *r_yofs)
{
	float height;
	int xofs=0, yofs;
	
	uiStyleFontSet(fs);

	height= BLF_ascender(fs->uifont_id);
	yofs= ceil( 0.5f*(rect->ymax - rect->ymin - height));

	if(fs->align==UI_STYLE_TEXT_CENTER) {
		xofs= floor( 0.5f*(rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str)));
		/* don't center text if it chops off the start of the text, 2 gives some margin */
		if(xofs < 2) {
			xofs= 2;
		}
	}
	else if(fs->align==UI_STYLE_TEXT_RIGHT) {
		xofs= rect->xmax - rect->xmin - BLF_width(fs->uifont_id, str) - 1;
	}
	
	/* clip is very strict, so we give it some space */
	BLF_clipping(fs->uifont_id, rect->xmin-1, rect->ymin-4, rect->xmax+1, rect->ymax+4);
	BLF_enable(fs->uifont_id, BLF_CLIPPING);
	BLF_position(fs->uifont_id, rect->xmin+xofs, rect->ymin+yofs, 0.0f);

	if (fs->shadow) {
		BLF_enable(fs->uifont_id, BLF_SHADOW);
		BLF_shadow(fs->uifont_id, fs->shadow, fs->shadowcolor, fs->shadowcolor, fs->shadowcolor, fs->shadowalpha);
		BLF_shadow_offset(fs->uifont_id, fs->shadx, fs->shady);
	}

	if (fs->kerning == 1)
		BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);

	BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
	BLF_disable(fs->uifont_id, BLF_CLIPPING);
	if (fs->shadow)
		BLF_disable(fs->uifont_id, BLF_SHADOW);
	if (fs->kerning == 1)
		BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);

	*r_xofs= xofs;
	*r_yofs= yofs;
}
コード例 #28
0
ファイル: clip_draw.c プロジェクト: vanangamudi/blender-main
void clip_draw_curfra_label(SpaceClip *sc, float x, float y)
{
	uiStyle *style = UI_GetStyle();
	int fontid = style->widget.uifont_id;
	char numstr[32];
	float font_dims[2] = {0.0f, 0.0f};

	/* frame number */
	BLF_size(fontid, 11.0f, U.dpi);
	BLI_snprintf(numstr, sizeof(numstr), "%d", sc->user.framenr);

	BLF_width_and_height(fontid, numstr, &font_dims[0], &font_dims[1]);

	glRecti(x, y, x + font_dims[0] + 6.0f, y + font_dims[1] + 4.0f);

	UI_ThemeColor(TH_TEXT);
	BLF_position(fontid, x + 2.0f, y + 2.0f, 0.0f);
	BLF_draw(fontid, numstr, sizeof(numstr));
}
コード例 #29
0
ファイル: interface_style.c プロジェクト: dfelinto/blender
/**
 * Same as #UI_fontstyle_draw but draw a colored backdrop.
 */
void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs,
                                       float x,
                                       float y,
                                       const char *str,
                                       const float col_fg[4],
                                       const float col_bg[4])
{
  if (fs->kerning == 1) {
    BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
  }

  UI_fontstyle_set(fs);

  {
    const float width = BLF_width(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
    const float height = BLF_height_max(fs->uifont_id);
    const float decent = BLF_descender(fs->uifont_id);
    const float margin = height / 4.0f;

    /* backdrop */
    float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f};

    UI_draw_roundbox_corner_set(UI_CNR_ALL);
    UI_draw_roundbox_aa(true,
                        x - margin,
                        (y + decent) - margin,
                        x + width + margin,
                        (y + decent) + height + margin,
                        margin,
                        color);
  }

  BLF_position(fs->uifont_id, x, y, 0.0f);
  BLF_color4fv(fs->uifont_id, col_fg);
  BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);

  if (fs->kerning == 1) {
    BLF_disable(fs->uifont_id, BLF_KERNING_DEFAULT);
  }
}
コード例 #30
0
ファイル: KX_BlenderGL.cpp プロジェクト: 244xiao/blender
/* Print 3D text */
void BL_print_game_line(int fontid, const char *text, int size, int dpi, float *color, double *mat, float aspect)
{
	/* gl prepping */
	DisableForText();

	/* the actual drawing */
	glColor4fv(color);

	/* multiply the text matrix by the object matrix */
	BLF_enable(fontid, BLF_MATRIX|BLF_ASPECT);
	BLF_matrix(fontid, mat);

	/* aspect is the inverse scale that allows you to increase */
	/* your resolution without sizing the final text size      */
	/* the bigger the size, the smaller the aspect	           */
	BLF_aspect(fontid, aspect, aspect, aspect);

	BLF_size(fontid, size, dpi);
	BLF_position(fontid, 0, 0, 0);
	BLF_draw(fontid, (char *)text, 65535);

	BLF_disable(fontid, BLF_MATRIX|BLF_ASPECT);
}