Download presentation
Presentation is loading. Please wait.
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 Immediate mode Contains GUI state
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 1 frame of lag
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, 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. 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 Other sources:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.