Anatomy of a project
The chronotext-cross framework relies on CMAKE
as a build system. It’s very commonly used in the C++ world and very powerful for cross platform matters.
A minimal project consists of a folder named after the project’s name and containing 5 files:
TestingTriangle
|
|-src
| |
| |-main.cpp
| |-Sketch.h
| |-SKetch.cpp
|
|-CMakeLists.txt
|-CTestConfig.cmake
CTestConfig.cmake
This file describes the platforms the project should run on. Note how the first line includes the name of the project.
CMakeLists.txt
This file is for telling which C++ files to should be compiled and which libraries should be linked (none in this case.) Note how the third line includes the name of the project.
main.cpp
This file is the C++ entry point. It defines that Sketch.cpp
is going to be used. On the desktop (i.e. macOS, Linux, etc.), the application will have a size of 1024x768 with x4 anti-alising. On the browser, the application will have x4 anti-alising (the size will be defined by the browser window’s dimensions.)
Sketch.h
This file is the C++ header of our Sketch. Sketches are classes that extend CrossSketch
and provide functionality for creating interactive applications. As you can see, there are 2 functions (setup()
and draw()
) as well as 2 variables (colorShader
and batch
.)
Sketch.cpp
This file is the C++ implementation of our Sketch. The setup()
function will be called once at the beginning, and the draw()
function will be called at each frame (i.e. 60 times per second.)