17 int VART::ViewerGlutOGL::glutIDVec[6] = { 0, 0, 0, 0, 0, 0 };
18 VART::ViewerGlutOGL* VART::ViewerGlutOGL::instancePtrVec[6] = { NULL, NULL, NULL, NULL, NULL, NULL };
24 cerr <<
"Warning: ViewerGlutOGL::HandleKey is deprecated, use OnKeyDown.\n";
25 HandleKey(static_cast<unsigned char>(key));
33 glutInitWindowSize(300,300);
41 glutInitWindowSize(newWidth, newHeight);
47 void VART::ViewerGlutOGL::CommonConstructor()
49 glutInitWindowPosition(0,0);
50 glutID = glutCreateWindow(
"V-ART Glut OpenGL Viewer");
54 drawHandlerPtr = NULL;
55 mouseController.SetOwner(
this);
58 autoChangeCameraAspect =
true;
59 autoNavigationEnabled =
true;
60 autoRespondKeys =
true;
61 glShadeModel(GL_SMOOTH);
62 glEnable(GL_DEPTH_TEST);
63 glEnable(GL_CULL_FACE);
65 glEnableClientState(GL_VERTEX_ARRAY);
66 glEnableClientState(GL_NORMAL_ARRAY);
74 while (glutIDVec[i] != glutID)
77 instancePtrVec[i] = NULL;
82 idleHndPtr = newIHPtr;
89 int currentWindow = glutGetWindow();
90 glutSetWindow(glutID);
91 glutPositionWindow(x,y);
92 glutSetWindow(currentWindow);
97 int currentWindow = glutGetWindow();
98 if (autoChangeCameraAspect && ptScene)
100 ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
101 float horScale =
static_cast<float>(newWidth)/width;
102 float verScale =
static_cast<float>(newHeight)/height;
103 ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
107 glutSetWindow(glutID);
108 glutReshapeWindow(newWidth, newHeight);
109 glutSetWindow(currentWindow);
115 glutSetWindow(glutID);
120 drawHandlerPtr = newDHPtr;
128 if (cameraPtr == NULL)
129 cameraPtr = scene.GetCurrentCamera();
130 if (scene.GetNumLights() > 0)
132 int currentWindow = glutGetWindow();
133 glutSetWindow(glutID);
134 glEnable(GL_LIGHTING);
135 glutSetWindow(currentWindow);
141 static float bgColor[4];
142 ptScene->GetBackgroundColor().GetScaled(1.0f, bgColor);
143 glClearColor(bgColor[0], bgColor[1], bgColor[2], bgColor[3]);
144 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
151 glutIdleFunc(IdleMngr);
158 glutInit(argcPtr, argv);
159 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH | GLUT_MULTISAMPLE);
166 if (instancePtrVec[i])
167 instancePtrVec[i]->PostRedisplay();
170 void VART::ViewerGlutOGL::DrawCB0()
180 viewerPtr->ptScene->DrawOGL(viewerPtr->cameraPtr);
183 if (viewerPtr->ptScene == NULL)
185 cerr <<
"Fatal error: VART::ViewerGlutOGL tried to draw a scene pointed by NULL!" << endl;
189 if (!(viewerPtr->ptScene->DrawOGL()))
191 cerr <<
"Fatal error: VART::Scene::DrawOGL returned false!\n\a"
192 <<
"This means that V-ART has been compiled with no underlying rendering "
193 <<
"engine, please check your project options and re-compile V-ART." << endl;
197 if (viewerPtr->drawHandlerPtr)
198 viewerPtr->drawHandlerPtr->
OnDraw();
202 void VART::ViewerGlutOGL::DrawCB1()
204 ViewerGlutOGL* viewerPtr = instancePtrVec[1];
206 viewerPtr->ptScene->DrawOGL(viewerPtr->cameraPtr);
207 if (viewerPtr->drawHandlerPtr)
208 viewerPtr->drawHandlerPtr->OnDraw();
212 void VART::ViewerGlutOGL::DrawCB2()
214 ViewerGlutOGL* viewerPtr = instancePtrVec[2];
215 viewerPtr->ClearOGLBuffers();
216 viewerPtr->ptScene->DrawOGL(viewerPtr->cameraPtr);
217 if (viewerPtr->drawHandlerPtr)
218 viewerPtr->drawHandlerPtr->OnDraw();
222 void VART::ViewerGlutOGL::DrawCB3()
224 ViewerGlutOGL* viewerPtr = instancePtrVec[3];
225 viewerPtr->ClearOGLBuffers();
226 viewerPtr->ptScene->DrawOGL(viewerPtr->cameraPtr);
227 if (viewerPtr->drawHandlerPtr)
228 viewerPtr->drawHandlerPtr->OnDraw();
232 void VART::ViewerGlutOGL::DrawCB4()
234 ViewerGlutOGL* viewerPtr = instancePtrVec[4];
235 viewerPtr->ClearOGLBuffers();
236 viewerPtr->ptScene->DrawOGL(viewerPtr->cameraPtr);
237 if (viewerPtr->drawHandlerPtr)
238 viewerPtr->drawHandlerPtr->OnDraw();
242 void VART::ViewerGlutOGL::DrawCB5()
244 ViewerGlutOGL* viewerPtr = instancePtrVec[5];
245 viewerPtr->ClearOGLBuffers();
246 viewerPtr->ptScene->DrawOGL(viewerPtr->cameraPtr);
247 if (viewerPtr->drawHandlerPtr)
248 viewerPtr->drawHandlerPtr->OnDraw();
252 void VART::ViewerGlutOGL::MouseCB0(
int button,
int state,
int x,
int y)
255 int keyModifier = glutGetModifiers();
261 case GLUT_LEFT_BUTTON:
264 case GLUT_MIDDLE_BUTTON:
267 case GLUT_RIGHT_BUTTON:
276 if (state == GLUT_DOWN)
286 if (keyModifier & GLUT_ACTIVE_SHIFT)
290 if (keyModifier & GLUT_ACTIVE_CTRL)
294 if (keyModifier & GLUT_ACTIVE_ALT)
299 viewerPtr->mouseController.
OnClick();
302 void VART::ViewerGlutOGL::MouseCB1(
int button,
int state,
int x,
int y)
305 int keyModifier = glutGetModifiers();
311 case GLUT_LEFT_BUTTON:
314 case GLUT_MIDDLE_BUTTON:
317 case GLUT_RIGHT_BUTTON:
326 if (state == GLUT_DOWN)
336 if (keyModifier & GLUT_ACTIVE_SHIFT)
340 if (keyModifier & GLUT_ACTIVE_CTRL)
344 if (keyModifier & GLUT_ACTIVE_ALT)
349 viewerPtr->mouseController.
OnClick();
352 void VART::ViewerGlutOGL::MouseCB2(
int button,
int state,
int x,
int y)
355 int keyModifier = glutGetModifiers();
361 case GLUT_LEFT_BUTTON:
364 case GLUT_MIDDLE_BUTTON:
367 case GLUT_RIGHT_BUTTON:
376 if (state == GLUT_DOWN)
386 if (keyModifier & GLUT_ACTIVE_SHIFT)
390 if (keyModifier & GLUT_ACTIVE_CTRL)
394 if (keyModifier & GLUT_ACTIVE_ALT)
399 viewerPtr->mouseController.
OnClick();
402 void VART::ViewerGlutOGL::MouseCB3(
int button,
int state,
int x,
int y)
405 int keyModifier = glutGetModifiers();
411 case GLUT_LEFT_BUTTON:
414 case GLUT_MIDDLE_BUTTON:
417 case GLUT_RIGHT_BUTTON:
426 if (state == GLUT_DOWN)
436 if (keyModifier & GLUT_ACTIVE_SHIFT)
440 if (keyModifier & GLUT_ACTIVE_CTRL)
444 if (keyModifier & GLUT_ACTIVE_ALT)
449 viewerPtr->mouseController.
OnClick();
452 void VART::ViewerGlutOGL::MouseCB4(
int button,
int state,
int x,
int y)
455 int keyModifier = glutGetModifiers();
461 case GLUT_LEFT_BUTTON:
464 case GLUT_MIDDLE_BUTTON:
467 case GLUT_RIGHT_BUTTON:
476 if (state == GLUT_DOWN)
486 if (keyModifier & GLUT_ACTIVE_SHIFT)
490 if (keyModifier & GLUT_ACTIVE_CTRL)
494 if (keyModifier & GLUT_ACTIVE_ALT)
499 viewerPtr->mouseController.
OnClick();
502 void VART::ViewerGlutOGL::MouseCB5(
int button,
int state,
int x,
int y)
505 int keyModifier = glutGetModifiers();
511 case GLUT_LEFT_BUTTON:
514 case GLUT_MIDDLE_BUTTON:
517 case GLUT_RIGHT_BUTTON:
526 if (state == GLUT_DOWN)
536 if (keyModifier & GLUT_ACTIVE_SHIFT)
540 if (keyModifier & GLUT_ACTIVE_CTRL)
544 if (keyModifier & GLUT_ACTIVE_ALT)
549 viewerPtr->mouseController.
OnClick();
552 void VART::ViewerGlutOGL::DragMouseCB0(
int x,
int y)
554 instancePtrVec[0]->mouseController.SetCurrentPosititon(x,y);
555 instancePtrVec[0]->mouseController.OnDrag();
558 void VART::ViewerGlutOGL::DragMouseCB1(
int x,
int y)
560 instancePtrVec[1]->mouseController.SetCurrentPosititon(x,y);
561 instancePtrVec[1]->mouseController.OnDrag();
564 void VART::ViewerGlutOGL::DragMouseCB2(
int x,
int y)
566 instancePtrVec[2]->mouseController.SetCurrentPosititon(x,y);
567 instancePtrVec[2]->mouseController.OnDrag();
570 void VART::ViewerGlutOGL::DragMouseCB3(
int x,
int y)
572 instancePtrVec[3]->mouseController.SetCurrentPosititon(x,y);
573 instancePtrVec[3]->mouseController.OnDrag();
576 void VART::ViewerGlutOGL::DragMouseCB4(
int x,
int y)
578 instancePtrVec[4]->mouseController.SetCurrentPosititon(x,y);
579 instancePtrVec[4]->mouseController.OnDrag();
582 void VART::ViewerGlutOGL::DragMouseCB5(
int x,
int y)
584 instancePtrVec[5]->mouseController.SetCurrentPosititon(x,y);
585 instancePtrVec[5]->mouseController.OnDrag();
588 void VART::ViewerGlutOGL::HandleKey(
unsigned char key)
590 VART::Camera* cameraPtr = ptScene->GetCurrentCamera();
594 cameraPtr->YawAroundTarget(0.01);
597 cameraPtr->YawAroundTarget(-0.01);
600 cameraPtr->PitchAroundTarget(0.01);
603 cameraPtr->PitchAroundTarget(-0.01);
616 void VART::ViewerGlutOGL::SpecialKeyCB0(
int key,
int x,
int y)
620 if (viewerPtr->kbHandlerPtr) {
622 viewerPtr->kbHandlerPtr->
OnKeyDown(key+255);
626 void VART::ViewerGlutOGL::SpecialKeyCB1(
int key,
int x,
int y)
630 if (viewerPtr->kbHandlerPtr) {
632 viewerPtr->kbHandlerPtr->
OnKeyDown(key+255);
636 void VART::ViewerGlutOGL::SpecialKeyCB2(
int key,
int x,
int y)
640 if (viewerPtr->kbHandlerPtr) {
642 viewerPtr->kbHandlerPtr->
OnKeyDown(key+255);
646 void VART::ViewerGlutOGL::SpecialKeyCB3(
int key,
int x,
int y)
650 if (viewerPtr->kbHandlerPtr) {
652 viewerPtr->kbHandlerPtr->
OnKeyDown(key+255);
656 void VART::ViewerGlutOGL::SpecialKeyCB4(
int key,
int x,
int y)
660 if (viewerPtr->kbHandlerPtr) {
662 viewerPtr->kbHandlerPtr->
OnKeyDown(key+255);
666 void VART::ViewerGlutOGL::SpecialKeyCB5(
int key,
int x,
int y)
670 if (viewerPtr->kbHandlerPtr) {
672 viewerPtr->kbHandlerPtr->
OnKeyDown(key+255);
678 void VART::ViewerGlutOGL::SpecialKeyUpCB0(
int key,
int x,
int y)
682 if (viewerPtr->kbHandlerPtr)
683 viewerPtr->kbHandlerPtr->
OnKeyUp(key+255);
686 void VART::ViewerGlutOGL::SpecialKeyUpCB1(
int key,
int x,
int y)
690 if (viewerPtr->kbHandlerPtr)
691 viewerPtr->kbHandlerPtr->
OnKeyUp(key+255);
694 void VART::ViewerGlutOGL::SpecialKeyUpCB2(
int key,
int x,
int y)
698 if (viewerPtr->kbHandlerPtr)
699 viewerPtr->kbHandlerPtr->
OnKeyUp(key+255);
702 void VART::ViewerGlutOGL::SpecialKeyUpCB3(
int key,
int x,
int y)
706 if (viewerPtr->kbHandlerPtr)
707 viewerPtr->kbHandlerPtr->
OnKeyUp(key+255);
710 void VART::ViewerGlutOGL::SpecialKeyUpCB4(
int key,
int x,
int y)
714 if (viewerPtr->kbHandlerPtr)
715 viewerPtr->kbHandlerPtr->
OnKeyUp(key+255);
718 void VART::ViewerGlutOGL::SpecialKeyUpCB5(
int key,
int x,
int y)
722 if (viewerPtr->kbHandlerPtr)
723 viewerPtr->kbHandlerPtr->
OnKeyUp(key+255);
727 void VART::ViewerGlutOGL::KeyboardCB0(
unsigned char key,
int x,
int y)
731 if (viewerPtr->kbHandlerPtr)
732 viewerPtr->kbHandlerPtr->
OnKeyDown(static_cast<int>(key));
735 viewerPtr->HandleKey(key);
738 void VART::ViewerGlutOGL::KeyboardCB1(
unsigned char key,
int x,
int y)
742 if (viewerPtr->kbHandlerPtr)
743 viewerPtr->kbHandlerPtr->
OnKeyDown(static_cast<int>(key));
746 viewerPtr->HandleKey(key);
749 void VART::ViewerGlutOGL::KeyboardCB2(
unsigned char key,
int x,
int y)
753 if (viewerPtr->kbHandlerPtr)
754 viewerPtr->kbHandlerPtr->
OnKeyDown(static_cast<int>(key));
757 viewerPtr->HandleKey(key);
760 void VART::ViewerGlutOGL::KeyboardCB3(
unsigned char key,
int x,
int y)
764 if (viewerPtr->kbHandlerPtr)
765 viewerPtr->kbHandlerPtr->
OnKeyDown(static_cast<int>(key));
768 viewerPtr->HandleKey(key);
771 void VART::ViewerGlutOGL::KeyboardCB4(
unsigned char key,
int x,
int y)
775 if (viewerPtr->kbHandlerPtr)
776 viewerPtr->kbHandlerPtr->
OnKeyDown(static_cast<int>(key));
779 viewerPtr->HandleKey(key);
782 void VART::ViewerGlutOGL::KeyboardCB5(
unsigned char key,
int x,
int y)
786 if (viewerPtr->kbHandlerPtr)
787 viewerPtr->kbHandlerPtr->
OnKeyDown(static_cast<int>(key));
790 viewerPtr->HandleKey(key);
794 void VART::ViewerGlutOGL::OnKeyUpCB0(
unsigned char key,
int x,
int y)
798 if (viewerPtr->kbHandlerPtr)
799 viewerPtr->kbHandlerPtr->
OnKeyUp(static_cast<int>(key));
802 void VART::ViewerGlutOGL::OnKeyUpCB1(
unsigned char key,
int x,
int y)
806 if (viewerPtr->kbHandlerPtr)
807 viewerPtr->kbHandlerPtr->
OnKeyUp(static_cast<int>(key));
810 void VART::ViewerGlutOGL::OnKeyUpCB2(
unsigned char key,
int x,
int y)
814 if (viewerPtr->kbHandlerPtr)
815 viewerPtr->kbHandlerPtr->
OnKeyUp(static_cast<int>(key));
818 void VART::ViewerGlutOGL::OnKeyUpCB3(
unsigned char key,
int x,
int y)
822 if (viewerPtr->kbHandlerPtr)
823 viewerPtr->kbHandlerPtr->
OnKeyUp(static_cast<int>(key));
826 void VART::ViewerGlutOGL::OnKeyUpCB4(
unsigned char key,
int x,
int y)
830 if (viewerPtr->kbHandlerPtr)
831 viewerPtr->kbHandlerPtr->
OnKeyUp(static_cast<int>(key));
834 void VART::ViewerGlutOGL::OnKeyUpCB5(
unsigned char key,
int x,
int y)
838 if (viewerPtr->kbHandlerPtr)
839 viewerPtr->kbHandlerPtr->
OnKeyUp(static_cast<int>(key));
843 void VART::ViewerGlutOGL::ResizeCB0(
int newWidth,
int newHeight)
847 assert(viewerPtr->ptScene != NULL);
848 viewerPtr->ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
849 float horScale =
static_cast<float>(newWidth)/viewerPtr->width;
850 float verScale = static_cast<float>(newHeight)/viewerPtr->height;
851 viewerPtr->ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
853 viewerPtr->width = newWidth;
854 viewerPtr->height = newHeight;
855 glViewport(0,0,newWidth,newHeight);
858 void VART::ViewerGlutOGL::ResizeCB1(
int newWidth,
int newHeight)
862 assert(viewerPtr->ptScene != NULL);
863 viewerPtr->ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
864 float horScale =
static_cast<float>(newWidth)/viewerPtr->width;
865 float verScale = static_cast<float>(newHeight)/viewerPtr->height;
866 viewerPtr->ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
868 viewerPtr->width = newWidth;
869 viewerPtr->height = newHeight;
870 glViewport(0,0,newWidth,newHeight);
873 void VART::ViewerGlutOGL::ResizeCB2(
int newWidth,
int newHeight)
877 assert(viewerPtr->ptScene != NULL);
878 viewerPtr->ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
879 float horScale =
static_cast<float>(newWidth)/viewerPtr->width;
880 float verScale = static_cast<float>(newHeight)/viewerPtr->height;
881 viewerPtr->ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
883 viewerPtr->width = newWidth;
884 viewerPtr->height = newHeight;
885 glViewport(0,0,newWidth,newHeight);
888 void VART::ViewerGlutOGL::ResizeCB3(
int newWidth,
int newHeight)
892 assert(viewerPtr->ptScene != NULL);
893 viewerPtr->ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
894 float horScale =
static_cast<float>(newWidth)/viewerPtr->width;
895 float verScale = static_cast<float>(newHeight)/viewerPtr->height;
896 viewerPtr->ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
898 viewerPtr->width = newWidth;
899 viewerPtr->height = newHeight;
900 glViewport(0,0,newWidth,newHeight);
903 void VART::ViewerGlutOGL::ResizeCB4(
int newWidth,
int newHeight)
907 assert(viewerPtr->ptScene != NULL);
908 viewerPtr->ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
909 float horScale =
static_cast<float>(newWidth)/viewerPtr->width;
910 float verScale = static_cast<float>(newHeight)/viewerPtr->height;
911 viewerPtr->ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
913 viewerPtr->width = newWidth;
914 viewerPtr->height = newHeight;
915 glViewport(0,0,newWidth,newHeight);
918 void VART::ViewerGlutOGL::ResizeCB5(
int newWidth,
int newHeight)
922 assert(viewerPtr->ptScene != NULL);
923 viewerPtr->ptScene->SetAllCamerasAspectRatio(static_cast<float>(newWidth)/newHeight);
924 float horScale =
static_cast<float>(newWidth)/viewerPtr->width;
925 float verScale = static_cast<float>(newHeight)/viewerPtr->height;
926 viewerPtr->ptScene->ChangeAllCamerasViewVolume(horScale,verScale);
928 viewerPtr->width = newWidth;
929 viewerPtr->height = newHeight;
930 glViewport(0,0,newWidth,newHeight);
939 int currentWindow = glutGetWindow();
940 glutSetWindow(glutID);
941 if (mouseController.AnyButtonIsDown() && autoNavigationEnabled)
943 VART::Camera* ptCam = ptScene->GetCurrentCamera();
946 double pitchAngle = mouseController.GetYDrag() * 0.00001;
947 double yawAngle = mouseController.GetXDrag() * -0.00001;
948 ptCam->PitchAroundTarget(pitchAngle);
949 ptCam->YawAroundTarget(yawAngle);
955 double Xdiff = mouseController.GetXDrag() * walkStep;
956 double Ydiff = mouseController.GetYDrag() * (-walkStep);
957 ptCam->MoveSideways(Xdiff);
958 ptCam->MoveUp(Ydiff);
962 double Ydiff = mouseController.GetYDrag() * (-walkStep);
963 double yawAngle = mouseController.GetXDrag() * -0.00001;
964 ptCam->MoveForward(Ydiff);
965 ptCam->Yaw(yawAngle);
971 idleHndPtr->OnIdle();
976 glutSetWindow(currentWindow);
979 void VART::ViewerGlutOGL::IdleMngr()
981 for (
int i = 0; i < 6; ++i)
982 if (instancePtrVec[i])
983 instancePtrVec[i]->Idle();
986 void VART::ViewerGlutOGL::RegisterCallbacks()
989 while ((i<6) && (glutIDVec[i] != 0))
993 glutIDVec[i] = glutID;
994 instancePtrVec[i] =
this;
998 glutDisplayFunc(DrawCB0);
999 glutMouseFunc(MouseCB0);
1000 glutMotionFunc(DragMouseCB0);
1001 glutKeyboardFunc(KeyboardCB0);
1002 glutKeyboardUpFunc(OnKeyUpCB0);
1003 glutReshapeFunc(ResizeCB0);
1004 glutSpecialFunc(SpecialKeyCB0);
1005 glutSpecialUpFunc(SpecialKeyUpCB0);
1008 glutDisplayFunc(DrawCB1);
1009 glutMouseFunc(MouseCB1);
1010 glutMotionFunc(DragMouseCB1);
1011 glutKeyboardFunc(KeyboardCB1);
1012 glutKeyboardUpFunc(OnKeyUpCB1);
1013 glutReshapeFunc(ResizeCB1);
1014 glutSpecialFunc(SpecialKeyCB1);
1015 glutSpecialUpFunc(SpecialKeyUpCB1);
1018 glutDisplayFunc(DrawCB2);
1019 glutMouseFunc(MouseCB2);
1020 glutMotionFunc(DragMouseCB2);
1021 glutKeyboardFunc(KeyboardCB2);
1022 glutKeyboardUpFunc(OnKeyUpCB2);
1023 glutReshapeFunc(ResizeCB2);
1024 glutSpecialFunc(SpecialKeyCB2);
1025 glutSpecialUpFunc(SpecialKeyUpCB2);
1028 glutDisplayFunc(DrawCB3);
1029 glutMouseFunc(MouseCB3);
1030 glutMotionFunc(DragMouseCB3);
1031 glutKeyboardFunc(KeyboardCB3);
1032 glutKeyboardUpFunc(OnKeyUpCB3);
1033 glutReshapeFunc(ResizeCB3);
1034 glutSpecialFunc(SpecialKeyCB3);
1035 glutSpecialUpFunc(SpecialKeyUpCB3);
1038 glutDisplayFunc(DrawCB4);
1039 glutMouseFunc(MouseCB4);
1040 glutMotionFunc(DragMouseCB4);
1041 glutKeyboardFunc(KeyboardCB4);
1042 glutKeyboardUpFunc(OnKeyUpCB4);
1043 glutReshapeFunc(ResizeCB4);
1044 glutSpecialFunc(SpecialKeyCB4);
1045 glutSpecialUpFunc(SpecialKeyUpCB4);
1048 glutDisplayFunc(DrawCB5);
1049 glutMouseFunc(MouseCB5);
1050 glutMotionFunc(DragMouseCB5);
1051 glutKeyboardFunc(KeyboardCB5);
1052 glutKeyboardUpFunc(OnKeyUpCB5);
1053 glutReshapeFunc(ResizeCB5);
1054 glutSpecialFunc(SpecialKeyCB5);
1055 glutSpecialUpFunc(SpecialKeyUpCB5);
1063 int currentWindow = glutGetWindow();
1064 glutSetWindow(glutID);
1066 glutSetWindow(currentWindow);
1071 int currentWindow = glutGetWindow();
1072 glutSetWindow(glutID);
1074 glutSetWindow(currentWindow);
1079 int currentWindow = glutGetWindow();
1080 glutSetWindow(glutID);
1081 glutSetWindowTitle(newTitle.c_str());
1082 glutSetIconTitle(newTitle.c_str());
1083 glutSetWindow(currentWindow);
1088 int currentWindow = glutGetWindow();
1089 glutSetWindow(glutID);
1090 glutIconifyWindow();
1091 glutSetWindow(currentWindow);
1096 int currentWindow = glutGetWindow();
1097 glutSetWindow(glutID);
1098 glutPostRedisplay();
1099 glutSetWindow(currentWindow);
1104 kbHandlerPtr = ptrKbH;
1115 mouseController.SetClickHandler(newCHPtr);
1120 mouseController.SetDragHandler(newDHPtr);
1125 mouseController.SetMotionHandler(newMHPtr);
void ClearOGLBuffers()
Sets clear color and clears OpenGL buffers.
void SetDragHandler(MouseControl::DragHandler *newDHPtr)
Sets the mouse drag handler.
virtual void OnDraw()=0
Called when the window is redrawn.
void SetModifierState(ModifierID mdValue, bool state)
Sets the modifier state on last event.
ViewerGlutOGL * viewerPtr
Points to the viewer on which the handler was attached.
void SetCamera(Camera *camPtr)
Sets the camera used to view the scene.
ViewerGlutOGL * viewerPtr
Points to the viewer on which the handler was attached.
V-ART Viewer that uses GLUT/OpenGL.
void SetCurrentPosititon(int newX, int newY)
Set the current position.
Header file for V-ART class "ViewerGlutOGL".
void Iconify()
Iconifies (minimizes) the viewer window.
void Show()
Shows the viewer.
void SetSize(int newWidth, int newHeight)
Sets the window size of the viewer.
void NewEvent(ButtonID btn, StateID newState)
Registers new button event.
void Idle()
Idle Management.
ViewerGlutOGL()
Creates an empty, unusable viewer positioned at (0,0).
virtual void HandleSpecialKey(int key)
Called when a special key is pressed.
static void Init(int *argcPtr, char *argv[])
Initializes GLUT Library.
void SetPosition(int x, int y)
Changes the position of a viewer.
void SetClickHandler(MouseControl::ClickHandler *newCHPtr)
Sets the mouse click handler.
void TurnIntoCurrentWindow()
Make the viewer become the current window.
void OnClick()
Activates click handler, if any.
static void MainLoop()
Enters main rendering loop.
void SetMotionHandler(MouseControl::MotionHandler *newMHPtr)
Sets the mouse motion handler.
const unsigned int MAX_VIEWERS
void SetDrawHandler(DrawHandler *newDHPtr)
Sets the drawing handler.
void SetIdleHandler(IdleHandler *newIHPtr)
Sets the idle time handler.
bool autoChangeCameraAspect
void SetTitle(const std::string &newTitle)
Changes window title.
ViewerGlutOGL * viewerPtr
Points to the viewer on which the handler was attached.
void PostRedisplay()
Marks the viewer window for redisplay.
void SetKbHandler(KbHandler *ptrKbH)
Add a keyboard handler to the viewer.
void Hide()
Hides the viewer.
virtual void OnKeyDown(int key)
Called when a key is pressed.
void SetReleasedPosition(int newX, int newY)
Sets the position of last button release.
void SetScene(Scene &scene)
Attaches a scene to the viewer.
virtual void OnKeyUp(int key)
Called when a key is released.
static void RedisplayAll()
Marks all viewers for redisplay.
void SetClickPosition(int newX, int newY)
Sets the position of last click.