セレクション機能 gluPickMatrixの中身
googleのコード検索で見つかったソースです。
備忘録の為日記に書きます。
void gluPickMatrix(GLfloat x, GLfloat y,GLfloat width, GLfloat height, GLint viewport[4]) { float sx, sy; float tx, ty; // from OGL_Sample code library // /* Translate and scale the picked region to the entire window */ // glTranslatef((viewport[2] - 2 * (x - viewport[0])) / deltax, // (viewport[3] - 2 * (y - viewport[1])) / deltay, 0); // glScalef(viewport[2] / deltax, viewport[3] / deltay, 1.0); sx = viewport[2] / width; sy = viewport[3] / height; tx = (viewport[2] + 2.0f * (viewport[0] - x)) / width; ty = (viewport[3] + 2.0f * (viewport[1] - y)) / height; mp[0][0] = sx; mp[0][3] = tx; mp[1][1] = sy; mp[1][3] = ty; glMultMatrixf((GLfloat*)&mp); }
こっちの方が早いのかな?スケールや並行移動するより…