# OpenGLShader::SetVec4 设置四维向量 uniform 变量(数组重载版本)。 ```cpp void SetVec4(const char* name, const float* values); ``` 通过名称查找并设置着色器中的四维向量 uniform 变量,使用浮点数数组作为输入。 **参数:** - `name` - uniform 变量名称 - `values` - 指向 4 个 float 元素的数组指针 **返回:** 无 **线程安全:** ❌(需要在渲染线程调用) **示例:** ```cpp // 设置颜色 float color[4] = { 1.0f, 0.5f, 0.2f, 1.0f }; shader->SetVec4("u_color", color); // 设置齐次坐标 float position[4] = { 10.0f, 20.0f, 30.0f, 1.0f }; shader->SetVec4("u_position", position); ``` ## 相关文档 - [OpenGLShader 总览](shader.md) - 返回类总览 - [SetVec4 (xyzw)](../../shader/set-vec4.md) - xyzw分量版本 - [SetVec3 (float*)](set-vec3-array.md) - 三维向量数组版本