[Bf-blender-cvs] [7fc632a856] blender2.8: OpenGL immediate mode: drawarmature.c (end)
Clément Foucault
noreply at git.blender.org
Tue Feb 14 00:54:04 CET 2017
Commit: 7fc632a8564000731779bb66c7ddd6066b6511cd
Author: Clément Foucault
Date: Tue Feb 14 00:34:52 2017 +0100
Branches: blender2.8
https://developer.blender.org/rB7fc632a8564000731779bb66c7ddd6066b6511cd
OpenGL immediate mode: drawarmature.c (end)
No deprecated call left.
===================================================================
M source/blender/editors/space_view3d/drawarmature.c
M source/blender/editors/space_view3d/drawobject.c
M source/blender/editors/space_view3d/view3d_intern.h
===================================================================
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 1de862b72e..c14a4f980a 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -153,7 +153,6 @@ static void cp_shade_color3ub(unsigned char cp[3], const int offset)
/* This function sets the gl-color for coloring a certain bone (based on bcolor) */
static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
{
- /* TODO remove glColor/UI_ThemeColor functions when no longer needed */
switch (colCode) {
case PCHAN_COLOR_NORMAL:
{
@@ -175,24 +174,19 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
cp_shade_color3ub(cp, -50);
}
- glColor3ubv(cp);
rgb_uchar_to_float(fcolor, cp);
}
else {
if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) {
- UI_ThemeColor(TH_BONE_POSE_ACTIVE);
UI_GetThemeColor4fv(TH_BONE_POSE_ACTIVE, fcolor);
}
else if (boneflag & BONE_DRAW_ACTIVE) {
- UI_ThemeColorBlend(TH_WIRE, TH_BONE_POSE, 0.15f); /* unselected active */
UI_GetThemeColorBlendShade4fv(TH_WIRE, TH_BONE_POSE, 0.15f, 0, fcolor);
}
else if (boneflag & BONE_SELECTED) {
- UI_ThemeColor(TH_BONE_POSE);
UI_GetThemeColor4fv(TH_BONE_POSE, fcolor);
}
else {
- UI_ThemeColor(TH_WIRE);
UI_GetThemeColor4fv(TH_WIRE, fcolor);
}
}
@@ -202,11 +196,9 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
case PCHAN_COLOR_SOLID:
{
if (bcolor) {
- glColor3ubv((unsigned char *)bcolor->solid);
rgb_uchar_to_float(fcolor, (unsigned char *)bcolor->solid);
}
else {
- UI_ThemeColor(TH_BONE_SOLID);
UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
}
@@ -221,7 +213,6 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
else if (constflag & PCHAN_HAS_SPLINEIK) rgba_char_args_set((char *)cp, 200, 255, 0, 80);
else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 80);
- glColor4ubv(cp);
rgba_uchar_to_float(fcolor, cp);
return true;
@@ -243,20 +234,16 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
copy_v3_v3_char((char *)cp, bcolor->solid);
}
- glColor3ubv(cp);
rgb_uchar_to_float(fcolor, cp);
}
else {
if (boneflag & BONE_DRAW_ACTIVE) {
- UI_ThemeColorShade(TH_BONE_POSE, 40);
UI_GetThemeColorShade4fv(TH_BONE_POSE, 40, fcolor);
}
else if (boneflag & BONE_SELECTED) {
- UI_ThemeColor(TH_BONE_POSE);
UI_GetThemeColor4fv(TH_BONE_POSE, fcolor);
}
else {
- UI_ThemeColor(TH_BONE_SOLID);
UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
}
}
@@ -281,20 +268,16 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
cp_shade_color3ub(cp, -30);
}
- glColor3ubv(cp);
rgb_uchar_to_float(fcolor, cp);
}
else {
if (boneflag & BONE_DRAW_ACTIVE) {
- UI_ThemeColorShade(TH_BONE_POSE, 10);
UI_GetThemeColorShade4fv(TH_BONE_POSE, 10, fcolor);
}
else if (boneflag & BONE_SELECTED) {
- UI_ThemeColorShade(TH_BONE_POSE, -30);
UI_GetThemeColorShade4fv(TH_BONE_POSE, -30, fcolor);
}
else {
- UI_ThemeColorShade(TH_BONE_SOLID, -30);
UI_GetThemeColorShade4fv(TH_BONE_SOLID, -30, fcolor);
}
}
@@ -311,18 +294,15 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
else if (constflag & PCHAN_HAS_CONST) rgba_char_args_set((char *)cp, 0, 255, 120, 255);
else if (constflag) UI_GetThemeColor4ubv(TH_BONE_POSE, cp); /* PCHAN_HAS_ACTION */
- glColor4ubv(cp);
rgb_uchar_to_float(fcolor, cp);
}
else {
if (bcolor) {
const char *cp = bcolor->solid;
- glColor4ub(cp[0], cp[1], cp[2], 204);
rgb_uchar_to_float(fcolor, (unsigned char *)cp);
fcolor[3] = 204.f / 255.f;
}
else {
- UI_ThemeColorShade(TH_BACK, -30);
UI_GetThemeColorShade4fv(TH_BACK, -30, fcolor);
}
}
@@ -336,21 +316,16 @@ static bool set_pchan_glColor(short colCode, int boneflag, short constflag)
static void set_ebone_glColor(const unsigned int boneflag)
{
- /* TODO remove glColor/UI_ThemeColor functions when no longer needed */
if ((boneflag & BONE_DRAW_ACTIVE) && (boneflag & BONE_SELECTED)) {
- UI_ThemeColor(TH_EDGE_SELECT);
UI_GetThemeColor4fv(TH_EDGE_SELECT, fcolor);
}
else if (boneflag & BONE_DRAW_ACTIVE) {
- UI_ThemeColorBlend(TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f); /* unselected active */
UI_GetThemeColorBlendShade4fv(TH_WIRE_EDIT, TH_EDGE_SELECT, 0.15f, 0, fcolor);
}
else if (boneflag & BONE_SELECTED) {
- UI_ThemeColorShade(TH_EDGE_SELECT, -20);
UI_GetThemeColorShade4fv(TH_EDGE_SELECT, -20, fcolor);
}
else {
- UI_ThemeColor(TH_WIRE_EDIT);
UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
}
}
@@ -700,11 +675,9 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag,
if (dt <= OB_WIRE) {
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_ROOTSEL) {
- UI_ThemeColor(TH_VERTEX_SELECT);
UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
}
else {
- UI_ThemeColor(TH_VERTEX);
UI_GetThemeColor4fv(TH_VERTEX, fcolor);
}
}
@@ -713,7 +686,6 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag,
if (armflag & ARM_POSEMODE)
set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0);
else {
- UI_ThemeColor(TH_BONE_SOLID);
UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
}
}
@@ -731,11 +703,9 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag,
if (dt <= OB_WIRE) {
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_TIPSEL) {
- UI_ThemeColor(TH_VERTEX_SELECT);
UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
}
else {
- UI_ThemeColor(TH_VERTEX);
UI_GetThemeColor4fv(TH_VERTEX, fcolor);
}
}
@@ -744,7 +714,6 @@ static void draw_bone_points(const short dt, int armflag, unsigned int boneflag,
if (armflag & ARM_POSEMODE)
set_pchan_glColor(PCHAN_COLOR_SOLID, boneflag, 0);
else {
- UI_ThemeColor(TH_BONE_SOLID);
UI_GetThemeColor4fv(TH_BONE_SOLID, fcolor);
}
}
@@ -944,11 +913,9 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4],
/* sphere root color */
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_ROOTSEL) {
- UI_ThemeColor(TH_VERTEX_SELECT);
UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
}
else {
- UI_ThemeColor(TH_VERTEX);
UI_GetThemeColor4fv(TH_VERTEX, fcolor);
}
}
@@ -968,11 +935,9 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4],
/* Draw tip point */
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_TIPSEL) {
- UI_ThemeColor(TH_VERTEX_SELECT);
UI_GetThemeColor4fv(TH_VERTEX_SELECT, fcolor);
}
else {
- UI_ThemeColor(TH_VERTEX);
UI_GetThemeColor4fv(TH_VERTEX, fcolor);
}
}
@@ -985,11 +950,9 @@ static void draw_sphere_bone_wire(float smat[4][4], float imat[4][4],
/* base */
if (armflag & ARM_EDITMODE) {
if (boneflag & BONE_SELECTED){
- UI_ThemeColor(TH_SELECT);
UI_GetThemeColor4fv(TH_SELECT, fcolor);
}
else {
- UI_ThemeColor(TH_WIRE_EDIT);
UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
}
}
@@ -1188,19 +1151,9 @@ static void draw_sphere_bone(const short dt, int armflag, int boneflag, short co
gpuMatrixEnd();
}
-static GLubyte bm_dot6[] = {0x0, 0x18, 0x3C, 0x7E, 0x7E, 0x3C, 0x18, 0x0};
-static GLubyte bm_dot8[] = {0x3C, 0x7E, 0xFF, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C};
-
-static GLubyte bm_dot5[] = {0x0, 0x0, 0x10, 0x38, 0x7c, 0x38, 0x10, 0x0};
-static GLubyte bm_dot7[] = {0x0, 0x38, 0x7C, 0xFE, 0xFE, 0xFE, 0x7C, 0x38};
-
-
static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned int id,
bPoseChannel *pchan, EditBone *ebone)
{
- /* call this once, avoid constant changing */
- BLI_assert(glaGetOneInt(GL_UNPACK_ALIGNMENT) == 1);
-
float length;
if (pchan)
@@ -1208,59 +1161,62 @@ static void draw_line_bone(int armflag, int boneflag, short constflag, unsigned
else
length = ebone->length;
- glPushMatrix();
- glScalef(length, length, length);
+ VertexFormat *format = immVertexFormat();
+ unsigned int pos = add_attrib(format, "pos", GL_FLOAT, 3, KEEP_FLOAT);
+
+ gpuMatrixBegin3D_legacy();
+ gpuPushMatrix();
+ gpuScale3f(length, length, length);
/* this chunk not in object mode */
if (armflag & (ARM_EDITMODE | ARM_POSEMODE)) {
glLineWidth(4.0f);
- if (G.f & G_PICKSEL) {
- /* no bitmap in selection mode, crashes 3d cards...
- * instead draw a solid point the same size */
- glPointSize(8.0f);
- }
+ glPointSize(8.0f);
if (armflag & ARM_POSEMODE)
set_pchan_glColor(PCHAN_COLOR_NORMAL, boneflag, constflag);
else if (armflag & ARM_EDITMODE) {
- UI_ThemeColor(TH_WIRE_EDIT);
+ UI_GetThemeColor4fv(TH_WIRE_EDIT, fcolor);
}
-
+
+ /* line */
+ immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR);
+ immUniformColor4fv(fcolor);
+
+ if (id != -1)
+ GPU_select_load_id(id | BONESEL_BONE);
+
+ immBegin(GL_LINES, 2);
+ immVertex3f(pos, 0.0f, 1.0f, 0.0f);
+ immVertex3f(pos, 0.0f, 0.0f, 0.0f);
+ immEnd();
+
+ immUnbindProgram();
+
+ immBindBuiltinProgram(GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR);
+ immUniformColor4fv(fcolor);
+
/* Draw root point if we are not connected */
if ((boneflag & BONE_CONNECTED) == 0) {
- if (G.f & G_PICKSEL) {
+ if (G.f & G_PICKSEL)
GPU_select_load_id(id | BONESEL_ROOT);
- glBegin(GL_POINTS);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glEnd();
- }
- else {
- glRasterPos3f(0.0f, 0.0f, 0.0f);
- glBitmap(8, 8, 4, 4, 0, 0, bm_dot8);
- }
+
+ immBegin(GL_POINTS, 1);
+ immVertex3f(pos, 0.0f, 0.0f, 0.0f);
+ immEnd();
}
-
- if (id != -1)
- GPU_select_load_id((GLuint) id | BONESEL_BONE);
-
- glBegin(GL_LINES);
- glVertex3f(0.0f, 0.0f, 0.0f);
- glVertex3f(0.0f, 1.0f, 0.0f);
- glEnd();
-
+
/* tip */
- if (G.f & G_PICKSEL) {
- /* no bitmap in se
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list