Difference between revisions of "Jsvx"

From April
Jump to: navigation, search
Line 1: Line 1:
== The Boilerplate ==
+
== The Building Blocks ==
  
 
Before we dive in, we need to discuss the basic building blocks of an application in Jsvx.
 
Before we dive in, we need to discuss the basic building blocks of an application in Jsvx.

Revision as of 19:09, 2 April 2015

The Building Blocks

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");
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.