1 / 18

GUI Programming

GUI Programming. Alex Feldmeier. Concepts. Create GUI from scratch OpenGL has no built in GUI Developers create new GUI for every game. What you have. Mouse location Mouse button up/down Keyboard key events Ability to draw images. Layout Managers. Scalable to more complex projects

garret
Download Presentation

GUI Programming

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. GUI Programming Alex Feldmeier

  2. Concepts • Create GUI from scratch • OpenGL has no built in GUI • Developers create new GUI for every game

  3. What you have • Mouse location • Mouse button up/down • Keyboard key events • Ability to draw images

  4. Layout Managers • Scalable to more complex projects • Resizable to resolutions and aspect ratios • Standardized format (XML) • Drag and drop controls

  5. XML • Standardized format • Easier to edit • Easier to read • Less code

  6. Component Overlap • Which draws on top • Which handles events • Should you clip

  7. Clipping • Used for windows • Need to clip both image and boundaries • Can be hard clipping rotated component (Unity)

  8. Types • Retained mode • Contains GUI state • Immediate mode • Rendered when needed

  9. Retained mode (pros) • Industry standard for years • More object oriented • Central control • Good for looping back • Ex: dragging • Only renders when updating

  10. Retained mode (cons) • Lots of callbacks • Harder for changing components • Uses separate place for 2D and 3D

  11. Immediate mode (pros) • All GUI code in 1 place • Build into pre-existing rendering code • Easier to add widget to screen • Redraws whole screen every time (can be con) • Good for games • If component not needed, don’t draw it

  12. Immediate mode (cons) • Hard for program to traverse GUI • GUI doesn’t control everything • 1 frame of lag • Needs watchers at end of renderer to check what happened • Ex: dragging • Code is decentralized

  13. Event Handling (Retained Mode) • Event class • Component activated • EventListener interface • handleEvent(Event e); • User-side function to perform event (ex: button click)

  14. Component States(Immediate Mode) • Active • Mouse click • Hot • Mouse hover • Focus • Used for keyboard input

  15. Active • Mouse click • Ex: button pressed • Maintains state until mouse release • Only hot item can be active

  16. Hot • Mouse hover • Ex: button highlights • Loses state when mouse exits • Only obtainable if (one of the following) • It is active • Nothing else is active

  17. Focus • Takes keyboard input • Acts like active but does not lock hot

  18. References • Adams, Ernest, and Andrew Rollings. Fundamentals of Game Design. Berkeley, CA: New Riders, 2010. Print. • Astle, Dave, and Kevin Hawkins. Beginning OpenGL Game Programming. Boston, MA: Thomson/Course Technology, 2004. Print. • Eckstein, Robert, Marc Loy, and Dave Wood. Java Swing. Sebastopol, CA: O'Reilly, 1998. Print. • Harrington, Jan L. Object-oriented C Data Structures for Real Programmers. San Diego: Morgan Kaufmann, 2002. Print. • Thorn, Alan. "Game Engine Design and Implementation." Game Engine Design and Implementation. Jones & Bartlett Learning, n.d. Web. 13 Oct. 2013. • Other sources: • http://mollyrocket.com • http://mollyrocket.com/861 • http://johno.se/book/index.html • http://sol.gfxile.net/imgui/

More Related