1

回転変換行列を適用するには、回転行列を単位行列に掛けて、その行列をシェーダーに戻しますか? オブジェクトを X 軸に沿って 90 度回転できるようにしたいと考えています。PVR ツールには既にこれを実行できる機能があることは知っていますが、回転行列を以下の mMVP 行列に乗算するかどうかを確認したかっただけです。ありがとう

   bool OGLESIntroducingPVRTools::RenderScene()
{
    // Clears the color and depth buffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // Binds the loaded texture
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, m_uiTexture[0]);

    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, m_uiTexture[1]);


    // Use the loaded shader program
    glUseProgram(m_ShaderProgram.uiId);

    /*
        Creates the Model View Projection (MVP) matrix using the PVRTMat4 class from the tools.
        The tools contain a complete set of functions to operate on 4x4 matrices.
    */
    PVRTMat4 mMVP = PVRTMat4::Identity();

    if(PVRShellGet(prefIsRotated) && PVRShellGet(prefFullScreen)) // If the screen is rotated
        mMVP = PVRTMat4::RotationZ(-1.57f);

    /*
        Pass this matrix to the shader.
        The .m field of a PVRTMat4 contains the array of float used to
        communicate with OpenGL ES.
    */
    glUniformMatrix4fv(m_ShaderProgram.auiLoc[eMVPMatrix], 1, GL_FALSE, mMVP.ptr());

    /*
        Draw a triangle.
        Please refer to the training course IntroducingPVRShell for a detailed explanation.
    */

    // Bind the VBO
    glBindBuffer(GL_ARRAY_BUFFER, m_ui32Vbo);

    // Pass the vertex data
    glEnableVertexAttribArray(VERTEX_ARRAY);
    glVertexAttribPointer(VERTEX_ARRAY, 3, GL_FLOAT, GL_FALSE, m_ui32VertexStride, 0);

    // Pass the texture coordinates data
    glEnableVertexAttribArray(TEXCOORD_ARRAY);
    glVertexAttribPointer(TEXCOORD_ARRAY, 2, GL_FLOAT, GL_FALSE, m_ui32VertexStride, (void*) (sizeof(GLfloat) * 3) /* Uvs start after the position */);

    // Draws a non-indexed triangle array
    glDrawArrays(GL_TRIANGLES, 0, 6);


    return true;
}
4

0 に答える 0