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! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Lua Game Development Cookbook

You're reading from   Lua Game Development Cookbook Over 70 recipes that will help you master the elements and best practices required to build a modern game engine using Lua

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781849515504
Length 360 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mário Kašuba Mário Kašuba
Author Profile Icon Mário Kašuba
Mário Kašuba
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Lua Game Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
1. Basics of the Game Engine FREE CHAPTER 2. Events 3. Graphics – Common Methods 4. Graphics – Legacy Method with OpenGL 1.x–2.1 5. Graphics – Modern Method with OpenGL 3.0+ 6. The User Interface 7. Physics and Game Mechanics 8. Artificial Intelligence 9. Sounds and Networking Index

Showing the part of the window with the stencil test and window content scrolling


Sometimes you'll need to draw only a part of the window content inside the closed region. In this case, you could have used the scissor test to define the rectangular region. Pixels would be drawn only inside this region. The downside of this approach would be that this region is strictly rectangular and each side of the region would be parallel with the corresponding screen side.

In this recipe, you'll learn how to use stencil test, which provides a more general solution to this problem. Stencil test defines a bit mask with any shape.

Getting ready

Before getting started, make sure you have the stencil buffer available on your graphic card. Nowadays, almost any graphic card allows you to use stencil buffer with at least 8 bits per pixel depth. This will provide enough space to draw 255 masked layers of windows.

Be sure to initialize the stencil buffer before setting up the graphic mode with this code:

SDL.SDL_GL_SetAttribute...
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 $15.99/month. Cancel anytime
Visually different images