Zap is an API designed for creating graphics applications such as games. It provides simple function calls while imposing almost no limitations compared to raw OpenGL.
The API can be used by anyone familiar with C++ who has experience with GLSL and basic OpenGL. Developers who know more OpenGL can also use additional OpenGL code in combination with Zap.
This is what Zap is currently able to do:
- Controller and keyboard input
- Mouse input and events
- Create and manage windows
- Render meshes
- Draw text and buttons
- Load models
- Play audio
With a little more effort, you can also add lighting quickly.
Features:
- Allows direct control over OpenGL calls
- Easily extendable and modifiable
- High performance
- Mix Zap with raw OpenGL code
- Optional additions (audio, GUI, etc.)
- Good for learning OpenGL (replace parts of your code with raw OpenGL)
- Faster development than using raw OpenGL
Build for Visual Studio using Premake
Windows:
- Requirements: Visual Studio 2022
Clone this repository and run Windows_GenerateVS.bat in the Build_Premake/Windows folder.
For more detailed information, see the wiki.
Choose your release and follow the provided instructions.
#include "Zap.h"
int main()
{
zap::Init();
zap::Window window(1280, 720, "Hello Window");
zap::InitGlad();
window.UpdateViewport(true);
while (window.Open())
{
zap::ClearBackground(zap::BackgroundColors::ORANGE);
if (window.GetInput(zap::Key::ESC, zap::State::PRESSED))
{
window.Close();
}
window.Update();
window.Draw();
}
zap::Delete();
}zap::Init();
zap::Delete();Use these functions to manage the API's OpenGL resources. Every Zap call must be made between these two functions.
zap::Window window(1280, 720, "Hello Window");This creates a Window instance. The parameters specify the width, height, and title of the window.
Multiple windows:
Only one window can exist per thread. To create multiple windows, create and manage them in different threads.
zap::InitGlad();GLAD is a loader that retrieves OpenGL function pointers. It must be initialized after creating a window.
window.UpdateViewport(true);If the window is resized, call UpdateViewport to update the viewport to the new window size.
while (window.Open())
{
zap::ClearBackground(zap::BackgroundColors::ORANGE);
if (window.GetInput(zap::Key::ESC, zap::State::PRESSED))
{
window.Close();
}
window.Update();
window.Draw();
}This while loop runs while the window is open. Inside the loop, ClearBackground fills the window with an orange color.
window.Update();
window.Draw();These functions are among the most important. Update() processes window events such as keyboard and mouse input. Draw() renders the scene. All rendering and drawing operations should occur before calling Draw().
See the wiki: https://github.com/ScriptCodex13/Zap-Library/wiki
You can use this library without including the license file in your binary distribution; however, you must comply with the licenses of its dependencies. Remember to include those licenses in your project.
- stb_image to load images
- GLFW to manage windows
- GLAD to load OpenGL functions
- Premake to build the project
- glm for math
- FreeType (under the FTL license) for font loading
- miniaudio for audio
- assimp for model loading
- Provided fonts come from Google Fonts: https://fonts.google.com/
- zlib in combination with assimp
Join our Discord server to ask questions and chat with the developers.
We need more help to grow and improve this project. If you'd like to contribute or have questions, feel free to open a pull request or an issue. Any help is greatly appreciated.