void cubepos::append_move(char*&p,int mv){ append_face(p,mv/TWISTS); *p++= "123"[mv%TWISTS]; *p= 0; }
inline void append_face(uint32_t a, uint32_t b, uint32_t c){ append_face(Face3(a, b, c)); }
/** * Make a string from the given state vector. * For example, return "state.matrix.texture[2].inverse". * Use free() to deallocate the string. */ char * _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) { char str[1000] = ""; char tmp[30]; append(str, "state."); append_token(str, state[0]); switch (state[0]) { case STATE_MATERIAL: append_face(str, state[1]); append_token(str, state[2]); break; case STATE_LIGHT: append_index(str, state[1]); /* light number [i]. */ append_token(str, state[2]); /* coefficients */ break; case STATE_LIGHTMODEL_AMBIENT: append(str, "lightmodel.ambient"); break; case STATE_LIGHTMODEL_SCENECOLOR: if (state[1] == 0) { append(str, "lightmodel.front.scenecolor"); } else { append(str, "lightmodel.back.scenecolor"); } break; case STATE_LIGHTPROD: append_index(str, state[1]); /* light number [i]. */ append_face(str, state[2]); append_token(str, state[3]); break; case STATE_TEXGEN: append_index(str, state[1]); /* tex unit [i] */ append_token(str, state[2]); /* plane coef */ break; case STATE_TEXENV_COLOR: append_index(str, state[1]); /* tex unit [i] */ append(str, "color"); break; case STATE_CLIPPLANE: append_index(str, state[1]); /* plane [i] */ append(str, ".plane"); break; case STATE_MODELVIEW_MATRIX: case STATE_PROJECTION_MATRIX: case STATE_MVP_MATRIX: case STATE_TEXTURE_MATRIX: case STATE_PROGRAM_MATRIX: { /* state[0] = modelview, projection, texture, etc. */ /* state[1] = which texture matrix or program matrix */ /* state[2] = first row to fetch */ /* state[3] = last row to fetch */ /* state[4] = transpose, inverse or invtrans */ const gl_state_index mat = state[0]; const GLuint index = (GLuint) state[1]; const GLuint firstRow = (GLuint) state[2]; const GLuint lastRow = (GLuint) state[3]; const gl_state_index modifier = state[4]; if (index || mat == STATE_TEXTURE_MATRIX || mat == STATE_PROGRAM_MATRIX) append_index(str, index); if (modifier) append_token(str, modifier); if (firstRow == lastRow) sprintf(tmp, ".row[%d]", firstRow); else sprintf(tmp, ".row[%d..%d]", firstRow, lastRow); append(str, tmp); } break; case STATE_POINT_SIZE: break; case STATE_POINT_ATTENUATION: break; case STATE_FOG_PARAMS: break; case STATE_FOG_COLOR: break; case STATE_NUM_SAMPLES: break; case STATE_DEPTH_RANGE: break; case STATE_FRAGMENT_PROGRAM: case STATE_VERTEX_PROGRAM: /* state[1] = {STATE_ENV, STATE_LOCAL} */ /* state[2] = parameter index */ append_token(str, state[1]); append_index(str, state[2]); break; case STATE_NORMAL_SCALE: break; case STATE_INTERNAL: append_token(str, state[1]); if (state[1] == STATE_CURRENT_ATTRIB) append_index(str, state[2]); break; default: _mesa_problem(NULL, "Invalid state in _mesa_program_state_string"); break; } return _mesa_strdup(str); }