0
\$\begingroup\$

So I'm learning how to make games and program, and while trying to setup a projection camera using GLM in GFLW, this line of code refuses to work and I can't figuire out why. The code is in the image below. Thanks!

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Side note: Posting the code as text in the future would be helpful. \$\endgroup\$ – Luke Briggs Nov 20 '16 at 6:02
1
\$\begingroup\$

The message you're seeing is saying your argument types aren't right. As 3 of the arguments are float values and they correctly match, then that means m_windowWidth / m_windowHeight must be an integer when it needs to be a float. So, try:

glm::perspective(45.0f, m_windowWidth / static_cast<float>(m_windowHeight), 0.1f, 100f);
| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks for the reply, it made me realize how dumb I was, but actually the window width and height were actually ints and they needs to be floats so i did, glm::perspective(45.0f, (float) (m_windowWidth / m_windowHeight), 0.1f, 100f); and it worked \$\endgroup\$ – Alalayo Nov 20 '16 at 6:08
  • \$\begingroup\$ @Alalayo Ah I slightly misread your IDE - edited. \$\endgroup\$ – Luke Briggs Nov 20 '16 at 6:12
  • \$\begingroup\$ @user94189 thanks for the edit; it's the middle of the night here so I straight copied the above comment without considering that it's doing an integer division - I think it's time to go and get some sleep! :P \$\endgroup\$ – Luke Briggs Nov 20 '16 at 6:18
  • \$\begingroup\$ @Alalayo that is not going to be 100% correct. m_windowWidth / m_windowHeight is an int expression which will be calculated as int (truncating the numbers after the decimal) and only after the truncation will the number be converted to floating point. Instead convert one or both of the variables to float. \$\endgroup\$ – ratchet freak Nov 21 '16 at 17:08
0
\$\begingroup\$

the width and height of the window were actually ints they needed to be floats so I just casted it to a float and it worked.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ See the updated answer; straight casting to float as in your comment is incorrect. \$\endgroup\$ – Luke Briggs Nov 20 '16 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.