c ++ / Opengl:带有__declspec(align('16'))的形参不会对齐 [英] c++/Opengl: formal parameter with __declspec(align('16')) won't be aligned

查看:287
本文介绍了c ++ / Opengl:带有__declspec(align('16'))的形参不会对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置着色器统一的功能,但是当我尝试编译它,我得到这个错误:

I am trying to make function for setting shader uniforms, but when I try to compile it I get this error :


错误2错误C2719:'value':与
__declspec(align('16'))的形式参数不会对齐

Error 2 error C2719: 'value': formal parameter with __declspec(align('16')) won't be aligned

这里是函数的代码:

void Shader::setUniform(std::string name, const glm::mat4 value){
    GLint uniform = glGetUniformLocation(m_program, name.c_str());
    glUniformMatrix4fv(uniform, 1, GL_FALSE, (GLfloat*)&value);
}

我正在使用Visual studio 2013。

I am using Visual studio 2013.

推荐答案

Microsoft的文档该错误:


align __ declspec 修饰符不允许用于函数参数。

The align __declspec modifier is not permitted on function parameters.

strong>复制参数到未对齐的位置。传递一个常量引用到现有的对齐数据。

Don't copy the parameter to an unaligned location. Pass a constant reference to the existing, aligned data.

void Shader::setUniform(const std::string &name, const glm::mat4 &value)
//                                               ^^^^^           ^

这篇关于c ++ / Opengl:带有__declspec(align('16'))的形参不会对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆