GAM531 DPS931 – Week 2 Into the Engine. Last Time in GAM531… Engine Core Client Interface Operating System API Device API Engine DX11 Device GL 4.3 Device.

Slides:



Advertisements
Similar presentations
Chapter 3 – Lists A list is just what the name implies, a finite, ordered sequence of items. Order indicates each item has a position. A list of size 0.
Advertisements

Chapter 12 Lists and Iterators. List Its an abstract concept not a vector, array, or linked structure. Those are implementations of a List. A list is a.
1 Joe Meehean. Ordered collection of items Not necessarily sorted 0-index (first item is item 0) Abstraction 2 Item 0 Item 1 Item 2 … Item N.
ArrayLists The lazy mans array. Whats the matter here? int[] list = new int[10]; list[0] = 5; list[2] = hey; list[3] = 15; list[4] = 23;
Brown Bag #2 Advanced C++. Topics  Templates  Standard Template Library (STL)  Pointers and Smart Pointers  Exceptions  Lambda Expressions  Tips.
Collections Chapter Java Collection Frameworks The Java collection framework is a set of utility classes and interfaces. Designed for working with.
Problem Solving 5 Using Java API for Searching and Sorting Applications ICS-201 Introduction to Computing II Semester 071.
An Introduction to Hashing. By: Sara Kennedy Presented: November 1, 2002.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
COMP 171 Data Structures and Algorithms Tutorial 1 Template and STL.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
More on the STL vector list stack queue priority_queue.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Queues CS-240 & CS-341 Dick Steflik. Queues First In, First Out operation - FIFO As items are added they are chronologically ordered, items are removed.
Standard Template Library. Homework List HW will be posted on webpage Due Nov 15.
Standard library types Practical session # 3 Software Engineering
C++ / G4MICE Course Session 3 Introduction to Classes Pointers and References Makefiles Standard Template Library.
GAM531 DPS931 – Week 1 Introduction. Professors Joseph Hughes Info: scs.senecac.on.ca/~jp.hughes T2104 Roles: Primary Lecturer.
GAM531 DPS931 – Week 9 OpenGL 4.3 and Direct X 11.
Sorting and Vectors Mechanism for representing lists JPC and JWD © 2002 McGraw-Hill, Inc. Modified by S. Sudarshan.
Java Programming: Advanced Topics 1 Collections and Wealth of Utilities.
Data Structures: CSCI 362 – Stack Implementation Data Structures: CSCI 362 – Stack Implementation lecture notes adapted from Data Structures with C++ using.
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
1 Chapter 3 Lists, Stacks, and Queues Abstract Data Types, Vectors Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
GAM531 DPS931 – Week 5 The Scene. Reviewing the Engine Engine DX11 Device GL 4.3 Device ControllerManagerModel DX11 Object GL 4.3 Object DX 11 API GL.
SNU OOPSLA Lab. Chap17. Standard Containers © copyright 2001 SNU OOPSLA Lab.
Main Index Contents 11 Main Index Contents Week 3 – The Vector Container.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Generic Programming Using the C++ Standard Template Library.
Stacks. A stack is a data structure that holds a sequence of elements and stores and retrieves items in a last-in first- out manner (LIFO). This means.
COMP 103 Linked Lists. 2 RECAP-TODAY RECAP  Linked Structures: LinkedNode  Iterating and printing Linked Nodes  Inserting and removing Linked Nodes.
STL multimap Container. STL multimaps multimaps are associative containers –Link a key to a value –AKA: Hashtables, Associative Arrays –A multimap allows.
Working with Batches of Data Lecture 4 Hartmut Kaiser
An Introduction to STL. The C++ Standard Template Libraries  In 1990, Alex Stepanov and Meng Lee of Hewlett Packard Laboratories extended C++ with a.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Templates.
A Generic List Class and Linked Lists Andy Wang Data Structures, Algorithms, and Generic Programming.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Ticket Booth Base Level 3 1. In the completed program, the ticket seller will: Select a venue from a menu of all venues. Select a show from a menu of.
1 9/6/05CS360 Windows Programming CS360 Windows Programming.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
The Standard Template Library Container Classes Version 1.0.
Copyright © 2006 Pearson Addison-Wesley. All rights reserved Today’s Learning Objective  Standard Template Library.
Data Structure Specification  Language independent  Abstract Data Type  C++  Abstract Class.
The List ADT Reading: Sections 3.2, 3.3, 3.5.
Generics & Collection Classes Version 1.0. Topics Generic Methods and Classes Generic Collection Classes List Enumerators Queue Stack LinkedList.
1 Chapter 3 Lists, Stacks, and Queues Reading: Sections 3.1, 3.2, 3.3, 3.4 Abstract Data Types (ADT) Iterators Implementation of Vector.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 20: Container classes; strings.
Lecture 7.  There are 2 types of libraries used by standard C++ The C standard library (math.h) and C++ The C++ standard template library  Allows us.
 2003 Prentice Hall, Inc. All rights reserved vector Sequence Container Declarations –std::vector v; type : int, float, etc. Iterators –std::vector.
1 Linked Multiple Queues. 2 A real world example. Not in the book. Sometimes we have a fixed number of items that move around among a fixed set of queues.
CSCI  Sequence Containers – store sequences of values ◦ vector ◦ deque ◦ list  Associative Containers – use “keys” to access data rather than.
Chapter  Array-like data structures  ArrayList  Queue  Stack  Hashtable  SortedList  Offer programming convenience for specific access.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 19: Container classes; strings.
Coming up Implementation vs. Interface The Truth about variables Comparing strings HashMaps.
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Vectors Holds a set of elements, like an array
C++ Programming Standard Library
Chapter 18: Linked Lists.
Linked Lists.
Practical Session 4 Rule of 5 R-value reference Unique pointer
STL Iterators Separating Container from Data Access.
STL (Standard Template Library)
C++ Programming: chapter 10 – STL
Final Exam Review Inheritance Template Functions and Classes
An Introduction to STL.
Lab 03 – Linked List.
Data Structures & Programming
Data Structures & Programming
Presentation transcript:

GAM531 DPS931 – Week 2 Into the Engine

Last Time in GAM531… Engine Core Client Interface Operating System API Device API Engine DX11 Device GL 4.3 Device ControllerManagerModel DX11 Object GL 4.3 Object DX 11 API GL 4.3 API DX 11 API GL 4.3 API 1 m 1 1 or 1 1 or 1 1 iEngine iController iModel

Back to the Engine iEngine.hpp namespace Emperor { class iEngine {…}; } Engine.hpp namespace Emperor { template class Engine : public iEngine, public Singleton > {…}; }

The Singleton Engine DeviceMeshVertexShader Buffer TextureMaterialActorNodeBlendStateRasterizerSceneObject Controller ManagerLightCamera Engine * engine; x10,000 class Engine { static Engine* self; public: Engine() {self = this;} static Engine* getPtr() { return self; } void stuff(); }; Engine::getPtr()->stuff();

Our Singleton Class (hold on…) template class Singleton { private: static D* self; protected: public: Singleton() { if(!self) self = (D*)this; else EMP_FATAL_ERROR(“…"); } virtual ~Singleton() {self = 0;} static D* getPtr() {return self;} }; template D* Singleton ::self = nullptr; template class Engine : public iEngine, public Singleton > {…}; } Engine ::getPtr()->initialize();

Deeper into the Engine Engine.hpp namespace Emperor { template class Engine : public iEngine, public Singleton > { SceneController sCont; ResourceController rCont; … public: iSceneController* getSceneController() {return &sCont;} iResourceController* getResourceController() {return &rCont;} }; } EngineController 1 m

Why do we use controllers? Convenience & Separation Resource Scene Window

Scene vs. Resource Statue1.obj Summoner.obj BigDude.obj

Into the Controller SceneController.hpp namespace Emperor { template class SceneController : public iSceneController { public: ActorManager actMan; CameraManager camMan; LightManager lgtMan; NodeManager nodMan; … }; } ControllerManager 1 m iSceneController.hpp namespace Emperor { … class iSceneController { … public: virtual iActor* createActor() = 0; virtual iCamera* createCamera() = 0; virtual iLight* createLight() = 0; virtual iNode* createNode() = 0; }; }

What does a Manager Do? Hiring – Creating the object Firing – Destroying the object Keeping Tabs – Having a reference to all objects Organizing/Scheduling – Dealing with tasks that deal with all objects Damage Control – Releasing resources if they have not been released by shutdown

Into the Manager BaseManager.hpp template class BaseManager { protected: ArrayList objects; ArrayList activeObjects; public: BaseManager() {} virtual ~BaseManager() {…} T* createObject() {…} void removeObject(T* o) {…} void activateObject(T* o) {…} void deactivateObject(T* o) {…} }; ManagerModel 1 m #define ArrayList std::vector

Std::Vector Std::Vector is a dynamic array Common Functions: push_back(T) – add a value to the back pop_back() – removes the last value size() – returns the number of values front() – returns first value (ref) back() – returns last value (ref) [N] (subscript) – returns the Nth value (ref) begin() – returns an iterator to the beginning beg end end() – returns an iterator to the end

Std::Iterator Std::Iterator is a unified method of iterating over many STL data structures //iterating over a std::vector //assume ar is a std::vector for(auto i = ar.begin(), end = ar.end(); i!=end; i++) { std::cout << *i; } i end std::vector ::iterator i = ar.begin(); i += 3; std::cout << i – ar.begin(); //outputs 3 auto i = ar.begin(); ar.push_back(25); std::cout << *i; //throws exception, iterator not valid

Std::Iterator Cont Many STL functions use the std::iterator std::vector intvec; intvec.push_back(20); intvec.push_back(93); intvec.insert(intvec.begin() + 1, 50);//inserts between 20 and 93 intvec.erase(intvec.begin());//removes 20 from the list auto i = std::find(intvec.begin(), intvec.end(), 93); //returns iterator to the second element i = std::find(intvec.begin(), intvec.end(), 108); //returns iterator to the end of the array

Into the Manager BaseManager.hpp template class BaseManager { protected: ArrayList objects; ArrayList activeObjects; public: BaseManager() {} virtual ~BaseManager() {…} T* createObject() {…} void removeObject(T* o) {…} void activateObject(T* o) {…} void deactivateObject(T* o) {…} }; ManagerModel 1 m #define ArrayList std::vector

Scene vs. Resource Statue1.obj Summoner.obj BigDude.obj

Into the Resource Manager ResourceManager.hpp template class ResourceManager { protected: HashMap resources; virtual T* createResource(const String& r) = 0; public: ResourceManager() {} virtual ~ResourceManager() {…} T* newResource(const String& r) {…} T* getResource(const String& resource) {…} void removeResource(T* a) {…} }; #define HashMap std::map

std::map 0x248F std::map is an associative container (key-value pairs) which relies on unique keys Common Functions: insert(KEY,VALUE) – insert key and value erase(KEY) – removes key and associated values size() – returns the number of elements clear() – empties the container find(KEY) – returns an iterator to the element [KEY] (subscript) – returns the value associated with the key (ref) test.obj begin() – returns an iterator to the beginning end() – returns an iterator to the end 0x1C8AHello? 0x52CEeng.exe Key (String) Value (Pointer)

std::map usage 0x248F template T* findOrAdd(std::map & res, const std::string& key) { if( res.find(key) == res.end()) { res[key] = new T(); } return res[key]; } int main() { std::map im; *findOrAdd(im, “Test”) = 15; *findOrAdd(im, “Snap”) = 20; *findOrAdd(im, “Test”) = 33; return 0; } Test 0x1C8ASnap Key (String) Value (Pointer)

Into the Resource Manager ResourceManager.hpp template class ResourceManager { protected: HashMap resources; virtual T* createResource(const String& r) = 0; public: ResourceManager() {} virtual ~ResourceManager() {…} T* newResource(const String& r) {…} T* getResource(const String& resource) {…} void removeResource(T* a) {…} }; #define HashMap std::map

Scene vs. Resource Statue1.obj Summoner.obj BigDude.obj

Engine DX11 Device GL 4.3 Device ControllerManagerModel DX11 Object GL 4.3 Object DX 11 API GL 4.3 API DX 11 API GL 4.3 API 1 m 1 1 or 1 1 or 1 1 iEngine iController iModel To Recap

To Do Create zenit wiki accounts if you don’t already have one Add your user information to the student list on the wiki Read over Assignment 1 (will be released Friday) Begin to look for group partners (2-3 per group) Bookmark the GAM531 website Make an account on Bit Bucket