OpenGL 5.0 code comments

  1. Time-based animation
    static CStopWatch    rotTimer;
    float yRot = rotTimer.GetElapsedSeconds() * 60.0f;

2. Draw the ground

    shaderManager.UseStockShader(GLT_SHADER_FLAT,
                                 transformPipeline.GetModelViewProjectionMatrix(),
                                 vFloorColor);

  1. Translational position such that the large ball (3.0) to the inside of the screen
   
    modelViewMatrix.Translate(0.0f, 0.0f, -3.0f);

  1. Big ball rotation
    modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);

5. Obtain light source position, specify the appropriate shader (point source shader)

 M3DVector4f vLightPos = {0.0f,10.0f,5.0f,1.0f};

 shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(),
                                 transformPipeline.GetProjectionMatrix(), vLightPos, vTorusColor);

Code Address: https://gitee.com/xgkp/spherical_effect_50.git

Reproduced in: https: //www.jianshu.com/p/2f30942a0e97

Guess you like

Origin blog.csdn.net/weixin_34208185/article/details/91150354