diff options
Diffstat (limited to 'source/blender/editors/interface/resources.c')
-rw-r--r-- | source/blender/editors/interface/resources.c | 118 |
1 files changed, 101 insertions, 17 deletions
diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index fa5d5806bb8..a845ed27d0d 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -51,13 +51,14 @@ #include "BKE_texture.h" -#include "BIF_gl.h" #include "UI_interface.h" #include "UI_interface_icons.h" #include "interface_intern.h" +#include "GPU_compatibility.h" + /* global for themes */ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); @@ -968,8 +969,15 @@ void UI_ThemeColor(int colorid) const unsigned char *cp; cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); - glColor3ubv(cp); + gpuCurrentColor3ubv(cp); +} +void UI_ThemeAppendColor(int colorid) +{ + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + gpuColor3ubv(cp); } /* plus alpha */ @@ -978,8 +986,7 @@ void UI_ThemeColor4(int colorid) const unsigned char *cp; cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); - glColor4ubv(cp); - + gpuCurrentColor4ubv(cp); } /* set the color with offset for shades */ @@ -987,17 +994,41 @@ void UI_ThemeColorShade(int colorid, int offset) { int r, g, b; const unsigned char *cp; - + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + r = offset + (int) cp[0]; CLAMP(r, 0, 255); + g = offset + (int) cp[1]; CLAMP(g, 0, 255); + b = offset + (int) cp[2]; CLAMP(b, 0, 255); - //glColor3ub(r, g, b); - glColor4ub(r, g, b, cp[3]); + + gpuCurrentColor4ub(r, g, b, cp[3]); } + +// set the color with offset for shades +void UI_ThemeAppendColorShade(int colorid, int offset) +{ + int r, g, b; + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + + r = offset + (int) cp[0]; + CLAMP(r, 0, 255); + + g = offset + (int) cp[1]; + CLAMP(g, 0, 255); + + b = offset + (int) cp[2]; + CLAMP(b, 0, 255); + + gpuColor4ub(r, g, b, cp[3]); +} + void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) { int r, g, b, a; @@ -1012,7 +1043,24 @@ void UI_ThemeColorShadeAlpha(int colorid, int coloffset, int alphaoffset) CLAMP(b, 0, 255); a = alphaoffset + (int) cp[3]; CLAMP(a, 0, 255); - glColor4ub(r, g, b, a); + gpuCurrentColor4ub(r, g, b, a); +} + +void UI_ThemeAppendColorShadeAlpha(int colorid, int coloffset, int alphaoffset) +{ + int r, g, b, a; + const unsigned char *cp; + + cp = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid); + r = coloffset + (int) cp[0]; + CLAMP(r, 0, 255); + g = coloffset + (int) cp[1]; + CLAMP(g, 0, 255); + b = coloffset + (int) cp[2]; + CLAMP(b, 0, 255); + a = alphaoffset + (int) cp[3]; + CLAMP(a, 0, 255); + gpuColor4ub(r, g, b, a); } /* blend between to theme colors, and set it */ @@ -1029,7 +1077,23 @@ void UI_ThemeColorBlend(int colorid1, int colorid2, float fac) g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); - glColor3ub(r, g, b); + gpuCurrentColor3ub(r, g, b); +} + +void UI_ThemeAppendColorBlend(int colorid1, int colorid2, float fac) +{ + int r, g, b; + const unsigned char *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + r = floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); + g = floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); + b = floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); + + gpuColor3ub(r, g, b); } /* blend between to theme colors, shade it, and set it */ @@ -1037,7 +1101,7 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) { int r, g, b; const unsigned char *cp1, *cp2; - + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); @@ -1045,12 +1109,33 @@ void UI_ThemeColorBlendShade(int colorid1, int colorid2, float fac, int offset) r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); - + CLAMP(r, 0, 255); CLAMP(g, 0, 255); CLAMP(b, 0, 255); - - glColor3ub(r, g, b); + + gpuCurrentColor3ub(r, g, b); +} + +// blend between to theme colors, shade it, and set it +void UI_ThemeAppendColorBlendShade(int colorid1, int colorid2, float fac, int offset) +{ + int r, g, b; + const unsigned char *cp1, *cp2; + + cp1 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid1); + cp2 = UI_ThemeGetColorPtr(theme_active, theme_spacetype, colorid2); + + CLAMP(fac, 0.0f, 1.0f); + r = offset + floorf((1.0f - fac) * cp1[0] + fac * cp2[0]); + g = offset + floorf((1.0f - fac) * cp1[1] + fac * cp2[1]); + b = offset + floorf((1.0f - fac) * cp1[2] + fac * cp2[2]); + + CLAMP(r, 0, 255); + CLAMP(g, 0, 255); + CLAMP(b, 0, 255); + + gpuColor3ub(r, g, b); } /* blend between to theme colors, shade it, and set it */ @@ -1073,7 +1158,7 @@ void UI_ThemeColorBlendShadeAlpha(int colorid1, int colorid2, float fac, int off CLAMP(b, 0, 255); CLAMP(a, 0, 255); - glColor4ub(r, g, b, a); + gpuCurrentColor4ub(r, g, b, a); } @@ -1204,7 +1289,7 @@ void UI_ColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned char c g = g < 0 ? 0 : (g > 255 ? 255 : g); b = b < 0 ? 0 : (b > 255 ? 255 : b); - glColor3ub(r, g, b); + gpuCurrentColor3ub(r, g, b); } void UI_GetColorPtrShade3ubv(const unsigned char cp[3], unsigned char col[3], int offset) @@ -1247,9 +1332,8 @@ void UI_GetColorPtrBlendShade3ubv(const unsigned char cp1[3], const unsigned cha void UI_ThemeClearColor(int colorid) { float col[3]; - UI_GetThemeColor3fv(colorid, col); - glClearColor(col[0], col[1], col[2], 0.0); + gpuSetClearColorvf(col, 0.0); } void UI_make_axis_color(const unsigned char src_col[3], unsigned char dst_col[3], const char axis) |