Reputation: 128
I am trying to make a simple GLFW key callback function using the provided code in the documentation:
void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) {
if (key == GLFW_KEY_W && action = GLFW_PRESS) {
glTranslatef(0.25f, 0, 0);
}
if (key == GLFW_KEY_A && action = GLFW_PRESS) {
glTranslatef(0, 0, 0.25f);
}
if (key == GLFW_KEY_S && action = GLFW_PRESS) {
glTranslatef(-0.25f, 0, 0);
}
if (key == GLFW_KEY_D && action = GLFW_PRESS) {
glTranslatef(0, 0, -0.25f);
}
}
However, G++ throws the error:
glfw3.h:310:37: error: lvalue required as left operand of assignment
310 | #define GLFW_PRESS 1
| ^
main.cpp:70:36: note: in expansion of macro 'GLFW_PRESS'
70 | if (key == GLFW_KEY_W && action = GLFW_PRESS) {
for every one of these "if" statements.
I encountered it when compiling with this command:
g++ main.cpp -lopengl32 -lglu32 -lglfw3 -mwindows
. I have correctly installed GLFW with MinGW, that compiles fine on its own.
Upvotes: 1
Views: 66