Module RubyCube
In: rubycube.c

Methods

Constants

KEY_LEFT = INT2FIX(RC_KEY_LEFT)
KEY_RIGHT = INT2FIX(RC_KEY_RIGHT)
KEY_UP = INT2FIX(RC_KEY_UP)
KEY_DOWN = INT2FIX(RC_KEY_DOWN)
EVENT_KEYBOARD = INT2FIX(EVENT_KEYBOARD)
EVENT_KEYBOARD_LETTER = INT2FIX(EVENT_KEYBOARD_LETTER)
EVENT_MOUSE_BUTTON_UP = INT2FIX(EVENT_MOUSE_BUTTON_UP)
EVENT_MOUSE_BUTTON_DOWN = INT2FIX(EVENT_MOUSE_BUTTON_DOWN)
EVENT_MOUSE_ACTIVE = INT2FIX(EVENT_MOUSE_ACTIVE)
EVENT_MOUSE_PASSIVE = INT2FIX(EVENT_MOUSE_PASSIVE)
EVENT_ANIM_COMPLETE = INT2FIX(EVENT_ANIM_COMPLETE)
EVENT_COLLISION = INT2FIX(EVENT_COLLISION)
EVENT_APPLICATION = INT2FIX(EVENT_APPLICATION)
EVENT_TIMER = INT2FIX(EVENT_TIMER)
ZERO = INT2FIX(GL_ZERO)
ONE = INT2FIX(GL_ONE)
DST_COLOR = INT2FIX(GL_DST_COLOR)
ONE_MINUS_DST_COLOR = INT2FIX(GL_ONE_MINUS_DST_COLOR)
SRC_ALPHA = INT2FIX(GL_SRC_ALPHA)
ONE_MINUS_SRC_ALPHA = INT2FIX(GL_ONE_MINUS_SRC_COLOR)
DST_ALPHA = INT2FIX(GL_DST_ALPHA)
ONE_MINUS_DST_ALPHA = INT2FIX(GL_ONE_MINUS_DST_ALPHA)
SRC_ALPHA_SATURATE = INT2FIX(GL_SRC_ALPHA_SATURATE)
SHAPE_FORMAT_POINTS = INT2FIX(SHAPE_FORMAT_POINTS)
SHAPE_FORMAT_LINES = INT2FIX(SHAPE_FORMAT_LINES)
SHAPE_FORMAT_QUADS = INT2FIX(SHAPE_FORMAT_QUADS)
SHAPE_FORMAT_TRIANGLES = INT2FIX(SHAPE_FORMAT_TRIANGLES)
SHAPE_FORMAT_TRIANGLE_FAN = INT2FIX(SHAPE_FORMAT_TRIANGLE_FAN)
SHAPE_FORMAT_TRIANGLE_STRIP = INT2FIX(SHAPE_FORMAT_TRIANGLE_STRIP)
POLY_MODE_LINE = INT2FIX(POLY_MODE_LINE)
POLY_MODE_FILL = INT2FIX(POLY_MODE_FILL)

Public Instance methods

Sets the clear color for the back buffer

Parameters

  • red is a floating point number between 0 and 1.0
  • green is a floating point number between 0 and 1.0
  • blue is a floating point number between 0 and 1.0
  • alpha is a floating point number between 0 and 1.0

Examples

 # Clear the back buffer to white before any shapes are rendered
 RubyCube.clear_color(1.0, 1.0, 1.0, 1.0)

Toggle between full screen and windowed mode. (toggles asynchronously)

Returns the desired full screen state

Examples

 RubyCube.start("test", 640, 480)

 # Toggle full screen
 RubyCube.full_screen

Returns the current full screen status of ruby cube

Change the global gravity constant for physics simulated shapes.

Examples

 RubyCube.gravity = -9.8

Returns the current flag that enables lighting

Change the current enable flag.

Converts the perspective transformation to an orthographic screen space projection where 1 graphical unit == 1 screen pixel. This is the default mode for simplicity.

Pause the animation system.

Converts to a perspective correct transformation. RubyCube will have better support for 3d mode later.

Parameters

  • fov Field of view of the perspective transform
  • aspectRatio Usually w/h if you pass 0 this is done automatically
  • nearPlane Near clipping plane
  • farPlane Far clipping plane

Examples

 RubyCube.perspective(90, 0, 1, 1000)

Change the polygon filling mode of the renderer

See also

 RubyCube::POLY_MODE_LINE
 RubyCube::POLY_MODE_FILL

Returns true when event data has been filled into event_data.

This turns out to be a lot faster and in most cases more convient then passing a set of blocks for every kind of callback you might want to receive. Higher level event handling semantics can be built on this method very easily.

See the EVENT_* constants for event types. testevents.rb shows examples of all relevant events.

Events are the primary way that the background thread communicates with your ruby application. The events will overflow and the oldest events will be lost if you don’t read events in a timely manner. This method call belongs at the top of your ruby loop.

Parameters

  • array_buffer The array buffer will contain the data of the event.

Examples

 event_data = []
 RubyCube.read_event(event_data)

 puts "Event type: #{event_data[0]}"

Resume the animation system. The animation system is running by default.

Returns the ID of the timer. Each time the timer is hit it will deliver a EVENT_TIMER event type. Timers with a repeatCount of -1 will repeat forever.

Parameters

  • interval Interval time in seconds between timer events
  • repeatCount -1, 0, N. -1 means repeat forever, 0 to N repeats the expected times

Examples

 RubyCube.set_timer(60, -1) # interval 60 seconds, repeat forever
 RubyCube.set_timer(.01, 10) # interval 10 milliseconds, repeat 10 times

This is the startup routine for the rubycube system. If you don’t call this method first bad things will happen later.

RubyCube will start a background thread that updates your shapes and renders everything.

Parameters

  • windowTitle String title of window shown
  • width Width of window in pixels
  • height Height of window in pixels

Examples

 RubyCube.start("My application", 800, 600)

Change the global translation for the model view matrix. This could be used to implement camera shake or scrolling.

Parameters

  • x X component of translation
  • y Y component of translation
  • z Z component of translation

Animate the modification of the global scale in the model view transform.

This method does not yet work correctly.

[Validate]