-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from micro-gl/ci
Embed micro-gl for buulding examples
- Loading branch information
Showing
240 changed files
with
38,158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
bin/ | ||
cmake-build-debug/ | ||
cmake-build-release/ | ||
.idea/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
project("microgl" | ||
VERSION | ||
1.0.0 | ||
DESCRIPTION | ||
"fast, slim, embeddable, headers files only C++11 graphics library, that\ can run on any 32/64 bits computer without **FPU** or **GPU**. no standard library required." | ||
HOMEPAGE_URL | ||
"https://micro-gl.github.io/docs") | ||
|
||
enable_language(CXX) | ||
set (CMAKE_CXX_STANDARD 11) | ||
include(GNUInstallDirs) | ||
include(CMakePackageConfigHelpers) | ||
message("===============\n${PROJECT_NAME} v${PROJECT_VERSION} project \n===============") | ||
|
||
add_library(${PROJECT_NAME} INTERFACE) | ||
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) | ||
|
||
# expose public include directory | ||
#target_include_directories(${PROJECT_NAME} INTERFACE ${PROJECT_SOURCE_DIR}/include) | ||
# define target includes for both direct build via add_subdirectory() and for | ||
# defined installation configuration to allow easier package find | ||
target_include_directories( | ||
${PROJECT_NAME} INTERFACE | ||
$<BUILD_INTERFACE:${${PROJECT_NAME}_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
|
||
#target_link_libraries(${PROJECT_NAME} INTERFACE micro-alloc micro-tess) | ||
|
||
# Don't make the install target depend on the all target. | ||
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true) | ||
|
||
### install | ||
install(TARGETS ${PROJECT_NAME} | ||
EXPORT ${PROJECT_NAME}_Targets | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
|
||
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake" | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY SameMajorVersion) | ||
|
||
configure_package_config_file( | ||
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in" | ||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
INSTALL_DESTINATION | ||
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
# install cmake config files for targets of this lib, so they can be found more easily | ||
# without a custom find script, but with find_package(microgl CONFIG) command | ||
install(EXPORT ${PROJECT_NAME}_Targets | ||
FILE ${PROJECT_NAME}Targets.cmake | ||
NAMESPACE ${PROJECT_NAME}:: | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
|
||
install(FILES | ||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" | ||
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" | ||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake) | ||
# install include files | ||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/microgl DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# License | ||
Copyright (2021), `Tomer Shalev` (`[email protected]`, `https://github.com/HendrixString`). | ||
All Rights Reserved. | ||
License is a custom open source semi-permissive license with the following guidelines: | ||
1. unless otherwise stated inside a specific file, derivative work and usage of a specific | ||
file is permitted and should be credited to the project and the author of this project. | ||
2. Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<div align='center'> | ||
<img src='microgl-512-logo-rounded.png' style='height: 200px;'/> | ||
</div> | ||
|
||
# micro{gl} | ||
**Fast**, Super **Slim**, **Embeddable**, **Headers** only **`C++11`** vector graphics library, that | ||
can run on any 32/64 bits computer without **FPU** or **GPU**. **No standard library required**. | ||
|
||
|
||
check out our website at [micro-gl.github.io/docs/microgl](https://micro-gl.github.io/docs/microgl) | ||
|
||
<div align='center'> | ||
<img src='micro-gl-sample.png' style='opacity: 0.75; max-height: 200'/> | ||
</div> | ||
|
||
## Features | ||
|
||
|
||
> **Language** | ||
- **`C++11`**, does not use any **`STL`** library and **standard library**. | ||
- **headers only** library | ||
- most functions are templates, which means you compile only what is used | ||
- compile-time polymorphism (no runtime virtual methods) | ||
- support for 32 bits and 64 bits | ||
- self contained and modular. | ||
|
||
> **Graphics** | ||
- very modular design. if something does not exist, you can implement your own | ||
- over 10 blending modes impemented, you can wrote your own and supply as well | ||
- **`porter-duff`** alpha compositing | ||
- support for 2d sampler | ||
- can support any pixel coding you need, we implemeted a lot out of the box | ||
- can render 3d geometries | ||
- we support 3d shaders | ||
- no need for **GPU**, it is all **CPU** | ||
- no need for **FPU** | ||
- support for any number system including **`Q`** numbers (fixed point), no need to use float points | ||
|
||
> **Geometry** | ||
- fast implementation for common shapes (rect, rounded rectangles, circles, triangles) | ||
- batch traingles like **GPU** would | ||
- support polygons of any type convex, simple, and complex polygons | ||
- path fills(with even-odd or zero-one fill rule) in any precision | ||
- stroke fills | ||
- quadrilaterals | ||
- bezier patches | ||
- we providea dynamic array, but you can plug your own. | ||
|
||
## Installing `micro{gl}` | ||
`microgl` is a headers only library, which gives the following install possibilities: | ||
1. Using `cmake` to invoke the `install` target, that will copy everything in your system via | ||
```bash | ||
$ mkdir cmake-build-release | ||
$ cd cmake-build-release | ||
$ cmake -DCMAKE_BUILD_TYPE=Release .. | ||
$ cmake --install . | ||
``` | ||
2. Copying the `include/microgl` to anywhere you want. | ||
|
||
## Consuming `micro{gl}` | ||
Following options are available: | ||
1. copy the project to a sub folder of your project. inside your **`CMakeLists.txt`** add | ||
```cmake | ||
add_subdirectory(/path/to/microgl) | ||
target_link_libraries(your_app microgl) | ||
``` | ||
2. If you installed **`micro{gl}`** with option 1 (see above) at your system, you can instead | ||
```cmake | ||
find_package(microgl CONFIG REQUIRED) | ||
target_link_libraries(your_app microgl::microgl) | ||
``` | ||
3. If you have not installed, you can add in your app's `CMakeLists.txt` | ||
```cmake | ||
target_include_directories(app path/to/microgl/folder/include/) | ||
``` | ||
4. If you manually copied the `include/microgl` to the default system include path, | ||
you can use `cmake/Findmicrogl.cmake` to automatically create the cmake targets | ||
```cmake | ||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/path/to/Findmicrogl/folder) | ||
find_package(microgl REQUIRED) | ||
target_link_libraries(your_app microgl::microgl) | ||
``` | ||
5. Just copy the `include/microgl` into a sub folder of your project and include the header | ||
files you need with relative path in your source files. | ||
|
||
## Running Examples | ||
First make sure you have | ||
- [SDL2](https://www.libsdl.org/) installed at your system. | ||
- [cmake](https://cmake.org/download/) installed at your system. | ||
|
||
There are two ways: | ||
1. Use your favourite IDE to load the root `CMakeLists.txt` file, and then it | ||
will pick up all of the targets, including the examples | ||
2. Using the command line: | ||
```bash | ||
$ mkdir cmake-build-release | ||
$ cd cmake-build-release | ||
$ cmake -DCMAKE_BUILD_TYPE=Release .. | ||
$ cmake --build . --target <example_name> | ||
$ ../examples/bin/example_name | ||
``` | ||
|
||
```text | ||
Author: Tomer Shalev, [email protected], all rights reserved (2021) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# TODO | ||
1. investigate allocator for bitmap and static allocator and creation of pre-bitmap | ||
2. add uv transform matrix for drawing (per-vertex) | ||
3. uv instristic support | ||
4. add static asserts for geometric container types | ||
5. test my allocators with tess algorithms | ||
6. make boundary_buffer conditional | ||
7. | ||
8. DONE: add rgba_t to color.h and remove color namespace | ||
9. DONE: create git repos for micro-tess and micro-alloc | ||
10. DONE: add author copyrights | ||
11. DONE: refactor private drawing algorithms as _internal | ||
12. DONE: make allocators seperate lib | ||
13. DONE: try make Q within-place 32 bits | ||
14. DONE: re-work functions into tess | ||
15. DONE: try make tess self-contained | ||
16. DONE: add vec classes into tess | ||
17. DONE: make planar sub division allocator aware | ||
18. DONE: make chunker allocator-aware | ||
19. DONE: make path allocator aware | ||
20. DONE: move some enums into tess package | ||
21. DONE: move base classes of sampler/bitmap, porter-duff, shader into their packages | ||
22. DONE: rework curve_divider into 1 file | ||
23. DONE: z-buffer allocator aware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#======================================================================================== | ||
# Copyright (2021), Tomer Shalev ([email protected], https://github.com/HendrixString). | ||
# All Rights Reserved. | ||
# | ||
# this should help find the microgl headers-only package and define the microgl target that was | ||
# installed on your system and does not include CMakeLists.txt file, so you can easily link to it. | ||
# If successful, the following will happen: | ||
# 1. microgl_INCLUDE_DIR will be defined | ||
# 2. microgl::microgl target will be defined so you can link to it using target_link_libraries(..) | ||
#======================================================================================== | ||
include(GNUInstallDirs) | ||
include(FindPackageHandleStandardArgs) | ||
|
||
find_path(microgl_INCLUDE_DIR | ||
NAMES microgl | ||
HINTS ${CMAKE_INSTALL_INCLUDEDIR} | ||
PATH_SUFFIXES clippers bitmaps samplers) | ||
set(microgl_LIBRARY "/dont/use") | ||
find_package_handle_standard_args(microgl DEFAULT_MSG | ||
microgl_LIBRARY microgl_INCLUDE_DIR) | ||
|
||
if(microgl_FOUND) | ||
message("MICROGL was found !!!") | ||
else(microgl_FOUND) | ||
message("MICROGL was NOT found !!!") | ||
endif(microgl_FOUND) | ||
|
||
if(microgl_FOUND AND NOT TARGET microgl::microgl) | ||
# build the target | ||
add_library(microgl::microgl INTERFACE IMPORTED) | ||
set_target_properties( | ||
microgl::microgl | ||
PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${microgl_INCLUDE_DIR}") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
check_required_components("@PROJECT_NAME@") |
Oops, something went wrong.