TOW is a tiny OpenGL wrapper written in Literate. The Literate code of TOW is not much different from C++, you can read them without any knowledge about Literate. TOW only encapsulates the primary functions of OpenGL but provides more convenient methods with safety and less overhead🚀.
To draw things on the screen, usually, you only need these two objects: Framebuffer
and Graphicpipeline
, see the code below for detail.
// draw a simple triangle
tow::FramebufferPtr fb;
tow::GraphicPipelinePtr pipeline;
void init(){
using namespace tow;
fb = Framebuffer::create();
vec2 vertices[] = { {-1, -1}, {1, -1}, {0, 1} };
auto layout = VertexLayout::create();
layout->add("a_position", {GL_FLOAT, 2});
layout->stride(sizeof(vec2));
auto bufGroup = BufferGroup::create();
bufGroup->createBuffer("b_vertex", vertices, {GL_ARRAY_BUFFER, sizeof(vec2), 3});
pipeline = GraphicPipeline::create({bufGroup, "b_vertex"}, layout);
}
void render(int x, int y, int w, int h){
fb->bind(x, y, w, h);
tow::drawArrays(pipeline, GL_TRIANGLES);
}
On Windows, make sure you have installed vs2017 or later before running premake5.bat.
On other platforms, you should install premake5, make and Literate corresponding to the platform, and then type in the command:
make -C lit all
premake5 your_action
For most people, enter the command:
git clone https://github.com/czq1989/tow.git
But if you are in China and the cloning speed is slow, you can enter the command:
git clone https://gitclone.com/github.com/czq1989/tow.git
A viewer that can load gltf/glb file, and supports PBR, skin, morph target, and animation. Most files I have tested are from sketchfab and GeneratedAssets, however, in order to keep this repository small, I don't put all of them into the assets folder.
A simple shader toy emulator that you can write glsl code to implement cool graphic effects.
An editor that is used to edit game UI elements. If you have a PSD file that all UI elements have already been arranged, drop it into the editor, then you can make some changes again or save it as a JSON file.
A block editor like Minecraft, but easier to select and create blocks.
A simple and fast paint tool based on SDF supports undo, redo and layer blending.
Thanks to: