Sha256: 1dec2dd138b24964a03c8249cb2cdc15eb3704b247b6e3bddcdc8301c4442463

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

#include "rays/ruby/camera.h"


#include "rays/ruby/image.h"
#include "defs.h"


RUCY_DEFINE_VALUE_FROM_TO(Rays::Camera)

#define THIS  to<Rays::Camera*>(self)

#define CHECK RUCY_CHECK_OBJECT(Rays::Camera, self)


static
VALUE alloc(VALUE klass)
{
	return new_type<Rays::Camera>(klass);
}

static
VALUE initialize(VALUE self)
{
	RUCY_CHECK_OBJ(Rays::Camera, self);

	*THIS = Rays::Camera();
	return self;
}

static
VALUE start(VALUE self)
{
	CHECK;
	return value(THIS->start());
}

static
VALUE stop(VALUE self)
{
	CHECK;
	THIS->stop();
}

static
VALUE is_active(VALUE self)
{
	CHECK;
	return value(THIS->is_active());
}

static
VALUE image(VALUE self)
{
	CHECK;
	const Rays::Image* img = THIS->image();
	return img ? value(*img) : nil();
}


static Class cCamera;

void
Init_camera ()
{
	Module mRays = rb_define_module("Rays");

	cCamera = rb_define_class_under(mRays, "Camera", rb_cObject);
	rb_define_alloc_func(cCamera, alloc);
	rb_define_private_method(cCamera, "initialize", RUBY_METHOD_FUNC(initialize), -1);
	rb_define_method(cCamera, "start", RUBY_METHOD_FUNC(start), 0);
	rb_define_method(cCamera, "stop", RUBY_METHOD_FUNC(stop), 0);
	cCamera.define_method("active?", is_active);
	rb_define_method(cCamera, "image", RUBY_METHOD_FUNC(image), 0);
}


namespace Rays
{


	Class
	camera_class ()
	{
		return cCamera;
	}


}// Rays

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rays-0.1.16 .doc/ext/rays/camera.cpp