diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-07-14 15:27:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-07-14 15:36:00 +0300 |
commit | 0918461d61127f5d7e9dd7d81441a77b4bdd962d (patch) | |
tree | 256a28c9b586ab8588797bc3e63dec31f485bff8 /source/blender/gpu | |
parent | 2cffd6649b0e9b646bc090e4bba90e9873fb2982 (diff) |
Move from MTFace to MTexPoly w/ texture checks
Part of moving away from MFace.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_draw.h | 12 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_draw.c | 46 |
2 files changed, 33 insertions, 25 deletions
diff --git a/source/blender/gpu/GPU_draw.h b/source/blender/gpu/GPU_draw.h index 845ae9d2b30..2e160683618 100644 --- a/source/blender/gpu/GPU_draw.h +++ b/source/blender/gpu/GPU_draw.h @@ -39,7 +39,7 @@ extern "C" { struct ImBuf; struct Image; struct ImageUser; -struct MTFace; +struct MTexPoly; struct Object; struct Scene; struct View3D; @@ -83,7 +83,7 @@ int GPU_get_material_alpha_blend(void); * be drawn using one or the other * - passing NULL clears the state again */ -int GPU_set_tpage(struct MTFace *tface, int mipmap, int transp); +int GPU_set_tpage(struct MTexPoly *mtexpoly, int mipmap, int transp); void GPU_clear_tpage(bool force); /* Lights @@ -97,9 +97,11 @@ int GPU_scene_object_lights(struct Scene *scene, struct Object *ob, /* Text render * - based on moving uv coordinates */ -void GPU_render_text(struct MTFace *tface, int mode, - const char *textstr, int textlen, unsigned int *col, - float *v1, float *v2, float *v3, float *v4, int glattrib); +void GPU_render_text( + struct MTexPoly *mtexpoly, int mode, + const char *textstr, int textlen, unsigned int *col, + const float *v_quad[4], const float *uv_quad[4], + int glattrib); /* Mipmap settings * - these will free textures on changes */ diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c index e033fbbd1d4..f7060779676 100644 --- a/source/blender/gpu/intern/gpu_draw.c +++ b/source/blender/gpu/intern/gpu_draw.c @@ -92,12 +92,18 @@ static void gpu_mcol(unsigned int ucol) glColor3ub(cp[3], cp[2], cp[1]); } -void GPU_render_text(MTFace *tface, int mode, - const char *textstr, int textlen, unsigned int *col, - float *v1, float *v2, float *v3, float *v4, int glattrib) +void GPU_render_text( + MTexPoly *mtexpoly, int mode, + const char *textstr, int textlen, unsigned int *col, + const float *v_quad[4], const float *uv_quad[4], + int glattrib) { - if ((mode & GEMAT_TEXT) && (textlen > 0) && tface->tpage) { - Image* ima = (Image *)tface->tpage; + if ((mode & GEMAT_TEXT) && (textlen > 0) && mtexpoly->tpage) { + const float *v1 = v_quad[0]; + const float *v2 = v_quad[1]; + const float *v3 = v_quad[2]; + const float *v4 = v_quad[3]; + Image *ima = (Image *)mtexpoly->tpage; ImBuf *first_ibuf; const size_t textlen_st = textlen; size_t index; @@ -116,7 +122,7 @@ void GPU_render_text(MTFace *tface, int mode, /* color has been set */ - if (tface->mode & TF_OBCOL) + if (mtexpoly->mode & TF_OBCOL) col = NULL; else if (!col) glColor3f(1.0f, 1.0f, 1.0f); @@ -159,12 +165,12 @@ void GPU_render_text(MTFace *tface, int mode, matrixGlyph(first_ibuf, character, & centerx, ¢ery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance); - uv[0][0] = (tface->uv[0][0] - centerx) * sizex + transx; - uv[0][1] = (tface->uv[0][1] - centery) * sizey + transy; - uv[1][0] = (tface->uv[1][0] - centerx) * sizex + transx; - uv[1][1] = (tface->uv[1][1] - centery) * sizey + transy; - uv[2][0] = (tface->uv[2][0] - centerx) * sizex + transx; - uv[2][1] = (tface->uv[2][1] - centery) * sizey + transy; + uv[0][0] = (uv_quad[0][0] - centerx) * sizex + transx; + uv[0][1] = (uv_quad[0][1] - centery) * sizey + transy; + uv[1][0] = (uv_quad[1][0] - centerx) * sizex + transx; + uv[1][1] = (uv_quad[1][1] - centery) * sizey + transy; + uv[2][0] = (uv_quad[2][0] - centerx) * sizex + transx; + uv[2][1] = (uv_quad[2][1] - centery) * sizey + transy; glBegin(GL_POLYGON); if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[0]); @@ -183,8 +189,8 @@ void GPU_render_text(MTFace *tface, int mode, glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]); if (v4) { - uv[3][0] = (tface->uv[3][0] - centerx) * sizex + transx; - uv[3][1] = (tface->uv[3][1] - centery) * sizey + transy; + uv[3][0] = (uv_quad[3][0] - centerx) * sizex + transx; + uv[3][1] = (uv_quad[3][1] - centery) * sizey + transy; if (glattrib >= 0) glVertexAttrib2fvARB(glattrib, uv[3]); else glTexCoord2fv(uv[3]); @@ -249,7 +255,7 @@ static struct GPUTextureState { int alphablend; float anisotropic; int gpu_mipmap; - MTFace *lasttface; + MTexPoly *lasttface; } GTS = {0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 1, 0, 0, -1, 1.0f, 0, NULL}; /* Mipmap settings */ @@ -899,23 +905,23 @@ static void gpu_verify_repeat(Image *ima) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } -int GPU_set_tpage(MTFace *tface, int mipmap, int alphablend) +int GPU_set_tpage(MTexPoly *mtexpoly, int mipmap, int alphablend) { Image *ima; /* check if we need to clear the state */ - if (tface == NULL) { + if (mtexpoly == NULL) { GPU_clear_tpage(false); return 0; } - ima = tface->tpage; - GTS.lasttface = tface; + ima = mtexpoly->tpage; + GTS.lasttface = mtexpoly; gpu_verify_alpha_blend(alphablend); gpu_verify_reflection(ima); - if (GPU_verify_image(ima, NULL, tface->tile, 1, mipmap, false)) { + if (GPU_verify_image(ima, NULL, mtexpoly->tile, 1, mipmap, false)) { GTS.curtile = GTS.tile; GTS.curima = GTS.ima; GTS.curtilemode = GTS.tilemode; |