200 likes | 228 Views
"Explore how libQGLViewer, a C++ library based on Qt, simplifies OpenGL 3D viewer development by enabling camera movement, object selection, camera path control, screenshot saving, and more. Learn about drawing functions, demos, and customization features for an enriched viewer experience."
E N D
Introduction to C & C++ Lecture 13 – libQGLViewer JJCAO
libQGLViewer • C++ library • based on Qt • eases the creation of OpenGL 3D viewers with some of the typical 3D viewer functionalities: • move the camera using the mouse • object selection • camera paths control using F1..F12 (demo with simpleViewer) • screenshot saving • …
Without libQGLViewer void MyGLWindow::draw(){ if (!valid())//for window creat and resize initGL(); // clears the color buffer and depth buffer using the current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); view_all();// setup camera (only once) //begin of drawing glPushMatrix();//to avoid cumulate effect //setup viewpoint from current arcball arcball_.glDraw(); // draw … … glPopMatrix(); //end of drawing }
Demos • CGAL-3.8\demo\Triangulation_3
simpleViewer D:\libQGLViewer-2.3.10\examples\simpleViewer
manipulatedFrame D:\libQGLViewer-2.3.10\examples\manipulatedFrame
manipulatedFrame setManipulatedFrame(new ManipulatedFrame()) glMultMatrixd(manipulatedFrame()->matrix()); setAxisIsDrawn() drawAxis() D:\libQGLViewer-2.3.10\examples\manipulatedFrame
Select /pick D:\libQGLViewer-2.3.10\examples\select
Select /pick D:\libQGLViewer-2.3.10\examples\select
Select /pick virtual void drawWithNames(); virtual void postSelection(constQPoint& point); glPushName(i); camera()->convertClickToLine(point, orig, dir); selectedPoint = camera()->pointUnderPixel(point, found); selectedName(); D:\libQGLViewer-2.3.10\examples\select
keyboardAndMouse D:\libQGLViewer-2.3.10\examples\keyboardAndMouse
keyboardAndMouse No effect! Why? D:\libQGLViewer-2.3.10\examples\keyboardAndMouse
keyboardAndMouse D:\libQGLViewer-2.3.10\examples\keyboardAndMouse
keyboardAndMouse D:\libQGLViewer-2.3.10\examples\keyboardAndMouse
keyboardAndMouse • setShortcut()changestandard action bindings (axis, grid or fps display, exit...). • setMouseBinding() and setWheelBinding()changestandard action mouse bindings (camera rotation, translation, object selection...). • If you want to define new keyboard shortcuts, overloadkeyPressEvent() and bind your own new actions. Use setKeyDescription() to add your shortcuts in the help window. • To define new mouse actions, overload mouse(Press|Move|Release)Event. OverloadsetMouseBindingDescription() to update the help window binding tab. D:\libQGLViewer-2.3.10\examples\keyboardAndMouse
Animation D:\libQGLViewer-2.3.10\examples\animation
Animation D:\libQGLViewer-2.3.10\examples\animation
Animation • When animation is activated(the Returnkey toggles animation), the animate() and then the draw() functions are called in an infinite loop. • You can tune the frequency of your animation (default is 25Hz) using setAnimationInterval(). The frame rate will then be fixed, provided that your animation loop function is fast enough. D:\libQGLViewer-2.3.10\examples\animation
Interface Practice in the Designer D:\libQGLViewer-2.3.10\examples\interface