1 / 26

FLTK and OpenGL

FLTK and OpenGL. Jyun-Ming Chen. Content. Review inter-widget communication “ Double.c ” -based examples Idle, timer, … numerous events Fluid-based implementation Viewer examples. Value can be controlled by the text widget and the slider Demonstrate inter-widget communications. v.

harper
Download Presentation

FLTK and OpenGL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. FLTK and OpenGL Jyun-Ming Chen Topics in Computer Graphics

  2. Content • Review inter-widget communication • “Double.c”-based examples • Idle, timer, … numerous events • Fluid-based implementation • Viewer examples

  3. Value can be controlled by the text widget and the slider Demonstrate inter-widget communications v value 13 Review: Widget Talk Design

  4. WidgetTalk

  5. Handle()

  6. Subclass Fl_Gl_Window Draw(): display callback Redraw(): PostRedisplay Handle(): mouse/kbd event handler Valid(): off when FLTK creates a new context for this window, or when the window resizes; on after draw() is called. Using OpenGL in FLTK reshape

  7. Class design Private double angle; Private double speed; Public draw(); Public handle(); Public toggleMotion(); Other issues: Speed control Time-based animation “Callback” Reshape Display Mouse Keyboard Timer Idle Double.c by Fl_Gl_Window

  8. Idle function add_idle(void (*cb)(void*), void* = 0); void remove_idle(void (*cb)(void*), void* = 0); Timer function: one-shot timeout callback Fl::add_timeout (double t, // seconds Fl_Timeout_Handler,void* = 0); void remove_timeout(Fl_Timeout_Handler, void* = 0); void repeat_timeout(double t, Fl_Timeout_Handler,void* = 0); Animation Class method of Fl

  9. Summary: OpenGL Using Fluid (or Fl_Group)

  10. First example: shape • First, simple application with no animation! • Create Shape_Win class with these method • Set_sides • Draw() • Generate interface with fluid: • A double_win and a slider • Callback of the slider: set the sides and calls redraw

  11. Creating a Double.cin FLTK

  12. Create main() Create a function Step 1

  13. Select main Create a Window inside main() Step 2

  14. A subclass of Fl_Gl_Window Must define draw() Include them in the directory Class Double_Win Later …

  15. Add the class Double_Win into the window First, create a group Add these… Step 3

  16. Use timeout “fl_spin” to animate Spin_on: records the spin status Toggle Motion

  17. Add a button for toggleMotion First, create a button Add these… Step 4

  18. Finally, • Save the fluid file • Generate the codes • Compile and run!

  19. Flaux – my addition to FLTK • Glm.c: OBJ reader • Glutshapes.c: the glut primitives • Glutteapot.c: the Utah teapot • Viewer: the class of spherical viewer

  20. Viewer Methods • Void center (float*c); • Void center (const float c[3]); • Float extent(); • Void extent (float e); • Float fovY(); • Void fovY(float f); • Void set_content (void (*fun)(void)); • Color & depth buffers are already cleared • No need to “swapbuffer”… taken care of by FLTK • Void set_glinit(void(void (*fun)(void));

  21. About Viewer • Design philosophy • Only a simple prototype, illustrating how camera control is done by an event handler • As to the displaying content, simply handed out to a content function call • If additional control (by GUI)is demanded (e.g., turn on/off lights, animation, etc.), one needs to customize the draw( ) with additional public methods to be called from other widgets. MD2chooser is a good example.

  22. Shapes • Sphere, cone, cube, torus • Dodecahedron, octahedron, icosahedron, tetrahedron • Teapot About FL/glut.h • I do not wish to mix GLUT with FLTK. Hence, all shapes routines are extracted out of glut library and make them in an aux library.

  23. Other Examples

  24. OBJ_Viewer • Version 0: straight modification from viewer • Version 1: ViewerGLM • augmented Viewer with: pmodel and set_objmodel () • Version 2: Derive OBJ_Viewer from Viewer

  25. OBJ Chooser • Use Fl_File_Chooser, ViewerGLM and Fluid

  26. Texture Experiment • Using plain Viewer • Testing wrap and filters

More Related