Reputation: 9183
I'm concerned mainly with glm library. I want to translate a vector+matrix, using glm::translate, but it throws errors:
I have the following code:
#define GLEW_STATIC
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <GL\glew.h>
#include <GL\GLU.h>
#include <GL\glut.h>
#include <glm.hpp>
#include <GL\gl.h>
#include <gtx\transform2.hpp>
#include <GLFW\glfw3.h>
using namespace std;
using namespace glm;
int main()
{
if (!glfwInit())
{
fprintf(stderr, "Failed to initialize GLFW\n");
return -1;
}
// defining the matrices
glm::mat4 myMatrix = glm::translate(10f,0.0f,0.0f);
glm::vec4 myVector(10.0f, 10.0f, 10.0f, 0.0f);
glm::vec4 transformedVector = myMatrix * myVectors; // multiplication
return 0;
}
When I execute the code, I get the following errors:
error C2059: syntax error : 'bad suffix on number'
error C2146: syntax error : missing ')' before identifier 'f'
error C2784: 'glm::detail::tmat4x4<T,P> glm::translate(const glm::detail::
tvec3<T,P> &)' : could not deduce template argument for 'const glm::detail::tvec3<T,P> &' from 'int'
and a bunch of more errors.
Using the @lazyCoder's solution, I eliminated many errors. Though, I get an error about glm::translate() which is about arguments:
error C2780: 'glm::detail::tmat4x4<T,P> glm::translate(const glm::detail::tvec3<T,P> &)
' : expects 1 arguments - 3 provided
1> c:\opengl\glm-0.9.5.4\glm\glm\gtx\transform.hpp(61) : see declaration of
'glm::translate'
error C2780: 'glm::detail::tmat4x4<T,P> glm::translate(const glm::detail::tmat4x4<T,P>
&,const glm::detail::tvec3<T,P> &)' : expects 2 arguments - 3 provided
1> c:\opengl\glm-0.9.5.4\glm\glm\gtc\matrix_transform.hpp(86) : see declaration of 'glm::translate'
Upvotes: 0
Views: 1075
Reputation: 422
This may be a recent change (using glm 9.61 I believe), and I don't know if it's relevant for this discussion anymore, but glm::translate() appears to take arguments glm::mat4x4 and glm::vec3 respectively.
Thusly, when I had a similar error as above I changed my expression from
glm::translate(10.f,0.f,0.f)
to
glm::translate(glm::mat4x4(),glm::vec3(10.f,0.f,0.f)).
Upvotes: 0
Reputation: 336
replace the first argument of the translate
call with 10.f
the compiler complains about an improper suffix on the number, or to quote the g++ error message invalid suffix "f" on integer constant
follow up to the consecutive error I don't now glm but it seems that translate
takes a vec3
as input and not 3 arguments so try
translate(glm::vec3(10.f, 0.f, 0.f))
Upvotes: 4