1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the plugins of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
42 #include "waylandsurfacetexturematerial.h"
43 #include <QtGui/QOpenGLContext>
45 static const char wayland_surface_texture_material_vertex[] =
46 "uniform highp mat4 qt_Matrix; \n"
47 "attribute highp vec4 qt_VertexPosition; \n"
48 "attribute highp vec2 qt_VertexTexCoord; \n"
49 "varying highp vec2 qt_TexCoord; \n"
51 " qt_TexCoord = qt_VertexTexCoord; \n"
52 " gl_Position = qt_Matrix * qt_VertexPosition; \n"
56 static const char wayland_surface_texture_opaque_material_fragment[] =
57 "varying highp vec2 qt_TexCoord; \n"
58 "uniform sampler2D qt_Texture; \n"
59 "uniform lowp float qt_Opacity; \n"
61 " gl_FragColor = vec4(texture2D(qt_Texture, qt_TexCoord).rgb, 1.0) * qt_Opacity; \n"
64 static const char wayland_surface_texture_material_fragment[] =
65 "varying highp vec2 qt_TexCoord; \n"
66 "uniform sampler2D qt_Texture; \n"
67 "uniform lowp float qt_Opacity; \n"
69 " gl_FragColor = texture2D(qt_Texture, qt_TexCoord) * qt_Opacity; \n"
72 QList<QByteArray> WaylandSurfaceTextureMaterial::attributes() const
74 QList<QByteArray> attributeList;
75 attributeList << "qt_VertexPosition";
76 attributeList << "qt_VertexTexCoord";
80 void WaylandSurfaceTextureMaterial::updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState)
83 newState->texture()->bind();
86 const char *WaylandSurfaceTextureMaterial::vertexShader() const
88 return wayland_surface_texture_material_vertex;
91 const char *WaylandSurfaceTextureMaterial::fragmentShader() const
93 return wayland_surface_texture_material_fragment;
96 QList<QByteArray> WaylandSurfaceTextureOpaqueMaterial::attributes() const
98 QList<QByteArray> attributeList;
99 attributeList << "qt_VertexPosition";
100 attributeList << "qt_VertexTexCoord";
101 return attributeList;
104 void WaylandSurfaceTextureOpaqueMaterial::updateState(const WaylandSurfaceTextureState *newState, const WaylandSurfaceTextureState *oldState)
107 newState->texture()->bind();
110 const char *WaylandSurfaceTextureOpaqueMaterial::vertexShader() const
112 return wayland_surface_texture_material_vertex;
115 const char *WaylandSurfaceTextureOpaqueMaterial::fragmentShader() const
117 return wayland_surface_texture_opaque_material_fragment;