Difference between revisions of "Jsvx"
Line 5: | Line 5: | ||
=== Vx_world === | === Vx_world === | ||
A vx_world is a collection of objects that can be rendered in the same scene. Most simple applications only need one vx_world, but nothing says you can’t have more. You can think of a vx_world as a setting, a scene, or a room. If objects can appear in the same camera frame, they need to be in the same vx_world. A vx_world is created with a call to vx_world_create: | A vx_world is a collection of objects that can be rendered in the same scene. Most simple applications only need one vx_world, but nothing says you can’t have more. You can think of a vx_world as a setting, a scene, or a room. If objects can appear in the same camera frame, they need to be in the same vx_world. A vx_world is created with a call to vx_world_create: | ||
− | + | vx_world_t *vw = vx_world_create(); | |
=== Vx_buffer === | === Vx_buffer === | ||
A vx_buffer is a collection of objects in a vx_world that are rendered together. They represent a group of objects that can be “turned on and off”, similar to a layer in many photo editing platforms. Vx_buffers are also the only way to render objects in Jsvx. To render an object, or collection of objects, you follow these steps. | A vx_buffer is a collection of objects in a vx_world that are rendered together. They represent a group of objects that can be “turned on and off”, similar to a layer in many photo editing platforms. Vx_buffers are also the only way to render objects in Jsvx. To render an object, or collection of objects, you follow these steps. | ||
* Ask the vx_world for a named buffer. (if a buffer with that name exists, the vx_world will return a pointer to the existing buffer) | * Ask the vx_world for a named buffer. (if a buffer with that name exists, the vx_world will return a pointer to the existing buffer) | ||
+ | vx_buffer_t *vb = vx_world_get_buffer(vw, "buffer_name"); | ||
* Add objects to the back of the buffer (vx_buffers implement double buffering to prevent tears and jitters during rendering.) https://docs.oracle.com/javase/tutorial/extra/fullscreen/doublebuf.html | * Add objects to the back of the buffer (vx_buffers implement double buffering to prevent tears and jitters during rendering.) https://docs.oracle.com/javase/tutorial/extra/fullscreen/doublebuf.html | ||
+ | vx_buffer_add_back(vb, obj); | ||
* Swap the buffer. | * Swap the buffer. | ||
+ | vx_buffer_swap(vb); | ||
=== Vx_canvas === | === Vx_canvas === |
Revision as of 19:09, 2 April 2015
The Boilerplate
Before we dive in, we need to discuss the basic building blocks of an application in Jsvx.
Vx_world
A vx_world is a collection of objects that can be rendered in the same scene. Most simple applications only need one vx_world, but nothing says you can’t have more. You can think of a vx_world as a setting, a scene, or a room. If objects can appear in the same camera frame, they need to be in the same vx_world. A vx_world is created with a call to vx_world_create:
vx_world_t *vw = vx_world_create();
Vx_buffer
A vx_buffer is a collection of objects in a vx_world that are rendered together. They represent a group of objects that can be “turned on and off”, similar to a layer in many photo editing platforms. Vx_buffers are also the only way to render objects in Jsvx. To render an object, or collection of objects, you follow these steps.
- Ask the vx_world for a named buffer. (if a buffer with that name exists, the vx_world will return a pointer to the existing buffer)
vx_buffer_t *vb = vx_world_get_buffer(vw, "buffer_name");
- Add objects to the back of the buffer (vx_buffers implement double buffering to prevent tears and jitters during rendering.) https://docs.oracle.com/javase/tutorial/extra/fullscreen/doublebuf.html
vx_buffer_add_back(vb, obj);
- Swap the buffer.
vx_buffer_swap(vb);
Vx_canvas
A Vx_canvas represents a portion of a literal display device such as a computer monitor or a phone screen. (Does it? look through the code)
Vx_layer
A vx_layer represents a “view” into a vx_world. It acts like a moveable camera that inspects the scene (the vx_world). Vx_layers are also responsible for communicating user-initiated events such as mouse clicks and keystrokes to the server system.