You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/QuickStart.md
+37-12
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
--------
2
-
**DISCLAIMER: This project is very much a Work In Progress. We're making it accessible in this very early state so that participants to the [Wheel Reinvention Jam 2023](https://handmade.network/jam/2023) can try it out and maybe use it as their jamming platform. Expect bugs, missing and/or incomplete features, unstable APIs, and sparse documentation. Some current issues might be a show stopper for you, so make sure you can build and run the sample apps before jumping in.**
2
+
**DISCLAIMER: This project is very much a Work In Progress. Expect bugs, missing and/or incomplete features, unstable APIs, and sparse documentation. Some current issues might be a show stopper for you, so make sure you can build and run the sample apps before jumping in.**
3
3
4
4
**If you do choose to try out Orca anyway, well thanks! We'll do our best to answer your questions, and we'd really appreciate to hear your feedback!**
5
5
@@ -13,16 +13,41 @@ This is a short introduction to developing an application that can be run by the
13
13
14
14
An Orca app is a WebAssembly module designed for the Orca runtime. Your app interacts with the Orca runtime via WebAssembly imports and exports. For example, you can import functions from the Orca runtime to get user input, and export functions to the Orca runtime to draw to the screen.
15
15
16
-
Orca also ships with a core library, written in C, which facilitates interaction with the Orca runtime and provides features like UI. This library should be compiled along with your app as part of producing your WebAssembly module.
16
+
Orca also ships with a core library, written in C, which facilitates interaction with the Orca runtime and provides features like UI. It also ships with a C standard library implementation designed to work on WebAssembly. These libraries should be linked to your app as part of producing your WebAssembly module.
17
17
18
18
You can, in principle, write an Orca app in any programming language that supports WebAssembly. However, at this early stage, C is the only officially supported language.
19
19
20
20

21
21
22
+
For example, here's how we build the WebAssembly module for our Breakout example app:
Once you have compiled your WebAssembly module, you can bundle this module into an executable using the `orca bundle` command. The application bundle can include images, fonts, or any other private data that the app needs in order to function. These files can be read or written from the app without asking the user for permission. The resulting Orca executables are therefore self-contained.
The next line of `oc_on_init()` creates a _graphics surface_. A surface represents a destination you can draw into using a specific API. In this sample, we're going to use a canvas surface, which allows drawing with a 2D vector graphics API. Other samples use a GLES surface to draw with the OpenGL ES API.
97
+
Orca apps can create several _graphics surfaces_. A surface represents a destination you can draw into using a specific API. In this sample, we're going to use the canvas API, which allows drawing with a 2D vector graphics API. Other samples use a GLES surface to draw with the OpenGL ES API.
73
98
74
-
Before drawing into it, the surface must be selected as the current surface by calling `oc_surface_select()`. Once all drawing is done you can display the result by calling `oc_surface_present()`.
99
+
We first create a _canvas renderer_. From that renderer we can then create a _graphics surface_ compatible for drawing 2D vector graphics.
75
100
76
101
```c
77
102
oc_surface surface = { 0 };
78
-
oc_canvas canvas = { 0 };
103
+
oc_canvas_renderer renderer = { 0 };
104
+
oc_canvas_context context = { 0 };
79
105
80
106
ORCA_EXPORT void oc_on_init(void)
81
107
{
82
108
// ...
83
-
surface = oc_surface_canvas();
84
-
canvas = oc_canvas_create();
109
+
renderer = oc_canvas_renderer_create();
110
+
surface = oc_canvas_surface_create(renderer);
85
111
// ...
86
112
}
87
113
```
88
114
89
115
### Canvas
90
116
91
-
After creating the surface, we create a _canvas_. A canvas holds some context for drawing commands, like the current color or stroke width, as well as a command buffer that records all drawing commands. All canvas drawing functions use an implicit _current canvas_. You can select a canvas to be the current canvas by calling `oc_canvas_select()`, as seen at the begining of `oc_on_frame_refresh()`.
117
+
After creating the surface, , we create a _canvas context_. A canvas holds some context for drawing commands, like the current color or stroke width, as well as a command buffer that records all drawing commands. All canvas drawing functions use an implicit _current canvas_. You can select a canvas to be the current canvas by calling `oc_canvas_select()`, as seen at the begining of `oc_on_frame_refresh()`.
92
118
93
119
Canvas drawing functions like `oc_fill()` or `oc_stroke` merely add to the current canvas command buffer. You can later render those commands onto a canvas surface by calling `oc_render()`.
94
120
@@ -97,13 +123,12 @@ To summarize, the general structure of canvas drawing code is like the following
97
123
```c
98
124
ORCA_EXPORT void oc_on_frame_refresh(void)
99
125
{
100
-
oc_canvas_select(canvas); // make the canvas current
126
+
oc_canvas_context_select(context); // make the canvas current
101
127
102
128
//... add commands to the canvas command buffer using drawing functions
103
129
104
-
oc_surface_select(surface); // select the canvas surface
105
-
oc_render(canvas); // render the canvas commands into it
106
-
oc_surface_present(surface); // display the result
130
+
oc_canvas_render(renderer, context, surface); // render the canvas commands into the surface
131
+
oc_canvas_present(renderer, surface); // display the surface
0 commit comments