- Hands-On C++ Game Animation Programming
- Gabor Szauer
- 272字
- 2021-06-30 14:45:47
Creating the application class
It would be difficult to maintain a cluttered window entry function. Instead, you need to create an abstract Application class. This class will contain some basic functions, such as Initialize, Update, Render, and Shutdown. All of the code samples provided for this book will be built on top of the Application base class.
Create a new file, Application.h. The declaration of the Application class is provided in the following code sample. Add this declaration to the newly created Application.h file:
#ifndef _H_APPLICATION_
#define _H_APPLICATION_
class Application {
private:
Application(const Application&);
Application& operator=(const Application&);
public:
inline Application() { }
inline virtual ~Application() { }
inline virtual void Initialize() { }
inline virtual void Update(float inDeltaTime) { }
inline virtual void Render(float inAspectRatio) { }
inline virtual void Shutdown() { }
};
#endif
The Initialize, Update, Render, and Shutdown functions are the life cycle of an application. All these functions will be called directly from the Win32 window code. Update and Render take arguments. To update a frame, the delta time between the current and last frame needs to be known. To render a frame, the aspect ratio of the window must be known.
The life cycle functions are virtual. Each chapter in the downloadable materials for this book has an example that is a subclass of the Application class that demonstrates a concept from that chapter.
Next, you will be adding an OpenGL loader to the project.
- 國際大學生程序設計競賽中山大學內部選拔真題解(二)
- Python高級編程
- Java設計模式及實踐
- 軟件架構:Python語言實現
- Building an RPG with Unity 2018
- MongoDB,Express,Angular,and Node.js Fundamentals
- ASP.NET開發寶典
- 數字媒體技術概論
- 基于MATLAB的控制系統仿真及應用
- VMware vRealize Orchestrator Essentials
- C#教程
- Getting Started with Kubernetes
- Java程序設計項目教程(第二版)
- SQL Server 2005數據庫項目教程
- Vue.js+Node.js開發實戰:從入門到項目上線