Exemplo n.º 1
0
bool RenderTarget_clear(JSContext *cx, unsigned argc, jsval *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp( argc, vp ); Value value=args.computeThis( cx );
    RenderTarget *target=(RenderTarget *) JS_GetPrivate( &value.toObject() );

    GLfloat r = -1;
    GLfloat g = -1;
    GLfloat b = -1;
    GLfloat a = -1;
	
    GLint depth=1.0;

    if ( argc >= 1 && args[0].isObject() )
    {
        RootedObject object(cx, &args[0].toObject() );
        RootedValue red(cx), green(cx), blue(cx), alpha(cx);

        JS_GetProperty( cx, HandleObject(object), "r", MutableHandleValue(&red) );
        JS_GetProperty( cx, HandleObject(object), "g", MutableHandleValue(&green) );
        JS_GetProperty( cx, HandleObject(object), "b", MutableHandleValue(&blue) );
        JS_GetProperty( cx, HandleObject(object), "a", MutableHandleValue(&alpha) );

        r=red.toNumber(); g=green.toNumber(); b=blue.toNumber(); a=alpha.toNumber();
    }

    if ( argc >= 2 ) depth=args[1].toInt32();

    target->clear( r, g, b, a, depth );

    return true;
}
Exemplo n.º 2
0
bool RenderTarget_bindAsTexture(JSContext *cx, unsigned argc, jsval *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp( argc, vp ); Value value=args.computeThis( cx );

    RenderTarget *target=(RenderTarget *) JS_GetPrivate( &value.toObject() );
    target->bindAsTexture();
    return true;
}
Exemplo n.º 3
0
bool RenderTarget_resize(JSContext *cx, unsigned argc, jsval *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp( argc, vp ); Value value=args.computeThis( cx );

    if ( argc == 2 )
    {
        RenderTarget *target=(RenderTarget *) JS_GetPrivate( &value.toObject() );
        target->resize( args[0].toInt32(), args[1].toInt32() );
    }
    return true;
}
Exemplo n.º 4
0
bool RenderTarget_dispose(JSContext *cx, unsigned argc, jsval *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp( argc, vp ); Value value=args.computeThis( cx );

    RenderTarget *target=(RenderTarget *) JS_GetPrivate( &value.toObject() );
    target->dispose();

    // --- VG.Renderer().removeResource(this);
    
    RootedValue *renderer=g_host->executeScript( "VG.Renderer()" );
    RootedObject rendererObject( cx, &renderer->toObject() );

    RootedValue rc( cx );
    RootedValue thisValue( cx, value );

    bool ok=Call( cx, HandleObject( rendererObject ), "removeResource", HandleValueArray( thisValue ), MutableHandleValue( &rc ) );

    return true;
}
Exemplo n.º 5
0
bool RenderTarget_setScissor(JSContext *cx, unsigned argc, jsval *vp)
{
    JS::CallArgs args = JS::CallArgsFromVp( argc, vp ); Value value=args.computeThis( cx );
    RenderTarget *target=(RenderTarget *) JS_GetPrivate( &value.toObject() );

    if ( argc == 1 && args[0].isObject() )
    {
        RootedObject object(cx, &args[0].toObject() );
        RootedValue x(cx), y(cx), width(cx), height(cx);

        JS_GetProperty( cx, HandleObject(object), "x", MutableHandleValue(&x) );
        JS_GetProperty( cx, HandleObject(object), "y", MutableHandleValue(&y) );
        JS_GetProperty( cx, HandleObject(object), "width", MutableHandleValue(&width) );
        JS_GetProperty( cx, HandleObject(object), "height", MutableHandleValue(&height) );   

        target->setScissor( x.toInt32(), y.toInt32(), width.toInt32(), height.toInt32() );     
    } else target->setScissor( 0, 0, 0, 0 );  

    return true;
}