-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optional vertex modulation in draw API
- Loading branch information
Showing
7 changed files
with
236 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[](../header.md ':include') | ||
|
||
# cf_draw_set_vertex_callback | ||
|
||
Category: [draw](/api_reference?id=draw) | ||
GitHub: [cute_draw.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_draw.h) | ||
--- | ||
|
||
An optional callback for modifying vertices before they are sent to the GPU. | ||
|
||
```cpp | ||
void cf_draw_set_vertex_callback(CF_VertexFn* vertex_fn); | ||
``` | ||
## Remarks | ||
Setup this callback to apply per-vertex modulations for implementing advanced graphical effects. | ||
`Count` is always a multiple of three, as this function always processes large batched arrays of | ||
triangles. Since all shapes are rendered with signed-distance functions, most shapes merely generate | ||
a single quad, so you may find triangle counts lower than originally anticipated. | ||
Call [cf_draw_set_vertex_callback](/draw/cf_draw_set_vertex_callback.md) to setup your callback. | ||
There is no adjecancy info provided. If you need to know which triangles connect to others you | ||
should probably redesign your feature to not require adjecancy information, or use your own custom | ||
rendering solution. With a custom solution you may use low-level graphics in cute_graphics.h, where | ||
any adjacency info can be controlled 100% by you a-priori. | ||
## Related Pages | ||
[CF_Vertex](/draw/cf_vertex.md) | ||
[CF_VertexFn](/draw/cf_vertexfn.md) | ||
cf_draw_push_vertex_callback | ||
cf_draw_pop_vertex_callback |
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,38 @@ | ||
[](../header.md ':include') | ||
|
||
# CF_Vertex | ||
|
||
Category: [draw](/api_reference?id=draw) | ||
GitHub: [cute_draw.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_draw.h) | ||
--- | ||
|
||
The full vertex layout CF uses just before sending verts to the GPU. | ||
|
||
Struct Members | Description | ||
--- | --- | ||
`CF_V2 p` | World space position. | ||
`CF_V2 posH` | "Homogenous" position transformed by the camera. | ||
`CF_V2 a, b, c` | For internal use -- used in signed-distance functions for rendering shapes. | ||
`CF_V2 uv` | For internal use -- used for sprite rendering. | ||
`CF_Pixel color` | Color for rendering shapes (ignored for sprites). | ||
`float radius` | For internal use -- Used for applying "chubbiness" factor for shapes, or radii on circle/capsule. | ||
`float stroke` | For internal use -- Used for shape rendering for border style stroke rendering (no fill). | ||
`float aa` | For internal use -- Factor for the size of antialiasing. | ||
`uint8_t type` | For internal use -- The type of shape to be rendered, used by the signed-distance functions within CF's internal fragment shader. | ||
`uint8_t alpha` | Used for the alpha-component (transparency). | ||
`uint8_t fill` | For internal use -- Whether or not to render shapes as filled or strokedx. | ||
`uint8_t not_used` | For internal use -- Reserved for a future purpose, simply fulfills byte alignment for now. | ||
`CF_Color attributes` | Four general purpose floats passed into custom user shaders. | ||
|
||
## Remarks | ||
|
||
You may fill in vertices via callback by `cf_draw_push_vertex_callback`. See [CF_VertexFn](/draw/cf_vertexfn.md). | ||
This is useful when you need to fill in unique `attributes` per-vertex, or modify any other | ||
bits of the vertex before rendering. This could be used to implement features like dynamically | ||
generated UV's for shape slicing, or complex lighting systems. | ||
|
||
## Related Pages | ||
|
||
cf_draw_pop_vertex_callback | ||
[CF_VertexFn](/draw/cf_vertexfn.md) | ||
cf_draw_push_vertex_callback |
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,33 @@ | ||
[](../header.md ':include') | ||
|
||
# CF_VertexFn | ||
|
||
Category: [draw](/api_reference?id=draw) | ||
GitHub: [cute_draw.h](https://github.com/RandyGaul/cute_framework/blob/master/include/cute_draw.h) | ||
--- | ||
|
||
An optional callback for modifying vertices before they are sent to the GPU. | ||
|
||
```cpp | ||
typedef void (CF_VertexFn)(CF_Vertex* verts, int count); | ||
``` | ||
## Remarks | ||
Setup this callback to apply per-vertex modulations for implementing advanced graphical effects. | ||
`Count` is always a multiple of three, as this function always processes large batched arrays of | ||
triangles. Since all shapes are rendered with signed-distance functions, most shapes merely generate | ||
a single quad, so you may find triangle counts lower than originally anticipated. | ||
Call [cf_draw_set_vertex_callback](/draw/cf_draw_set_vertex_callback.md) to setup your callback. | ||
There is no adjecancy info provided. If you need to know which triangles connect to others you | ||
should probably redesign your feature to not require adjecancy information, or use your own custom | ||
rendering solution. With a custom solution you may use low-level graphics in cute_graphics.h, where | ||
any adjacency info can be controlled 100% by you a-priori. | ||
## Related Pages | ||
[CF_Vertex](/draw/cf_vertex.md) | ||
cf_draw_pop_vertex_callback | ||
cf_draw_push_vertex_callback |
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
Oops, something went wrong.