diff --git a/main.c b/main.c index 46a9f9e..2be426d 100644 --- a/main.c +++ b/main.c @@ -30,6 +30,10 @@ unsigned int VAO; float currentTime, deltaTime, lastFrame,startTime; float mousePosX,mousePosY,camPosX,camPosY,camPosZ,camDirX,camDirY,camDirZ; +//283=3.14/2 * 180 +const int maxYmouse = 283; +// more precision means less speed +const int camPrecision = 2; static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { @@ -58,24 +62,25 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos) { - mousePosX = xpos; - mousePosY = ypos; /* //if (xpos>283){ //////283=3.14/2 * 180 // //xpos=283 //} //if (xpos<-283){ // //xpos=-283 - //} - if (ypos>283){ - //ypos=283 + //}*/ + int maxYcorrected = maxYmouse*camPrecision; + if (ypos>maxYcorrected){ + glfwSetCursorPos(window, xpos, maxYcorrected); } - if (ypos<283){ - //ypos=-283 + if (ypos<-maxYcorrected){ + glfwSetCursorPos(window, xpos, -maxYcorrected); } - */ + if (DEBUG_MODE % 3 == 0) printf("x:%f | y:%f\n",xpos, ypos); + mousePosX = xpos/camPrecision; + mousePosY = ypos/camPrecision; } int main (){ diff --git a/shaders/quad.fs b/shaders/quad.fs index 86a0ce5..e42cf75 100644 --- a/shaders/quad.fs +++ b/shaders/quad.fs @@ -89,8 +89,8 @@ void main(){ vec3 lookingAt = vec3(0.); vec3 posCam = vec3(2.5,0.5,2.5);//vec3(-3.*sin(Time*.15),.6*cos(Time*.15),3.*cos(Time*.15)); //vec3 posCam = vec3(-3.*sin(MousePos.x/400)*(1-abs(atan(MousePos.y/500))),2*atan(MousePos.y/300),3.*cos(MousePos.x/400)*(1-abs(atan(MousePos.y/500)))); - float pan=MousePos.x/180.; - float tilt=MousePos.y/180.; + float pan=-MousePos.x/180.; + float tilt=-MousePos.y/180.; //tilt=max(min(tilt,3.14*.45),-3.14*.45); int parity = int(tilt/3.14-.5); if(parity%2==1){