Browser and Game Engines Ali Rantakari T -106.5840 Seminar on Software Systems Presentation on 24 November 2010 Aalto University School of Science and Technology Department of Computer Science and Engineering
Contents • Introduction • Definition • Game Engines • Reference architecture • Provided features • Web Browser Engines • Interface design • Conclusion
Introduction The topic is wide and deep. Let’s not get lost, or drown. Focus in this presentation is on the usage of engines in Application applications; the relevant things in connecting the two. We perceive the engine as a black box of which we may know the provided Engine features and perhaps a general ? structure but we are not concerned with internal implementation details.
Questions • What is the engine? • What does the engine provide? • How is the engine used in an application? • As a library? • As a framework (inversion of control)? To what extent? • What is the interface like? • Where is the boundary between engine and application?
Inversion of Control (IoC) • Term used in this presentation not in the design pattern sense but in the architectural principle sense • Who is responsible for the control flow? • Martin Fowler: “defining characteristic of a framework ”
Inversion of Control: Library Library Direct calls to library App code Program flow
Inversion of Control: Framework Framework Program flow Callbacks on registered handlers App code
Game Engines
Game Engine: Definitions • Sherrod: “a framework comprised of a collection of different tools, utilities, and interfaces that hide the low-level details of the various tasks that make up a video game” • Lewis and Jacobson: “collection of modules of simulation code that do not directly specify the game’s behaviour (game logic) or game’s environment (level data)” • J.Gregory: “We should probably reserve the term ‘game engine’ for software that is extensible and can be used as the foundation for many different games without major modification” • “The part that’s not specific to any one game”
Game Engine: Definitions • Generally: a bit vague • Consensus: Not just a rendering engine (e.g. OGRE) • Is the toolset part of the engine? • In this presentation we use the concept of the runtime game engine which excludes the toolset from the definition
Game Engine: Definitions • J.Gregory: “Clearly this is not a black-and-white distinction. We can think of a gamut of reusability onto which every engine falls” (see figure) • In this presentation we focus on (somewhat) generic (3D) game engines Picture credit: J.Gregory; Game Engine Architecture.
Folmer: A Reference Architecture for Games Picture credit: E.Folmer; Component based game development - a solution to escalating costs and expanding deadlines?
Game (Engine) Components Summary: Lots of stuff Picture credit: J.Gregory; Game Engine Architecture.
Game (Engine) Components 1/3 Continues
Game (Engine) Components 2/3 Continues
Game (Engine) Components 3/3 “Runloop” or “Main loop”
Domain Boundary • J.Gregory in Game Engine Architecture : • “If a line can reasonably be drawn between the game engine and the game itself, [the engine’s gameplay foundation systems] lie just beneath this line” • “[in practice] the line between the engine and the game can probably be best visualized as one big blur – a gradient that arcs across these components as it links the engine to the game”
Panda3D Implementing game- specific functionality • Application base class has a runloop implementation (although it can easily be substituted with something else) • Lacks a predefined entity system so it has to be manually built • Custom tasks can be attached to runloop via a TaskManager • Custom Event handlers can be registered for arbitrary global events
Unreal Engine Implementing game- specific functionality • Scripting system divided into UnrealScript (textual scripting) and Kismet (visual scripting) • Inheritance-based entity system • Custom game entities (Actor, Info, Controller...) can be created with custom behavior and properties • Actors (entities) may define handlers for events and trigger them in other Actors globally
Crystal Space ( ) + CEL ( ) Implementing game- specific functionality • Crystal Space is primarily a rendering engine; CEL provides entity management and other features for games • Composition-based entity system • Custom entities and behaviors composed declaratively (XML) or imperatively (Python) • Behaviors and property sets attached to Entities via Property Classes • Property classes may message each other through Entity channels
Commonalities Somewhat homogeneous: • Main connection points are in the gameplay foundations modules • Implementation / lower level design of the interface varies • Entity system may be composition- or inheritance- based, or it might not exist • Messaging/event channels may be e.g. per-entity or “entity system” global • Connection based on IoC (delegates / callback interfaces for game model objects, event handlers)
Web Browser Engines
Browser Engine: Definitions • webkit.org: “WebKit is an open source web browser engine”, “All of the rendering logic, SVG support, transforms, network support, etc. is [in WebCore]” “WebKit: the front-end layer used by applications” • MDN: Gecko: “Gecko is the name of the layout engine developed by the Mozilla Project.” • MDN: Introduction to Gecko and Embedding: “Gecko is the browser engine, networking, parsers, content models, chrome and the other technologies that Mozilla and other applications are built from. In other words, all the stuff which is not application specific.”
Browser Engine: Definitions • Generally: quite clear • Confusion: rendering engine and browser engine • Grosskurth and Godfrey: “an embeddable component that provides a high-level interface to the Rendering Engine. It loads a given URI and supports primitive browsing actions such as forward, back, and reload. It provides hooks for viewing various aspects of the browsing session such as current page load progress and JavaScript alerts. It also allows the querying and manipulation of Rendering Engine settings.”
A Reference Architecture for Web Browsers Application Engine
WebKit, as provided in in OS X Safari Architecture WebKit Main API connection points Connect app to browser engine by User User Interface hosting a WebView instance and providing Persistence delegate protocol implementations User Interface Secure Brower Engine (WebKit) Persistence (Keychain) Browser Engine WebView Adapter (KWQ) Engine Persistence KHTML Data Persistence Rendering Engine Core KJS Expat Cocoa / Carbon Foundation Networking XML Display Backend WebScripting, WebScriptObject PCRE Parser JavaScript Interpreter Connect app to scripting environment via a WebView’s windowScriptObject and by attaching Picture credit: A. Grosskurth and M. W. Godfrey; Architecture and evolution your own WebScripting protocol of the modern web browser implementation(s) there
Mozilla’s Gecko Mozilla’s Main API connection Mozilla Architecture points Connect app to browser engine by hosting User Interface an ns WebBrowser instance and providing delegate interface implementations UI Toolkit (XPFE) User Interface User, Secure, Browser Engine & Engine Persistence Gecko Rendering Engine nsWebBrowser Data Persistence Spider − GTK+ Necko Expat Monkey Adapter JavaScript XML Security Interpreter Parser GTK+ / X11 Libraries (NSS/PSM) Networking Display Backend XPConnect Connect app to scripting environment via a nsIDOMWindow ’s wrappedJSObject and by Picture credit: A. Grosskurth and M. W. Godfrey; Architecture and evolution attaching your own XPConnect wrappers there of the modern web browser
The Internet Explorer engine, as provided in Windows IE Main API connection points Connect app to browser engine by hosting a WebBrowser instance (or to rendering engine by hosting an WebBrowser MSHTML instance) and providing delegate interface implementations MSHTML IDispatch Connect app to scripting environment by providing IDispatch interface implementations for WebBrowser or MSHTML through the IDocHostUIHandler interface implementation
Commonalities Very homogeneous: • Main connection point for embedding or hosting: a class representing the browser engine • Possibly also a class representing the “raw” rendering engine (e.g. MSHTML in IE) • Connection based on IoC (delegates / callback interfaces) • Interface between JavaScript environment and host via mechanisms in the type system that connects the engine to the JS environment
Summary Game Engines Browser Engines Definition Vague Clear Features Variant Static Interface Somewhat homogeneous Homogeneous Relevant Gameplay system, Browser engine Entity management system, component, (Rendering Interface Event/Messaging system engine component), modules JavaScript environment’s window object Interface Framework (IoC) Framework (IoC) Design
Questions; Discussion.
Recommend
More recommend