Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
C++ Game Development By Example

You're reading from   C++ Game Development By Example Learn to build games and graphics with SFML, OpenGL, and Vulkan using C++ programming

Arrow left icon
Product type Paperback
Published in May 2019
Publisher Packt
ISBN-13 9781789535303
Length 420 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Siddharth Shekar Siddharth Shekar
Author Profile Icon Siddharth Shekar
Siddharth Shekar
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Section 1: Basic Concepts
2. C++ Concepts FREE CHAPTER 3. Mathematics and Graphics Concepts 4. Section 2: SFML 2D Game Development
5. Setting Up Your Game 6. Creating Your Game 7. Finalizing Your Game 8. Section 3: Modern OpenGL 3D Game Development
9. Getting Started with OpenGL 10. Building on the Game Objects 11. Enhancing Your Game with Collision, Loops, and Lighting 12. Section 4: Rendering 3D Objects with Vulkan
13. Getting Started with Vulkan 14. Preparing the Clear Screen 15. Creating Object Resources 16. Drawing Vulkan Objects 17. Other Books You May Enjoy

Creating the clear screen

In the VulkanApplication.h file, we will add three new functions, called drawBegin, drawEnd, and cleanup. drawBegin will be called before we pass in any draw commands, and drawEnd will be called once the drawing is done and the frame is ready to be presented to the viewport. In the cleanup function, we will destroy all the resources.

We will also create two variables. The first is uint32_t, to get the current picture from the swapchain, and the second is currentCommandBuffer of the VkCommandBuffer type to get the current command buffer:

public: 
    
   static VulkanApplication* getInstance(); 
   static VulkanApplication* instance; 
 
   ~VulkanApplication(); 
 
   void initVulkan(GLFWwindow* window); 
 
   void drawBegin(); 
   void drawEnd(); 
void cleanup(); 
 
private: 
 
   uint32_t imageIndex = 0; 
   VkCommandBuffer currentCommandBuffer; 
 
 ...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime