~compiz-team/compiz/0.9.12

« back to all changes in this revision

Viewing changes to plugins/opengl/opengl.cpp

  • Committer: Dennis kasprzyk
  • Author(s): Dennis Kasprzyk
  • Date: 2009-03-15 05:09:18 UTC
  • Revision ID: git-v1:163f6b6f3c3b7764987cbdf8e03cc355edeaa499
New generalized build system.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2008 Dennis Kasprzyk
3
 
 * Copyright © 2007 Novell, Inc.
4
 
 *
5
 
 * Permission to use, copy, modify, distribute, and sell this software
6
 
 * and its documentation for any purpose is hereby granted without
7
 
 * fee, provided that the above copyright notice appear in all copies
8
 
 * and that both that copyright notice and this permission notice
9
 
 * appear in supporting documentation, and that the name of
10
 
 * Dennis Kasprzyk not be used in advertising or publicity pertaining to
11
 
 * distribution of the software without specific, written prior permission.
12
 
 * Dennis Kasprzyk makes no representations about the suitability of this
13
 
 * software for any purpose. It is provided "as is" without express or
14
 
 * implied warranty.
15
 
 *
16
 
 * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
 
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18
 
 * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
 
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
 
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21
 
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22
 
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23
 
 *
24
 
 * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25
 
 *          David Reveman <davidr@novell.com>
26
 
 */
27
 
 
28
 
#include <core/core.h>
29
 
#include <core/privatehandler.h>
30
 
#include "privates.h"
31
 
 
32
 
const CompMetadata::OptionInfo glOptionInfo[GL_OPTION_NUM] = {
33
 
    { "texture_filter", "int", RESTOSTRING (0, 2), 0, 0 },
34
 
    { "lighting", "bool", 0, 0, 0 },
35
 
    { "sync_to_vblank", "bool", 0, 0, 0 },
36
 
    { "texture_compression", "bool", 0, 0, 0 },
37
 
};
38
 
 
39
 
CompOption::Vector &
40
 
GLScreen::getOptions ()
41
 
{
42
 
    return priv->opt;
43
 
}
44
 
 
45
 
bool
46
 
GLScreen::setOption (const char        *name,
47
 
                     CompOption::Value &value)
48
 
{
49
 
    CompOption   *o;
50
 
    unsigned int index;
51
 
 
52
 
    o = CompOption::findOption (priv->opt, name, &index);
53
 
    if (!o)
54
 
        return false;
55
 
 
56
 
    switch (index) {
57
 
        case GL_OPTION_TEXTURE_FILTER:
58
 
            if (o->set (value))
59
 
            {
60
 
                priv->cScreen->damageScreen ();
61
 
 
62
 
                if (!o->value ().i ())
63
 
                    priv->textureFilter = GL_NEAREST;
64
 
                else
65
 
                    priv->textureFilter = GL_LINEAR;
66
 
 
67
 
                return true;
68
 
            }
69
 
            break;
70
 
        default:
71
 
            if (CompOption::setOption (*o, value))
72
 
                return true;
73
 
            break;
74
 
    }
75
 
 
76
 
    return false;
77
 
}
78
 
 
79
 
class OpenglPluginVTable :
80
 
    public CompPlugin::VTableForScreenAndWindow<GLScreen, GLWindow>
81
 
{
82
 
    public:
83
 
 
84
 
        bool init ();
85
 
        void fini ();
86
 
 
87
 
        PLUGIN_OPTION_HELPER (GLScreen)
88
 
};
89
 
 
90
 
COMPIZ_PLUGIN_20081216 (opengl, OpenglPluginVTable)
91
 
 
92
 
bool
93
 
OpenglPluginVTable::init ()
94
 
{
95
 
    if (!CompPlugin::checkPluginABI ("core", CORE_ABIVERSION) ||
96
 
        !CompPlugin::checkPluginABI ("composite", COMPIZ_COMPOSITE_ABI))
97
 
        return false;
98
 
 
99
 
    CompPrivate p;
100
 
    p.uval = COMPIZ_OPENGL_ABI;
101
 
    screen->storeValue ("opengl_ABI", p);
102
 
 
103
 
    getMetadata ()->addFromOptionInfo (glOptionInfo, GL_OPTION_NUM);
104
 
    getMetadata ()->addFromFile (name ());
105
 
 
106
 
    return true;
107
 
}
108
 
 
109
 
void
110
 
OpenglPluginVTable::fini ()
111
 
{
112
 
    screen->eraseValue ("opengl_ABI");
113
 
}