~ubuntu-branches/ubuntu/lucid/compiz-fusion-plugins-extra/lucid

« back to all changes in this revision

Viewing changes to src/gears/gears.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2007-12-05 22:48:25 UTC
  • mfrom: (1.1.15 upstream)
  • Revision ID: james.westby@ubuntu.com-20071205224825-yhfs0zm2evj7ca3x
Tags: 0.6.99+git20071127-0ubuntu1
new git HEAD snapshot

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <unistd.h>
32
32
#include <math.h>
33
33
 
34
 
#include <compiz.h>
35
 
#include <cube.h>
36
 
 
37
 
 
38
 
#define DEG2RAD (M_PI / 180.0f)
39
 
 
40
 
static const CompTransform identity =
41
 
{
42
 
   {
43
 
        1.0, 0.0, 0.0, 0.0,
44
 
        0.0, 1.0, 0.0, 0.0,
45
 
        0.0, 0.0, 1.0, 0.0,
46
 
        0.0, 0.0, 0.0, 1.0
47
 
    }
48
 
};
49
 
 
50
 
#define MULTMV(m, v) { \
51
 
        float v0 = m[0]*v[0] + m[4]*v[1] + m[8]*v[2] + m[12]*v[3]; \
52
 
        float v1 = m[1]*v[0] + m[5]*v[1] + m[9]*v[2] + m[13]*v[3]; \
53
 
        float v2 = m[2]*v[0] + m[6]*v[1] + m[10]*v[2] + m[14]*v[3]; \
54
 
        float v3 = m[3]*v[0] + m[7]*v[1] + m[11]*v[2] + m[15]*v[3]; \
55
 
        v[0] = v0; v[1] = v1; v[2] = v2; v[3] = v3; }
 
34
#include <compiz-core.h>
 
35
#include <compiz-cube.h>
56
36
 
57
37
static int displayPrivateIndex;
58
38
 
83
63
GearsScreen;
84
64
 
85
65
#define GET_GEARS_DISPLAY(d) \
86
 
    ((GearsDisplay *) (d)->privates[displayPrivateIndex].ptr)
 
66
    ((GearsDisplay *) (d)->base.privates[displayPrivateIndex].ptr)
87
67
#define GEARS_DISPLAY(d) \
88
68
    GearsDisplay *gd = GET_GEARS_DISPLAY(d);
89
69
 
90
70
#define GET_GEARS_SCREEN(s, gd) \
91
 
    ((GearsScreen *) (s)->privates[(gd)->screenPrivateIndex].ptr)
 
71
    ((GearsScreen *) (s)->base.privates[(gd)->screenPrivateIndex].ptr)
92
72
#define GEARS_SCREEN(s) \
93
73
    GearsScreen *gs = GET_GEARS_SCREEN(s, GET_GEARS_DISPLAY(s->display))
94
74
 
408
388
                  CompDisplay *d)
409
389
{
410
390
    GearsDisplay *gd;
411
 
    CompPlugin   *cube = findActivePlugin ("cube");
412
 
 
413
 
    CompOption  *option;
414
 
    int                 nOption;
415
 
 
416
 
    if (!cube || !cube->vTable->getDisplayOptions)
417
 
        return FALSE;
418
 
 
419
 
    option = (*cube->vTable->getDisplayOptions) (cube, d, &nOption);
420
 
 
421
 
    if (getIntOptionNamed (option, nOption, "abi", 0) != CUBE_ABIVERSION)
422
 
    {
423
 
        compLogMessage (d, "gears", CompLogLevelError,
424
 
                        "cube ABI version mismatch");
425
 
        return FALSE;
426
 
    }
427
 
 
428
 
    cubeDisplayPrivateIndex = getIntOptionNamed (option, nOption, "index", -1);
429
 
 
430
 
    if (cubeDisplayPrivateIndex < 0)
431
 
        return FALSE;
432
 
 
433
 
    gd = malloc (sizeof (GearsDisplay) );
 
391
 
 
392
    if (!checkPluginABI ("core", CORE_ABIVERSION) ||
 
393
        !checkPluginABI ("cube", CUBE_ABIVERSION))
 
394
        return FALSE;
 
395
 
 
396
    if (!getPluginDisplayIndex (d, "cube", &cubeDisplayPrivateIndex))
 
397
        return FALSE;
 
398
 
 
399
    gd = malloc (sizeof (GearsDisplay));
434
400
 
435
401
    if (!gd)
436
402
        return FALSE;
443
409
        return FALSE;
444
410
    }
445
411
 
446
 
    d->privates[displayPrivateIndex].ptr = gd;
 
412
    d->base.privates[displayPrivateIndex].ptr = gd;
447
413
 
448
414
    return TRUE;
449
415
}
480
446
    if (!gs)
481
447
        return FALSE;
482
448
 
483
 
    s->privates[gd->screenPrivateIndex].ptr = gs;
 
449
    s->base.privates[gd->screenPrivateIndex].ptr = gs;
484
450
 
485
451
    glLightfv (GL_LIGHT1, GL_AMBIENT, ambientLight);
486
452
    glLightfv (GL_LIGHT1, GL_DIFFUSE, diffuseLight);
557
523
        freeDisplayPrivateIndex (displayPrivateIndex);
558
524
}
559
525
 
560
 
static int
561
 
gearsGetVersion (CompPlugin *plugin,
562
 
                 int        version)
563
 
{
564
 
    return ABIVERSION;
 
526
static CompBool
 
527
gearsInitObject (CompPlugin *p,
 
528
                 CompObject *o)
 
529
{
 
530
    static InitPluginObjectProc dispTab[] = {
 
531
        (InitPluginObjectProc) 0, /* InitCore */
 
532
        (InitPluginObjectProc) gearsInitDisplay,
 
533
        (InitPluginObjectProc) gearsInitScreen
 
534
    };
 
535
 
 
536
    RETURN_DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), TRUE, (p, o));
 
537
}
 
538
 
 
539
static void
 
540
gearsFiniObject (CompPlugin *p,
 
541
                 CompObject *o)
 
542
{
 
543
    static FiniPluginObjectProc dispTab[] = {
 
544
        (FiniPluginObjectProc) 0, /* FiniCore */
 
545
        (FiniPluginObjectProc) gearsFiniDisplay,
 
546
        (FiniPluginObjectProc) gearsFiniScreen
 
547
    };
 
548
 
 
549
    DISPATCH (o, dispTab, ARRAY_SIZE (dispTab), (p, o));
565
550
}
566
551
 
567
552
CompPluginVTable gearsVTable = {
568
 
 
569
553
    "gears",
570
 
    gearsGetVersion,
571
554
    0,
572
555
    gearsInit,
573
556
    gearsFini,
574
 
    gearsInitDisplay,
575
 
    gearsFiniDisplay,
576
 
    gearsInitScreen,
577
 
    gearsFiniScreen,
578
 
    0,
579
 
    0,
580
 
    0,
581
 
    0,
 
557
    gearsInitObject,
 
558
    gearsFiniObject,
582
559
    0,
583
560
    0
584
561
};
585
562
 
586
563
CompPluginVTable *
587
 
getCompPluginInfo (void)
 
564
getCompPluginInfo20070830 (void)
588
565
{
589
566
    return &gearsVTable;
590
567
}