【问题标题】:glm::value_ptr has too many argumentsglm::value_ptr 有太多参数
【发布时间】:2016-08-28 16:07:54
【问题描述】:

我是 OpenGL 和 GLM 的新手。我一直在关注在线教程,希望能找到一个有效的教程。一个教程告诉我使用这个 sn-p:

//Define the screen width and height, and get the ratio
const float S_WIDTH = 800;
const float S_HEIGHT = 600;
const float S_RATIO = S_WIDTH / S_HEIGHT;

//In my shader "shdprog" get the uniform variable "ortho"'s location
GLuint orthoadr = glGetUniformLocation(shdprog, "ortho");

//Create a 4x4 matrix using glm
glm::mat4 ortho = glm::ortho(-S_RATIO, S_RATIO, -1.f, 1.f, -1.f, 1.f);

//Set the custom GLSL "ortho" uniform to the value of the glm::mat4 ortho
glUniform4fv(orthoadr, 1, GL_FALSE, glm::value_ptr(ortho)/*too many arguments in function call*/);

无论出于何种原因,Visual Studio 告诉我glm::value_ptr() 有太多参数(“函数调用中的参数太多”)。即使删除所有参数也不会改变任何内容。

我的教程错了吗?还是我打错了什么?

【问题讨论】:

  • 请发布minimal reproducible example,以及您收到的确切错误消息。
  • 很抱歉。这样更好吗?
  • 这不是你的问题,但const float S_RATIO = S_WIDTH / S_HEIGHT 会产生一个值 1。你正在做 integer 数学运算,结果是一个整数,然后转变成一个浮子。当您四舍五入到最接近的整数时,800/600 为 1。
  • 知道了,因为我刚到那里,所以我无法调试我的代码。

标签: c++ glm-math


【解决方案1】:

glUniform4fv 采用 三个 参数。您显然要查找的函数是glUniformMatrix4fv,它需要四个。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多