Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<GL/freeglut.h>
- void mouseWheel(int button, int dir, int x, int y)
- {
- printf("in mouse wheel n");
- if (dir > 0)
- {
- // Zoom in
- ztrans = ztrans - 1.0;
- printf("scroll in = %0.3fn ",ztrans);
- }
- else
- {
- // Zoom out
- ztrans = ztrans + 1.0;
- printf("scroll out = %0.3fn ",ztrans);
- }
- glutPostRedisplay();
- }
- int main(int argc, char **argv)
- {
- // general initializations
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
- glutInitWindowPosition(100, 100);
- glutInitWindowSize(800, 400);
- glutCreateWindow("Rotation");
- // register callbacks
- glutReshapeFunc(changeSize);
- glutDisplayFunc(renderScene);
- glutIdleFunc(renderScene);
- glutIgnoreKeyRepeat(1);
- glutMouseFunc(mouseButton);
- glutMotionFunc(mouseMove);
- glutMouseWheelFunc(mouseWheel); // Register mouse wheel function
- glEnable(GL_DEPTH_TEST);
- glutMainLoop();
- return 0;
- static int k;
- static int ztrans
- void mouseWheel(int button, int dir, int x, int y)
- {
- k = dir; // int dir is +1 of -1 based on the direction of the wheel motion
- ztrans = ztrans + k;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement