208
208
/*generate texture*/
209
210
st->txh.pixelformat = GF_PIXEL_RGBA;
211
211
st->txh.stride = st->txh.width*4;
212
212
st->txh.transparent = 1;
214
st->txh.pixelformat = GF_PIXEL_RGB_24;
215
st->txh.stride = st->txh.width*3;
213
217
st->surface->width = st->txh.width;
214
218
st->surface->height = st->txh.height;
319
323
void R3D_InitCompositeTexture3D(Render3D *sr, GF_Node *node)
325
M_CompositeTexture3D *c3d = (M_CompositeTexture3D *)node;
321
326
CompositeTextureStack *st = malloc(sizeof(CompositeTextureStack));
322
327
memset(st, 0, sizeof(CompositeTextureStack));
323
328
gf_sr_texture_setup(&st->txh, sr->compositor, node);
324
st->txh.flags = GF_SR_TEXTURE_REPEAT_S | GF_SR_TEXTURE_REPEAT_T;
330
if (c3d->repeatS) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S;
331
if (c3d->repeatT) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T;
326
333
/*create composite surface*/
327
334
st->surface = VS_New();
337
344
void R3D_InitCompositeTexture2D(Render3D *sr, GF_Node *node)
346
M_CompositeTexture2D *c2d = (M_CompositeTexture2D *)node;
339
347
CompositeTextureStack *st = malloc(sizeof(CompositeTextureStack));
340
348
memset(st, 0, sizeof(CompositeTextureStack));
341
349
gf_sr_texture_setup(&st->txh, sr->compositor, node);
342
st->txh.flags = GF_SR_TEXTURE_REPEAT_S | GF_SR_TEXTURE_REPEAT_T;
351
if ((c2d->repeatSandT==1) || (c2d->repeatSandT==3) ) st->txh.flags |= GF_SR_TEXTURE_REPEAT_S;
352
if (c2d->repeatSandT>1) st->txh.flags |= GF_SR_TEXTURE_REPEAT_T;
344
354
/*create composite surface*/
345
355
st->surface = VS_New();
379
390
while (txcoord.y<0) txcoord.y += FIX_ONE; while (txcoord.y>FIX_ONE) txcoord.y -= FIX_ONE;
381
392
/*convert to tx space*/
382
ev->mouse.x = FIX2INT(txcoord.x - FIX_ONE/2) * st->surface->width;
383
ev->mouse.y = FIX2INT(txcoord.y - FIX_ONE/2) * st->surface->height;
393
ev->mouse.x = FIX2INT( (txcoord.x - FIX_ONE/2) * st->surface->width);
394
ev->mouse.y = FIX2INT( (txcoord.y - FIX_ONE/2) * st->surface->height);
385
396
eff = effect3d_new();
386
397
eff->surface = st->surface;
391
402
VS_SetupEffects(st->surface, eff);
393
404
children = Composite_GetChildren(st->txh.owner);
394
for (i=0; i<gf_list_count(children); i++) {
395
GF_Node *child = gf_list_get(children, i);
406
while ((child = gf_list_enum(children, &i))) {
396
407
SensorHandler *hsens = r3d_get_sensor_handler(child);
397
408
if (hsens) gf_list_add(eff->sensors, hsens);
415
static void UpdateMatteTexture(GF_TextureHandler *txh)
419
static void DestroyMatteTexture(GF_Node *node)
421
MatteTextureStack *st = (MatteTextureStack *) gf_node_get_private(node);
422
/*prevent destroying of sub textures*/
424
gf_sr_texture_destroy(&st->txh);
428
void R3D_InitMatteTexture(Render3D *sr, GF_Node *node)
430
M_MatteTexture *matte = (M_MatteTexture *)node;
431
MatteTextureStack *st;
432
GF_SAFEALLOC(st, sizeof(MatteTextureStack));
433
gf_sr_texture_setup(&st->txh, sr->compositor, node);
434
st->txh.flags = GF_SR_TEXTURE_MATTE;
435
st->txh.update_texture_fcnt = UpdateMatteTexture;
436
gf_node_set_private(node, st);
437
gf_node_set_predestroy_function(node, DestroyMatteTexture);
440
GF_TextureHandler *r3d_matte_get_texture(GF_Node *node)
442
GF_TextureHandler *hdl = R3D_GetTextureHandler(((M_MatteTexture*)node)->surfaceB);
443
if (hdl) hdl->matteTexture = node;
406
447
GF_TextureHandler *R3D_GetTextureHandler(GF_Node *n)
449
GF_TextureHandler *hdl;
408
450
if (!n) return NULL;
409
451
switch (gf_node_get_tag(n)) {
410
case TAG_MPEG4_CompositeTexture2D: return r3d_composite_get_texture(n);
411
case TAG_MPEG4_CompositeTexture3D: return r3d_composite_get_texture(n);
412
case TAG_MPEG4_LinearGradient: return r3d_lg_get_texture(n);
413
case TAG_MPEG4_RadialGradient: return r3d_rg_get_texture(n);
415
case TAG_MPEG4_MatteTexture: return matte_get_texture(n);
417
default: return gf_sr_texture_get_handler(n);
452
case TAG_MPEG4_CompositeTexture2D: hdl = r3d_composite_get_texture(n); break;
453
case TAG_MPEG4_CompositeTexture3D: hdl = r3d_composite_get_texture(n); break;
454
case TAG_MPEG4_LinearGradient: hdl = r3d_lg_get_texture(n); break;
455
case TAG_MPEG4_RadialGradient: hdl = r3d_rg_get_texture(n); break;
456
case TAG_MPEG4_MatteTexture: return r3d_matte_get_texture(n);
457
default: hdl = gf_sr_texture_get_handler(n); break;
459
hdl->matteTexture = NULL;