- 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.
- 基于粒計(jì)算模型的圖像處理
- Python快樂編程:人工智能深度學(xué)習(xí)基礎(chǔ)
- C語言程序設(shè)計(jì)
- Java程序設(shè)計(jì)與計(jì)算思維
- Visual Basic程序設(shè)計(jì)教程
- Object-Oriented JavaScript(Second Edition)
- jQuery從入門到精通 (軟件開發(fā)視頻大講堂)
- PhoneGap Mobile Application Development Cookbook
- Apache Mahout Clustering Designs
- Corona SDK Mobile Game Development:Beginner's Guide(Second Edition)
- Mastering Xamarin.Forms(Second Edition)
- Python機(jī)器學(xué)習(xí):預(yù)測(cè)分析核心算法
- R用戶Python學(xué)習(xí)指南:數(shù)據(jù)科學(xué)方法
- 微信小程序開發(fā)實(shí)戰(zhàn):設(shè)計(jì)·運(yùn)營·變現(xiàn)(圖解案例版)
- Android Game Programming by Example