I am trying to test out the entirety of the window module to get a hang of it. As part of that project im trying to change the glClearColor on every frame depending on the position of the axis! Problem is when i first move the analogue stick it works just fine! Now when i try to hold the analogue stick to the left it only works for the first frame then it fails the if test! All the code besides the axis part work. I am using the Xbox 360 Controller for PC if that helps. Code below:
Event event;
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
while (window.isOpen())
{
while (window.pollEvent(event))
{
if (event.type == Event::Closed)
{
window.close();
}
else if (event.type == Event::Resized)
{
glViewport(0, 0, event.size.width, event.size.height);
}
else if (Keyboard::isKeyPressed(Keyboard::Escape))
{
window.close();
}
else if (Joystick::isButtonPressed(0, 0))
{
window.close();
}
else if(Joystick::getAxisPosition(0, Joystick::X) > 50)
{
R = R + 0.01f;
G = R + 0.01f;
B = R + 0.01f;
}
else if(Joystick::getAxisPosition(0, Joystick::X) < -50)
{
R = R - 0.01f;
G = R - 0.01f;
B = R - 0.01f;
}
}
// clear the buffers
glClearColor(R, G, B, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// end the current frame (internally swaps the front and back buffers)
window.display();
}
Thanks in advance~!