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); }
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); }
static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args) { float aspect; int fontid; if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect)) return NULL; BLF_aspect(fontid, aspect, aspect, 1.0); Py_RETURN_NONE; }
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); }
/* 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); }
static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf *ibuf, int fontid, int fstep) { float offsx, offsy; if (ibuf == NULL) { printf("%s: no ibuf for picture '%s'\n", __func__, picture ? picture->name : "<NIL>"); return; } if (ibuf->rect == NULL && ibuf->rect_float) { IMB_rect_from_float(ibuf); imb_freerectfloatImBuf(ibuf); } if (ibuf->rect == NULL) return; GHOST_ActivateWindowDrawingContext(g_WS.ghost_window); /* offset within window */ offsx = 0.5f * (((float)ps->win_x - ps->zoom * ibuf->x) / (float)ps->win_x); offsy = 0.5f * (((float)ps->win_y - ps->zoom * ibuf->y) / (float)ps->win_y); CLAMP(offsx, 0.0f, 1.0f); CLAMP(offsy, 0.0f, 1.0f); glRasterPos2f(offsx, offsy); 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(offsx, offsy, offsx + (ps->zoom * ibuf->x) / (float)ps->win_x, offsy + (ps->zoom * ibuf->y) / (float)ps->win_y); } glDrawPixels(ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); glDisable(GL_BLEND); pupdate_time(); if (picture && (g_WS.qual & (WS_QUAL_SHIFT | WS_QUAL_LMOUSE)) && (fontid != -1)) { int sizex, sizey; float fsizex_inv, fsizey_inv; char str[32 + FILE_MAX]; cpack(-1); BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->name, fstep / swaptime); playanim_window_get_size(&sizex, &sizey); fsizex_inv = 1.0f / sizex; fsizey_inv = 1.0f / sizey; 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); BLF_draw(fontid, str, sizeof(str)); } GHOST_SwapWindowBuffers(g_WS.ghost_window); }