Presentation is loading. Please wait.

Presentation is loading. Please wait.

GUI Programming Alex Feldmeier. Concepts Create GUI from scratch Create GUI from scratch OpenGL has no built in GUI OpenGL has no built in GUI Developers.

Similar presentations


Presentation on theme: "GUI Programming Alex Feldmeier. Concepts Create GUI from scratch Create GUI from scratch OpenGL has no built in GUI OpenGL has no built in GUI Developers."— Presentation transcript:

1 GUI Programming Alex Feldmeier

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

18 References Adams, Ernest, and Andrew Rollings. Fundamentals of Game Design. Berkeley, CA: New Riders, Print. Adams, Ernest, and Andrew Rollings. Fundamentals of Game Design. Berkeley, CA: New Riders, Print. Astle, Dave, and Kevin Hawkins. Beginning OpenGL Game Programming. Boston, MA: Thomson/Course Technology, Print. Astle, Dave, and Kevin Hawkins. Beginning OpenGL Game Programming. Boston, MA: Thomson/Course Technology, Print. Eckstein, Robert, Marc Loy, and Dave Wood. Java Swing. Sebastopol, CA: O'Reilly, Print. Eckstein, Robert, Marc Loy, and Dave Wood. Java Swing. Sebastopol, CA: O'Reilly, Print. Harrington, Jan L. Object-oriented C Data Structures for Real Programmers. San Diego: Morgan Kaufmann, Print. Harrington, Jan L. Object-oriented C Data Structures for Real Programmers. San Diego: Morgan Kaufmann, Print. Thorn, Alan. "Game Engine Design and Implementation." Game Engine Design and Implementation. Jones & Bartlett Learning, n.d. Web. 13 Oct Thorn, Alan. "Game Engine Design and Implementation." Game Engine Design and Implementation. Jones & Bartlett Learning, n.d. Web. 13 Oct Other sources: Other sources:


Download ppt "GUI Programming Alex Feldmeier. Concepts Create GUI from scratch Create GUI from scratch OpenGL has no built in GUI OpenGL has no built in GUI Developers."

Similar presentations


Ads by Google