GUI Programming Alex Feldmeier Concepts Create GUI from

  • Slides: 18
Download presentation
GUI Programming Alex Feldmeier

GUI Programming Alex Feldmeier

Concepts Create GUI from scratch n Open. GL has no built in GUI n

Concepts Create GUI from scratch n Open. GL has no built in GUI n Developers create new GUI for every game n

What you have Mouse location n Mouse button up/down n Keyboard key events n

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

Layout Managers Scalable to more complex projects n Resizable to resolutions and aspect ratios

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

XML n n Standardized format Easier to edit Easier to read Less code

XML n n Standardized format Easier to edit Easier to read Less code

Component Overlap Which draws on top n Which handles events n Should you clip

Component Overlap Which draws on top n Which handles events n Should you clip n

Clipping Used for windows n Need to clip both image and boundaries n Can

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

Types n Retained mode n n Contains GUI state Immediate mode n Rendered when

Types n Retained mode n n Contains GUI state Immediate mode n Rendered when needed

Retained mode (pros) Industry standard for years n More object oriented n Central control

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

Retained mode (cons) Lots of callbacks n Harder for changing components n Uses separate

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

Immediate mode (pros) All GUI code in 1 place n Build into pre-existing rendering

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

Immediate mode (cons) n Hard for program to traverse GUI n n GUI doesn’t

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

Event Handling (Retained Mode) n Event class n n Component activated Event. Listener interface

Event Handling (Retained Mode) n Event class n n Component activated Event. Listener interface handle. Event(Event e); n User-side function to perform event (ex: button click) n

Component States (Immediate Mode) n Active n n Hot n n Mouse click Mouse

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

Active Mouse click n Ex: button pressed n Maintains state until mouse release n

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

Hot Mouse hover n Ex: button highlights n Loses state when mouse exits n

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

Focus Takes keyboard input n Acts like active but does not lock hot n

Focus Takes keyboard input n Acts like active but does not lock hot n

References n n n Adams, Ernest, and Andrew Rollings. Fundamentals of Game Design. Berkeley,

References n n n Adams, Ernest, and Andrew Rollings. Fundamentals of Game Design. Berkeley, CA: New Riders, 2010. Print. Astle, Dave, and Kevin Hawkins. Beginning Open. GL 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: n n http: //mollyrocket. com/861 http: //johno. se/book/index. html http: //sol. gfxile. net/imgui/