OpenGL代码注释5.0

  1. 基于时间动画
    static CStopWatch    rotTimer;
    float yRot = rotTimer.GetElapsedSeconds() * 60.0f;

2.绘制地面

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

  1. 使得大球位置平移(3.0)向屏幕里面
   
    modelViewMatrix.Translate(0.0f, 0.0f, -3.0f);

  1. 大球自转
    modelViewMatrix.Rotate(yRot, 0.0f, 1.0f, 0.0f);

5.获取光源位置,指定合适的着色器(点光源着色器)

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

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

代码地址:https://gitee.com/xgkp/spherical_effect_50.git

转载于:https://www.jianshu.com/p/2f30942a0e97

猜你喜欢

转载自blog.csdn.net/weixin_34208185/article/details/91150354
今日推荐