Reputation: 10790
Honestly, I couldnt think of a better title for this issue because I am having 2 problems and I don't know the cause.
The first problem I have is this
//global declaration
float g_posX = 0.0f;
.............
//if keydown happens
g_posX += 0.03f;
&m_mtxView._41 = g_posX;
I get this error
cannot convert from 'float' to 'float *'
So I assume that the matrix only accepts pointers. So i change the varible to this....
//global declaration
float *g_posX = 0.0f;
.............
//if keydown happens
g_posX += 0.03f;
&m_mtxView._41 = &g_posX;
and I get this error
cannot convert from 'float' to 'float *'
which is pretty much saying that I can not declare g_posX as a pointer.
honestly, I don't know what to do.
Upvotes: 1
Views: 843
Reputation: 13099
1.)
m_mtxView._41 = g_posX;
2.)
Update: this piece of code is quite unnecessary, although it shows how to use a pointer allocated on the heap.
float* g_posX = new float; // declare a pointer to the address of a new float
*g_posX = 0.0f; // set the value of what it points to, to 0.0This
m_mtxView._41 = *g_posX; // set the value of m_mtxView._41 to the value of g_posX
delete g_posX; // free the memory that posX allocates.
Hint: Read "*****" as "value of" and "&" as "address of"
Upvotes: 6
Reputation: 224139
Why are you trying to take the address of m_mtxView._41
? What's wrong with m_mtxView._41 = g_posX;
?
Upvotes: 1