Merge lp:~glmark2-dev/glmark2/ideas into lp:glmark2/2011.11

Proposed by Jesse Barker
Status: Merged
Merged at revision: 206
Proposed branch: lp:~glmark2-dev/glmark2/ideas
Merge into: lp:glmark2/2011.11
Diff against target: 4613 lines (+4301/-3)
46 files modified
COPYING.SGI (+40/-0)
android/jni/Android.ndk.mk (+14/-1)
data/shaders/ideas-lamp-lit.frag (+68/-0)
data/shaders/ideas-lamp-lit.vert (+28/-0)
data/shaders/ideas-lamp-unlit.frag (+6/-0)
data/shaders/ideas-lamp-unlit.vert (+11/-0)
data/shaders/ideas-logo-flat.frag (+6/-0)
data/shaders/ideas-logo-flat.vert (+9/-0)
data/shaders/ideas-logo-shadow.frag (+10/-0)
data/shaders/ideas-logo-shadow.vert (+9/-0)
data/shaders/ideas-logo.frag (+35/-0)
data/shaders/ideas-logo.vert (+28/-0)
data/shaders/ideas-paper.frag (+6/-0)
data/shaders/ideas-paper.vert (+22/-0)
data/shaders/ideas-table.frag (+6/-0)
data/shaders/ideas-table.vert (+22/-0)
data/shaders/ideas-text.frag (+6/-0)
data/shaders/ideas-text.vert (+18/-0)
data/shaders/ideas-under-table.frag (+6/-0)
data/shaders/ideas-under-table.vert (+11/-0)
src/android.cpp (+1/-0)
src/default-benchmarks.h (+1/-0)
src/libmatrix/program.cc (+12/-0)
src/libmatrix/program.h (+1/-0)
src/main.cpp (+1/-0)
src/scene-ideas.cpp (+426/-0)
src/scene-ideas/a.cc (+179/-0)
src/scene-ideas/characters.h (+157/-0)
src/scene-ideas/d.cc (+142/-0)
src/scene-ideas/e.cc (+139/-0)
src/scene-ideas/i.cc (+116/-0)
src/scene-ideas/lamp.cc (+258/-0)
src/scene-ideas/lamp.h (+64/-0)
src/scene-ideas/logo.cc (+789/-0)
src/scene-ideas/logo.h (+126/-0)
src/scene-ideas/m.cc (+210/-0)
src/scene-ideas/n.cc (+146/-0)
src/scene-ideas/o.cc (+139/-0)
src/scene-ideas/s.cc (+130/-0)
src/scene-ideas/splines.cc (+200/-0)
src/scene-ideas/splines.h (+83/-0)
src/scene-ideas/t.cc (+147/-0)
src/scene-ideas/table.cc (+353/-0)
src/scene-ideas/table.h (+94/-0)
src/scene.h (+21/-0)
src/wscript_build (+5/-2)
To merge this branch: bzr merge lp:~glmark2-dev/glmark2/ideas
Reviewer Review Type Date Requested Status
Alexandros Frantzis Approve
Review via email: mp+105134@code.launchpad.net

Description of the change

This branch adds a new scene to glmark2 (SceneIdeas) based upon the old SGI "Ideas in Motion" GLUT/OpenGL demo. For those that have never seen it, this scene sees a fly around of a table illuminated by a lamp (all lit). On the table is a piece of paper with the words "ideas in motion" and a flattened version of the old tubular-framed cube SGI logo. As the fly around progresses, the logo emerges from the paper, fully three dimensional, lit and phong shaded. As it fully emerges, it casts a shadow around the table. While this demo is close to 20 years old (it was originally implemented in IrisGL, which predates OpenGL), it is still pretty cool. In addition to the standard options, this scene has a "speed" option which governs the fly around. For benchmark purposes, running at max speed (the default) is probably best. For demo purposes, we would want to determine the right combination of duration and speed to let the scene naturally cycle (those values are likely quite platform dependent). While none of the source is shared with the original demo, the vertex position data comes from that demo and this scene would not be possible without it, so, per the copyrights on the original demo source, those are reproduced along with the Linaro copyrights and a copy of the original copyright notice is now included with the glmark2 source in a file called "COPYING.SGI".

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

In SceneIdeas::update_time(), there is this comment:

// If we're also running continuously, we need to reset back to the
// beginning after a few seconds.

However, I don't see what is being described here actually happening, i.e., the scene is paused forever after finishing.

It would be good to add proper validation to this scene. The problem is that the first frame of SceneIdeas is empty, so there isn't much to check. We could extend the scene interface to be able to notify a scene that it is being validated, therefore giving it a chance to render a frame that makes more sense for validation instead of just the first frame. Anyway, this is not a blocker. We can add validation to this scene later, when the aforementioned interface is in place.

Finally, do we want to add this scene to those benchmarked by default?

lp:~glmark2-dev/glmark2/ideas updated
225. By Jesse Barker

SceneIdeas: Remove extraneous comment.

226. By Jesse Barker

SceneIdeas: Add to default benchmark list.

Revision history for this message
Jesse Barker (jesse-barker) wrote :

> In SceneIdeas::update_time(), there is this comment:
>
> // If we're also running continuously, we need to reset back to the
> // beginning after a few seconds.
>
> However, I don't see what is being described here actually happening, i.e.,
> the scene is paused forever after finishing.

Good catch. The original demo code handles the "run-forever" case differently than the glmark2 framework. I've removed those extraneous lines.

>
> It would be good to add proper validation to this scene. The problem is that
> the first frame of SceneIdeas is empty, so there isn't much to check. We could
> extend the scene interface to be able to notify a scene that it is being
> validated, therefore giving it a chance to render a frame that makes more
> sense for validation instead of just the first frame. Anyway, this is not a
> blocker. We can add validation to this scene later, when the aforementioned
> interface is in place.

As this scene is temporally driven, I suppose it would be possible to initialize time somewhere in the middle of the fly around so we could sample an "interesting" pixel, rather than a black one. I might prefer to do this later (post-merge).

>
> Finally, do we want to add this scene to those benchmarked by default?

Done. Again, here, we might want to tweak the values later to ensure that the scene gets "far enough" along but not so far that it's rendering the final frame many times.

cheers,
Jesse

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

> Good catch. The original demo code handles the "run-forever" case differently
> than the glmark2 framework. I've removed those extraneous lines.

What do you think about using something like: https://code.launchpad.net/~linaro-graphics-wg/glmark2/ideas-loop

> As this scene is temporally driven, I suppose it would be possible to
> initialize time somewhere in the middle of the fly around so we could sample
> an "interesting" pixel, rather than a black one. I might prefer to do this
> later (post-merge).

Sounds good.

> Done. Again, here, we might want to tweak the values later to ensure that the
> scene gets "far enough" along but not so far that it's rendering the final
> frame many times.

I am not sure if we should add this as the first test. My suggestion would be to put it after the "buffer" tests, just before the shader feature tests. At least that is what I have been doing when adding new tests so far.

Revision history for this message
Jesse Barker (jesse-barker) wrote :

> > Good catch. The original demo code handles the "run-forever" case
> differently
> > than the glmark2 framework. I've removed those extraneous lines.
>
> What do you think about using something like: https://code.launchpad.net
> /~linaro-graphics-wg/glmark2/ideas-loop

Seems fine. Should we do this now or post-merge?

>
> > As this scene is temporally driven, I suppose it would be possible to
> > initialize time somewhere in the middle of the fly around so we could sample
> > an "interesting" pixel, rather than a black one. I might prefer to do this
> > later (post-merge).
>
> Sounds good.
>
> > Done. Again, here, we might want to tweak the values later to ensure that
> the
> > scene gets "far enough" along but not so far that it's rendering the final
> > frame many times.
>
> I am not sure if we should add this as the first test. My suggestion would be
> to put it after the "buffer" tests, just before the shader feature tests. At
> least that is what I have been doing when adding new tests so far.

Done. I didn't see a pattern to the tests (apart from the shader feature ones being at the end), so I just added it. I've moved it after the buffer ones.

cheers,
jesse

lp:~glmark2-dev/glmark2/ideas updated
227. By Jesse Barker

Move SceneIdeas to after SceneBuffer in the default initialization of the
benchmark list.

228. By Jesse Barker

SceneIdeas: Use Alexandros' suggestion to reverse time at the end of each 'cycle'
through the fly around.

Revision history for this message
Jesse Barker (jesse-barker) wrote :

> > > Good catch. The original demo code handles the "run-forever" case
> > differently
> > > than the glmark2 framework. I've removed those extraneous lines.
> >
> > What do you think about using something like: https://code.launchpad.net
> > /~linaro-graphics-wg/glmark2/ideas-loop
>
> Seems fine. Should we do this now or post-merge?

OK. I did this and pushed it up to the branch (revision 228). Let me know what you think and then we should be set to merge.

cheers,
Jesse

>
> >
> > > As this scene is temporally driven, I suppose it would be possible to
> > > initialize time somewhere in the middle of the fly around so we could
> sample
> > > an "interesting" pixel, rather than a black one. I might prefer to do
> this
> > > later (post-merge).
> >
> > Sounds good.
> >
> > > Done. Again, here, we might want to tweak the values later to ensure that
> > the
> > > scene gets "far enough" along but not so far that it's rendering the final
> > > frame many times.
> >
> > I am not sure if we should add this as the first test. My suggestion would
> be
> > to put it after the "buffer" tests, just before the shader feature tests. At
> > least that is what I have been doing when adding new tests so far.
>
> Done. I didn't see a pattern to the tests (apart from the shader feature ones
> being at the end), so I just added it. I've moved it after the buffer ones.
>
> cheers,
> jesse

lp:~glmark2-dev/glmark2/ideas updated
229. By Jesse Barker

SceneIdeas: Update the comment for clarity.

Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Another thing I noticed is that if you use the default scene options, i.e., if your just use '-b ideas' to run the benchmark you get an incomplete run. This happens because the default cycle time of tests is 10 seconds, but ideas uses 12. I think it would be nice if the default speed was such that the scene completes a cycle in the default 10 seconds.

Also, I think the 'speed' scene option should be a float instead of an enumerated value. This will allow users to set the speed to any value, and therefore schedule complete cycles for any duration they choose (e.g. for demo purposes).

We can consider these after merging the branch, if you prefer.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'COPYING.SGI'
2--- COPYING.SGI 1970-01-01 00:00:00 +0000
3+++ COPYING.SGI 2012-05-09 20:57:19 +0000
4@@ -0,0 +1,40 @@
5+The data and some of the control logic for the "ideas" scene was adapted from
6+the "Ideas in Motion" GLUT demo. Per the rights granted by the source for that
7+demo, the following notice is reproduced here:
8+
9+/*
10+ * (c) Copyright 1993, Silicon Graphics, Inc.
11+ * ALL RIGHTS RESERVED
12+ * Permission to use, copy, modify, and distribute this software for
13+ * any purpose and without fee is hereby granted, provided that the above
14+ * copyright notice appear in all copies and that both the copyright notice
15+ * and this permission notice appear in supporting documentation, and that
16+ * the name of Silicon Graphics, Inc. not be used in advertising
17+ * or publicity pertaining to distribution of the software without specific,
18+ * written prior permission.
19+ *
20+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
21+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
22+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
23+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
24+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
25+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
26+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
27+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
28+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
29+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
30+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
31+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
32+ *
33+ * US Government Users Restricted Rights
34+ * Use, duplication, or disclosure by the Government is subject to
35+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
36+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
37+ * clause at DFARS 252.227-7013 and/or in similar or successor
38+ * clauses in the FAR or the DOD or NASA FAR Supplement.
39+ * Unpublished-- rights reserved under the copyright laws of the
40+ * United States. Contractor/manufacturer is Silicon Graphics,
41+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
42+ *
43+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
44+ */
45
46=== modified file 'android/jni/Android.ndk.mk'
47--- android/jni/Android.ndk.mk 2012-03-22 10:37:35 +0000
48+++ android/jni/Android.ndk.mk 2012-05-09 20:57:19 +0000
49@@ -19,14 +19,27 @@
50
51 include $(CLEAR_VARS)
52
53+LOCAL_CPP_EXTENSION := .cc
54+LOCAL_MODULE := libglmark2-ideas
55+LOCAL_CFLAGS := -DGLMARK_DATA_PATH="" -DUSE_GLESv2 -Werror -Wall -Wextra\
56+ -Wnon-virtual-dtor
57+LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \
58+ $(LOCAL_PATH)/src/libmatrix
59+LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/src/scene-ideas/*.cc))
60+
61+include $(BUILD_STATIC_LIBRARY)
62+
63+include $(CLEAR_VARS)
64+
65 LOCAL_MODULE_TAGS := optional
66 LOCAL_MODULE := libglmark2-android
67-LOCAL_STATIC_LIBRARIES := libglmark2-matrix libglmark2-png
68+LOCAL_STATIC_LIBRARIES := libglmark2-matrix libglmark2-png libglmark2-ideas
69 LOCAL_CFLAGS := -DGLMARK_DATA_PATH="" -DGLMARK_VERSION="\"2012.03\"" \
70 -DUSE_GLESv2 -Werror -Wall -Wextra -Wnon-virtual-dtor
71 LOCAL_LDLIBS := -landroid -llog -lGLESv2 -lEGL -lz
72 LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \
73 $(LOCAL_PATH)/src/libmatrix \
74+ $(LOCAL_PATH)/src/scene-ideas \
75 $(LOCAL_PATH)/src/libpng
76 LOCAL_SRC_FILES := $(filter-out src/canvas% src/main.cpp, \
77 $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/src/*.cpp))) \
78
79=== added file 'data/shaders/ideas-lamp-lit.frag'
80--- data/shaders/ideas-lamp-lit.frag 1970-01-01 00:00:00 +0000
81+++ data/shaders/ideas-lamp-lit.frag 2012-05-09 20:57:19 +0000
82@@ -0,0 +1,68 @@
83+struct LightSourceParameters
84+{
85+ vec4 ambient;
86+ vec4 diffuse;
87+ vec4 specular;
88+ vec4 position;
89+};
90+LightSourceParameters lightSource[3];
91+uniform mat4 modelview;
92+uniform vec4 light0Position;
93+uniform vec4 light1Position;
94+uniform vec4 light2Position;
95+varying vec3 vertex_normal;
96+varying vec4 vertex_position;
97+varying vec3 eye_direction;
98+
99+vec3 unitvec(vec4 v1, vec4 v2)
100+{
101+ if (v1.w == 0.0 && v2.w == 0.0)
102+ return vec3(v2 - v1);
103+ if (v1.w == 0.0)
104+ return vec3(-v1);
105+ if (v2.w == 0.0)
106+ return vec3(v2);
107+ return v2.xyz/v2.w - v1.xyz/v1.w;
108+}
109+
110+void main()
111+{
112+ lightSource[0] = LightSourceParameters(
113+ vec4(0.0, 0.0, 0.0, 1.0),
114+ vec4(1.0, 1.0, 1.0, 1.0),
115+ vec4(1.0, 1.0, 1.0, 1.0),
116+ vec4(0.0, 1.0, 0.0, 0.0)
117+ );
118+ lightSource[1] = LightSourceParameters(
119+ vec4(0.0, 0.0, 0.0, 1.0),
120+ vec4(0.3, 0.3, 0.5, 1.0),
121+ vec4(0.3, 0.3, 0.5, 1.0),
122+ vec4(-1.0, 0.0, 0.0, 0.0)
123+ );
124+ lightSource[2] = LightSourceParameters(
125+ vec4(0.2, 0.2, 0.2, 1.0),
126+ vec4(0.2, 0.2, 0.2, 1.0),
127+ vec4(0.2, 0.2, 0.2, 1.0),
128+ vec4(0.0, -1.0, 0.0, 0.0)
129+ );
130+ vec4 matAmbient = vec4(0.0, 0.0, 0.0, 1.0);
131+ vec4 matDiffuse = vec4(1.0, 0.2, 0.2, 1.0);
132+ vec4 matSpecular = vec4(0.5, 0.5, 0.5, 1.0);
133+ float matShininess = 20.0;
134+ vec4 diffuseSum = vec4(0.0, 0.0, 0.0, 0.0);
135+ vec4 specularSum = vec4(0.0, 0.0, 0.0, 0.0);
136+ vec4 ambientSum = vec4(0.0, 0.0, 0.0, 0.0);
137+ vec3 normalized_normal = normalize(vertex_normal);
138+ lightSource[0].position = light0Position;
139+ lightSource[1].position = light1Position;
140+ lightSource[2].position = light2Position;
141+ for (int light = 0; light < 3; light++) {
142+ vec4 light_position = lightSource[light].position;
143+ vec3 light_direction = normalize(unitvec(vertex_position, light_position));
144+ vec3 reflection = reflect(-light_direction, normalized_normal);
145+ specularSum += pow(max(0.0, dot(reflection, eye_direction)), matShininess) * lightSource[light].specular;
146+ diffuseSum += max(0.0, dot(normalized_normal, light_direction)) * lightSource[light].diffuse;
147+ ambientSum += lightSource[light].ambient;
148+ }
149+ gl_FragColor = (matSpecular * specularSum) + (matAmbient * ambientSum) + (matDiffuse * diffuseSum);
150+}
151
152=== added file 'data/shaders/ideas-lamp-lit.vert'
153--- data/shaders/ideas-lamp-lit.vert 1970-01-01 00:00:00 +0000
154+++ data/shaders/ideas-lamp-lit.vert 2012-05-09 20:57:19 +0000
155@@ -0,0 +1,28 @@
156+uniform mat4 projection;
157+uniform mat4 modelview;
158+uniform mat3 normalMatrix;
159+varying vec3 vertex_normal;
160+varying vec4 vertex_position;
161+varying vec3 eye_direction;
162+attribute vec3 vertex;
163+attribute vec3 normal;
164+
165+vec3 unitvec(vec4 v1, vec4 v2)
166+{
167+ if (v1.w == 0.0 && v2.w == 0.0)
168+ return vec3(v2 - v1);
169+ if (v1.w == 0.0)
170+ return vec3(-v1);
171+ if (v2.w == 0.0)
172+ return vec3(v2);
173+ return v2.xyz/v2.w - v1.xyz/v1.w;
174+}
175+
176+void main()
177+{
178+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
179+ gl_Position = projection * modelview * curVertex;
180+ vertex_normal = normalMatrix * normal;
181+ vertex_position = modelview * curVertex;
182+ eye_direction = normalize(unitvec(vertex_position, vec4(0.0, 0.0, 0.0, 1.0)));
183+}
184
185=== added file 'data/shaders/ideas-lamp-unlit.frag'
186--- data/shaders/ideas-lamp-unlit.frag 1970-01-01 00:00:00 +0000
187+++ data/shaders/ideas-lamp-unlit.frag 2012-05-09 20:57:19 +0000
188@@ -0,0 +1,6 @@
189+varying vec4 color;
190+
191+void main()
192+{
193+ gl_FragColor = color;
194+}
195
196=== added file 'data/shaders/ideas-lamp-unlit.vert'
197--- data/shaders/ideas-lamp-unlit.vert 1970-01-01 00:00:00 +0000
198+++ data/shaders/ideas-lamp-unlit.vert 2012-05-09 20:57:19 +0000
199@@ -0,0 +1,11 @@
200+uniform mat4 projection;
201+uniform mat4 modelview;
202+attribute vec3 vertex;
203+varying vec4 color;
204+
205+void main()
206+{
207+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
208+ gl_Position = projection * modelview * curVertex;
209+ color = vec4(1.0, 1.0, 1.0, 1.0);
210+}
211
212=== added file 'data/shaders/ideas-logo-flat.frag'
213--- data/shaders/ideas-logo-flat.frag 1970-01-01 00:00:00 +0000
214+++ data/shaders/ideas-logo-flat.frag 2012-05-09 20:57:19 +0000
215@@ -0,0 +1,6 @@
216+uniform vec4 logoColor;
217+
218+void main()
219+{
220+ gl_FragColor = logoColor;
221+}
222
223=== added file 'data/shaders/ideas-logo-flat.vert'
224--- data/shaders/ideas-logo-flat.vert 1970-01-01 00:00:00 +0000
225+++ data/shaders/ideas-logo-flat.vert 2012-05-09 20:57:19 +0000
226@@ -0,0 +1,9 @@
227+uniform mat4 projection;
228+uniform mat4 modelview;
229+attribute vec3 vertex;
230+
231+void main()
232+{
233+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
234+ gl_Position = projection * modelview * curVertex;
235+}
236
237=== added file 'data/shaders/ideas-logo-shadow.frag'
238--- data/shaders/ideas-logo-shadow.frag 1970-01-01 00:00:00 +0000
239+++ data/shaders/ideas-logo-shadow.frag 2012-05-09 20:57:19 +0000
240@@ -0,0 +1,10 @@
241+uniform sampler2D tex;
242+
243+void main()
244+{
245+ vec2 curPos = gl_FragCoord.xy / 32.0;
246+ vec4 color = texture2D(tex, curPos);
247+ if (color.w < 0.5)
248+ discard;
249+ gl_FragColor = color;
250+}
251
252=== added file 'data/shaders/ideas-logo-shadow.vert'
253--- data/shaders/ideas-logo-shadow.vert 1970-01-01 00:00:00 +0000
254+++ data/shaders/ideas-logo-shadow.vert 2012-05-09 20:57:19 +0000
255@@ -0,0 +1,9 @@
256+uniform mat4 projection;
257+uniform mat4 modelview;
258+attribute vec3 vertex;
259+
260+void main()
261+{
262+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
263+ gl_Position = projection * modelview * curVertex;
264+}
265
266=== added file 'data/shaders/ideas-logo.frag'
267--- data/shaders/ideas-logo.frag 1970-01-01 00:00:00 +0000
268+++ data/shaders/ideas-logo.frag 2012-05-09 20:57:19 +0000
269@@ -0,0 +1,35 @@
270+uniform vec4 light0Position;
271+varying vec3 vertex_normal;
272+varying vec4 vertex_position;
273+varying vec3 eye_direction;
274+
275+vec3 unitvec(vec4 v1, vec4 v2)
276+{
277+ if (v1.w == 0.0 && v2.w == 0.0)
278+ return vec3(v2 - v1);
279+ if (v1.w == 0.0)
280+ return vec3(-v1);
281+ if (v2.w == 0.0)
282+ return vec3(v2);
283+ return v2.xyz/v2.w - v1.xyz/v1.w;
284+}
285+
286+void main()
287+{
288+ vec4 lightAmbient = vec4(0.0, 0.0, 0.0, 1.0);
289+ vec4 lightDiffuse = vec4(1.0, 1.0, 1.0, 1.0);
290+ vec4 lightSpecular = vec4(1.0, 1.0, 1.0, 1.0);
291+ vec4 matAmbient = vec4(0.1, 0.1, 0.1, 1.0);
292+ vec4 matDiffuse = vec4(0.5, 0.4, 0.7, 1.0);
293+ vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0);
294+ float matShininess = 30.0;
295+ vec3 light_direction = normalize(unitvec(vertex_position, light0Position));
296+ vec3 normalized_normal = normalize(vertex_normal);
297+ vec3 reflection = reflect(-light_direction, normalized_normal);
298+ float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess);
299+ float diffuseTerm = max(0.0, dot(normalized_normal, light_direction));
300+ vec4 specular = (lightSpecular * matSpecular);
301+ vec4 ambient = (lightAmbient * matAmbient);
302+ vec4 diffuse = (lightDiffuse * matDiffuse);
303+ gl_FragColor = (specular * specularTerm) + ambient + (diffuse * diffuseTerm);
304+}
305
306=== added file 'data/shaders/ideas-logo.vert'
307--- data/shaders/ideas-logo.vert 1970-01-01 00:00:00 +0000
308+++ data/shaders/ideas-logo.vert 2012-05-09 20:57:19 +0000
309@@ -0,0 +1,28 @@
310+uniform mat4 projection;
311+uniform mat4 modelview;
312+uniform mat3 normalMatrix;
313+varying vec3 vertex_normal;
314+varying vec4 vertex_position;
315+varying vec3 eye_direction;
316+attribute vec3 vertex;
317+attribute vec3 normal;
318+
319+vec3 unitvec(vec4 v1, vec4 v2)
320+{
321+ if (v1.w == 0.0 && v2.w == 0.0)
322+ return vec3(v2 - v1);
323+ if (v1.w == 0.0)
324+ return vec3(-v1);
325+ if (v2.w == 0.0)
326+ return vec3(v2);
327+ return v2.xyz/v2.w - v1.xyz/v1.w;
328+}
329+
330+void main()
331+{
332+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
333+ gl_Position = projection * modelview * curVertex;
334+ vertex_normal = normalMatrix * normal;
335+ vertex_position = modelview * curVertex;
336+ eye_direction = normalize(unitvec(vertex_position, vec4(0.0, 0.0, 0.0, 1.0)));
337+}
338
339=== added file 'data/shaders/ideas-paper.frag'
340--- data/shaders/ideas-paper.frag 1970-01-01 00:00:00 +0000
341+++ data/shaders/ideas-paper.frag 2012-05-09 20:57:19 +0000
342@@ -0,0 +1,6 @@
343+varying vec4 color;
344+
345+void main()
346+{
347+ gl_FragColor = color;
348+}
349
350=== added file 'data/shaders/ideas-paper.vert'
351--- data/shaders/ideas-paper.vert 1970-01-01 00:00:00 +0000
352+++ data/shaders/ideas-paper.vert 2012-05-09 20:57:19 +0000
353@@ -0,0 +1,22 @@
354+uniform mat4 projection;
355+uniform mat4 modelview;
356+uniform vec3 lightPosition;
357+uniform vec3 logoDirection;
358+uniform float currentTime;
359+attribute vec3 vertex;
360+varying vec4 color;
361+
362+void main()
363+{
364+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
365+ gl_Position = projection * modelview * curVertex;
366+ float referenceTime = 15.0;
367+ vec3 lightDirection = normalize(lightPosition - vertex);
368+ float c = max(dot(lightDirection, logoDirection), 0.0);
369+ c = c * c * c * lightDirection.y;
370+ if ((currentTime > referenceTime - 5.0) && (currentTime < referenceTime - 3.0))
371+ {
372+ c *= 1.0 - (currentTime - (referenceTime - 5.0)) * 0.5;
373+ }
374+ color = vec4(c, c, (c * 0.78125), 1.0);
375+}
376
377=== added file 'data/shaders/ideas-table.frag'
378--- data/shaders/ideas-table.frag 1970-01-01 00:00:00 +0000
379+++ data/shaders/ideas-table.frag 2012-05-09 20:57:19 +0000
380@@ -0,0 +1,6 @@
381+varying vec4 color;
382+
383+void main()
384+{
385+ gl_FragColor = color;
386+}
387
388=== added file 'data/shaders/ideas-table.vert'
389--- data/shaders/ideas-table.vert 1970-01-01 00:00:00 +0000
390+++ data/shaders/ideas-table.vert 2012-05-09 20:57:19 +0000
391@@ -0,0 +1,22 @@
392+uniform mat4 projection;
393+uniform mat4 modelview;
394+uniform vec3 lightPosition;
395+uniform vec3 logoDirection;
396+uniform float currentTime;
397+attribute vec3 vertex;
398+varying vec4 color;
399+
400+void main()
401+{
402+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
403+ gl_Position = projection * modelview * curVertex;
404+ float referenceTime = 15.0;
405+ vec3 lightDirection = normalize(lightPosition - vertex);
406+ float c = max(dot(lightDirection, logoDirection), 0.0);
407+ c = c * c * c * lightDirection.y;
408+ if ((currentTime > referenceTime - 5.0) && (currentTime < referenceTime - 3.0))
409+ {
410+ c *= 1.0 - (currentTime - (referenceTime - 5.0)) * 0.5;
411+ }
412+ color = vec4(c, c, c, 1.0);
413+}
414
415=== added file 'data/shaders/ideas-text.frag'
416--- data/shaders/ideas-text.frag 1970-01-01 00:00:00 +0000
417+++ data/shaders/ideas-text.frag 2012-05-09 20:57:19 +0000
418@@ -0,0 +1,6 @@
419+varying vec4 color;
420+
421+void main()
422+{
423+ gl_FragColor = color;
424+}
425
426=== added file 'data/shaders/ideas-text.vert'
427--- data/shaders/ideas-text.vert 1970-01-01 00:00:00 +0000
428+++ data/shaders/ideas-text.vert 2012-05-09 20:57:19 +0000
429@@ -0,0 +1,18 @@
430+uniform mat4 projection;
431+uniform mat4 modelview;
432+uniform float currentTime;
433+attribute vec2 vertex;
434+varying vec4 color;
435+
436+void main()
437+{
438+ vec4 curVertex = vec4(vertex.x, vertex.y, 0.0, 1.0);
439+ gl_Position = projection * modelview * curVertex;
440+ float referenceTime = 15.0;
441+ float c = 0.0;
442+ if (currentTime > referenceTime * 1.0 - 5.0)
443+ {
444+ c = (currentTime - (referenceTime * 1.0 - 5.0)) / 2.0;
445+ }
446+ color = vec4(c, c, c, 1.0);
447+}
448
449=== added file 'data/shaders/ideas-under-table.frag'
450--- data/shaders/ideas-under-table.frag 1970-01-01 00:00:00 +0000
451+++ data/shaders/ideas-under-table.frag 2012-05-09 20:57:19 +0000
452@@ -0,0 +1,6 @@
453+varying vec4 color;
454+
455+void main()
456+{
457+ gl_FragColor = color;
458+}
459
460=== added file 'data/shaders/ideas-under-table.vert'
461--- data/shaders/ideas-under-table.vert 1970-01-01 00:00:00 +0000
462+++ data/shaders/ideas-under-table.vert 2012-05-09 20:57:19 +0000
463@@ -0,0 +1,11 @@
464+uniform mat4 projection;
465+uniform mat4 modelview;
466+attribute vec3 vertex;
467+varying vec4 color;
468+
469+void main()
470+{
471+ vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
472+ gl_Position = projection * modelview * curVertex;
473+ color = vec4(0.0, 0.0, 0.0, 1.0);
474+}
475
476=== modified file 'src/android.cpp'
477--- src/android.cpp 2012-02-15 16:00:26 +0000
478+++ src/android.cpp 2012-05-09 20:57:19 +0000
479@@ -186,6 +186,7 @@
480 Benchmark::register_scene(*new ScenePulsar(*g_canvas));
481 Benchmark::register_scene(*new SceneDesktop(*g_canvas));
482 Benchmark::register_scene(*new SceneBuffer(*g_canvas));
483+ Benchmark::register_scene(*new SceneIdeas(*g_canvas));
484
485 g_benchmark_collection = new BenchmarkCollection();
486 g_benchmark_collection->populate_from_options();
487
488=== modified file 'src/default-benchmarks.h'
489--- src/default-benchmarks.h 2011-11-14 12:39:08 +0000
490+++ src/default-benchmarks.h 2012-05-09 20:57:19 +0000
491@@ -60,6 +60,7 @@
492 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=false");
493 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=subdata:interleave=false");
494 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=true");
495+ benchmarks.push_back("ideas:speed=max:duration=12");
496 benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=0");
497 benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=5");
498 benchmarks.push_back("conditionals:vertex-steps=5:fragment-steps=0");
499
500=== modified file 'src/libmatrix/program.cc'
501--- src/libmatrix/program.cc 2012-01-26 17:00:43 +0000
502+++ src/libmatrix/program.cc 2012-05-09 20:57:19 +0000
503@@ -19,6 +19,7 @@
504
505 using std::string;
506 using LibMatrix::mat4;
507+using LibMatrix::mat3;
508 using LibMatrix::vec2;
509 using LibMatrix::vec3;
510 using LibMatrix::vec4;
511@@ -275,6 +276,17 @@
512 }
513
514 Program::Symbol&
515+Program::Symbol::operator=(const mat3& m)
516+{
517+ if (type_ == Uniform)
518+ {
519+ // Our matrix representation is column-major, so transpose is false here.
520+ glUniformMatrix3fv(location_, 1, GL_FALSE, m);
521+ }
522+ return *this;
523+}
524+
525+Program::Symbol&
526 Program::Symbol::operator=(const vec2& v)
527 {
528 if (type_ == Uniform)
529
530=== modified file 'src/libmatrix/program.h'
531--- src/libmatrix/program.h 2012-01-26 17:00:43 +0000
532+++ src/libmatrix/program.h 2012-05-09 20:57:19 +0000
533@@ -126,6 +126,7 @@
534 // These members cause data to be bound to program variables, so
535 // the program must be bound for use for these to be effective.
536 Symbol& operator=(const LibMatrix::mat4& m);
537+ Symbol& operator=(const LibMatrix::mat3& m);
538 Symbol& operator=(const LibMatrix::vec2& v);
539 Symbol& operator=(const LibMatrix::vec3& v);
540 Symbol& operator=(const LibMatrix::vec4& v);
541
542=== modified file 'src/main.cpp'
543--- src/main.cpp 2012-03-22 10:37:04 +0000
544+++ src/main.cpp 2012-05-09 20:57:19 +0000
545@@ -60,6 +60,7 @@
546 scenes.push_back(new ScenePulsar(canvas));
547 scenes.push_back(new SceneDesktop(canvas));
548 scenes.push_back(new SceneBuffer(canvas));
549+ scenes.push_back(new SceneIdeas(canvas));
550
551 for (vector<Scene*>::const_iterator iter = scenes.begin();
552 iter != scenes.end();
553
554=== added directory 'src/scene-ideas'
555=== added file 'src/scene-ideas.cpp'
556--- src/scene-ideas.cpp 1970-01-01 00:00:00 +0000
557+++ src/scene-ideas.cpp 2012-05-09 20:57:19 +0000
558@@ -0,0 +1,426 @@
559+/*
560+ * (c) Copyright 1993, Silicon Graphics, Inc.
561+ * Copyright © 2012 Linaro Limited
562+ *
563+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
564+ *
565+ * glmark2 is free software: you can redistribute it and/or modify it under the
566+ * terms of the GNU General Public License as published by the Free Software
567+ * Foundation, either version 3 of the License, or (at your option) any later
568+ * version.
569+ *
570+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
571+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
572+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
573+ * details.
574+ *
575+ * You should have received a copy of the GNU General Public License along with
576+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
577+ *
578+ * Authors:
579+ * Jesse Barker
580+ */
581+#include "scene.h"
582+#include "stack.h"
583+#include "splines.h"
584+#include "table.h"
585+#include "logo.h"
586+#include "lamp.h"
587+#include "util.h"
588+#include "log.h"
589+#include <sys/time.h>
590+
591+using LibMatrix::Stack4;
592+using LibMatrix::mat4;
593+using LibMatrix::vec3;
594+using LibMatrix::vec4;
595+using LibMatrix::uvec3;
596+using std::string;
597+
598+class SceneIdeasPrivate
599+{
600+public:
601+ SceneIdeasPrivate() :
602+ valid_(false),
603+ currentSpeed_(SPEED_MAXIMUM),
604+ currentTime_(START_TIME_),
605+ timeOffset_(START_TIME_)
606+ {
607+ startTime_.tv_sec = 0;
608+ startTime_.tv_usec = 0;
609+ }
610+ ~SceneIdeasPrivate()
611+ {
612+ }
613+ void initialize(const string& speed);
614+ void reset_time();
615+ void update_time();
616+ void update_projection(const mat4& proj);
617+ void draw();
618+
619+private:
620+ float speed_from_optval(const string& optval);
621+ void postIdle();
622+ void initLights();
623+ bool valid_;
624+ Stack4 projection_;
625+ Stack4 modelview_;
626+ float currentSpeed_;
627+ float currentTime_;
628+ float timeOffset_;
629+ struct timeval startTime_;
630+ static const float CYCLE_TIME_;
631+ static const float TIME_;
632+ static const float START_TIME_;
633+ static const float SPEED_SLOW;
634+ static const float SPEED_MEDIUM;
635+ static const float SPEED_FAST;
636+ static const float SPEED_MAXIMUM;
637+ // Table
638+ Table table_;
639+ // Logo
640+ SGILogo logo_;
641+ // Lamp
642+ Lamp lamp_;
643+ // Light constants
644+ static const vec4 light0_position_;
645+ static const vec4 light1_position_;
646+ static const vec4 light2_position_;
647+ // Object constants
648+ ViewFromSpline viewFromSpline_;
649+ ViewToSpline viewToSpline_;
650+ LightPositionSpline lightPosSpline_;
651+ LogoPositionSpline logoPosSpline_;
652+ LogoRotationSpline logoRotSpline_;
653+ vec3 viewFrom_;
654+ vec3 viewTo_;
655+ vec3 lightPos_;
656+ vec3 logoPos_;
657+ vec3 logoRot_;
658+ vec4 lightPositions_[3];
659+};
660+
661+const float SceneIdeasPrivate::SPEED_SLOW(0.2);
662+const float SceneIdeasPrivate::SPEED_MEDIUM(0.4);
663+const float SceneIdeasPrivate::SPEED_FAST(0.7);
664+const float SceneIdeasPrivate::SPEED_MAXIMUM(1.0);
665+const float SceneIdeasPrivate::TIME_(15.0);
666+const float SceneIdeasPrivate::CYCLE_TIME_(TIME_ * 1.0 - 3.0);
667+const float SceneIdeasPrivate::START_TIME_(0.6);
668+const vec4 SceneIdeasPrivate::light0_position_(0.0, 1.0, 0.0, 0.0);
669+const vec4 SceneIdeasPrivate::light1_position_(-1.0, 0.0, 0.0, 0.0);
670+const vec4 SceneIdeasPrivate::light2_position_(0.0, -1.0, 0.0, 0.0);
671+
672+void
673+SceneIdeasPrivate::initLights()
674+{
675+ const mat4& curMV(modelview_.getCurrent());
676+ lightPositions_[0] = curMV * light0_position_;
677+ lightPositions_[1] = curMV * light1_position_;
678+ lightPositions_[2] = curMV * light2_position_;
679+}
680+
681+void
682+SceneIdeasPrivate::initialize(const string& speed)
683+{
684+ // Initialize the positions for the lights we'll use.
685+ initLights();
686+
687+ // Tell the objects in the scene to initialize themselves.
688+ table_.init();
689+ if (!table_.valid())
690+ {
691+ Log::debug("SceneIdeas: table object not properly initialized!\n");
692+ return;
693+ }
694+ logo_.init();
695+ if (!logo_.valid())
696+ {
697+ Log::debug("SceneIdeas: logo object not properly initialized!\n");
698+ return;
699+ }
700+ lamp_.init();
701+ if (!lamp_.valid())
702+ {
703+ Log::debug("SceneIdeas: lamp object not properly initialized!\n");
704+ return;
705+ }
706+
707+ reset_time();
708+
709+ currentSpeed_ = speed_from_optval(speed);
710+
711+ // If we're here, we're okay to run.
712+ valid_ = true;
713+}
714+
715+void
716+SceneIdeasPrivate::reset_time()
717+{
718+ timeOffset_ = START_TIME_;
719+ gettimeofday(&startTime_, NULL);
720+}
721+
722+void
723+SceneIdeasPrivate::update_time()
724+{
725+ // Compute new time
726+ struct timeval current = {0, 0};
727+ gettimeofday(&current, NULL);
728+ float timediff = (current.tv_sec - startTime_.tv_sec) +
729+ static_cast<double>(current.tv_usec - startTime_.tv_usec) / 1000000.0;
730+ float sceneTime = timediff * currentSpeed_ + timeOffset_;
731+
732+ // Keep the current time in [START_TIME_..CYCLE_TIME_)
733+ // Every other cycle starting with 0 start at the beginning and goes
734+ // forward in time. Other cycles start at the end and go backwards.
735+ currentTime_ = std::fmod(sceneTime, CYCLE_TIME_);
736+ unsigned int cycle = sceneTime/CYCLE_TIME_;
737+ if (cycle % 2)
738+ {
739+ currentTime_ = CYCLE_TIME_ - currentTime_;
740+ }
741+}
742+
743+void
744+SceneIdeasPrivate::update_projection(const mat4& proj)
745+{
746+ // Projection hasn't changed since last frame.
747+ if (projection_.getCurrent() == proj)
748+ {
749+ return;
750+ }
751+
752+ projection_.loadIdentity();
753+ projection_ *= proj;
754+}
755+
756+float
757+SceneIdeasPrivate::speed_from_optval(const string& optval)
758+{
759+ float retVal(SPEED_MAXIMUM);
760+ if (optval == "slow")
761+ {
762+ retVal = SPEED_SLOW;
763+ }
764+ else if (optval == "medium")
765+ {
766+ retVal = SPEED_MEDIUM;
767+ }
768+ else if (optval == "fast")
769+ {
770+ retVal = SPEED_FAST;
771+ }
772+ else if (optval != "max")
773+ {
774+ Log::error("Unknown speed option '%s', using default.\n", optval.c_str());
775+ }
776+
777+ return retVal;
778+}
779+
780+SceneIdeas::SceneIdeas(Canvas& canvas) :
781+ Scene(canvas, "ideas")
782+{
783+ options_["speed"] = Scene::Option("speed", "max",
784+ "Rendering speed [slow, medium, fast, max]");
785+}
786+
787+SceneIdeas::~SceneIdeas()
788+{
789+ delete priv_;
790+}
791+
792+bool
793+SceneIdeas::load()
794+{
795+ running_ = false;
796+ return true;
797+}
798+
799+void
800+SceneIdeas::unload()
801+{
802+}
803+
804+void
805+SceneIdeas::setup()
806+{
807+ Scene::setup();
808+ priv_ = new SceneIdeasPrivate();
809+ priv_->initialize(options_["speed"].value);
810+ priv_->update_projection(canvas_.projection());
811+
812+ // Core Scene state
813+ currentFrame_ = 0;
814+ running_ = true;
815+ startTime_ = Util::get_timestamp_us() / 1000000.0;
816+ lastUpdateTime_ = startTime_;
817+}
818+
819+void
820+SceneIdeas::update()
821+{
822+ Scene::update();
823+ priv_->update_time();
824+ priv_->update_projection(canvas_.projection());
825+}
826+
827+void
828+SceneIdeasPrivate::draw()
829+{
830+ viewFromSpline_.getCurrentVec(currentTime_, viewFrom_);
831+ viewToSpline_.getCurrentVec(currentTime_, viewTo_);
832+ lightPosSpline_.getCurrentVec(currentTime_, lightPos_);
833+ logoPosSpline_.getCurrentVec(currentTime_, logoPos_);
834+ logoRotSpline_.getCurrentVec(currentTime_, logoRot_);
835+
836+ // Tell the logo its new position
837+ logo_.setPosition(logoPos_);
838+
839+ vec4 lp4(lightPos_.x(), lightPos_.y(), lightPos_.z(), 0.0);
840+
841+ //
842+ // SHADOW
843+ //
844+ modelview_.loadIdentity();
845+ modelview_.lookAt(viewFrom_.x(), viewFrom_.y(), viewFrom_.z(),
846+ viewTo_.x(), viewTo_.y(), viewTo_.z(),
847+ 0.0, 1.0, 0.0);
848+
849+ float pca(0.0);
850+ if (viewFrom_.y() > 0.0)
851+ {
852+ table_.draw(modelview_, projection_, lightPos_, logoPos_, currentTime_, pca);
853+ }
854+
855+ glEnable(GL_CULL_FACE);
856+ glDisable(GL_DEPTH_TEST);
857+
858+ if (logoPos_.y() < 0.0)
859+ {
860+ // Set the color assuming we're still under the table.
861+ uvec3 flatColor(128 / 2, 102 / 2, 179 / 2);
862+ if (logoPos_.y() > -0.33)
863+ {
864+ // We're emerging from the table
865+ float c(1.0 - logoPos_.y() / -0.33);
866+ pca /= 4.0;
867+ flatColor.x(static_cast<unsigned int>(128.0 * (1.0 - c) * 0.5 + 255.0 * pca * c));
868+ flatColor.y(static_cast<unsigned int>(102.0 * (1.0 - c) * 0.5 + 255.0 * pca * c));
869+ flatColor.z(static_cast<unsigned int>(179.0 * (1.0 - c) * 0.5 + 200.0 * pca * c));
870+ }
871+
872+ modelview_.push();
873+ modelview_.scale(0.04, 0.0, 0.04);
874+ modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
875+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0);
876+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0);
877+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0);
878+ modelview_.rotate(0.1 * 353, 1.0, 0.0, 0.0);
879+ modelview_.rotate(0.1 * 450, 0.0, 1.0, 0.0);
880+
881+ logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_FLAT, flatColor);
882+
883+ modelview_.pop();
884+ }
885+
886+ if (logoPos_.y() > 0.0)
887+ {
888+ modelview_.push();
889+ modelview_.translate(lightPos_.x(), lightPos_.y(), lightPos_.z());
890+ mat4 tv;
891+ tv[3][1] = -1.0;
892+ tv[3][3] = 0.0;
893+ tv[0][0] = tv[1][1] = tv[2][2] = lightPos_.y();
894+ modelview_ *= tv;
895+ modelview_.translate(-lightPos_.x() + logoPos_.x(),
896+ -lightPos_.y() + logoPos_.y(),
897+ -lightPos_.z() + logoPos_.z());
898+ modelview_.scale(0.04, 0.04, 0.04);
899+ modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
900+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0);
901+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0);
902+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0);
903+ modelview_.rotate(35.3, 1.0, 0.0, 0.0);
904+ modelview_.rotate(45.0, 0.0, 1.0, 0.0);
905+
906+ logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_SHADOW);
907+
908+ modelview_.pop();
909+ }
910+ //
911+ // DONE SHADOW
912+ //
913+
914+ glEnable(GL_DEPTH_TEST);
915+ glDisable(GL_CULL_FACE);
916+
917+ modelview_.loadIdentity();
918+ modelview_.lookAt(viewFrom_.x(), viewFrom_.y(), viewFrom_.z(),
919+ viewTo_.x(), viewTo_.y(), viewTo_.z(),
920+ 0.0, 1.0, 0.0);
921+ modelview_.push();
922+ modelview_.translate(lightPos_.x(), lightPos_.y(), lightPos_.z());
923+ modelview_.scale(0.1, 0.1, 0.1);
924+ float x(lightPos_.x() - logoPos_.x());
925+ float y(lightPos_.y() - logoPos_.y());
926+ float z(lightPos_.z() - logoPos_.z());
927+ double a3(0.0);
928+ if (x != 0.0)
929+ {
930+ a3 = -atan2(z, x) * 10.0 * 180.0 / M_PI;
931+ }
932+ double a4(-atan2(sqrt(x * x + z * z), y) * 10.0 * 180.0 / M_PI);
933+ modelview_.rotate(0.1 * static_cast<int>(a3), 0.0, 1.0, 0.0);
934+ modelview_.rotate(0.1 * static_cast<int>(a4), 0.0, 0.0, 1.0);
935+ modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
936+
937+ lamp_.draw(modelview_, projection_, lightPositions_);
938+
939+ modelview_.pop();
940+
941+ lightPositions_[0] = modelview_.getCurrent() * lp4;
942+
943+ if (logoPos_.y() > -0.33)
944+ {
945+ modelview_.push();
946+ modelview_.translate(logoPos_.x(), logoPos_.y(), logoPos_.z());
947+ modelview_.scale(0.04, 0.04, 0.04);
948+ modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
949+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0);
950+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0);
951+ modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0);
952+ modelview_.rotate(35.3, 1.0, 0.0, 0.0);
953+ modelview_.rotate(45.0, 0.0, 1.0, 0.0);
954+
955+ logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_NORMAL);
956+
957+ modelview_.pop();
958+ }
959+
960+ if (viewFrom_.y() < 0.0)
961+ {
962+ table_.drawUnder(modelview_, projection_);
963+ }
964+}
965+
966+void
967+SceneIdeas::draw()
968+{
969+ priv_->draw();
970+}
971+
972+Scene::ValidationResult
973+SceneIdeas::validate()
974+{
975+ return Scene::ValidationSuccess;
976+}
977+
978+void
979+SceneIdeas::teardown()
980+{
981+ delete priv_;
982+ priv_ = 0;
983+ Scene::teardown();
984+}
985
986=== added file 'src/scene-ideas/a.cc'
987--- src/scene-ideas/a.cc 1970-01-01 00:00:00 +0000
988+++ src/scene-ideas/a.cc 2012-05-09 20:57:19 +0000
989@@ -0,0 +1,179 @@
990+/*
991+ * Vertex position data describing the letter 'a'
992+ *
993+ * (c) Copyright 1993, Silicon Graphics, Inc.
994+ * Copyright © 2012 Linaro Limited
995+ *
996+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
997+ *
998+ * glmark2 is free software: you can redistribute it and/or modify it under the
999+ * terms of the GNU General Public License as published by the Free Software
1000+ * Foundation, either version 3 of the License, or (at your option) any later
1001+ * version.
1002+ *
1003+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
1004+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1005+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1006+ * details.
1007+ *
1008+ * You should have received a copy of the GNU General Public License along with
1009+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
1010+ *
1011+ * Authors:
1012+ * Jesse Barker
1013+ */
1014+#include "characters.h"
1015+
1016+using LibMatrix::vec2;
1017+
1018+LetterA::LetterA()
1019+{
1020+ // Vertex data...
1021+ vertexData_.push_back(vec2(5.618949, 10.261048));
1022+ vertexData_.push_back(vec2(5.322348, 9.438848));
1023+ vertexData_.push_back(vec2(5.124614, 10.030832));
1024+ vertexData_.push_back(vec2(4.860968, 9.488181));
1025+ vertexData_.push_back(vec2(4.811534, 9.932169));
1026+ vertexData_.push_back(vec2(3.938208, 9.438848));
1027+ vertexData_.push_back(vec2(3.658084, 9.685509));
1028+ vertexData_.push_back(vec2(2.784758, 8.994862));
1029+ vertexData_.push_back(vec2(2.801236, 9.175745));
1030+ vertexData_.push_back(vec2(1.960865, 8.172662));
1031+ vertexData_.push_back(vec2(1.186406, 7.761562));
1032+ vertexData_.push_back(vec2(1.252317, 6.561151));
1033+ vertexData_.push_back(vec2(0.576725, 6.610483));
1034+ vertexData_.push_back(vec2(0.939238, 5.525180));
1035+ vertexData_.push_back(vec2(0.164779, 4.883864));
1036+ vertexData_.push_back(vec2(0.840371, 4.818089));
1037+ vertexData_.push_back(vec2(0.230690, 3.963001));
1038+ vertexData_.push_back(vec2(0.939238, 4.242549));
1039+ vertexData_.push_back(vec2(0.609681, 3.255909));
1040+ vertexData_.push_back(vec2(1.268795, 3.963001));
1041+ vertexData_.push_back(vec2(1.021627, 3.075026));
1042+ vertexData_.push_back(vec2(1.861998, 4.045221));
1043+ vertexData_.push_back(vec2(1.829042, 3.535457));
1044+ vertexData_.push_back(vec2(2.817714, 4.818089));
1045+ vertexData_.push_back(vec2(3.163749, 4.998972));
1046+ vertexData_.push_back(vec2(3.971164, 6.643371));
1047+ vertexData_.push_back(vec2(4.267765, 6.725591));
1048+ vertexData_.push_back(vec2(4.663234, 7.630010));
1049+ vertexData_.push_back(vec2(5.404737, 9.734840));
1050+ vertexData_.push_back(vec2(4.646756, 9.669065));
1051+ vertexData_.push_back(vec2(5.108136, 8.731757));
1052+ vertexData_.push_back(vec2(4.679712, 8.600205));
1053+ vertexData_.push_back(vec2(4.926879, 7.564234));
1054+ vertexData_.push_back(vec2(4.366632, 6.692703));
1055+ vertexData_.push_back(vec2(4.663234, 5.344296));
1056+ vertexData_.push_back(vec2(3.888774, 4.850976));
1057+ vertexData_.push_back(vec2(4.630278, 4.094553));
1058+ vertexData_.push_back(vec2(3.954686, 3.963001));
1059+ vertexData_.push_back(vec2(4.828012, 3.798561));
1060+ vertexData_.push_back(vec2(4.168898, 3.321686));
1061+ vertexData_.push_back(vec2(5.157569, 3.864337));
1062+ vertexData_.push_back(vec2(4.514933, 3.091470));
1063+ vertexData_.push_back(vec2(5.553038, 4.045221));
1064+ vertexData_.push_back(vec2(5.305870, 3.634121));
1065+ vertexData_.push_back(vec2(5.932029, 4.176773));
1066+
1067+ // Index data...
1068+ indexData_.push_back(0);
1069+ indexData_.push_back(1);
1070+ indexData_.push_back(2);
1071+ indexData_.push_back(3);
1072+ indexData_.push_back(4);
1073+ indexData_.push_back(5);
1074+ indexData_.push_back(6);
1075+ indexData_.push_back(7);
1076+ indexData_.push_back(8);
1077+ indexData_.push_back(9);
1078+ indexData_.push_back(10);
1079+ indexData_.push_back(11);
1080+ indexData_.push_back(12);
1081+ indexData_.push_back(13);
1082+ indexData_.push_back(14);
1083+ indexData_.push_back(15);
1084+ indexData_.push_back(16);
1085+ indexData_.push_back(17);
1086+ indexData_.push_back(18);
1087+ indexData_.push_back(19);
1088+ indexData_.push_back(20);
1089+ indexData_.push_back(21);
1090+ indexData_.push_back(22);
1091+ indexData_.push_back(23);
1092+ indexData_.push_back(24);
1093+ indexData_.push_back(25);
1094+ indexData_.push_back(26);
1095+ indexData_.push_back(27);
1096+ indexData_.push_back(28);
1097+ indexData_.push_back(29);
1098+ indexData_.push_back(30);
1099+ indexData_.push_back(31);
1100+ indexData_.push_back(32);
1101+ indexData_.push_back(33);
1102+ indexData_.push_back(34);
1103+ indexData_.push_back(35);
1104+ indexData_.push_back(36);
1105+ indexData_.push_back(37);
1106+ indexData_.push_back(38);
1107+ indexData_.push_back(39);
1108+ indexData_.push_back(40);
1109+ indexData_.push_back(41);
1110+ indexData_.push_back(42);
1111+ indexData_.push_back(43);
1112+ indexData_.push_back(44);
1113+ indexData_.push_back(0);
1114+ indexData_.push_back(2);
1115+ indexData_.push_back(4);
1116+ indexData_.push_back(6);
1117+ indexData_.push_back(8);
1118+ indexData_.push_back(10);
1119+ indexData_.push_back(12);
1120+ indexData_.push_back(14);
1121+ indexData_.push_back(16);
1122+ indexData_.push_back(18);
1123+ indexData_.push_back(20);
1124+ indexData_.push_back(22);
1125+ indexData_.push_back(24);
1126+ indexData_.push_back(26);
1127+ indexData_.push_back(27);
1128+ indexData_.push_back(25);
1129+ indexData_.push_back(23);
1130+ indexData_.push_back(21);
1131+ indexData_.push_back(19);
1132+ indexData_.push_back(17);
1133+ indexData_.push_back(15);
1134+ indexData_.push_back(13);
1135+ indexData_.push_back(11);
1136+ indexData_.push_back(9);
1137+ indexData_.push_back(7);
1138+ indexData_.push_back(5);
1139+ indexData_.push_back(3);
1140+ indexData_.push_back(1);
1141+ indexData_.push_back(28);
1142+ indexData_.push_back(30);
1143+ indexData_.push_back(32);
1144+ indexData_.push_back(34);
1145+ indexData_.push_back(36);
1146+ indexData_.push_back(38);
1147+ indexData_.push_back(40);
1148+ indexData_.push_back(42);
1149+ indexData_.push_back(44);
1150+ indexData_.push_back(43);
1151+ indexData_.push_back(41);
1152+ indexData_.push_back(39);
1153+ indexData_.push_back(37);
1154+ indexData_.push_back(35);
1155+ indexData_.push_back(33);
1156+ indexData_.push_back(31);
1157+ indexData_.push_back(29);
1158+
1159+ // Primitive state so that the draw call can issue the primitives we want.
1160+ unsigned int curOffset(0);
1161+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 28, curOffset));
1162+ curOffset += (28 * sizeof(unsigned int));
1163+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 17, curOffset));
1164+ curOffset += (17 * sizeof(unsigned int));
1165+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 28, curOffset));
1166+ curOffset += (28 * sizeof(unsigned int));
1167+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 17, curOffset));
1168+}
1169
1170=== added file 'src/scene-ideas/characters.h'
1171--- src/scene-ideas/characters.h 1970-01-01 00:00:00 +0000
1172+++ src/scene-ideas/characters.h 2012-05-09 20:57:19 +0000
1173@@ -0,0 +1,157 @@
1174+/*
1175+ * (c) Copyright 1993, Silicon Graphics, Inc.
1176+ * Copyright © 2012 Linaro Limited
1177+ *
1178+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
1179+ *
1180+ * glmark2 is free software: you can redistribute it and/or modify it under the
1181+ * terms of the GNU General Public License as published by the Free Software
1182+ * Foundation, either version 3 of the License, or (at your option) any later
1183+ * version.
1184+ *
1185+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
1186+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1187+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1188+ * details.
1189+ *
1190+ * You should have received a copy of the GNU General Public License along with
1191+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
1192+ *
1193+ * Authors:
1194+ * Jesse Barker
1195+ */
1196+#ifndef CHARACTERS_H_
1197+#define CHARACTERS_H_
1198+
1199+#include <vector>
1200+#include "vec.h"
1201+#include "gl-headers.h"
1202+
1203+class PrimitiveState
1204+{
1205+public:
1206+ PrimitiveState(unsigned int type, unsigned int count, unsigned int offset) :
1207+ type_(type),
1208+ count_(count),
1209+ bufferOffset_(offset) {}
1210+ ~PrimitiveState() {}
1211+ void issue() const
1212+ {
1213+ glDrawElements(type_, count_, GL_UNSIGNED_INT,
1214+ reinterpret_cast<const GLvoid*>(bufferOffset_));
1215+ }
1216+private:
1217+ PrimitiveState();
1218+ unsigned int type_; // Primitive type (e.g. GL_TRIANGLE_STRIP)
1219+ unsigned int count_; // Number of primitives
1220+ unsigned int bufferOffset_; // Offset into the element array buffer
1221+};
1222+
1223+struct Character
1224+{
1225+ void draw()
1226+ {
1227+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
1228+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
1229+ glVertexAttribPointer(vertexIndex_, 2, GL_FLOAT, GL_FALSE, 0, 0);
1230+ glEnableVertexAttribArray(vertexIndex_);
1231+ for (std::vector<PrimitiveState>::const_iterator primIt = primVec_.begin();
1232+ primIt != primVec_.end();
1233+ primIt++)
1234+ {
1235+ primIt->issue();
1236+ }
1237+ glBindBuffer(GL_ARRAY_BUFFER, 0);
1238+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
1239+ }
1240+ void init(int vertexAttribIndex)
1241+ {
1242+ vertexIndex_ = vertexAttribIndex;
1243+
1244+ // We need 2 buffers for our work here. One for the vertex data.
1245+ // and one for the index data.
1246+ glGenBuffers(2, &bufferObjects_[0]);
1247+
1248+ // First, setup the vertex data by binding the first buffer object,
1249+ // allocating its data store, and filling it in with our vertex data.
1250+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
1251+ glBufferData(GL_ARRAY_BUFFER, vertexData_.size() * sizeof(LibMatrix::vec2),
1252+ &vertexData_.front(), GL_STATIC_DRAW);
1253+
1254+ // Finally, setup the pointer to our vertex data and enable this
1255+ // attribute array.
1256+ glVertexAttribPointer(vertexIndex_, 2, GL_FLOAT, GL_FALSE, 0, 0);
1257+ glEnableVertexAttribArray(vertexIndex_);
1258+
1259+ // Now repeat for our index data.
1260+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
1261+ glBufferData(GL_ELEMENT_ARRAY_BUFFER,
1262+ indexData_.size() * sizeof(unsigned int), &indexData_.front(),
1263+ GL_STATIC_DRAW);
1264+
1265+ // Unbind our vertex buffer objects so that their state isn't affected
1266+ // by other objects.
1267+ glBindBuffer(GL_ARRAY_BUFFER, 0);
1268+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
1269+ }
1270+ ~Character()
1271+ {
1272+ glDeleteBuffers(2, &bufferObjects_[0]);
1273+ }
1274+ Character() :
1275+ vertexIndex_(0),
1276+ vertexArray_(0) {}
1277+ unsigned int bufferObjects_[2];
1278+ std::vector<LibMatrix::vec2> vertexData_;
1279+ std::vector<unsigned int> indexData_;
1280+ int vertexIndex_;
1281+ unsigned int vertexArray_;
1282+ std::vector<PrimitiveState> primVec_;
1283+};
1284+
1285+struct LetterI : Character
1286+{
1287+ LetterI();
1288+};
1289+
1290+struct LetterD : Character
1291+{
1292+ LetterD();
1293+};
1294+
1295+struct LetterE : Character
1296+{
1297+ LetterE();
1298+};
1299+
1300+struct LetterA : Character
1301+{
1302+ LetterA();
1303+};
1304+
1305+struct LetterS : Character
1306+{
1307+ LetterS();
1308+};
1309+
1310+struct LetterN : Character
1311+{
1312+ LetterN();
1313+};
1314+
1315+struct LetterM : Character
1316+{
1317+ LetterM();
1318+};
1319+
1320+struct LetterO : Character
1321+{
1322+ LetterO();
1323+};
1324+
1325+struct LetterT : Character
1326+{
1327+ LetterT();
1328+};
1329+
1330+#endif // CHARACTERS_H_
1331
1332=== added file 'src/scene-ideas/d.cc'
1333--- src/scene-ideas/d.cc 1970-01-01 00:00:00 +0000
1334+++ src/scene-ideas/d.cc 2012-05-09 20:57:19 +0000
1335@@ -0,0 +1,142 @@
1336+/*
1337+ * Vertex position data describing the letter 'd'
1338+ *
1339+ * (c) Copyright 1993, Silicon Graphics, Inc.
1340+ * Copyright © 2012 Linaro Limited
1341+ *
1342+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
1343+ *
1344+ * glmark2 is free software: you can redistribute it and/or modify it under the
1345+ * terms of the GNU General Public License as published by the Free Software
1346+ * Foundation, either version 3 of the License, or (at your option) any later
1347+ * version.
1348+ *
1349+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
1350+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1351+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1352+ * details.
1353+ *
1354+ * You should have received a copy of the GNU General Public License along with
1355+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
1356+ *
1357+ * Authors:
1358+ * Jesse Barker
1359+ */
1360+#include "characters.h"
1361+
1362+using LibMatrix::vec2;
1363+
1364+LetterD::LetterD()
1365+{
1366+ // Vertex data...
1367+ vertexData_.push_back(vec2(4.714579, 9.987679));
1368+ vertexData_.push_back(vec2(2.841889, 9.429158));
1369+ vertexData_.push_back(vec2(2.825462, 9.166325));
1370+ vertexData_.push_back(vec2(1.856263, 8.722793));
1371+ vertexData_.push_back(vec2(2.004107, 8.000000));
1372+ vertexData_.push_back(vec2(0.969199, 7.605750));
1373+ vertexData_.push_back(vec2(1.494866, 6.636550));
1374+ vertexData_.push_back(vec2(0.607803, 6.028748));
1375+ vertexData_.push_back(vec2(1.527721, 4.960986));
1376+ vertexData_.push_back(vec2(0.772074, 4.254620));
1377+ vertexData_.push_back(vec2(1.774127, 4.139630));
1378+ vertexData_.push_back(vec2(1.445585, 3.186858));
1379+ vertexData_.push_back(vec2(2.266940, 3.843942));
1380+ vertexData_.push_back(vec2(2.250513, 3.022587));
1381+ vertexData_.push_back(vec2(2.776181, 3.843942));
1382+ vertexData_.push_back(vec2(3.137577, 3.383984));
1383+ vertexData_.push_back(vec2(3.351129, 4.008214));
1384+ vertexData_.push_back(vec2(3.909651, 4.451746));
1385+ vertexData_.push_back(vec2(4.090349, 4.960986));
1386+ vertexData_.push_back(vec2(4.862423, 5.946612));
1387+ vertexData_.push_back(vec2(4.763860, 6.652977));
1388+ vertexData_.push_back(vec2(5.388090, 7.572895));
1389+ vertexData_.push_back(vec2(4.862423, 8.492813));
1390+ vertexData_.push_back(vec2(5.618070, 9.921971));
1391+ vertexData_.push_back(vec2(4.698152, 10.940452));
1392+ vertexData_.push_back(vec2(5.338809, 12.303902));
1393+ vertexData_.push_back(vec2(4.238193, 12.960985));
1394+ vertexData_.push_back(vec2(4.451746, 14.554415));
1395+ vertexData_.push_back(vec2(3.581109, 14.291581));
1396+ vertexData_.push_back(vec2(3.613963, 15.342916));
1397+ vertexData_.push_back(vec2(2.677618, 15.145790));
1398+ vertexData_.push_back(vec2(2.480493, 15.540041));
1399+ vertexData_.push_back(vec2(2.036961, 15.211499));
1400+ vertexData_.push_back(vec2(1.281314, 15.112936));
1401+
1402+ // Index data...
1403+ indexData_.push_back(0);
1404+ indexData_.push_back(1);
1405+ indexData_.push_back(2);
1406+ indexData_.push_back(3);
1407+ indexData_.push_back(4);
1408+ indexData_.push_back(5);
1409+ indexData_.push_back(6);
1410+ indexData_.push_back(7);
1411+ indexData_.push_back(8);
1412+ indexData_.push_back(9);
1413+ indexData_.push_back(10);
1414+ indexData_.push_back(11);
1415+ indexData_.push_back(12);
1416+ indexData_.push_back(13);
1417+ indexData_.push_back(14);
1418+ indexData_.push_back(15);
1419+ indexData_.push_back(16);
1420+ indexData_.push_back(17);
1421+ indexData_.push_back(18);
1422+ indexData_.push_back(19);
1423+ indexData_.push_back(20);
1424+ indexData_.push_back(21);
1425+ indexData_.push_back(22);
1426+ indexData_.push_back(23);
1427+ indexData_.push_back(24);
1428+ indexData_.push_back(25);
1429+ indexData_.push_back(26);
1430+ indexData_.push_back(27);
1431+ indexData_.push_back(28);
1432+ indexData_.push_back(29);
1433+ indexData_.push_back(30);
1434+ indexData_.push_back(31);
1435+ indexData_.push_back(32);
1436+ indexData_.push_back(33);
1437+ indexData_.push_back(0);
1438+ indexData_.push_back(2);
1439+ indexData_.push_back(4);
1440+ indexData_.push_back(6);
1441+ indexData_.push_back(8);
1442+ indexData_.push_back(10);
1443+ indexData_.push_back(12);
1444+ indexData_.push_back(14);
1445+ indexData_.push_back(16);
1446+ indexData_.push_back(18);
1447+ indexData_.push_back(20);
1448+ indexData_.push_back(22);
1449+ indexData_.push_back(24);
1450+ indexData_.push_back(26);
1451+ indexData_.push_back(28);
1452+ indexData_.push_back(30);
1453+ indexData_.push_back(32);
1454+ indexData_.push_back(33);
1455+ indexData_.push_back(31);
1456+ indexData_.push_back(29);
1457+ indexData_.push_back(27);
1458+ indexData_.push_back(25);
1459+ indexData_.push_back(23);
1460+ indexData_.push_back(21);
1461+ indexData_.push_back(19);
1462+ indexData_.push_back(17);
1463+ indexData_.push_back(15);
1464+ indexData_.push_back(13);
1465+ indexData_.push_back(11);
1466+ indexData_.push_back(9);
1467+ indexData_.push_back(7);
1468+ indexData_.push_back(5);
1469+ indexData_.push_back(3);
1470+ indexData_.push_back(1);
1471+
1472+ // Primitive state so that the draw call can issue the primitives we want.
1473+ unsigned int curOffset(0);
1474+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 34, curOffset));
1475+ curOffset += (34 * sizeof(unsigned int));
1476+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 34, curOffset));
1477+}
1478
1479=== added file 'src/scene-ideas/e.cc'
1480--- src/scene-ideas/e.cc 1970-01-01 00:00:00 +0000
1481+++ src/scene-ideas/e.cc 2012-05-09 20:57:19 +0000
1482@@ -0,0 +1,139 @@
1483+/*
1484+ * Vertex position data describing the letter 'e'
1485+ *
1486+ * (c) Copyright 1993, Silicon Graphics, Inc.
1487+ * Copyright © 2012 Linaro Limited
1488+ *
1489+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
1490+ *
1491+ * glmark2 is free software: you can redistribute it and/or modify it under the
1492+ * terms of the GNU General Public License as published by the Free Software
1493+ * Foundation, either version 3 of the License, or (at your option) any later
1494+ * version.
1495+ *
1496+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
1497+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1498+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1499+ * details.
1500+ *
1501+ * You should have received a copy of the GNU General Public License along with
1502+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
1503+ *
1504+ * Authors:
1505+ * Jesse Barker
1506+ */
1507+#include "characters.h"
1508+
1509+using LibMatrix::vec2;
1510+
1511+LetterE::LetterE()
1512+{
1513+ // Vertex data...
1514+ vertexData_.push_back(vec2(1.095436, 6.190871));
1515+ vertexData_.push_back(vec2(2.107884, 6.970954));
1516+ vertexData_.push_back(vec2(2.556017, 7.020747));
1517+ vertexData_.push_back(vec2(3.020747, 7.867220));
1518+ vertexData_.push_back(vec2(3.518672, 8.033195));
1519+ vertexData_.push_back(vec2(3.269710, 8.531120));
1520+ vertexData_.push_back(vec2(4.165975, 8.929461));
1521+ vertexData_.push_back(vec2(3.302905, 9.062241));
1522+ vertexData_.push_back(vec2(4.331950, 9.626556));
1523+ vertexData_.push_back(vec2(3.286307, 9.344398));
1524+ vertexData_.push_back(vec2(4.116183, 9.958507));
1525+ vertexData_.push_back(vec2(3.004149, 9.510373));
1526+ vertexData_.push_back(vec2(3.518672, 9.991701));
1527+ vertexData_.push_back(vec2(2.705394, 9.493776));
1528+ vertexData_.push_back(vec2(2.091286, 9.311203));
1529+ vertexData_.push_back(vec2(2.041494, 9.062241));
1530+ vertexData_.push_back(vec2(1.178423, 8.514523));
1531+ vertexData_.push_back(vec2(1.443983, 8.165976));
1532+ vertexData_.push_back(vec2(0.481328, 7.535270));
1533+ vertexData_.push_back(vec2(1.045643, 6.904564));
1534+ vertexData_.push_back(vec2(0.149378, 6.091286));
1535+ vertexData_.push_back(vec2(1.095436, 5.410789));
1536+ vertexData_.push_back(vec2(0.464730, 4.232365));
1537+ vertexData_.push_back(vec2(1.377593, 4.497925));
1538+ vertexData_.push_back(vec2(1.261411, 3.136930));
1539+ vertexData_.push_back(vec2(1.925311, 3.950207));
1540+ vertexData_.push_back(vec2(2.240664, 3.037344));
1541+ vertexData_.push_back(vec2(2.589212, 3.834025));
1542+ vertexData_.push_back(vec2(3.087137, 3.269710));
1543+ vertexData_.push_back(vec2(3.236515, 3.867220));
1544+ vertexData_.push_back(vec2(3.684647, 3.867220));
1545+ vertexData_.push_back(vec2(3.867220, 4.448133));
1546+ vertexData_.push_back(vec2(4.398340, 5.128631));
1547+
1548+ // Index data...
1549+ indexData_.push_back(0);
1550+ indexData_.push_back(1);
1551+ indexData_.push_back(2);
1552+ indexData_.push_back(3);
1553+ indexData_.push_back(4);
1554+ indexData_.push_back(5);
1555+ indexData_.push_back(6);
1556+ indexData_.push_back(7);
1557+ indexData_.push_back(8);
1558+ indexData_.push_back(9);
1559+ indexData_.push_back(10);
1560+ indexData_.push_back(11);
1561+ indexData_.push_back(12);
1562+ indexData_.push_back(13);
1563+ indexData_.push_back(14);
1564+ indexData_.push_back(15);
1565+ indexData_.push_back(16);
1566+ indexData_.push_back(17);
1567+ indexData_.push_back(18);
1568+ indexData_.push_back(19);
1569+ indexData_.push_back(20);
1570+ indexData_.push_back(21);
1571+ indexData_.push_back(22);
1572+ indexData_.push_back(23);
1573+ indexData_.push_back(24);
1574+ indexData_.push_back(25);
1575+ indexData_.push_back(26);
1576+ indexData_.push_back(27);
1577+ indexData_.push_back(28);
1578+ indexData_.push_back(29);
1579+ indexData_.push_back(30);
1580+ indexData_.push_back(31);
1581+ indexData_.push_back(32);
1582+ indexData_.push_back(0);
1583+ indexData_.push_back(2);
1584+ indexData_.push_back(4);
1585+ indexData_.push_back(6);
1586+ indexData_.push_back(8);
1587+ indexData_.push_back(10);
1588+ indexData_.push_back(12);
1589+ indexData_.push_back(14);
1590+ indexData_.push_back(16);
1591+ indexData_.push_back(18);
1592+ indexData_.push_back(20);
1593+ indexData_.push_back(22);
1594+ indexData_.push_back(24);
1595+ indexData_.push_back(26);
1596+ indexData_.push_back(28);
1597+ indexData_.push_back(30);
1598+ indexData_.push_back(32);
1599+ indexData_.push_back(31);
1600+ indexData_.push_back(29);
1601+ indexData_.push_back(27);
1602+ indexData_.push_back(25);
1603+ indexData_.push_back(23);
1604+ indexData_.push_back(21);
1605+ indexData_.push_back(19);
1606+ indexData_.push_back(17);
1607+ indexData_.push_back(15);
1608+ indexData_.push_back(13);
1609+ indexData_.push_back(11);
1610+ indexData_.push_back(9);
1611+ indexData_.push_back(7);
1612+ indexData_.push_back(5);
1613+ indexData_.push_back(3);
1614+ indexData_.push_back(1);
1615+
1616+ // Primitive state so that the draw call can issue the primitives we want.
1617+ unsigned int curOffset(0);
1618+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 33, curOffset));
1619+ curOffset += (33 * sizeof(unsigned int));
1620+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 33, curOffset));
1621+}
1622
1623=== added file 'src/scene-ideas/i.cc'
1624--- src/scene-ideas/i.cc 1970-01-01 00:00:00 +0000
1625+++ src/scene-ideas/i.cc 2012-05-09 20:57:19 +0000
1626@@ -0,0 +1,116 @@
1627+/*
1628+ * Vertex position data describing the letter 'i'
1629+ *
1630+ * (c) Copyright 1993, Silicon Graphics, Inc.
1631+ * Copyright © 2012 Linaro Limited
1632+ *
1633+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
1634+ *
1635+ * glmark2 is free software: you can redistribute it and/or modify it under the
1636+ * terms of the GNU General Public License as published by the Free Software
1637+ * Foundation, either version 3 of the License, or (at your option) any later
1638+ * version.
1639+ *
1640+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
1641+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1642+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1643+ * details.
1644+ *
1645+ * You should have received a copy of the GNU General Public License along with
1646+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
1647+ *
1648+ * Authors:
1649+ * Jesse Barker
1650+ */
1651+#include "characters.h"
1652+
1653+using LibMatrix::vec2;
1654+
1655+LetterI::LetterI()
1656+{
1657+ // Vertex data...
1658+ vertexData_.push_back(vec2(0.548767, 9.414791));
1659+ vertexData_.push_back(vec2(2.795284, 9.757771));
1660+ vertexData_.push_back(vec2(1.457663, 9.311897));
1661+ vertexData_.push_back(vec2(2.503751, 9.157557));
1662+ vertexData_.push_back(vec2(1.714898, 8.986067));
1663+ vertexData_.push_back(vec2(2.109325, 7.785638));
1664+ vertexData_.push_back(vec2(1.286174, 7.013934));
1665+ vertexData_.push_back(vec2(1.800643, 6.070740));
1666+ vertexData_.push_back(vec2(0.994641, 5.161843));
1667+ vertexData_.push_back(vec2(1.783494, 4.767417));
1668+ vertexData_.push_back(vec2(0.943194, 4.167202));
1669+ vertexData_.push_back(vec2(1.852090, 4.304394));
1670+ vertexData_.push_back(vec2(1.063237, 3.549839));
1671+ vertexData_.push_back(vec2(2.023580, 3.978564));
1672+ vertexData_.push_back(vec2(1.406217, 3.172562));
1673+ vertexData_.push_back(vec2(2.315113, 3.875670));
1674+ vertexData_.push_back(vec2(2.006431, 3.018221));
1675+ vertexData_.push_back(vec2(2.812433, 3.944266));
1676+ vertexData_.push_back(vec2(2.726688, 3.429796));
1677+ vertexData_.push_back(vec2(3.258307, 4.132905));
1678+ vertexData_.push_back(vec2(1.989282, 10.923902));
1679+ vertexData_.push_back(vec2(2.778135, 12.295820));
1680+ vertexData_.push_back(vec2(2.966774, 11.678456));
1681+ vertexData_.push_back(vec2(3.687031, 12.947481));
1682+
1683+ // Index data...
1684+ indexData_.push_back(0);
1685+ indexData_.push_back(1);
1686+ indexData_.push_back(2);
1687+ indexData_.push_back(3);
1688+ indexData_.push_back(4);
1689+ indexData_.push_back(5);
1690+ indexData_.push_back(6);
1691+ indexData_.push_back(7);
1692+ indexData_.push_back(8);
1693+ indexData_.push_back(9);
1694+ indexData_.push_back(10);
1695+ indexData_.push_back(11);
1696+ indexData_.push_back(12);
1697+ indexData_.push_back(13);
1698+ indexData_.push_back(14);
1699+ indexData_.push_back(15);
1700+ indexData_.push_back(16);
1701+ indexData_.push_back(17);
1702+ indexData_.push_back(18);
1703+ indexData_.push_back(19);
1704+ indexData_.push_back(20);
1705+ indexData_.push_back(21);
1706+ indexData_.push_back(22);
1707+ indexData_.push_back(23);
1708+ indexData_.push_back(0);
1709+ indexData_.push_back(2);
1710+ indexData_.push_back(4);
1711+ indexData_.push_back(6);
1712+ indexData_.push_back(8);
1713+ indexData_.push_back(10);
1714+ indexData_.push_back(12);
1715+ indexData_.push_back(14);
1716+ indexData_.push_back(16);
1717+ indexData_.push_back(18);
1718+ indexData_.push_back(19);
1719+ indexData_.push_back(17);
1720+ indexData_.push_back(15);
1721+ indexData_.push_back(13);
1722+ indexData_.push_back(11);
1723+ indexData_.push_back(9);
1724+ indexData_.push_back(7);
1725+ indexData_.push_back(5);
1726+ indexData_.push_back(3);
1727+ indexData_.push_back(1);
1728+ indexData_.push_back(20);
1729+ indexData_.push_back(22);
1730+ indexData_.push_back(23);
1731+ indexData_.push_back(21);
1732+
1733+ // Primitive state so that the draw call can issue the primitives we want.
1734+ unsigned int curOffset(0);
1735+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 20, curOffset));
1736+ curOffset += (20 * sizeof(unsigned int));
1737+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 4, curOffset));
1738+ curOffset += (4 * sizeof(unsigned int));
1739+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 20, curOffset));
1740+ curOffset += (20 * sizeof(unsigned int));
1741+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 4, curOffset));
1742+}
1743
1744=== added file 'src/scene-ideas/lamp.cc'
1745--- src/scene-ideas/lamp.cc 1970-01-01 00:00:00 +0000
1746+++ src/scene-ideas/lamp.cc 2012-05-09 20:57:19 +0000
1747@@ -0,0 +1,258 @@
1748+/*
1749+ * Vertex position data describing the lamp
1750+ *
1751+ * (c) Copyright 1993, Silicon Graphics, Inc.
1752+ * Copyright © 2012 Linaro Limited
1753+ *
1754+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
1755+ *
1756+ * glmark2 is free software: you can redistribute it and/or modify it under the
1757+ * terms of the GNU General Public License as published by the Free Software
1758+ * Foundation, either version 3 of the License, or (at your option) any later
1759+ * version.
1760+ *
1761+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
1762+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1763+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1764+ * details.
1765+ *
1766+ * You should have received a copy of the GNU General Public License along with
1767+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
1768+ *
1769+ * Authors:
1770+ * Jesse Barker
1771+ */
1772+#include "lamp.h"
1773+#include "shader-source.h"
1774+#include "log.h"
1775+#include "scene.h"
1776+
1777+using std::string;
1778+using LibMatrix::vec3;
1779+using LibMatrix::vec4;
1780+using LibMatrix::Stack4;
1781+
1782+const string Lamp::modelviewName_("modelview");
1783+const string Lamp::projectionName_("projection");
1784+const string Lamp::light0PositionName_("light0Position");
1785+const string Lamp::light1PositionName_("light1Position");
1786+const string Lamp::light2PositionName_("light2Position");
1787+const string Lamp::vertexAttribName_("vertex");
1788+const string Lamp::normalAttribName_("normal");
1789+const string Lamp::normalMatrixName_("normalMatrix");
1790+
1791+Lamp::Lamp() :
1792+ valid_(false)
1793+{
1794+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1795+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1796+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1797+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1798+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1799+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1800+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1801+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1802+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1803+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1804+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1805+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1806+ vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
1807+ vertexData_.push_back(vec3(0.438371, 0.000000, 0.898794));
1808+ vertexData_.push_back(vec3(0.379641, 0.219186, 0.898794));
1809+ vertexData_.push_back(vec3(0.219186, 0.379641, 0.898794));
1810+ vertexData_.push_back(vec3(0.000000, 0.438371, 0.898794));
1811+ vertexData_.push_back(vec3(-0.219186, 0.379641, 0.898794));
1812+ vertexData_.push_back(vec3(-0.379641, 0.219186, 0.898794));
1813+ vertexData_.push_back(vec3(-0.438371, 0.000000, 0.898794));
1814+ vertexData_.push_back(vec3(-0.379641, -0.219186, 0.898794));
1815+ vertexData_.push_back(vec3(-0.219186, -0.379641, 0.898794));
1816+ vertexData_.push_back(vec3(0.000000, -0.438371, 0.898794));
1817+ vertexData_.push_back(vec3(0.219186, -0.379641, 0.898794));
1818+ vertexData_.push_back(vec3(0.379641, -0.219186, 0.898794));
1819+ vertexData_.push_back(vec3(0.438371, 0.000000, 0.898794));
1820+ vertexData_.push_back(vec3(0.788011, 0.000000, 0.615662));
1821+ vertexData_.push_back(vec3(0.682437, 0.394005, 0.615662));
1822+ vertexData_.push_back(vec3(0.394005, 0.682437, 0.615662));
1823+ vertexData_.push_back(vec3(0.000000, 0.788011, 0.615662));
1824+ vertexData_.push_back(vec3(-0.394005, 0.682437, 0.615662));
1825+ vertexData_.push_back(vec3(-0.682437, 0.394005, 0.615662));
1826+ vertexData_.push_back(vec3(-0.788011, 0.000000, 0.615662));
1827+ vertexData_.push_back(vec3(-0.682437, -0.394005, 0.615662));
1828+ vertexData_.push_back(vec3(-0.394005, -0.682437, 0.615662));
1829+ vertexData_.push_back(vec3(0.000000, -0.788011, 0.615662));
1830+ vertexData_.push_back(vec3(0.394005, -0.682437, 0.615662));
1831+ vertexData_.push_back(vec3(0.682437, -0.394005, 0.615662));
1832+ vertexData_.push_back(vec3(0.788011, 0.000000, 0.615662));
1833+ vertexData_.push_back(vec3(0.978148, 0.000000, 0.207912));
1834+ vertexData_.push_back(vec3(0.847101, 0.489074, 0.207912));
1835+ vertexData_.push_back(vec3(0.489074, 0.847101, 0.207912));
1836+ vertexData_.push_back(vec3(0.000000, 0.978148, 0.207912));
1837+ vertexData_.push_back(vec3(-0.489074, 0.847101, 0.207912));
1838+ vertexData_.push_back(vec3(-0.847101, 0.489074, 0.207912));
1839+ vertexData_.push_back(vec3(-0.978148, 0.000000, 0.207912));
1840+ vertexData_.push_back(vec3(-0.847101, -0.489074, 0.207912));
1841+ vertexData_.push_back(vec3(-0.489074, -0.847101, 0.207912));
1842+ vertexData_.push_back(vec3(0.000000, -0.978148, 0.207912));
1843+ vertexData_.push_back(vec3(0.489074, -0.847101, 0.207912));
1844+ vertexData_.push_back(vec3(0.847101, -0.489074, 0.207912));
1845+ vertexData_.push_back(vec3(0.978148, 0.000000, 0.207912));
1846+ vertexData_.push_back(vec3(0.970296, 0.000000, -0.241922));
1847+ vertexData_.push_back(vec3(0.840301, 0.485148, -0.241922));
1848+ vertexData_.push_back(vec3(0.485148, 0.840301, -0.241922));
1849+ vertexData_.push_back(vec3(0.000000, 0.970296, -0.241922));
1850+ vertexData_.push_back(vec3(-0.485148, 0.840301, -0.241922));
1851+ vertexData_.push_back(vec3(-0.840301, 0.485148, -0.241922));
1852+ vertexData_.push_back(vec3(-0.970296, 0.000000, -0.241922));
1853+ vertexData_.push_back(vec3(-0.840301, -0.485148, -0.241922));
1854+ vertexData_.push_back(vec3(-0.485148, -0.840301, -0.241922));
1855+ vertexData_.push_back(vec3(0.000000, -0.970296, -0.241922));
1856+ vertexData_.push_back(vec3(0.485148, -0.840301, -0.241922));
1857+ vertexData_.push_back(vec3(0.840301, -0.485148, -0.241922));
1858+ vertexData_.push_back(vec3(0.970296, 0.000000, -0.241922));
1859+ vertexData_.push_back(vec3(0.766044, 0.000000, -0.642788));
1860+ vertexData_.push_back(vec3(0.663414, 0.383022, -0.642788));
1861+ vertexData_.push_back(vec3(0.383022, 0.663414, -0.642788));
1862+ vertexData_.push_back(vec3(0.000000, 0.766044, -0.642788));
1863+ vertexData_.push_back(vec3(-0.383022, 0.663414, -0.642788));
1864+ vertexData_.push_back(vec3(-0.663414, 0.383022, -0.642788));
1865+ vertexData_.push_back(vec3(-0.766044, 0.000000, -0.642788));
1866+ vertexData_.push_back(vec3(-0.663414, -0.383022, -0.642788));
1867+ vertexData_.push_back(vec3(-0.383022, -0.663414, -0.642788));
1868+ vertexData_.push_back(vec3(0.000000, -0.766044, -0.642788));
1869+ vertexData_.push_back(vec3(0.383022, -0.663414, -0.642788));
1870+ vertexData_.push_back(vec3(0.663414, -0.383022, -0.642788));
1871+ vertexData_.push_back(vec3(0.766044, 0.000000, -0.642788));
1872+
1873+ //
1874+ // The original implementation of both the logo and the lamp represented
1875+ // the vertex and normal data in a triply-dimensioned array of floats and
1876+ // all of the calls referenced double-indexed arrays of vector data.
1877+ // To my mind, this made the code look clunky and overly verbose.
1878+ // Representing the data as a STL vector of vec3 (itself a 3-float vector
1879+ // quantity) provides both an efficient container and allows for more
1880+ // concise looking code. The slightly goofy loops (using the original 2
1881+ // dimensional indices to compute a single offset into the STL vector) are
1882+ // a compromise to avoid rearranging the original data.
1883+ //
1884+ // - jesse 2010/10/04
1885+ //
1886+ for (unsigned int i = 0; i < 5; i++)
1887+ {
1888+ for (unsigned int j = 0; j < 13; j++)
1889+ {
1890+ indexData_.push_back(i * 13 + j);
1891+ indexData_.push_back((i + 1) * 13 + j);
1892+ }
1893+ }
1894+ unsigned int curIndex(5 * 13);
1895+ for (unsigned int i = 0; i < 12; i++)
1896+ {
1897+ indexData_.push_back(curIndex + i);
1898+ }
1899+}
1900+
1901+Lamp::~Lamp()
1902+{
1903+ if (valid_)
1904+ {
1905+ glDeleteBuffers(2, &bufferObjects_[0]);
1906+ }
1907+}
1908+
1909+void
1910+Lamp::init()
1911+{
1912+ // Make sure we don't re-initialize...
1913+ if (valid_)
1914+ {
1915+ return;
1916+ }
1917+
1918+ // Initialize shader sources from input files and create programs from them
1919+ // The program for handling lighting...
1920+ string lit_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-lit.vert");
1921+ string lit_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-lit.frag");
1922+ ShaderSource lit_vtx_source(lit_vtx_filename);
1923+ ShaderSource lit_frg_source(lit_frg_filename);
1924+ if (!Scene::load_shaders_from_strings(litProgram_, lit_vtx_source.str(),
1925+ lit_frg_source.str()))
1926+ {
1927+ Log::error("No valid program for lit lamp rendering\n");
1928+ return;
1929+ }
1930+
1931+ // The simple program with no lighting...
1932+ string unlit_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-unlit.vert");
1933+ string unlit_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-unlit.frag");
1934+ ShaderSource unlit_vtx_source(unlit_vtx_filename);
1935+ ShaderSource unlit_frg_source(unlit_frg_filename);
1936+ if (!Scene::load_shaders_from_strings(unlitProgram_, unlit_vtx_source.str(),
1937+ unlit_frg_source.str()))
1938+ {
1939+ Log::error("No valid program for unlit lamp rendering.\n");
1940+ return;
1941+ }
1942+
1943+ // We need 2 buffers for our work here. One for the vertex data.
1944+ // and one for the index data.
1945+ glGenBuffers(2, &bufferObjects_[0]);
1946+
1947+ // First, setup the vertex data by binding the first buffer object,
1948+ // allocating its data store, and filling it in with our vertex data.
1949+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
1950+ glBufferData(GL_ARRAY_BUFFER, vertexData_.size() * sizeof(vec3), &vertexData_.front(), GL_STATIC_DRAW);
1951+
1952+ // Now repeat for our index data.
1953+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
1954+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int), &indexData_.front(), GL_STATIC_DRAW);
1955+
1956+ // We're ready to go.
1957+ valid_ = true;
1958+}
1959+
1960+void
1961+Lamp::draw(Stack4& modelview, Stack4& projection, const vec4* lightPositions)
1962+{
1963+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
1964+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
1965+
1966+ litProgram_.start();
1967+ int vertexIndex(litProgram_[vertexAttribName_].location());
1968+ int normalIndex(litProgram_[normalAttribName_].location());
1969+ glVertexAttribPointer(vertexIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
1970+ glVertexAttribPointer(normalIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
1971+ glEnableVertexAttribArray(vertexIndex);
1972+ glEnableVertexAttribArray(normalIndex);
1973+ const LibMatrix::mat4& mv = modelview.getCurrent();
1974+ LibMatrix::mat3 normalMatrix(mv[0][0], mv[1][0], mv[2][0],
1975+ mv[0][1], mv[1][1], mv[2][1],
1976+ mv[0][2], mv[1][2], mv[2][2]);
1977+ normalMatrix.transpose().inverse();
1978+ litProgram_[normalMatrixName_] = normalMatrix;
1979+ litProgram_[modelviewName_] = mv;
1980+ litProgram_[projectionName_] = projection.getCurrent();
1981+ litProgram_[light0PositionName_] = lightPositions[0];
1982+ litProgram_[light1PositionName_] = lightPositions[1];
1983+ litProgram_[light2PositionName_] = lightPositions[2];
1984+ static const unsigned int sui(sizeof(unsigned int));
1985+ for (unsigned int i = 0; i < 5; i++)
1986+ {
1987+ glDrawElements(GL_TRIANGLE_STRIP, 26, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid*>(i * 26 * sui));
1988+ }
1989+ glDisableVertexAttribArray(normalIndex);
1990+ glDisableVertexAttribArray(vertexIndex);
1991+ litProgram_.stop();
1992+
1993+ unlitProgram_.start();
1994+ vertexIndex = unlitProgram_[vertexAttribName_].location();
1995+ glVertexAttribPointer(vertexIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
1996+ glEnableVertexAttribArray(vertexIndex);
1997+ unlitProgram_[modelviewName_] = mv;
1998+ unlitProgram_[projectionName_] = projection.getCurrent();
1999+ glDrawElements(GL_TRIANGLE_FAN, 12, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid*>(5 * 26 * sui));
2000+ glDisableVertexAttribArray(vertexIndex);
2001+ unlitProgram_.stop();
2002+
2003+ glBindBuffer(GL_ARRAY_BUFFER, 0);
2004+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2005+}
2006
2007=== added file 'src/scene-ideas/lamp.h'
2008--- src/scene-ideas/lamp.h 1970-01-01 00:00:00 +0000
2009+++ src/scene-ideas/lamp.h 2012-05-09 20:57:19 +0000
2010@@ -0,0 +1,64 @@
2011+/*
2012+ * (c) Copyright 1993, Silicon Graphics, Inc.
2013+ * Copyright © 2012 Linaro Limited
2014+ *
2015+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
2016+ *
2017+ * glmark2 is free software: you can redistribute it and/or modify it under the
2018+ * terms of the GNU General Public License as published by the Free Software
2019+ * Foundation, either version 3 of the License, or (at your option) any later
2020+ * version.
2021+ *
2022+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
2023+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2024+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2025+ * details.
2026+ *
2027+ * You should have received a copy of the GNU General Public License along with
2028+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
2029+ *
2030+ * Authors:
2031+ * Jesse Barker
2032+ */
2033+#ifndef LAMP_H_
2034+#define LAMP_H_
2035+
2036+#include <string>
2037+#include <vector>
2038+#include "vec.h"
2039+#include "stack.h"
2040+#include "gl-headers.h"
2041+#include "program.h"
2042+
2043+class Lamp
2044+{
2045+public:
2046+ Lamp();
2047+ ~Lamp();
2048+
2049+ void init();
2050+ bool valid() const { return valid_; }
2051+ void draw(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection,
2052+ const LibMatrix::vec4* lightPositions);
2053+private:
2054+ Program litProgram_;
2055+ Program unlitProgram_;
2056+ std::string litVertexShader_;
2057+ std::string litFragmentShader_;
2058+ std::string unlitVertexShader_;
2059+ std::string unlitFragmentShader_;
2060+ static const std::string modelviewName_;
2061+ static const std::string projectionName_;
2062+ static const std::string light0PositionName_;
2063+ static const std::string light1PositionName_;
2064+ static const std::string light2PositionName_;
2065+ static const std::string vertexAttribName_;
2066+ static const std::string normalAttribName_;
2067+ static const std::string normalMatrixName_;
2068+ std::vector<LibMatrix::vec3> vertexData_;
2069+ std::vector<unsigned int> indexData_;
2070+ unsigned int bufferObjects_[2];
2071+ bool valid_;
2072+};
2073+
2074+#endif // LAMP_H_
2075
2076=== added file 'src/scene-ideas/logo.cc'
2077--- src/scene-ideas/logo.cc 1970-01-01 00:00:00 +0000
2078+++ src/scene-ideas/logo.cc 2012-05-09 20:57:19 +0000
2079@@ -0,0 +1,789 @@
2080+/*
2081+ * Vertex position data describing the old Silicon Graphics logo
2082+ *
2083+ * (c) Copyright 1993, Silicon Graphics, Inc.
2084+ * Copyright © 2012 Linaro Limited
2085+ *
2086+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
2087+ *
2088+ * glmark2 is free software: you can redistribute it and/or modify it under the
2089+ * terms of the GNU General Public License as published by the Free Software
2090+ * Foundation, either version 3 of the License, or (at your option) any later
2091+ * version.
2092+ *
2093+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
2094+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2095+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2096+ * details.
2097+ *
2098+ * You should have received a copy of the GNU General Public License along with
2099+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
2100+ *
2101+ * Authors:
2102+ * Jesse Barker
2103+ */
2104+#include "logo.h"
2105+#include "scene.h"
2106+#include "shader-source.h"
2107+#include "log.h"
2108+
2109+using std::string;
2110+using LibMatrix::vec3;
2111+using LibMatrix::uvec3;
2112+using LibMatrix::vec4;
2113+using LibMatrix::Stack4;
2114+using LibMatrix::mat4;
2115+
2116+const unsigned int SGILogo::textureResolution_(32);
2117+const string SGILogo::modelviewName_("modelview");
2118+const string SGILogo::projectionName_("projection");
2119+const string SGILogo::lightPositionName_("light0Position");
2120+const string SGILogo::logoColorName_("logoColor");
2121+const string SGILogo::vertexAttribName_("vertex");
2122+const string SGILogo::normalAttribName_("normal");
2123+const string SGILogo::normalMatrixName_("normalMatrix");
2124+
2125+SGILogo::SGILogo(void) :
2126+ normalNormalIndex_(0),
2127+ normalVertexIndex_(0),
2128+ flatVertexIndex_(0),
2129+ shadowVertexIndex_(0),
2130+ vertexIndex_(0),
2131+ valid_(false),
2132+ drawStyle_(LOGO_NORMAL)
2133+{
2134+ // Single cylinder data...
2135+ singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2136+ singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 5.000000));
2137+ singleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
2138+ singleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 5.000000));
2139+ singleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2140+ singleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 5.000000));
2141+ singleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2142+ singleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 5.000000));
2143+ singleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2144+ singleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 5.000000));
2145+ singleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2146+ singleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 5.000000));
2147+ singleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
2148+ singleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 5.000000));
2149+ singleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
2150+ singleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 5.000000));
2151+ singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2152+ singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 5.000000));
2153+
2154+ singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2155+ singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2156+ singleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
2157+ singleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
2158+ singleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
2159+ singleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
2160+ singleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2161+ singleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2162+ singleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2163+ singleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2164+ singleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2165+ singleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2166+ singleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
2167+ singleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
2168+ singleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
2169+ singleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
2170+ singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2171+ singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2172+
2173+ // Double cylinder data...
2174+ doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2175+ doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 7.000000));
2176+ doubleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
2177+ doubleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 7.000000));
2178+ doubleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2179+ doubleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 7.000000));
2180+ doubleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2181+ doubleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 7.000000));
2182+ doubleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2183+ doubleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 7.000000));
2184+ doubleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2185+ doubleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 7.000000));
2186+ doubleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
2187+ doubleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 7.000000));
2188+ doubleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
2189+ doubleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 7.000000));
2190+ doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2191+ doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 7.000000));
2192+
2193+ doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2194+ doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2195+ doubleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
2196+ doubleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
2197+ doubleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
2198+ doubleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
2199+ doubleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2200+ doubleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2201+ doubleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2202+ doubleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2203+ doubleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2204+ doubleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2205+ doubleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
2206+ doubleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
2207+ doubleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
2208+ doubleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
2209+ doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2210+ doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2211+
2212+ // Elbow data...
2213+ elbowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2214+ elbowVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
2215+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2216+ elbowVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2217+ elbowVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2218+ elbowVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2219+ elbowVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
2220+ elbowVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
2221+ elbowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2222+ elbowVertices_.push_back(vec3(1.000000, 0.034074, 0.258819));
2223+ elbowVertices_.push_back(vec3(0.707107, 0.717087, 0.075806));
2224+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2225+ elbowVertices_.push_back(vec3(-0.707107, 0.717087, 0.075806));
2226+ elbowVertices_.push_back(vec3(-1.000000, 0.034074, 0.258819));
2227+ elbowVertices_.push_back(vec3(-0.707107, -0.648939, 0.441832));
2228+ elbowVertices_.push_back(vec3(0.000000, -0.931852, 0.517638));
2229+ elbowVertices_.push_back(vec3(0.707107, -0.648939, 0.441832));
2230+ elbowVertices_.push_back(vec3(1.000000, 0.034074, 0.258819));
2231+ elbowVertices_.push_back(vec3(1.000000, 0.133975, 0.500000));
2232+ elbowVertices_.push_back(vec3(0.707107, 0.746347, 0.146447));
2233+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2234+ elbowVertices_.push_back(vec3(-0.707107, 0.746347, 0.146447));
2235+ elbowVertices_.push_back(vec3(-1.000000, 0.133975, 0.500000));
2236+ elbowVertices_.push_back(vec3(-0.707107, -0.478398, 0.853553));
2237+ elbowVertices_.push_back(vec3(0.000000, -0.732051, 1.000000));
2238+ elbowVertices_.push_back(vec3(0.707107, -0.478398, 0.853553));
2239+ elbowVertices_.push_back(vec3(1.000000, 0.133975, 0.500000));
2240+ elbowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
2241+ elbowVertices_.push_back(vec3(0.707107, 0.792893, 0.207107));
2242+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2243+ elbowVertices_.push_back(vec3(-0.707107, 0.792893, 0.207107));
2244+ elbowVertices_.push_back(vec3(-1.000000, 0.292893, 0.707107));
2245+ elbowVertices_.push_back(vec3(-0.707107, -0.207107, 1.207107));
2246+ elbowVertices_.push_back(vec3(0.000000, -0.414214, 1.414214));
2247+ elbowVertices_.push_back(vec3(0.707107, -0.207107, 1.207107));
2248+ elbowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
2249+ elbowVertices_.push_back(vec3(1.000000, 0.500000, 0.866025));
2250+ elbowVertices_.push_back(vec3(0.707107, 0.853553, 0.253653));
2251+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2252+ elbowVertices_.push_back(vec3(-0.707107, 0.853553, 0.253653));
2253+ elbowVertices_.push_back(vec3(-1.000000, 0.500000, 0.866025));
2254+ elbowVertices_.push_back(vec3(-0.707107, 0.146447, 1.478398));
2255+ elbowVertices_.push_back(vec3(0.000000, 0.000000, 1.732051));
2256+ elbowVertices_.push_back(vec3(0.707107, 0.146447, 1.478398));
2257+ elbowVertices_.push_back(vec3(1.000000, 0.500000, 0.866025));
2258+ elbowVertices_.push_back(vec3(1.000000, 0.741181, 0.965926));
2259+ elbowVertices_.push_back(vec3(0.707107, 0.924194, 0.282913));
2260+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2261+ elbowVertices_.push_back(vec3(-0.707107, 0.924194, 0.282913));
2262+ elbowVertices_.push_back(vec3(-1.000000, 0.741181, 0.965926));
2263+ elbowVertices_.push_back(vec3(-0.707107, 0.558168, 1.648939));
2264+ elbowVertices_.push_back(vec3(0.000000, 0.482362, 1.931852));
2265+ elbowVertices_.push_back(vec3(0.707107, 0.558168, 1.648939));
2266+ elbowVertices_.push_back(vec3(1.000000, 0.741181, 0.965926));
2267+ elbowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
2268+ elbowVertices_.push_back(vec3(0.707107, 1.000000, 0.292893));
2269+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2270+ elbowVertices_.push_back(vec3(-0.707107, 1.000000, 0.292893));
2271+ elbowVertices_.push_back(vec3(-1.000000, 1.000000, 1.000000));
2272+ elbowVertices_.push_back(vec3(-0.707107, 1.000000, 1.707107));
2273+ elbowVertices_.push_back(vec3(0.000000, 1.000000, 2.000000));
2274+ elbowVertices_.push_back(vec3(0.707107, 1.000000, 1.707107));
2275+ elbowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
2276+
2277+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2278+ elbowNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
2279+ elbowNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
2280+ elbowNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2281+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2282+ elbowNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2283+ elbowNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
2284+ elbowNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
2285+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2286+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2287+ elbowNormals_.push_back(vec3(0.707107, 0.683013, -0.183013));
2288+ elbowNormals_.push_back(vec3(0.000000, 0.965926, -0.258819));
2289+ elbowNormals_.push_back(vec3(-0.707107, 0.683013, -0.183013));
2290+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2291+ elbowNormals_.push_back(vec3(-0.707107, -0.683013, 0.183013));
2292+ elbowNormals_.push_back(vec3(0.000000, -0.965926, 0.258819));
2293+ elbowNormals_.push_back(vec3(0.707107, -0.683013, 0.183013));
2294+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2295+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2296+ elbowNormals_.push_back(vec3(0.707107, 0.612372, -0.353553));
2297+ elbowNormals_.push_back(vec3(0.000000, 0.866025, -0.500000));
2298+ elbowNormals_.push_back(vec3(-0.707107, 0.612372, -0.353553));
2299+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2300+ elbowNormals_.push_back(vec3(-0.707107, -0.612372, 0.353553));
2301+ elbowNormals_.push_back(vec3(0.000000, -0.866025, 0.500000));
2302+ elbowNormals_.push_back(vec3(0.707107, -0.612372, 0.353553));
2303+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2304+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2305+ elbowNormals_.push_back(vec3(0.707107, 0.500000, -0.500000));
2306+ elbowNormals_.push_back(vec3(0.000000, 0.707107, -0.707107));
2307+ elbowNormals_.push_back(vec3(-0.707107, 0.500000, -0.500000));
2308+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2309+ elbowNormals_.push_back(vec3(-0.707107, -0.500000, 0.500000));
2310+ elbowNormals_.push_back(vec3(0.000000, -0.707107, 0.707107));
2311+ elbowNormals_.push_back(vec3(0.707107, -0.500000, 0.500000));
2312+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2313+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2314+ elbowNormals_.push_back(vec3(0.707107, 0.353553, -0.612372));
2315+ elbowNormals_.push_back(vec3(0.000000, 0.500000, -0.866025));
2316+ elbowNormals_.push_back(vec3(-0.707107, 0.353553, -0.612372));
2317+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2318+ elbowNormals_.push_back(vec3(-0.707107, -0.353553, 0.612372));
2319+ elbowNormals_.push_back(vec3(0.000000, -0.500000, 0.866025));
2320+ elbowNormals_.push_back(vec3(0.707107, -0.353553, 0.612372));
2321+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2322+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2323+ elbowNormals_.push_back(vec3(0.707107, 0.183013, -0.683013));
2324+ elbowNormals_.push_back(vec3(0.000000, 0.258819, -0.965926));
2325+ elbowNormals_.push_back(vec3(-0.707107, 0.183013, -0.683013));
2326+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2327+ elbowNormals_.push_back(vec3(-0.707107, -0.183013, 0.683013));
2328+ elbowNormals_.push_back(vec3(0.000000, -0.258819, 0.965926));
2329+ elbowNormals_.push_back(vec3(0.707107, -0.183013, 0.683013));
2330+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2331+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2332+ elbowNormals_.push_back(vec3(0.707107, 0.000000, -0.707107));
2333+ elbowNormals_.push_back(vec3(0.000000, 0.000000, -1.000000));
2334+ elbowNormals_.push_back(vec3(-0.707107, 0.000000, -0.707107));
2335+ elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2336+ elbowNormals_.push_back(vec3(-0.707107, 0.000000, 0.707107));
2337+ elbowNormals_.push_back(vec3(0.000000, 0.000000, 1.000000));
2338+ elbowNormals_.push_back(vec3(0.707107, 0.000000, 0.707107));
2339+ elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
2340+
2341+ elbowShadowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2342+ elbowShadowVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
2343+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2344+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
2345+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
2346+ elbowShadowVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
2347+ elbowShadowVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
2348+ elbowShadowVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
2349+ elbowShadowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
2350+ elbowShadowVertices_.push_back(vec3(1.000000, 0.019215, 0.195090));
2351+ elbowShadowVertices_.push_back(vec3(0.707107, 0.712735, 0.057141));
2352+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2353+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.712735, 0.057141));
2354+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.019215, 0.195090));
2355+ elbowShadowVertices_.push_back(vec3(-0.707107, -0.674305, 0.333040));
2356+ elbowShadowVertices_.push_back(vec3(0.000000, -0.961571, 0.390181));
2357+ elbowShadowVertices_.push_back(vec3(0.707107, -0.674305, 0.333040));
2358+ elbowShadowVertices_.push_back(vec3(1.000000, 0.019215, 0.195090));
2359+ elbowShadowVertices_.push_back(vec3(1.000000, 0.076120, 0.382683));
2360+ elbowShadowVertices_.push_back(vec3(0.707107, 0.729402, 0.112085));
2361+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2362+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.729402, 0.112085));
2363+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.076120, 0.382683));
2364+ elbowShadowVertices_.push_back(vec3(-0.707107, -0.577161, 0.653282));
2365+ elbowShadowVertices_.push_back(vec3(0.000000, -0.847759, 0.765367));
2366+ elbowShadowVertices_.push_back(vec3(0.707107, -0.577161, 0.653282));
2367+ elbowShadowVertices_.push_back(vec3(1.000000, 0.076120, 0.382683));
2368+ elbowShadowVertices_.push_back(vec3(1.000000, 0.168530, 0.555570));
2369+ elbowShadowVertices_.push_back(vec3(0.707107, 0.756468, 0.162723));
2370+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2371+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.756468, 0.162723));
2372+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.168530, 0.555570));
2373+ elbowShadowVertices_.push_back(vec3(-0.707107, -0.419407, 0.948418));
2374+ elbowShadowVertices_.push_back(vec3(0.000000, -0.662939, 1.111140));
2375+ elbowShadowVertices_.push_back(vec3(0.707107, -0.419407, 0.948418));
2376+ elbowShadowVertices_.push_back(vec3(1.000000, 0.168530, 0.555570));
2377+ elbowShadowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
2378+ elbowShadowVertices_.push_back(vec3(0.707107, 0.792893, 0.207107));
2379+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2380+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.792893, 0.207107));
2381+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.292893, 0.707107));
2382+ elbowShadowVertices_.push_back(vec3(-0.707107, -0.207107, 1.207107));
2383+ elbowShadowVertices_.push_back(vec3(0.000000, -0.414214, 1.414214));
2384+ elbowShadowVertices_.push_back(vec3(0.707107, -0.207107, 1.207107));
2385+ elbowShadowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
2386+ elbowShadowVertices_.push_back(vec3(1.000000, 0.444430, 0.831470));
2387+ elbowShadowVertices_.push_back(vec3(0.707107, 0.837277, 0.243532));
2388+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2389+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.837277, 0.243532));
2390+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.444430, 0.831470));
2391+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.051582, 1.419407));
2392+ elbowShadowVertices_.push_back(vec3(0.000000, -0.111140, 1.662939));
2393+ elbowShadowVertices_.push_back(vec3(0.707107, 0.051582, 1.419407));
2394+ elbowShadowVertices_.push_back(vec3(1.000000, 0.444430, 0.831470));
2395+ elbowShadowVertices_.push_back(vec3(1.000000, 0.617317, 0.923880));
2396+ elbowShadowVertices_.push_back(vec3(0.707107, 0.887915, 0.270598));
2397+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2398+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.887915, 0.270598));
2399+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.617317, 0.923880));
2400+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.346719, 1.577161));
2401+ elbowShadowVertices_.push_back(vec3(0.000000, 0.234633, 1.847759));
2402+ elbowShadowVertices_.push_back(vec3(0.707107, 0.346719, 1.577161));
2403+ elbowShadowVertices_.push_back(vec3(1.000000, 0.617317, 0.923880));
2404+ elbowShadowVertices_.push_back(vec3(1.000000, 0.804910, 0.980785));
2405+ elbowShadowVertices_.push_back(vec3(0.707107, 0.942859, 0.287265));
2406+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2407+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.942859, 0.287265));
2408+ elbowShadowVertices_.push_back(vec3(-1.000000, 0.804910, 0.980785));
2409+ elbowShadowVertices_.push_back(vec3(-0.707107, 0.666960, 1.674305));
2410+ elbowShadowVertices_.push_back(vec3(0.000000, 0.609819, 1.961571));
2411+ elbowShadowVertices_.push_back(vec3(0.707107, 0.666960, 1.674305));
2412+ elbowShadowVertices_.push_back(vec3(1.000000, 0.804910, 0.980785));
2413+ elbowShadowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
2414+ elbowShadowVertices_.push_back(vec3(0.707107, 1.000000, 0.292893));
2415+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
2416+ elbowShadowVertices_.push_back(vec3(-0.707107, 1.000000, 0.292893));
2417+ elbowShadowVertices_.push_back(vec3(-1.000000, 1.000000, 1.000000));
2418+ elbowShadowVertices_.push_back(vec3(-0.707107, 1.000000, 1.707107));
2419+ elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 2.000000));
2420+ elbowShadowVertices_.push_back(vec3(0.707107, 1.000000, 1.707107));
2421+ elbowShadowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
2422+
2423+ // Now that we've setup the vertex data, we can setup the map of how
2424+ // that data will be laid out in the buffer object.
2425+ static const unsigned int sv3(sizeof(vec3));
2426+ dataMap_.scvOffset = 0;
2427+ dataMap_.scvSize = singleCylinderVertices_.size() * sv3;
2428+ dataMap_.totalSize = dataMap_.scvSize;
2429+ dataMap_.scnOffset = dataMap_.scvOffset + dataMap_.scvSize;
2430+ dataMap_.scnSize = singleCylinderNormals_.size() * sv3;
2431+ dataMap_.totalSize += dataMap_.scnSize;
2432+ dataMap_.dcvOffset = dataMap_.scnOffset + dataMap_.scnSize;
2433+ dataMap_.dcvSize = doubleCylinderVertices_.size() * sv3;
2434+ dataMap_.totalSize += dataMap_.dcvSize;
2435+ dataMap_.dcnOffset = dataMap_.dcvOffset + dataMap_.dcvSize;
2436+ dataMap_.dcnSize = doubleCylinderNormals_.size() * sv3;
2437+ dataMap_.totalSize += dataMap_.dcnSize;
2438+ dataMap_.evOffset = dataMap_.dcnOffset + dataMap_.dcnSize;
2439+ dataMap_.evSize = elbowVertices_.size() * sv3;
2440+ dataMap_.totalSize += dataMap_.evSize;
2441+ dataMap_.enOffset = dataMap_.evOffset + dataMap_.evSize;
2442+ dataMap_.enSize = elbowNormals_.size() * sv3;
2443+ dataMap_.totalSize += dataMap_.enSize;
2444+ dataMap_.esvOffset = dataMap_.enOffset + dataMap_.enSize;
2445+ dataMap_.esvSize = elbowShadowVertices_.size() * sv3;
2446+ dataMap_.totalSize += dataMap_.esvSize;
2447+
2448+ //
2449+ // The original implementation of both the logo and the lamp represented
2450+ // the vertex and normal data in a triply-dimensioned array of floats and
2451+ // all of the calls referenced double-indexed arrays of vector data.
2452+ // To my mind, this made the code look clunky and overly verbose.
2453+ // Representing the data as a STL vector of vec3 (itself a 3-float vector
2454+ // quantity) provides both an efficient container and allows for more
2455+ // concise looking code. The slightly goofy loops (using the original 2
2456+ // dimensional indices to compute a single offset into the STL vector) are
2457+ // a compromise to avoid rearranging the original data.
2458+ //
2459+ // - jesse 2010/10/04
2460+ //
2461+ for (unsigned int i = 0; i < 8; i++)
2462+ {
2463+ for (unsigned int j = 0; j < 9; j++)
2464+ {
2465+ unsigned int index1(i * 9 + j);
2466+ unsigned int index2((i + 1) * 9 + j);
2467+ indexData_.push_back(index1);
2468+ indexData_.push_back(index2);
2469+ }
2470+ }
2471+
2472+ // Initialize the stipple pattern
2473+ static const unsigned int patterns[] = { 0xaaaaaaaa, 0x55555555 };
2474+ for (unsigned int i = 0; i < textureResolution_; i++)
2475+ {
2476+ for (unsigned int j = 0; j < textureResolution_; j++)
2477+ {
2478+ // Alternate the pattern every other line.
2479+ unsigned int curMask(1 << j);
2480+ unsigned int curPattern(patterns[i % 2]);
2481+ textureImage_[i][j] = ((curPattern & curMask) >> j) * 255;
2482+ }
2483+ }
2484+}
2485+
2486+SGILogo::~SGILogo()
2487+{
2488+ if (valid_)
2489+ {
2490+ glDeleteBuffers(2, &bufferObjects_[0]);
2491+ }
2492+}
2493+
2494+void
2495+SGILogo::init()
2496+{
2497+ // Make sure we don't re-initialize...
2498+ if (valid_)
2499+ {
2500+ return;
2501+ }
2502+
2503+ // Initialize shader sources from input files and create programs from them
2504+ // The program for handling the main object with lighting...
2505+ string logo_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-logo.vert");
2506+ string logo_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-logo.frag");
2507+ ShaderSource logo_vtx_source(logo_vtx_filename);
2508+ ShaderSource logo_frg_source(logo_frg_filename);
2509+ if (!Scene::load_shaders_from_strings(normalProgram_, logo_vtx_source.str(),
2510+ logo_frg_source.str()))
2511+ {
2512+ Log::error("No valid program for normal logo rendering\n");
2513+ return;
2514+ }
2515+ normalVertexIndex_ = normalProgram_[vertexAttribName_].location();
2516+ normalNormalIndex_ = normalProgram_[normalAttribName_].location();
2517+
2518+ // The program for handling the flat object...
2519+ string logo_flat_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-flat.vert");
2520+ string logo_flat_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-flat.frag");
2521+ ShaderSource logo_flat_vtx_source(logo_flat_vtx_filename);
2522+ ShaderSource logo_flat_frg_source(logo_flat_frg_filename);
2523+ if (!Scene::load_shaders_from_strings(flatProgram_, logo_flat_vtx_source.str(),
2524+ logo_flat_frg_source.str()))
2525+ {
2526+ Log::error("No valid program for flat logo rendering\n");
2527+ return;
2528+ }
2529+ flatVertexIndex_ = flatProgram_[vertexAttribName_].location();
2530+
2531+ // The program for handling the shadow object with texturing...
2532+ string logo_shadow_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-shadow.vert");
2533+ string logo_shadow_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-shadow.frag");
2534+ ShaderSource logo_shadow_vtx_source(logo_shadow_vtx_filename);
2535+ ShaderSource logo_shadow_frg_source(logo_shadow_frg_filename);
2536+ if (!Scene::load_shaders_from_strings(shadowProgram_, logo_shadow_vtx_source.str(),
2537+ logo_shadow_frg_source.str()))
2538+ {
2539+ Log::error("No valid program for shadow logo rendering\n");
2540+ return;
2541+ }
2542+ shadowVertexIndex_ = shadowProgram_[vertexAttribName_].location();
2543+
2544+ // We need 2 buffers for our work here. One for the vertex data.
2545+ // and one for the index data.
2546+ glGenBuffers(2, &bufferObjects_[0]);
2547+
2548+ // First, setup the vertex data by binding the first buffer object,
2549+ // allocating its data store, and filling it in with our vertex data.
2550+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
2551+ glBufferData(GL_ARRAY_BUFFER, dataMap_.totalSize, 0, GL_STATIC_DRAW);
2552+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.scvOffset, dataMap_.scvSize,
2553+ &singleCylinderVertices_.front());
2554+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.scnOffset, dataMap_.scnSize,
2555+ &singleCylinderNormals_.front());
2556+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.dcvOffset, dataMap_.dcvSize,
2557+ &doubleCylinderVertices_.front());
2558+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.dcnOffset, dataMap_.dcnSize,
2559+ &doubleCylinderNormals_.front());
2560+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.evOffset, dataMap_.evSize,
2561+ &elbowVertices_.front());
2562+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.enOffset, dataMap_.enSize,
2563+ &elbowNormals_.front());
2564+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.esvOffset, dataMap_.esvSize,
2565+ &elbowShadowVertices_.front());
2566+
2567+ // Now repeat for our index data.
2568+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
2569+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int),
2570+ &indexData_.front(), GL_STATIC_DRAW);
2571+
2572+ // Setup our the texture that the shadow program will use...
2573+ glGenTextures(1, &textureName_);
2574+ glBindTexture(GL_TEXTURE_2D, textureName_);
2575+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
2576+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
2577+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
2578+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
2579+ glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
2580+ textureResolution_, textureResolution_,
2581+ 0, GL_ALPHA, GL_UNSIGNED_BYTE, textureImage_);
2582+
2583+ // We're ready to go.
2584+ valid_ = true;
2585+}
2586+
2587+void
2588+SGILogo::bendForward(Stack4& ms)
2589+{
2590+ ms.translate(0.0, 1.0, 0.0);
2591+ ms.rotate(90.0, 1.0, 0.0, 0.0);
2592+ ms.translate(0.0, -1.0, 0.0);
2593+}
2594+
2595+void
2596+SGILogo::bendLeft(Stack4& ms)
2597+{
2598+ ms.rotate(-90.0, 0.0, 0.0, 1.0);
2599+ ms.translate(0.0, 1.0, 0.0);
2600+ ms.rotate(90.0, 1.0, 0.0, 0.0);
2601+ ms.translate(0.0, -1.0, 0.0);
2602+}
2603+
2604+void
2605+SGILogo::bendRight(Stack4& ms)
2606+{
2607+ ms.rotate(90.0, 0.0, 0.0, 1.0);
2608+ ms.translate(0.0, 1.0, 0.0);
2609+ ms.rotate(90.0, 1.0, 0.0, 0.0);
2610+ ms.translate(0.0, -1.0, 0.0);
2611+}
2612+
2613+void
2614+SGILogo::drawDoubleCylinder(void)
2615+{
2616+ glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2617+ reinterpret_cast<const GLvoid*>(dataMap_.dcvOffset));
2618+ if (drawStyle_ == LOGO_NORMAL)
2619+ {
2620+ glVertexAttribPointer(normalNormalIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2621+ reinterpret_cast<const GLvoid*>(dataMap_.dcnOffset));
2622+ }
2623+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 18);
2624+}
2625+
2626+void
2627+SGILogo::drawSingleCylinder(void)
2628+{
2629+ glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2630+ reinterpret_cast<const GLvoid*>(dataMap_.scvOffset));
2631+ if (drawStyle_ == LOGO_NORMAL)
2632+ {
2633+ glVertexAttribPointer(normalNormalIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2634+ reinterpret_cast<const GLvoid*>(dataMap_.scnOffset));
2635+ }
2636+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 18);
2637+}
2638+
2639+void
2640+SGILogo::drawElbow(void)
2641+{
2642+ static const unsigned int sui(sizeof(unsigned int));
2643+ unsigned int startIdx(0);
2644+ unsigned int endIdx(6);
2645+ if (drawStyle_ == LOGO_NORMAL)
2646+ {
2647+ glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2648+ reinterpret_cast<const GLvoid*>(dataMap_.evOffset));
2649+ glVertexAttribPointer(normalNormalIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2650+ reinterpret_cast<const GLvoid*>(dataMap_.enOffset));
2651+ }
2652+ else
2653+ {
2654+ endIdx = 8;
2655+ glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
2656+ reinterpret_cast<const GLvoid*>(dataMap_.esvOffset));
2657+ }
2658+
2659+ for (unsigned int i = startIdx; i < endIdx; i++)
2660+ {
2661+ unsigned int curOffset(i * 18 * sui);
2662+ glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_INT,
2663+ reinterpret_cast<const GLvoid*>(curOffset));
2664+ }
2665+}
2666+
2667+// Generate a normal matrix from a modelview matrix
2668+//
2669+// Since we can't universally handle the normal matrix inside the
2670+// vertex shader (inverse() and transpose() built-ins not supported by
2671+// GLSL ES, for example), we'll generate it here, and load it as a
2672+// uniform.
2673+void
2674+SGILogo::updateXform(const mat4& mv, Program& program)
2675+{
2676+ if (drawStyle_ == LOGO_NORMAL)
2677+ {
2678+ LibMatrix::mat3 normalMatrix(mv[0][0], mv[1][0], mv[2][0],
2679+ mv[0][1], mv[1][1], mv[2][1],
2680+ mv[0][2], mv[1][2], mv[2][2]);
2681+ normalMatrix.transpose().inverse();
2682+ program[normalMatrixName_] = normalMatrix;
2683+ }
2684+ program[modelviewName_] = mv;
2685+}
2686+
2687+Program&
2688+SGILogo::getProgram()
2689+{
2690+ switch (drawStyle_)
2691+ {
2692+ case LOGO_NORMAL:
2693+ return normalProgram_;
2694+ break;
2695+ case LOGO_FLAT:
2696+ return flatProgram_;
2697+ break;
2698+ case LOGO_SHADOW:
2699+ return shadowProgram_;
2700+ break;
2701+ }
2702+
2703+ return normalProgram_;
2704+}
2705+
2706+void
2707+SGILogo::draw(Stack4& modelview,
2708+ Stack4& projection,
2709+ const vec4& lightPosition,
2710+ DrawStyle style,
2711+ const uvec3& currentColor)
2712+{
2713+ if (!valid_)
2714+ {
2715+ return;
2716+ }
2717+
2718+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
2719+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
2720+
2721+ // Setup the program to use based upon draw style and set it running.
2722+ drawStyle_ = style;
2723+ vec4 logoColor(currentColor.x() / 255.0, currentColor.y() / 255.0, currentColor.z() / 255.0, 1.0);
2724+ Program& curProgram = getProgram();
2725+ curProgram.start();
2726+ switch (drawStyle_)
2727+ {
2728+ case LOGO_NORMAL:
2729+ curProgram[lightPositionName_] = lightPosition;
2730+ vertexIndex_ = normalVertexIndex_;
2731+ glEnableVertexAttribArray(normalNormalIndex_);
2732+ break;
2733+ case LOGO_FLAT:
2734+ curProgram[logoColorName_] = logoColor;
2735+ vertexIndex_ = flatVertexIndex_;
2736+ break;
2737+ case LOGO_SHADOW:
2738+ vertexIndex_ = shadowVertexIndex_;
2739+ break;
2740+ }
2741+
2742+ glEnableVertexAttribArray(vertexIndex_);
2743+ curProgram[projectionName_] = projection.getCurrent();
2744+ modelview.translate(5.500000, -3.500000, 4.500000);
2745+ modelview.translate(0.0, 0.0, -7.000000);
2746+ updateXform(modelview.getCurrent(), curProgram);
2747+ drawDoubleCylinder();
2748+ bendForward(modelview);
2749+ updateXform(modelview.getCurrent(), curProgram);
2750+ drawElbow();
2751+ modelview.translate(0.0, 0.0, -7.000000);
2752+ updateXform(modelview.getCurrent(), curProgram);
2753+ drawDoubleCylinder();
2754+ bendForward(modelview);
2755+ updateXform(modelview.getCurrent(), curProgram);
2756+ drawElbow();
2757+ modelview.translate(0.0, 0.0, -5.000000);
2758+ updateXform(modelview.getCurrent(), curProgram);
2759+ drawSingleCylinder();
2760+ bendRight(modelview);
2761+ updateXform(modelview.getCurrent(), curProgram);
2762+ drawElbow();
2763+ modelview.translate(0.0, 0.0, -7.000000);
2764+ updateXform(modelview.getCurrent(), curProgram);
2765+ drawDoubleCylinder();
2766+ bendForward(modelview);
2767+ updateXform(modelview.getCurrent(), curProgram);
2768+ drawElbow();
2769+ modelview.translate(0.0, 0.0, -7.000000);
2770+ updateXform(modelview.getCurrent(), curProgram);
2771+ drawDoubleCylinder();
2772+ bendForward(modelview);
2773+ updateXform(modelview.getCurrent(), curProgram);
2774+ drawElbow();
2775+ modelview.translate(0.0, 0.0, -5.000000);
2776+ updateXform(modelview.getCurrent(), curProgram);
2777+ drawSingleCylinder();
2778+ bendLeft(modelview);
2779+ updateXform(modelview.getCurrent(), curProgram);
2780+ drawElbow();
2781+ modelview.translate(0.0, 0.0, -7.000000);
2782+ updateXform(modelview.getCurrent(), curProgram);
2783+ drawDoubleCylinder();
2784+ bendForward(modelview);
2785+ updateXform(modelview.getCurrent(), curProgram);
2786+ drawElbow();
2787+ modelview.translate(0.0, 0.0, -7.000000);
2788+ updateXform(modelview.getCurrent(), curProgram);
2789+ drawDoubleCylinder();
2790+ bendForward(modelview);
2791+ updateXform(modelview.getCurrent(), curProgram);
2792+ drawElbow();
2793+ modelview.translate(0.0, 0.0, -5.000000);
2794+ updateXform(modelview.getCurrent(), curProgram);
2795+ drawSingleCylinder();
2796+ bendRight(modelview);
2797+ updateXform(modelview.getCurrent(), curProgram);
2798+ drawElbow();
2799+ modelview.translate(0.0, 0.0, -7.000000);
2800+ updateXform(modelview.getCurrent(), curProgram);
2801+ drawDoubleCylinder();
2802+ bendForward(modelview);
2803+ updateXform(modelview.getCurrent(), curProgram);
2804+ drawElbow();
2805+ modelview.translate(0.0, 0.0, -7.000000);
2806+ updateXform(modelview.getCurrent(), curProgram);
2807+ drawDoubleCylinder();
2808+ bendForward(modelview);
2809+ updateXform(modelview.getCurrent(), curProgram);
2810+ drawElbow();
2811+ modelview.translate(0.0, 0.0, -5.000000);
2812+ updateXform(modelview.getCurrent(), curProgram);
2813+ drawSingleCylinder();
2814+ bendLeft(modelview);
2815+ updateXform(modelview.getCurrent(), curProgram);
2816+ drawElbow();
2817+ modelview.translate(0.0, 0.0, -7.000000);
2818+ updateXform(modelview.getCurrent(), curProgram);
2819+ drawDoubleCylinder();
2820+ bendForward(modelview);
2821+ updateXform(modelview.getCurrent(), curProgram);
2822+ drawElbow();
2823+ modelview.translate(0.0, 0.0, -7.000000);
2824+ updateXform(modelview.getCurrent(), curProgram);
2825+ drawDoubleCylinder();
2826+ bendForward(modelview);
2827+ updateXform(modelview.getCurrent(), curProgram);
2828+ drawElbow();
2829+ modelview.translate(0.0, 0.0, -5.000000);
2830+ updateXform(modelview.getCurrent(), curProgram);
2831+ drawSingleCylinder();
2832+ bendRight(modelview);
2833+ updateXform(modelview.getCurrent(), curProgram);
2834+ drawElbow();
2835+ modelview.translate(0.0, 0.0, -7.000000);
2836+ updateXform(modelview.getCurrent(), curProgram);
2837+ drawDoubleCylinder();
2838+ bendForward(modelview);
2839+ updateXform(modelview.getCurrent(), curProgram);
2840+ drawElbow();
2841+ modelview.translate(0.0, 0.0, -7.000000);
2842+ updateXform(modelview.getCurrent(), curProgram);
2843+ drawDoubleCylinder();
2844+ bendForward(modelview);
2845+ updateXform(modelview.getCurrent(), curProgram);
2846+ drawElbow();
2847+ modelview.translate(0.0, 0.0, -5.000000);
2848+ updateXform(modelview.getCurrent(), curProgram);
2849+ drawSingleCylinder();
2850+ bendLeft(modelview);
2851+ updateXform(modelview.getCurrent(), curProgram);
2852+ drawElbow();
2853+ glDisableVertexAttribArray(vertexIndex_);
2854+ switch (drawStyle_)
2855+ {
2856+ case LOGO_NORMAL:
2857+ glDisableVertexAttribArray(normalNormalIndex_);
2858+ break;
2859+ case LOGO_FLAT:
2860+ break;
2861+ case LOGO_SHADOW:
2862+ break;
2863+ }
2864+ curProgram.stop();
2865+
2866+ glBindBuffer(GL_ARRAY_BUFFER, 0);
2867+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
2868+}
2869
2870=== added file 'src/scene-ideas/logo.h'
2871--- src/scene-ideas/logo.h 1970-01-01 00:00:00 +0000
2872+++ src/scene-ideas/logo.h 2012-05-09 20:57:19 +0000
2873@@ -0,0 +1,126 @@
2874+/*
2875+ * (c) Copyright 1993, Silicon Graphics, Inc.
2876+ * Copyright © 2012 Linaro Limited
2877+ *
2878+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
2879+ *
2880+ * glmark2 is free software: you can redistribute it and/or modify it under the
2881+ * terms of the GNU General Public License as published by the Free Software
2882+ * Foundation, either version 3 of the License, or (at your option) any later
2883+ * version.
2884+ *
2885+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
2886+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
2887+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
2888+ * details.
2889+ *
2890+ * You should have received a copy of the GNU General Public License along with
2891+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
2892+ *
2893+ * Authors:
2894+ * Jesse Barker
2895+ */
2896+#ifndef LOGO_H_
2897+#define LOGO_H_
2898+
2899+#include <string>
2900+#include <vector>
2901+#include "vec.h"
2902+#include "stack.h"
2903+#include "gl-headers.h"
2904+#include "program.h"
2905+
2906+class SGILogo
2907+{
2908+public:
2909+ SGILogo();
2910+ ~SGILogo();
2911+
2912+ // Initialize the logo
2913+ void init();
2914+ bool valid() const { return valid_; }
2915+ void setPosition(const LibMatrix::vec3& position) { currentPosition_ = position; }
2916+ // Tell the logo to draw itself. DrawStyle tells it how.
2917+ // - LOGO_NORMAL renders the logo lit and shaded.
2918+ // - LOGO_FLAT renders the logo as if flattened onto a surface.
2919+ // - LOGO_SHADOW renders a stippled-looking shadow of the object.
2920+ enum DrawStyle
2921+ {
2922+ LOGO_NORMAL,
2923+ LOGO_FLAT,
2924+ LOGO_SHADOW
2925+ };
2926+ void draw(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection,
2927+ const LibMatrix::vec4& lightPosition, DrawStyle style,
2928+ const LibMatrix::uvec3& color = LibMatrix::uvec3());
2929+
2930+private:
2931+ void drawElbow();
2932+ void drawSingleCylinder();
2933+ void drawDoubleCylinder();
2934+ void bendLeft(LibMatrix::Stack4& ms);
2935+ void bendRight(LibMatrix::Stack4& ms);
2936+ void bendForward(LibMatrix::Stack4& ms);
2937+ void updateXform(const LibMatrix::mat4& mv, Program& program);
2938+ Program& getProgram();
2939+ LibMatrix::vec3 currentPosition_;
2940+ std::vector<LibMatrix::vec3> singleCylinderVertices_;
2941+ std::vector<LibMatrix::vec3> singleCylinderNormals_;
2942+ std::vector<LibMatrix::vec3> doubleCylinderVertices_;
2943+ std::vector<LibMatrix::vec3> doubleCylinderNormals_;
2944+ std::vector<LibMatrix::vec3> elbowVertices_;
2945+ std::vector<LibMatrix::vec3> elbowNormals_;
2946+ std::vector<LibMatrix::vec3> elbowShadowVertices_;
2947+ std::vector<unsigned int> indexData_;
2948+ // A simple map so we know where each section of our data starts within
2949+ // our vertex buffer object.
2950+ struct VertexDataMap
2951+ {
2952+ unsigned int scvOffset;
2953+ unsigned int scvSize;
2954+ unsigned int scnOffset;
2955+ unsigned int scnSize;
2956+ unsigned int dcvOffset;
2957+ unsigned int dcvSize;
2958+ unsigned int dcnOffset;
2959+ unsigned int dcnSize;
2960+ unsigned int evOffset;
2961+ unsigned int evSize;
2962+ unsigned int enOffset;
2963+ unsigned int enSize;
2964+ unsigned int esvOffset;
2965+ unsigned int esvSize;
2966+ unsigned int totalSize;
2967+ } dataMap_;
2968+ unsigned int bufferObjects_[2];
2969+ Program normalProgram_;
2970+ Program flatProgram_;
2971+ Program shadowProgram_;
2972+ std::string normalVertexShader_;
2973+ std::string normalFragmentShader_;
2974+ std::string flatVertexShader_;
2975+ std::string flatFragmentShader_;
2976+ std::string shadowVertexShader_;
2977+ std::string shadowFragmentShader_;
2978+ int normalNormalIndex_;
2979+ int normalVertexIndex_;
2980+ int flatVertexIndex_;
2981+ int shadowVertexIndex_;
2982+ int vertexIndex_;
2983+ static const std::string modelviewName_;
2984+ static const std::string projectionName_;
2985+ static const std::string lightPositionName_;
2986+ static const std::string logoColorName_;
2987+ static const std::string vertexAttribName_;
2988+ static const std::string normalAttribName_;
2989+ static const std::string normalMatrixName_;
2990+ // "Shadow" state
2991+ GLuint textureName_;
2992+ GLubyte textureImage_[32][32];
2993+ // This is the size in each direction of our texture image
2994+ static const unsigned int textureResolution_;
2995+ bool valid_;
2996+ DrawStyle drawStyle_;
2997+};
2998+
2999+#endif // LOGO_H_
3000
3001=== added file 'src/scene-ideas/m.cc'
3002--- src/scene-ideas/m.cc 1970-01-01 00:00:00 +0000
3003+++ src/scene-ideas/m.cc 2012-05-09 20:57:19 +0000
3004@@ -0,0 +1,210 @@
3005+/*
3006+ * Vertex position data describing the letter 'm'
3007+ *
3008+ * (c) Copyright 1993, Silicon Graphics, Inc.
3009+ * Copyright © 2012 Linaro Limited
3010+ *
3011+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3012+ *
3013+ * glmark2 is free software: you can redistribute it and/or modify it under the
3014+ * terms of the GNU General Public License as published by the Free Software
3015+ * Foundation, either version 3 of the License, or (at your option) any later
3016+ * version.
3017+ *
3018+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3019+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3020+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3021+ * details.
3022+ *
3023+ * You should have received a copy of the GNU General Public License along with
3024+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3025+ *
3026+ * Authors:
3027+ * Jesse Barker
3028+ */
3029+#include "characters.h"
3030+
3031+using LibMatrix::vec2;
3032+
3033+LetterM::LetterM()
3034+{
3035+ // Vertex data...
3036+ vertexData_.push_back(vec2(0.590769, 9.449335));
3037+ vertexData_.push_back(vec2(2.116923, 9.842375));
3038+ vertexData_.push_back(vec2(1.362051, 9.383828));
3039+ vertexData_.push_back(vec2(2.527179, 9.825998));
3040+ vertexData_.push_back(vec2(1.591795, 9.072672));
3041+ vertexData_.push_back(vec2(2.789744, 9.514841));
3042+ vertexData_.push_back(vec2(1.690256, 8.663255));
3043+ vertexData_.push_back(vec2(2.658462, 8.335722));
3044+ vertexData_.push_back(vec2(1.575385, 7.222108));
3045+ vertexData_.push_back(vec2(2.067692, 6.255886));
3046+ vertexData_.push_back(vec2(0.918974, 4.028659));
3047+ vertexData_.push_back(vec2(1.050256, 3.013306));
3048+ vertexData_.push_back(vec2(0.705641, 3.013306));
3049+ vertexData_.push_back(vec2(2.018461, 6.386899));
3050+ vertexData_.push_back(vec2(1.788718, 5.617196));
3051+ vertexData_.push_back(vec2(2.921026, 7.991812));
3052+ vertexData_.push_back(vec2(3.167180, 8.008188));
3053+ vertexData_.push_back(vec2(3.544615, 8.827022));
3054+ vertexData_.push_back(vec2(3.872821, 8.843398));
3055+ vertexData_.push_back(vec2(4.414359, 9.547595));
3056+ vertexData_.push_back(vec2(4.447179, 9.056294));
3057+ vertexData_.push_back(vec2(5.120000, 9.891504));
3058+ vertexData_.push_back(vec2(4.841026, 8.843398));
3059+ vertexData_.push_back(vec2(5.825641, 9.809621));
3060+ vertexData_.push_back(vec2(5.005128, 8.040941));
3061+ vertexData_.push_back(vec2(5.989744, 8.761515));
3062+ vertexData_.push_back(vec2(4.906667, 6.714432));
3063+ vertexData_.push_back(vec2(5.595897, 7.123848));
3064+ vertexData_.push_back(vec2(3.987692, 2.996929));
3065+ vertexData_.push_back(vec2(4.348718, 2.996929));
3066+ vertexData_.push_back(vec2(5.218462, 5.977482));
3067+ vertexData_.push_back(vec2(5.251282, 6.354146));
3068+ vertexData_.push_back(vec2(6.449231, 7.893552));
3069+ vertexData_.push_back(vec2(6.400000, 8.221085));
3070+ vertexData_.push_back(vec2(7.302564, 8.843398));
3071+ vertexData_.push_back(vec2(7.351795, 9.334698));
3072+ vertexData_.push_back(vec2(7.827693, 9.154554));
3073+ vertexData_.push_back(vec2(8.008205, 9.842375));
3074+ vertexData_.push_back(vec2(8.139487, 9.121801));
3075+ vertexData_.push_back(vec2(8.795897, 9.973388));
3076+ vertexData_.push_back(vec2(8.402051, 8.728762));
3077+ vertexData_.push_back(vec2(9.337436, 9.531218));
3078+ vertexData_.push_back(vec2(8.402051, 8.040941));
3079+ vertexData_.push_back(vec2(9.288205, 8.433982));
3080+ vertexData_.push_back(vec2(7.745641, 5.813715));
3081+ vertexData_.push_back(vec2(8.320000, 5.928352));
3082+ vertexData_.push_back(vec2(7.286154, 4.012282));
3083+ vertexData_.push_back(vec2(7.991795, 4.126919));
3084+ vertexData_.push_back(vec2(7.499487, 3.357216));
3085+ vertexData_.push_back(vec2(8.533334, 3.766633));
3086+ vertexData_.push_back(vec2(8.123077, 3.062436));
3087+ vertexData_.push_back(vec2(8.927179, 3.832139));
3088+ vertexData_.push_back(vec2(8.910769, 3.340839));
3089+ vertexData_.push_back(vec2(9.550769, 4.126919));
3090+
3091+ // Index data...
3092+ indexData_.push_back(0);
3093+ indexData_.push_back(2);
3094+ indexData_.push_back(4);
3095+ indexData_.push_back(6);
3096+ indexData_.push_back(8);
3097+ indexData_.push_back(10);
3098+ indexData_.push_back(12);
3099+ indexData_.push_back(11);
3100+ indexData_.push_back(9);
3101+ indexData_.push_back(7);
3102+ indexData_.push_back(5);
3103+ indexData_.push_back(3);
3104+ indexData_.push_back(1);
3105+ indexData_.push_back(14);
3106+ indexData_.push_back(16);
3107+ indexData_.push_back(18);
3108+ indexData_.push_back(20);
3109+ indexData_.push_back(22);
3110+ indexData_.push_back(24);
3111+ indexData_.push_back(26);
3112+ indexData_.push_back(28);
3113+ indexData_.push_back(29);
3114+ indexData_.push_back(27);
3115+ indexData_.push_back(25);
3116+ indexData_.push_back(23);
3117+ indexData_.push_back(21);
3118+ indexData_.push_back(19);
3119+ indexData_.push_back(17);
3120+ indexData_.push_back(15);
3121+ indexData_.push_back(13);
3122+ indexData_.push_back(30);
3123+ indexData_.push_back(32);
3124+ indexData_.push_back(34);
3125+ indexData_.push_back(36);
3126+ indexData_.push_back(38);
3127+ indexData_.push_back(40);
3128+ indexData_.push_back(42);
3129+ indexData_.push_back(44);
3130+ indexData_.push_back(46);
3131+ indexData_.push_back(48);
3132+ indexData_.push_back(50);
3133+ indexData_.push_back(52);
3134+ indexData_.push_back(53);
3135+ indexData_.push_back(51);
3136+ indexData_.push_back(49);
3137+ indexData_.push_back(47);
3138+ indexData_.push_back(45);
3139+ indexData_.push_back(43);
3140+ indexData_.push_back(41);
3141+ indexData_.push_back(39);
3142+ indexData_.push_back(37);
3143+ indexData_.push_back(35);
3144+ indexData_.push_back(33);
3145+ indexData_.push_back(31);
3146+ indexData_.push_back(0);
3147+ indexData_.push_back(1);
3148+ indexData_.push_back(2);
3149+ indexData_.push_back(3);
3150+ indexData_.push_back(4);
3151+ indexData_.push_back(5);
3152+ indexData_.push_back(6);
3153+ indexData_.push_back(7);
3154+ indexData_.push_back(8);
3155+ indexData_.push_back(9);
3156+ indexData_.push_back(10);
3157+ indexData_.push_back(11);
3158+ indexData_.push_back(12);
3159+ indexData_.push_back(13);
3160+ indexData_.push_back(14);
3161+ indexData_.push_back(15);
3162+ indexData_.push_back(16);
3163+ indexData_.push_back(17);
3164+ indexData_.push_back(18);
3165+ indexData_.push_back(19);
3166+ indexData_.push_back(20);
3167+ indexData_.push_back(21);
3168+ indexData_.push_back(22);
3169+ indexData_.push_back(23);
3170+ indexData_.push_back(24);
3171+ indexData_.push_back(25);
3172+ indexData_.push_back(26);
3173+ indexData_.push_back(27);
3174+ indexData_.push_back(28);
3175+ indexData_.push_back(29);
3176+ indexData_.push_back(30);
3177+ indexData_.push_back(31);
3178+ indexData_.push_back(32);
3179+ indexData_.push_back(33);
3180+ indexData_.push_back(34);
3181+ indexData_.push_back(35);
3182+ indexData_.push_back(36);
3183+ indexData_.push_back(37);
3184+ indexData_.push_back(38);
3185+ indexData_.push_back(39);
3186+ indexData_.push_back(40);
3187+ indexData_.push_back(41);
3188+ indexData_.push_back(42);
3189+ indexData_.push_back(43);
3190+ indexData_.push_back(44);
3191+ indexData_.push_back(45);
3192+ indexData_.push_back(46);
3193+ indexData_.push_back(47);
3194+ indexData_.push_back(48);
3195+ indexData_.push_back(49);
3196+ indexData_.push_back(50);
3197+ indexData_.push_back(51);
3198+ indexData_.push_back(52);
3199+ indexData_.push_back(53);
3200+
3201+ // Primitive state so that the draw call can issue the primitives we want.
3202+ unsigned int curOffset(0);
3203+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 13, curOffset));
3204+ curOffset += (13 * sizeof(unsigned int));
3205+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 17, curOffset));
3206+ curOffset += (17 * sizeof(unsigned int));
3207+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 24, curOffset));
3208+ curOffset += (24 * sizeof(unsigned int));
3209+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 13, curOffset));
3210+ curOffset += (13 * sizeof(unsigned int));
3211+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 17, curOffset));
3212+ curOffset += (17 * sizeof(unsigned int));
3213+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 24, curOffset));
3214+}
3215
3216=== added file 'src/scene-ideas/n.cc'
3217--- src/scene-ideas/n.cc 1970-01-01 00:00:00 +0000
3218+++ src/scene-ideas/n.cc 2012-05-09 20:57:19 +0000
3219@@ -0,0 +1,146 @@
3220+/*
3221+ * Vertex position data describing the letter 'o'
3222+ *
3223+ * (c) Copyright 1993, Silicon Graphics, Inc.
3224+ * Copyright © 2012 Linaro Limited
3225+ *
3226+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3227+ *
3228+ * glmark2 is free software: you can redistribute it and/or modify it under the
3229+ * terms of the GNU General Public License as published by the Free Software
3230+ * Foundation, either version 3 of the License, or (at your option) any later
3231+ * version.
3232+ *
3233+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3234+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3235+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3236+ * details.
3237+ *
3238+ * You should have received a copy of the GNU General Public License along with
3239+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3240+ *
3241+ * Authors:
3242+ * Jesse Barker
3243+ */
3244+#include "characters.h"
3245+
3246+using LibMatrix::vec2;
3247+
3248+LetterN::LetterN()
3249+{
3250+ // Vertex data...
3251+ vertexData_.push_back(vec2(1.009307, 9.444788));
3252+ vertexData_.push_back(vec2(2.548087, 9.742002));
3253+ vertexData_.push_back(vec2(1.737332, 9.213622));
3254+ vertexData_.push_back(vec2(2.994829, 9.659443));
3255+ vertexData_.push_back(vec2(1.985522, 8.751290));
3256+ vertexData_.push_back(vec2(3.127198, 9.180598));
3257+ vertexData_.push_back(vec2(1.935884, 7.975232));
3258+ vertexData_.push_back(vec2(2.481903, 6.571723));
3259+ vertexData_.push_back(vec2(1.472596, 5.019608));
3260+ vertexData_.push_back(vec2(1.439504, 2.988648));
3261+ vertexData_.push_back(vec2(1.025853, 2.988648));
3262+ vertexData_.push_back(vec2(2.283350, 6.059855));
3263+ vertexData_.push_back(vec2(2.035160, 5.366357));
3264+ vertexData_.push_back(vec2(3.292658, 7.711042));
3265+ vertexData_.push_back(vec2(3.540848, 7.744066));
3266+ vertexData_.push_back(vec2(4.384695, 9.031992));
3267+ vertexData_.push_back(vec2(4.699069, 8.916409));
3268+ vertexData_.push_back(vec2(5.609100, 9.808049));
3269+ vertexData_.push_back(vec2(5.145812, 8.982456));
3270+ vertexData_.push_back(vec2(6.155119, 9.791537));
3271+ vertexData_.push_back(vec2(5.410548, 8.635707));
3272+ vertexData_.push_back(vec2(6.337125, 9.312694));
3273+ vertexData_.push_back(vec2(5.360910, 7.991744));
3274+ vertexData_.push_back(vec2(6.088935, 8.090816));
3275+ vertexData_.push_back(vec2(4.947259, 5.977296));
3276+ vertexData_.push_back(vec2(5.261634, 4.804954));
3277+ vertexData_.push_back(vec2(4.616339, 4.028896));
3278+ vertexData_.push_back(vec2(5.211996, 3.962848));
3279+ vertexData_.push_back(vec2(4.732162, 3.318886));
3280+ vertexData_.push_back(vec2(5.559462, 3.814241));
3281+ vertexData_.push_back(vec2(5.228542, 3.038184));
3282+ vertexData_.push_back(vec2(5.940021, 3.814241));
3283+ vertexData_.push_back(vec2(5.906929, 3.335397));
3284+ vertexData_.push_back(vec2(6.684591, 4.094943));
3285+
3286+ // Index data...
3287+ indexData_.push_back(0);
3288+ indexData_.push_back(1);
3289+ indexData_.push_back(2);
3290+ indexData_.push_back(3);
3291+ indexData_.push_back(4);
3292+ indexData_.push_back(5);
3293+ indexData_.push_back(6);
3294+ indexData_.push_back(7);
3295+ indexData_.push_back(8);
3296+ indexData_.push_back(9);
3297+ indexData_.push_back(10);
3298+ indexData_.push_back(11);
3299+ indexData_.push_back(12);
3300+ indexData_.push_back(13);
3301+ indexData_.push_back(14);
3302+ indexData_.push_back(15);
3303+ indexData_.push_back(16);
3304+ indexData_.push_back(17);
3305+ indexData_.push_back(18);
3306+ indexData_.push_back(19);
3307+ indexData_.push_back(20);
3308+ indexData_.push_back(21);
3309+ indexData_.push_back(22);
3310+ indexData_.push_back(23);
3311+ indexData_.push_back(24);
3312+ indexData_.push_back(25);
3313+ indexData_.push_back(26);
3314+ indexData_.push_back(27);
3315+ indexData_.push_back(28);
3316+ indexData_.push_back(29);
3317+ indexData_.push_back(30);
3318+ indexData_.push_back(31);
3319+ indexData_.push_back(32);
3320+ indexData_.push_back(33);
3321+ indexData_.push_back(0);
3322+ indexData_.push_back(2);
3323+ indexData_.push_back(4);
3324+ indexData_.push_back(6);
3325+ indexData_.push_back(8);
3326+ indexData_.push_back(10);
3327+ indexData_.push_back(9);
3328+ indexData_.push_back(7);
3329+ indexData_.push_back(5);
3330+ indexData_.push_back(3);
3331+ indexData_.push_back(1);
3332+ indexData_.push_back(12);
3333+ indexData_.push_back(14);
3334+ indexData_.push_back(16);
3335+ indexData_.push_back(18);
3336+ indexData_.push_back(20);
3337+ indexData_.push_back(22);
3338+ indexData_.push_back(24);
3339+ indexData_.push_back(26);
3340+ indexData_.push_back(28);
3341+ indexData_.push_back(30);
3342+ indexData_.push_back(32);
3343+ indexData_.push_back(33);
3344+ indexData_.push_back(31);
3345+ indexData_.push_back(29);
3346+ indexData_.push_back(27);
3347+ indexData_.push_back(25);
3348+ indexData_.push_back(23);
3349+ indexData_.push_back(21);
3350+ indexData_.push_back(19);
3351+ indexData_.push_back(17);
3352+ indexData_.push_back(15);
3353+ indexData_.push_back(13);
3354+ indexData_.push_back(11);
3355+
3356+ // Primitive state so that the draw call can issue the primitives we want.
3357+ unsigned int curOffset(0);
3358+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 11, curOffset));
3359+ curOffset += (11 * sizeof(unsigned int));
3360+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 23, curOffset));
3361+ curOffset += (23 * sizeof(unsigned int));
3362+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 11, curOffset));
3363+ curOffset += (11 * sizeof(unsigned int));
3364+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 23, curOffset));
3365+}
3366
3367=== added file 'src/scene-ideas/o.cc'
3368--- src/scene-ideas/o.cc 1970-01-01 00:00:00 +0000
3369+++ src/scene-ideas/o.cc 2012-05-09 20:57:19 +0000
3370@@ -0,0 +1,139 @@
3371+/*
3372+ * Vertex position data describing the letter 'o'
3373+ *
3374+ * (c) Copyright 1993, Silicon Graphics, Inc.
3375+ * Copyright © 2012 Linaro Limited
3376+ *
3377+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3378+ *
3379+ * glmark2 is free software: you can redistribute it and/or modify it under the
3380+ * terms of the GNU General Public License as published by the Free Software
3381+ * Foundation, either version 3 of the License, or (at your option) any later
3382+ * version.
3383+ *
3384+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3385+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3386+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3387+ * details.
3388+ *
3389+ * You should have received a copy of the GNU General Public License along with
3390+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3391+ *
3392+ * Authors:
3393+ * Jesse Barker
3394+ */
3395+#include "characters.h"
3396+
3397+using LibMatrix::vec2;
3398+
3399+LetterO::LetterO()
3400+{
3401+ // Vertex data...
3402+ vertexData_.push_back(vec2(2.975610, 9.603255));
3403+ vertexData_.push_back(vec2(2.878049, 9.342828));
3404+ vertexData_.push_back(vec2(2.292683, 9.131231));
3405+ vertexData_.push_back(vec2(2.048780, 8.691760));
3406+ vertexData_.push_back(vec2(1.707317, 8.528993));
3407+ vertexData_.push_back(vec2(1.658537, 7.731434));
3408+ vertexData_.push_back(vec2(0.878049, 7.047813));
3409+ vertexData_.push_back(vec2(1.349594, 5.550356));
3410+ vertexData_.push_back(vec2(0.569106, 5.029501));
3411+ vertexData_.push_back(vec2(1.528455, 4.443540));
3412+ vertexData_.push_back(vec2(0.991870, 3.434385));
3413+ vertexData_.push_back(vec2(1.967480, 3.955239));
3414+ vertexData_.push_back(vec2(1.772358, 2.994914));
3415+ vertexData_.push_back(vec2(2.422764, 3.825025));
3416+ vertexData_.push_back(vec2(2.829268, 3.092574));
3417+ vertexData_.push_back(vec2(3.154472, 3.971516));
3418+ vertexData_.push_back(vec2(3.512195, 3.727365));
3419+ vertexData_.push_back(vec2(3.772358, 4.264496));
3420+ vertexData_.push_back(vec2(4.130081, 4.524924));
3421+ vertexData_.push_back(vec2(4.162601, 4.996948));
3422+ vertexData_.push_back(vec2(4.699187, 5.403866));
3423+ vertexData_.push_back(vec2(4.471545, 6.461852));
3424+ vertexData_.push_back(vec2(5.219512, 7.243133));
3425+ vertexData_.push_back(vec2(4.439024, 8.105799));
3426+ vertexData_.push_back(vec2(5.235772, 8.756866));
3427+ vertexData_.push_back(vec2(4.065041, 8.870804));
3428+ vertexData_.push_back(vec2(4.991870, 9.391658));
3429+ vertexData_.push_back(vec2(3.853658, 9.228891));
3430+ vertexData_.push_back(vec2(4.390244, 9.912513));
3431+ vertexData_.push_back(vec2(3.463415, 9.407935));
3432+ vertexData_.push_back(vec2(3.674797, 9.912513));
3433+ vertexData_.push_back(vec2(2.829268, 9.342828));
3434+ vertexData_.push_back(vec2(2.959350, 9.603255));
3435+
3436+ // Index data...
3437+ indexData_.push_back(0);
3438+ indexData_.push_back(1);
3439+ indexData_.push_back(2);
3440+ indexData_.push_back(3);
3441+ indexData_.push_back(4);
3442+ indexData_.push_back(5);
3443+ indexData_.push_back(6);
3444+ indexData_.push_back(7);
3445+ indexData_.push_back(8);
3446+ indexData_.push_back(9);
3447+ indexData_.push_back(10);
3448+ indexData_.push_back(11);
3449+ indexData_.push_back(12);
3450+ indexData_.push_back(13);
3451+ indexData_.push_back(14);
3452+ indexData_.push_back(15);
3453+ indexData_.push_back(16);
3454+ indexData_.push_back(17);
3455+ indexData_.push_back(18);
3456+ indexData_.push_back(19);
3457+ indexData_.push_back(20);
3458+ indexData_.push_back(21);
3459+ indexData_.push_back(22);
3460+ indexData_.push_back(23);
3461+ indexData_.push_back(24);
3462+ indexData_.push_back(25);
3463+ indexData_.push_back(26);
3464+ indexData_.push_back(27);
3465+ indexData_.push_back(28);
3466+ indexData_.push_back(29);
3467+ indexData_.push_back(30);
3468+ indexData_.push_back(31);
3469+ indexData_.push_back(32);
3470+ indexData_.push_back(0);
3471+ indexData_.push_back(2);
3472+ indexData_.push_back(4);
3473+ indexData_.push_back(6);
3474+ indexData_.push_back(8);
3475+ indexData_.push_back(10);
3476+ indexData_.push_back(12);
3477+ indexData_.push_back(14);
3478+ indexData_.push_back(16);
3479+ indexData_.push_back(18);
3480+ indexData_.push_back(20);
3481+ indexData_.push_back(22);
3482+ indexData_.push_back(24);
3483+ indexData_.push_back(26);
3484+ indexData_.push_back(28);
3485+ indexData_.push_back(30);
3486+ indexData_.push_back(32);
3487+ indexData_.push_back(31);
3488+ indexData_.push_back(29);
3489+ indexData_.push_back(27);
3490+ indexData_.push_back(25);
3491+ indexData_.push_back(23);
3492+ indexData_.push_back(21);
3493+ indexData_.push_back(19);
3494+ indexData_.push_back(17);
3495+ indexData_.push_back(15);
3496+ indexData_.push_back(13);
3497+ indexData_.push_back(11);
3498+ indexData_.push_back(9);
3499+ indexData_.push_back(7);
3500+ indexData_.push_back(5);
3501+ indexData_.push_back(3);
3502+ indexData_.push_back(1);
3503+
3504+ // Primitive state so that the draw call can issue the primitives we want.
3505+ unsigned int curOffset(0);
3506+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 33, curOffset));
3507+ curOffset += (33 * sizeof(unsigned int));
3508+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 33, curOffset));
3509+}
3510
3511=== added file 'src/scene-ideas/s.cc'
3512--- src/scene-ideas/s.cc 1970-01-01 00:00:00 +0000
3513+++ src/scene-ideas/s.cc 2012-05-09 20:57:19 +0000
3514@@ -0,0 +1,130 @@
3515+/*
3516+ * Vertex position data describing the letter 's'
3517+ *
3518+ * (c) Copyright 1993, Silicon Graphics, Inc.
3519+ * Copyright © 2012 Linaro Limited
3520+ *
3521+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3522+ *
3523+ * glmark2 is free software: you can redistribute it and/or modify it under the
3524+ * terms of the GNU General Public License as published by the Free Software
3525+ * Foundation, either version 3 of the License, or (at your option) any later
3526+ * version.
3527+ *
3528+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3529+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3530+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3531+ * details.
3532+ *
3533+ * You should have received a copy of the GNU General Public License along with
3534+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3535+ *
3536+ * Authors:
3537+ * Jesse Barker
3538+ */
3539+#include "characters.h"
3540+
3541+using LibMatrix::vec2;
3542+
3543+LetterS::LetterS()
3544+{
3545+ // Vertex data...
3546+ vertexData_.push_back(vec2(0.860393, 5.283798));
3547+ vertexData_.push_back(vec2(0.529473, 3.550052));
3548+ vertexData_.push_back(vec2(0.992761, 4.491228));
3549+ vertexData_.push_back(vec2(0.910031, 3.368421));
3550+ vertexData_.push_back(vec2(1.240951, 3.830753));
3551+ vertexData_.push_back(vec2(1.456050, 3.104231));
3552+ vertexData_.push_back(vec2(1.935884, 3.517028));
3553+ vertexData_.push_back(vec2(2.002068, 2.988648));
3554+ vertexData_.push_back(vec2(2.763185, 3.533540));
3555+ vertexData_.push_back(vec2(3.061013, 3.120743));
3556+ vertexData_.push_back(vec2(3.391934, 3.748194));
3557+ vertexData_.push_back(vec2(4.053774, 3.632611));
3558+ vertexData_.push_back(vec2(3.822130, 4.540764));
3559+ vertexData_.push_back(vec2(4.550155, 4.590299));
3560+ vertexData_.push_back(vec2(3.656670, 5.465428));
3561+ vertexData_.push_back(vec2(4.517063, 5.713106));
3562+ vertexData_.push_back(vec2(3.276112, 5.894737));
3563+ vertexData_.push_back(vec2(3.921407, 6.538700));
3564+ vertexData_.push_back(vec2(2.299896, 6.736842));
3565+ vertexData_.push_back(vec2(3.044467, 7.430341));
3566+ vertexData_.push_back(vec2(1.886246, 7.496388));
3567+ vertexData_.push_back(vec2(2.581179, 8.222910));
3568+ vertexData_.push_back(vec2(1.902792, 8.751290));
3569+ vertexData_.push_back(vec2(2.680455, 8.883385));
3570+ vertexData_.push_back(vec2(2.283350, 9.312694));
3571+ vertexData_.push_back(vec2(3.358842, 9.609907));
3572+ vertexData_.push_back(vec2(3.507756, 9.907121));
3573+ vertexData_.push_back(vec2(4.285419, 9.758514));
3574+ vertexData_.push_back(vec2(5.112720, 9.973168));
3575+ vertexData_.push_back(vec2(4.748707, 9.593395));
3576+
3577+ // Index data...
3578+ indexData_.push_back(0);
3579+ indexData_.push_back(1);
3580+ indexData_.push_back(2);
3581+ indexData_.push_back(3);
3582+ indexData_.push_back(4);
3583+ indexData_.push_back(5);
3584+ indexData_.push_back(6);
3585+ indexData_.push_back(7);
3586+ indexData_.push_back(8);
3587+ indexData_.push_back(9);
3588+ indexData_.push_back(10);
3589+ indexData_.push_back(11);
3590+ indexData_.push_back(12);
3591+ indexData_.push_back(13);
3592+ indexData_.push_back(14);
3593+ indexData_.push_back(15);
3594+ indexData_.push_back(16);
3595+ indexData_.push_back(17);
3596+ indexData_.push_back(18);
3597+ indexData_.push_back(19);
3598+ indexData_.push_back(20);
3599+ indexData_.push_back(21);
3600+ indexData_.push_back(22);
3601+ indexData_.push_back(23);
3602+ indexData_.push_back(24);
3603+ indexData_.push_back(25);
3604+ indexData_.push_back(26);
3605+ indexData_.push_back(27);
3606+ indexData_.push_back(28);
3607+ indexData_.push_back(29);
3608+ indexData_.push_back(0);
3609+ indexData_.push_back(2);
3610+ indexData_.push_back(4);
3611+ indexData_.push_back(6);
3612+ indexData_.push_back(8);
3613+ indexData_.push_back(10);
3614+ indexData_.push_back(12);
3615+ indexData_.push_back(14);
3616+ indexData_.push_back(16);
3617+ indexData_.push_back(18);
3618+ indexData_.push_back(20);
3619+ indexData_.push_back(22);
3620+ indexData_.push_back(24);
3621+ indexData_.push_back(26);
3622+ indexData_.push_back(28);
3623+ indexData_.push_back(29);
3624+ indexData_.push_back(27);
3625+ indexData_.push_back(25);
3626+ indexData_.push_back(23);
3627+ indexData_.push_back(21);
3628+ indexData_.push_back(19);
3629+ indexData_.push_back(17);
3630+ indexData_.push_back(15);
3631+ indexData_.push_back(13);
3632+ indexData_.push_back(11);
3633+ indexData_.push_back(9);
3634+ indexData_.push_back(7);
3635+ indexData_.push_back(5);
3636+ indexData_.push_back(3);
3637+ indexData_.push_back(1);
3638+
3639+ // Primitive state so that the draw call can issue the primitives we want.
3640+ unsigned int curOffset(0);
3641+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 30, curOffset));
3642+ curOffset += (30 * sizeof(unsigned int));
3643+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 30, curOffset));
3644+}
3645
3646=== added file 'src/scene-ideas/splines.cc'
3647--- src/scene-ideas/splines.cc 1970-01-01 00:00:00 +0000
3648+++ src/scene-ideas/splines.cc 2012-05-09 20:57:19 +0000
3649@@ -0,0 +1,200 @@
3650+/*
3651+ * (c) Copyright 1993, Silicon Graphics, Inc.
3652+ * Copyright © 2012 Linaro Limited
3653+ *
3654+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3655+ *
3656+ * glmark2 is free software: you can redistribute it and/or modify it under the
3657+ * terms of the GNU General Public License as published by the Free Software
3658+ * Foundation, either version 3 of the License, or (at your option) any later
3659+ * version.
3660+ *
3661+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3662+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3663+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3664+ * details.
3665+ *
3666+ * You should have received a copy of the GNU General Public License along with
3667+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3668+ *
3669+ * Authors:
3670+ * Jesse Barker
3671+ */
3672+#include "splines.h"
3673+
3674+using LibMatrix::vec3;
3675+
3676+void
3677+Spline::calcParams()
3678+{
3679+ unsigned int numParams(controlData_.size() - 3);
3680+ paramData_ = new param[numParams];
3681+ for (unsigned int i = 0; i < numParams; i++)
3682+ {
3683+ float x3(controlData_[i + 1].x());
3684+ float x2(controlData_[i + 2].x() - controlData_[i].x());
3685+ float x1(2.0 * controlData_[i].x() +
3686+ -2.0 * controlData_[i+1].x() +
3687+ 1.0 * controlData_[i+2].x() +
3688+ -1.0 * controlData_[i+3].x());
3689+ float x0(-1.0 * controlData_[i].x() +
3690+ 1.0 * controlData_[i+1].x() +
3691+ -1.0 * controlData_[i+2].x() +
3692+ 1.0 * controlData_[i+3].x());
3693+ float y3(controlData_[i + 1].y());
3694+ float y2(controlData_[i + 2].y() - controlData_[i].y());
3695+ float y1(2.0 * controlData_[i].y() +
3696+ -2.0 * controlData_[i+1].y() +
3697+ 1.0 * controlData_[i+2].y() +
3698+ -1.0 * controlData_[i+3].y());
3699+ float y0(-1.0 * controlData_[i].y() +
3700+ 1.0 * controlData_[i+1].y() +
3701+ -1.0 * controlData_[i+2].y() +
3702+ 1.0 * controlData_[i+3].y());
3703+ float z3(controlData_[i + 1].z());
3704+ float z2(controlData_[i + 2].z() - controlData_[i].z());
3705+ float z1(2.0 * controlData_[i].z() +
3706+ -2.0 * controlData_[i+1].z() +
3707+ 1.0 * controlData_[i+2].z() +
3708+ -1.0 * controlData_[i+3].z());
3709+ float z0(-1.0 * controlData_[i].z() +
3710+ 1.0 * controlData_[i+1].z() +
3711+ -1.0 * controlData_[i+2].z() +
3712+ 1.0 * controlData_[i+3].z());
3713+ paramData_[i][3].x(x3);
3714+ paramData_[i][2].x(x2);
3715+ paramData_[i][1].x(x1);
3716+ paramData_[i][0].x(x0);
3717+ paramData_[i][3].y(y3);
3718+ paramData_[i][2].y(y2);
3719+ paramData_[i][1].y(y1);
3720+ paramData_[i][0].y(y0);
3721+ paramData_[i][3].z(z3);
3722+ paramData_[i][2].z(z2);
3723+ paramData_[i][1].z(z1);
3724+ paramData_[i][0].z(z0);
3725+ }
3726+}
3727+
3728+void
3729+Spline::getCurrentVec(float currentTime, vec3& v) const
3730+{
3731+ unsigned int integerTime(static_cast<unsigned int>(currentTime));
3732+ float t(currentTime - static_cast<float>(integerTime));
3733+ v.x(paramData_[integerTime][3].x() +
3734+ paramData_[integerTime][2].x() * t +
3735+ paramData_[integerTime][1].x() * t * t +
3736+ paramData_[integerTime][0].x() * t * t * t);
3737+ v.y(paramData_[integerTime][3].y() +
3738+ paramData_[integerTime][2].y() * t +
3739+ paramData_[integerTime][1].y() * t * t +
3740+ paramData_[integerTime][0].y() * t * t * t);
3741+ v.z(paramData_[integerTime][3].z() +
3742+ paramData_[integerTime][2].z() * t +
3743+ paramData_[integerTime][1].z() * t * t +
3744+ paramData_[integerTime][0].z() * t * t * t);
3745+}
3746+
3747+ViewFromSpline::ViewFromSpline()
3748+{
3749+ addControlPoint(vec3(-1.0, 1.0, -4.0));
3750+ addControlPoint(vec3(-1.0, -3.0, -4.0));
3751+ addControlPoint(vec3(-3.0, 1.0, -3.0));
3752+ addControlPoint(vec3(-1.8, 2.0, 5.4));
3753+ addControlPoint(vec3(-0.4, 2.0, 1.2));
3754+ addControlPoint(vec3(-0.2, 1.5, 0.6));
3755+ addControlPoint(vec3(-0.2, 1.2, 0.6));
3756+ addControlPoint(vec3(-0.8, 1.0, 2.4));
3757+ addControlPoint(vec3(-1.0, 2.0, 3.0));
3758+ addControlPoint(vec3(0.0, 4.0, 3.6));
3759+ addControlPoint(vec3(-0.8, 4.0, 1.2));
3760+ addControlPoint(vec3(-0.2, 3.0, 0.6));
3761+ addControlPoint(vec3(-0.1, 2.0, 0.3));
3762+ addControlPoint(vec3(-0.1, 2.0, 0.3));
3763+ addControlPoint(vec3(-0.1, 2.0, 0.3));
3764+ addControlPoint(vec3(-0.1, 2.0, 0.3));
3765+ calcParams();
3766+}
3767+
3768+ViewToSpline::ViewToSpline()
3769+{
3770+ addControlPoint(vec3(-1.0, 1.0, 0.0));
3771+ addControlPoint(vec3(-1.0, -3.0, 0.0));
3772+ addControlPoint(vec3(-1.0, 1.0, 0.0));
3773+ addControlPoint(vec3(0.1, 0.0, -0.3));
3774+ addControlPoint(vec3(0.1, 0.0, -0.3));
3775+ addControlPoint(vec3(0.1, 0.0, -0.3));
3776+ addControlPoint(vec3(0.0, 0.2, 0.0));
3777+ addControlPoint(vec3(0.0, 0.6, 0.0));
3778+ addControlPoint(vec3(0.0, 0.8, 0.0));
3779+ addControlPoint(vec3(0.0, 0.8, 0.0));
3780+ addControlPoint(vec3(0.0, 0.8, 0.0));
3781+ addControlPoint(vec3(0.0, 0.8, 0.0));
3782+ addControlPoint(vec3(0.0, 0.8, 0.0));
3783+ addControlPoint(vec3(0.0, 0.8, 0.0));
3784+ addControlPoint(vec3(0.0, 0.8, 0.0));
3785+ addControlPoint(vec3(0.0, 0.8, 0.0));
3786+ calcParams();
3787+}
3788+
3789+LightPositionSpline::LightPositionSpline()
3790+{
3791+ addControlPoint(vec3(0.0, 1.8, 0.0));
3792+ addControlPoint(vec3(0.0, 1.8, 0.0));
3793+ addControlPoint(vec3(0.0, 1.6, 0.0));
3794+ addControlPoint(vec3(0.0, 1.6, 0.0));
3795+ addControlPoint(vec3(0.0, 1.6, 0.0));
3796+ addControlPoint(vec3(0.0, 1.6, 0.0));
3797+ addControlPoint(vec3(0.0, 1.4, 0.0));
3798+ addControlPoint(vec3(0.0, 1.3, 0.0));
3799+ addControlPoint(vec3(-0.2, 1.5, 2.0));
3800+ addControlPoint(vec3(0.8, 1.5, -0.4));
3801+ addControlPoint(vec3(-0.8, 1.5, -0.4));
3802+ addControlPoint(vec3(0.8, 2.0, 1.0));
3803+ addControlPoint(vec3(1.8, 5.0, -1.8));
3804+ addControlPoint(vec3(8.0, 10.0, -4.0));
3805+ addControlPoint(vec3(8.0, 10.0, -4.0));
3806+ addControlPoint(vec3(8.0, 10.0, -4.0));
3807+ calcParams();
3808+}
3809+
3810+LogoPositionSpline::LogoPositionSpline()
3811+{
3812+ addControlPoint(vec3(0.0, -0.5, 0.0));
3813+ addControlPoint(vec3(0.0, -0.5, 0.0));
3814+ addControlPoint(vec3(0.0, -0.5, 0.0));
3815+ addControlPoint(vec3(0.0, -0.5, 0.0));
3816+ addControlPoint(vec3(0.0, -0.5, 0.0));
3817+ addControlPoint(vec3(0.0, -0.5, 0.0));
3818+ addControlPoint(vec3(0.0, 0.0, 0.0));
3819+ addControlPoint(vec3(0.0, 0.6, 0.0));
3820+ addControlPoint(vec3(0.0, 0.75, 0.0));
3821+ addControlPoint(vec3(0.0, 0.8, 0.0));
3822+ addControlPoint(vec3(0.0, 0.8, 0.0));
3823+ addControlPoint(vec3(0.0, 0.5, 0.0));
3824+ addControlPoint(vec3(0.0, 0.5, 0.0));
3825+ addControlPoint(vec3(0.0, 0.5, 0.0));
3826+ addControlPoint(vec3(0.0, 0.5, 0.0));
3827+ addControlPoint(vec3(0.0, 0.5, 0.0));
3828+ calcParams();
3829+}
3830+
3831+LogoRotationSpline::LogoRotationSpline()
3832+{
3833+ addControlPoint(vec3(0.0, 0.0, -18.4));
3834+ addControlPoint(vec3(0.0, 0.0, -18.4));
3835+ addControlPoint(vec3(0.0, 0.0, -18.4));
3836+ addControlPoint(vec3(0.0, 0.0, -18.4));
3837+ addControlPoint(vec3(0.0, 0.0, -18.4));
3838+ addControlPoint(vec3(0.0, 0.0, -18.4));
3839+ addControlPoint(vec3(0.0, 0.0, -18.4));
3840+ addControlPoint(vec3(0.0, 0.0, -18.4));
3841+ addControlPoint(vec3(240.0, 360.0, 180.0));
3842+ addControlPoint(vec3(90.0, 180.0, 90.0));
3843+ addControlPoint(vec3(11.9, 0.0, -18.4));
3844+ addControlPoint(vec3(11.9, 0.0, -18.4));
3845+ addControlPoint(vec3(11.9, 0.0, -18.4));
3846+ addControlPoint(vec3(11.9, 0.0, -18.4));
3847+ addControlPoint(vec3(11.9, 0.0, -18.4));
3848+ calcParams();
3849+}
3850
3851=== added file 'src/scene-ideas/splines.h'
3852--- src/scene-ideas/splines.h 1970-01-01 00:00:00 +0000
3853+++ src/scene-ideas/splines.h 2012-05-09 20:57:19 +0000
3854@@ -0,0 +1,83 @@
3855+/*
3856+ * (c) Copyright 1993, Silicon Graphics, Inc.
3857+ * Copyright © 2012 Linaro Limited
3858+ *
3859+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3860+ *
3861+ * glmark2 is free software: you can redistribute it and/or modify it under the
3862+ * terms of the GNU General Public License as published by the Free Software
3863+ * Foundation, either version 3 of the License, or (at your option) any later
3864+ * version.
3865+ *
3866+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3867+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3868+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3869+ * details.
3870+ *
3871+ * You should have received a copy of the GNU General Public License along with
3872+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3873+ *
3874+ * Authors:
3875+ * Jesse Barker
3876+ */
3877+#ifndef SPLINES_H_
3878+#define SPLINES_H_
3879+
3880+#include <vector>
3881+#include "vec.h"
3882+
3883+class Spline
3884+{
3885+public:
3886+ Spline() :
3887+ paramData_(0) {}
3888+ ~Spline()
3889+ {
3890+ delete [] paramData_;
3891+ }
3892+ void addControlPoint(const LibMatrix::vec3& point) { controlData_.push_back(point); }
3893+ void getCurrentVec(float currentTime, LibMatrix::vec3& v) const;
3894+ void calcParams();
3895+
3896+private:
3897+ std::vector<LibMatrix::vec3> controlData_;
3898+ typedef LibMatrix::vec3 param[4];
3899+ param* paramData_;
3900+};
3901+
3902+class ViewFromSpline : public Spline
3903+{
3904+public:
3905+ ViewFromSpline();
3906+ ~ViewFromSpline() {}
3907+};
3908+
3909+class ViewToSpline : public Spline
3910+{
3911+public:
3912+ ViewToSpline();
3913+ ~ViewToSpline() {}
3914+};
3915+
3916+class LightPositionSpline : public Spline
3917+{
3918+public:
3919+ LightPositionSpline();
3920+ ~LightPositionSpline() {}
3921+};
3922+
3923+class LogoPositionSpline : public Spline
3924+{
3925+public:
3926+ LogoPositionSpline();
3927+ ~LogoPositionSpline() {}
3928+};
3929+
3930+class LogoRotationSpline : public Spline
3931+{
3932+public:
3933+ LogoRotationSpline();
3934+ ~LogoRotationSpline() {}
3935+};
3936+
3937+#endif // SPLINES_H_
3938
3939=== added file 'src/scene-ideas/t.cc'
3940--- src/scene-ideas/t.cc 1970-01-01 00:00:00 +0000
3941+++ src/scene-ideas/t.cc 2012-05-09 20:57:19 +0000
3942@@ -0,0 +1,147 @@
3943+/*
3944+ * Vertex position data describing the letter 't'
3945+ *
3946+ * (c) Copyright 1993, Silicon Graphics, Inc.
3947+ * Copyright © 2012 Linaro Limited
3948+ *
3949+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
3950+ *
3951+ * glmark2 is free software: you can redistribute it and/or modify it under the
3952+ * terms of the GNU General Public License as published by the Free Software
3953+ * Foundation, either version 3 of the License, or (at your option) any later
3954+ * version.
3955+ *
3956+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
3957+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
3958+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
3959+ * details.
3960+ *
3961+ * You should have received a copy of the GNU General Public License along with
3962+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
3963+ *
3964+ * Authors:
3965+ * Jesse Barker
3966+ */
3967+#include "characters.h"
3968+
3969+using LibMatrix::vec2;
3970+
3971+LetterT::LetterT()
3972+{
3973+ // Vertex data...
3974+ vertexData_.push_back(vec2(2.986667, 14.034801));
3975+ vertexData_.push_back(vec2(2.445128, 10.088024));
3976+ vertexData_.push_back(vec2(1.788718, 9.236438));
3977+ vertexData_.push_back(vec2(2.264615, 7.664279));
3978+ vertexData_.push_back(vec2(1.165128, 5.666326));
3979+ vertexData_.push_back(vec2(2.034872, 4.945752));
3980+ vertexData_.push_back(vec2(1.132308, 3.766633));
3981+ vertexData_.push_back(vec2(2.182564, 3.570113));
3982+ vertexData_.push_back(vec2(1.411282, 2.309109));
3983+ vertexData_.push_back(vec2(2.510769, 2.341863));
3984+ vertexData_.push_back(vec2(2.149744, 1.048106));
3985+ vertexData_.push_back(vec2(3.364103, 1.375640));
3986+ vertexData_.push_back(vec2(3.167180, 0.327533));
3987+ vertexData_.push_back(vec2(4.381538, 0.736950));
3988+ vertexData_.push_back(vec2(5.005128, 0.032753));
3989+ vertexData_.push_back(vec2(5.612308, 0.638690));
3990+ vertexData_.push_back(vec2(6.235898, 0.540430));
3991+ vertexData_.push_back(vec2(7.187692, 1.162743));
3992+ vertexData_.push_back(vec2(1.985641, 9.039918));
3993+ vertexData_.push_back(vec2(2.133333, 10.186285));
3994+ vertexData_.push_back(vec2(1.509744, 9.023541));
3995+ vertexData_.push_back(vec2(1.608205, 9.662231));
3996+ vertexData_.push_back(vec2(1.050256, 9.023541));
3997+ vertexData_.push_back(vec2(1.050256, 9.334698));
3998+ vertexData_.push_back(vec2(0.196923, 9.007165));
3999+ vertexData_.push_back(vec2(2.363077, 9.711361));
4000+ vertexData_.push_back(vec2(2.264615, 9.023541));
4001+ vertexData_.push_back(vec2(3.282051, 9.563972));
4002+ vertexData_.push_back(vec2(3.446154, 9.023541));
4003+ vertexData_.push_back(vec2(4.069744, 9.531218));
4004+ vertexData_.push_back(vec2(4.299487, 9.236438));
4005+ vertexData_.push_back(vec2(4.644103, 9.613101));
4006+ vertexData_.push_back(vec2(5.251282, 9.875128));
4007+
4008+ // Index data...
4009+ indexData_.push_back(0);
4010+ indexData_.push_back(1);
4011+ indexData_.push_back(2);
4012+ indexData_.push_back(3);
4013+ indexData_.push_back(4);
4014+ indexData_.push_back(5);
4015+ indexData_.push_back(6);
4016+ indexData_.push_back(7);
4017+ indexData_.push_back(8);
4018+ indexData_.push_back(9);
4019+ indexData_.push_back(10);
4020+ indexData_.push_back(11);
4021+ indexData_.push_back(12);
4022+ indexData_.push_back(13);
4023+ indexData_.push_back(14);
4024+ indexData_.push_back(15);
4025+ indexData_.push_back(16);
4026+ indexData_.push_back(17);
4027+ indexData_.push_back(18);
4028+ indexData_.push_back(19);
4029+ indexData_.push_back(20);
4030+ indexData_.push_back(21);
4031+ indexData_.push_back(22);
4032+ indexData_.push_back(23);
4033+ indexData_.push_back(24);
4034+ indexData_.push_back(25);
4035+ indexData_.push_back(26);
4036+ indexData_.push_back(27);
4037+ indexData_.push_back(28);
4038+ indexData_.push_back(29);
4039+ indexData_.push_back(30);
4040+ indexData_.push_back(31);
4041+ indexData_.push_back(32);
4042+ indexData_.push_back(0);
4043+ indexData_.push_back(2);
4044+ indexData_.push_back(4);
4045+ indexData_.push_back(6);
4046+ indexData_.push_back(8);
4047+ indexData_.push_back(10);
4048+ indexData_.push_back(12);
4049+ indexData_.push_back(14);
4050+ indexData_.push_back(16);
4051+ indexData_.push_back(17);
4052+ indexData_.push_back(15);
4053+ indexData_.push_back(13);
4054+ indexData_.push_back(11);
4055+ indexData_.push_back(9);
4056+ indexData_.push_back(7);
4057+ indexData_.push_back(5);
4058+ indexData_.push_back(3);
4059+ indexData_.push_back(1);
4060+ indexData_.push_back(18);
4061+ indexData_.push_back(20);
4062+ indexData_.push_back(22);
4063+ indexData_.push_back(24);
4064+ indexData_.push_back(23);
4065+ indexData_.push_back(21);
4066+ indexData_.push_back(19);
4067+ indexData_.push_back(26);
4068+ indexData_.push_back(28);
4069+ indexData_.push_back(30);
4070+ indexData_.push_back(32);
4071+ indexData_.push_back(31);
4072+ indexData_.push_back(29);
4073+ indexData_.push_back(27);
4074+ indexData_.push_back(25);
4075+
4076+ // Primitive state so that the draw call can issue the primitives we want.
4077+ unsigned int curOffset(0);
4078+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 18, curOffset));
4079+ curOffset += (18 * sizeof(unsigned int));
4080+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 7, curOffset));
4081+ curOffset += (7 * sizeof(unsigned int));
4082+ primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 8, curOffset));
4083+ curOffset += (8 * sizeof(unsigned int));
4084+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 18, curOffset));
4085+ curOffset += (18 * sizeof(unsigned int));
4086+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 7, curOffset));
4087+ curOffset += (7 * sizeof(unsigned int));
4088+ primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 8, curOffset));
4089+}
4090
4091=== added file 'src/scene-ideas/table.cc'
4092--- src/scene-ideas/table.cc 1970-01-01 00:00:00 +0000
4093+++ src/scene-ideas/table.cc 2012-05-09 20:57:19 +0000
4094@@ -0,0 +1,353 @@
4095+/*
4096+ * (c) Copyright 1993, Silicon Graphics, Inc.
4097+ * Copyright © 2012 Linaro Limited
4098+ *
4099+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
4100+ *
4101+ * glmark2 is free software: you can redistribute it and/or modify it under the
4102+ * terms of the GNU General Public License as published by the Free Software
4103+ * Foundation, either version 3 of the License, or (at your option) any later
4104+ * version.
4105+ *
4106+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
4107+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4108+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4109+ * details.
4110+ *
4111+ * You should have received a copy of the GNU General Public License along with
4112+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
4113+ *
4114+ * Authors:
4115+ * Jesse Barker
4116+ */
4117+#include "table.h"
4118+#include "scene.h"
4119+#include "shader-source.h"
4120+#include "log.h"
4121+
4122+using std::string;
4123+using LibMatrix::vec3;
4124+using LibMatrix::Stack4;
4125+
4126+const string Table::modelviewName_("modelview");
4127+const string Table::projectionName_("projection");
4128+const string Table::lightPositionName_("lightPosition");
4129+const string Table::logoDirectionName_("logoDirection");
4130+const string Table::curTimeName_("currentTime");
4131+const string Table::vertexAttribName_("vertex");
4132+const unsigned int Table::TABLERES_(12);
4133+const vec3 Table::paperVertices_[4] = {
4134+ vec3(-0.8, 0.0, 0.4),
4135+ vec3(-0.2, 0.0, -1.4),
4136+ vec3(0.4, 0.0, 0.8),
4137+ vec3(1.0, 0.0, -1.0),
4138+};
4139+
4140+Table::Table() :
4141+ tableVertexIndex_(0),
4142+ paperVertexIndex_(0),
4143+ textVertexIndex_(0),
4144+ underVertexIndex_(0),
4145+ valid_(false)
4146+{
4147+ tableVertices_.reserve((TABLERES_ + 1) * (TABLERES_ + 1));
4148+ for (unsigned int i = 0; i <= TABLERES_; i++)
4149+ {
4150+ for (unsigned int j = 0; j <= TABLERES_; j++)
4151+ {
4152+ float x((static_cast<float>(i) - static_cast<float>(TABLERES_) * 1.0 / 2.0) / 2.0);
4153+ float z((static_cast<float>(j) - static_cast<float>(TABLERES_) * 1.0 / 2.0) / 2.0);
4154+ tableVertices_.push_back(vec3(x, 0.0, z));
4155+ }
4156+ }
4157+
4158+ // Now that we've setup the vertex data, we can setup the map of how
4159+ // that data will be laid out in the buffer object.
4160+ dataMap_.tvOffset = 0;
4161+ dataMap_.tvSize = tableVertices_.size() * sizeof(vec3);
4162+ dataMap_.totalSize = dataMap_.tvSize;
4163+ dataMap_.pvOffset = dataMap_.tvOffset + dataMap_.tvSize;
4164+ dataMap_.pvSize = 4 * sizeof(vec3);
4165+ dataMap_.totalSize += dataMap_.pvSize;
4166+
4167+ for (unsigned int i = 0; i < TABLERES_; i++)
4168+ {
4169+ for (unsigned int j = 0; j <= TABLERES_; j++)
4170+ {
4171+ unsigned int curIndex1(i * (TABLERES_ + 1) + j);
4172+ unsigned int curIndex2((i + 1) * (TABLERES_ + 1) + j);
4173+ indexData_.push_back(curIndex1);
4174+ indexData_.push_back(curIndex2);
4175+ }
4176+ }
4177+}
4178+
4179+Table::~Table(void)
4180+{
4181+ if (valid_)
4182+ {
4183+ glDeleteBuffers(2, &bufferObjects_[0]);
4184+ }
4185+}
4186+
4187+void
4188+Table::init(void)
4189+{
4190+ // Make sure we don't re-initialize...
4191+ if (valid_)
4192+ {
4193+ return;
4194+ }
4195+
4196+ // Initialize shader sources from input files and create programs from them
4197+ // Program to render the table with lighting and a time-based fade...
4198+ string table_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-table.vert");
4199+ string table_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-table.frag");
4200+ ShaderSource table_vtx_source(table_vtx_filename);
4201+ ShaderSource table_frg_source(table_frg_filename);
4202+ if (!Scene::load_shaders_from_strings(tableProgram_, table_vtx_source.str(),
4203+ table_frg_source.str()))
4204+ {
4205+ Log::error("No valid program for table rendering.\n");
4206+ return;
4207+ }
4208+ textVertexIndex_ = tableProgram_[vertexAttribName_].location();
4209+
4210+ // Program to render the paper with lighting and a time-based fade...
4211+ string paper_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-paper.vert");
4212+ string paper_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-paper.frag");
4213+ ShaderSource paper_vtx_source(paper_vtx_filename);
4214+ ShaderSource paper_frg_source(paper_frg_filename);
4215+ if (!Scene::load_shaders_from_strings(paperProgram_, paper_vtx_source.str(),
4216+ paper_frg_source.str()))
4217+ {
4218+ Log::error("No valid program for paper rendering.\n");
4219+ return;
4220+ }
4221+ paperVertexIndex_ = paperProgram_[vertexAttribName_].location();
4222+
4223+ // Program to handle the text (time-based color fade)...
4224+ string text_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-text.vert");
4225+ string text_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-text.frag");
4226+ ShaderSource text_vtx_source(text_vtx_filename);
4227+ ShaderSource text_frg_source(text_frg_filename);
4228+ if (!Scene::load_shaders_from_strings(textProgram_, text_vtx_source.str(),
4229+ text_frg_source.str()))
4230+ {
4231+ Log::error("No valid program for text rendering.\n");
4232+ return;
4233+ }
4234+ textVertexIndex_ = textProgram_[vertexAttribName_].location();
4235+
4236+ // Program for the drawUnder functionality (just paint it black)...
4237+ string under_table_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-under-table.vert");
4238+ string under_table_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-under-table.frag");
4239+ ShaderSource under_table_vtx_source(under_table_vtx_filename);
4240+ ShaderSource under_table_frg_source(under_table_frg_filename);
4241+ if (!Scene::load_shaders_from_strings(underProgram_, under_table_vtx_source.str(),
4242+ under_table_frg_source.str()))
4243+ {
4244+ Log::error("No valid program for under table rendering.\n");
4245+ return;
4246+ }
4247+ underVertexIndex_ = underProgram_[vertexAttribName_].location();
4248+
4249+ // Tell all of the characters to initialize themselves...
4250+ i_.init(textVertexIndex_);
4251+ d_.init(textVertexIndex_);
4252+ e_.init(textVertexIndex_);
4253+ a_.init(textVertexIndex_);
4254+ s_.init(textVertexIndex_);
4255+ n_.init(textVertexIndex_);
4256+ m_.init(textVertexIndex_);
4257+ o_.init(textVertexIndex_);
4258+ t_.init(textVertexIndex_);
4259+
4260+ // We need 2 buffers for our work here. One for the vertex data.
4261+ // and one for the index data.
4262+ glGenBuffers(2, &bufferObjects_[0]);
4263+
4264+ // First, setup the vertex data by binding the first buffer object,
4265+ // allocating its data store, and filling it in with our vertex data.
4266+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
4267+ glBufferData(GL_ARRAY_BUFFER, dataMap_.totalSize, 0, GL_STATIC_DRAW);
4268+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.tvOffset, dataMap_.tvSize,
4269+ &tableVertices_.front());
4270+ glBufferSubData(GL_ARRAY_BUFFER, dataMap_.pvOffset, dataMap_.pvSize,
4271+ &paperVertices_[0]);
4272+
4273+ // Now repeat for our index data.
4274+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
4275+ glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int),
4276+ &indexData_.front(), GL_STATIC_DRAW);
4277+
4278+ // We're ready to go.
4279+ valid_ = true;
4280+}
4281+
4282+void
4283+Table::draw(Stack4& modelview,
4284+ Stack4& projection,
4285+ const vec3& lightPos,
4286+ const vec3& logoPos,
4287+ const float& currentTime,
4288+ float& paperAlpha_out)
4289+{
4290+ glDisable(GL_DEPTH_TEST);
4291+
4292+ // Compute the light direction with respect to the logo...
4293+ vec3 logoDirection(lightPos.x() - logoPos.x(), lightPos.y() - logoPos.y(),
4294+ lightPos.z() - logoPos.z());
4295+ logoDirection.normalize();
4296+
4297+ // Compute the alpha component based upon drawing the paper (all of this will
4298+ // be done in the shader, but we need to pass this back so that the logo's
4299+ // shadow will look right).
4300+ for (unsigned int i = 0; i < 4; i++)
4301+ {
4302+ vec3 lightDirection(lightPos.x() - paperVertices_[i].x(),
4303+ lightPos.y() - paperVertices_[i].y(),
4304+ lightPos.z() - paperVertices_[i].z());
4305+ lightDirection.normalize();
4306+ float c = vec3::dot(lightDirection, logoDirection);
4307+ if (c < 0.0)
4308+ {
4309+ c = 0.0;
4310+ }
4311+ c = c * c * c * lightDirection.y();
4312+ if ((currentTime > 10.0) && (currentTime < 12.0))
4313+ {
4314+ c *= 1.0 - (currentTime - 10.0) * 0.5;
4315+ }
4316+ paperAlpha_out += c;
4317+ }
4318+
4319+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
4320+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
4321+
4322+ // Draw the table top
4323+ tableProgram_.start();
4324+ tableProgram_[projectionName_] = projection.getCurrent();
4325+ tableProgram_[modelviewName_] = modelview.getCurrent();
4326+ tableProgram_[lightPositionName_] = lightPos;
4327+ tableProgram_[logoDirectionName_] = logoDirection;
4328+ tableProgram_[curTimeName_] = currentTime;
4329+ glVertexAttribPointer(tableVertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
4330+ reinterpret_cast<const GLvoid*>(dataMap_.tvOffset));
4331+ glEnableVertexAttribArray(tableVertexIndex_);
4332+ static const unsigned int twiceRes(2 * (TABLERES_ + 1));
4333+ for (unsigned int i = 0; i < TABLERES_; i++)
4334+ {
4335+ glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_INT,
4336+ reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned int)));
4337+ }
4338+ glDisableVertexAttribArray(tableVertexIndex_);
4339+ tableProgram_.stop();
4340+
4341+ if (logoPos.y() > -0.33 && logoPos.y() < 0.33)
4342+ {
4343+ glEnable(GL_DEPTH_TEST);
4344+ }
4345+
4346+ // Draw the paper lying on the table top
4347+ paperProgram_.start();
4348+ paperProgram_[projectionName_] = projection.getCurrent();
4349+ paperProgram_[modelviewName_] = modelview.getCurrent();
4350+ paperProgram_[lightPositionName_] = lightPos;
4351+ paperProgram_[logoDirectionName_] = logoDirection;
4352+ paperProgram_[curTimeName_] = currentTime;
4353+ glVertexAttribPointer(paperVertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
4354+ reinterpret_cast<const GLvoid*>(dataMap_.pvOffset));
4355+ glEnableVertexAttribArray(paperVertexIndex_);
4356+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
4357+ glDisableVertexAttribArray(paperVertexIndex_);
4358+ paperProgram_.stop();
4359+
4360+ glBindBuffer(GL_ARRAY_BUFFER, 0);
4361+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
4362+
4363+ glDisable(GL_DEPTH_TEST);
4364+
4365+ modelview.push();
4366+ modelview.rotate(-18.4, 0.0, 1.0, 0.0);
4367+ modelview.translate(-0.3, 0.0, -0.8);
4368+ modelview.rotate(-90.0, 1.0, 0.0, 0.0);
4369+ modelview.scale(0.015, 0.015, 0.015);
4370+
4371+ // Draw the text on the paper lying on the table top.
4372+ // Each character has its own array and element buffers, and they have
4373+ // been initialized with the vertex attrib location for this program.
4374+ textProgram_.start();
4375+ textProgram_[projectionName_] = projection.getCurrent();
4376+ textProgram_[modelviewName_] = modelview.getCurrent();
4377+ textProgram_[curTimeName_] = currentTime;
4378+ i_.draw();
4379+ modelview.translate(3.0, 0.0, 0.0);
4380+ textProgram_[modelviewName_] = modelview.getCurrent();
4381+ d_.draw();
4382+ modelview.translate(6.0, 0.0, 0.0);
4383+ textProgram_[modelviewName_] = modelview.getCurrent();
4384+ e_.draw();
4385+ modelview.translate(5.0, 0.0, 0.0);
4386+ textProgram_[modelviewName_] = modelview.getCurrent();
4387+ a_.draw();
4388+ modelview.translate(6.0, 0.0, 0.0);
4389+ textProgram_[modelviewName_] = modelview.getCurrent();
4390+ s_.draw();
4391+ modelview.translate(10.0, 0.0, 0.0);
4392+ textProgram_[modelviewName_] = modelview.getCurrent();
4393+ i_.draw();
4394+ modelview.translate(3.0, 0.0, 0.0);
4395+ textProgram_[modelviewName_] = modelview.getCurrent();
4396+ n_.draw();
4397+ modelview.translate(-31.0, -13.0, 0.0);
4398+ textProgram_[modelviewName_] = modelview.getCurrent();
4399+ m_.draw();
4400+ modelview.translate(10.0, 0.0, 0.0);
4401+ textProgram_[modelviewName_] = modelview.getCurrent();
4402+ o_.draw();
4403+ modelview.translate(5.0, 0.0, 0.0);
4404+ textProgram_[modelviewName_] = modelview.getCurrent();
4405+ t_.draw();
4406+ modelview.translate(4.0, 0.0, 0.0);
4407+ textProgram_[modelviewName_] = modelview.getCurrent();
4408+ i_.draw();
4409+ modelview.translate(3.5, 0.0, 0.0);
4410+ textProgram_[modelviewName_] = modelview.getCurrent();
4411+ o_.draw();
4412+ modelview.translate(5.0, 0.0, 0.0);
4413+ textProgram_[modelviewName_] = modelview.getCurrent();
4414+ n_.draw();
4415+ textProgram_.stop();
4416+
4417+ modelview.pop();
4418+}
4419+
4420+void
4421+Table::drawUnder(Stack4& modelview, Stack4& projection)
4422+{
4423+ glDisable(GL_DEPTH_TEST);
4424+
4425+ glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
4426+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
4427+
4428+ underProgram_.start();
4429+ underProgram_[modelviewName_] = modelview.getCurrent();
4430+ underProgram_[projectionName_] = projection.getCurrent();
4431+ glVertexAttribPointer(underVertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
4432+ reinterpret_cast<const GLvoid*>(dataMap_.tvOffset));
4433+ glEnableVertexAttribArray(underVertexIndex_);
4434+ static const unsigned int twiceRes(2 * (TABLERES_ + 1));
4435+ for (unsigned int i = 0; i < TABLERES_; i++)
4436+ {
4437+ glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_INT,
4438+ reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned int)));
4439+ }
4440+ glDisableVertexAttribArray(underVertexIndex_);
4441+ underProgram_.stop();
4442+
4443+ glBindBuffer(GL_ARRAY_BUFFER, 0);
4444+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
4445+
4446+ glEnable(GL_DEPTH_TEST);
4447+}
4448
4449=== added file 'src/scene-ideas/table.h'
4450--- src/scene-ideas/table.h 1970-01-01 00:00:00 +0000
4451+++ src/scene-ideas/table.h 2012-05-09 20:57:19 +0000
4452@@ -0,0 +1,94 @@
4453+/*
4454+ * (c) Copyright 1993, Silicon Graphics, Inc.
4455+ * Copyright © 2012 Linaro Limited
4456+ *
4457+ * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
4458+ *
4459+ * glmark2 is free software: you can redistribute it and/or modify it under the
4460+ * terms of the GNU General Public License as published by the Free Software
4461+ * Foundation, either version 3 of the License, or (at your option) any later
4462+ * version.
4463+ *
4464+ * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
4465+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
4466+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
4467+ * details.
4468+ *
4469+ * You should have received a copy of the GNU General Public License along with
4470+ * glmark2. If not, see <http://www.gnu.org/licenses/>.
4471+ *
4472+ * Authors:
4473+ * Jesse Barker
4474+ */
4475+#ifndef TABLE_H_
4476+#define TABLE_H_
4477+
4478+#include <string>
4479+#include <vector>
4480+#include "characters.h"
4481+#include "program.h"
4482+#include "stack.h"
4483+
4484+class Table
4485+{
4486+public:
4487+ Table();
4488+ ~Table();
4489+
4490+ void init();
4491+ bool valid() const { return valid_; }
4492+ void draw(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection,
4493+ const LibMatrix::vec3& lightPosition, const LibMatrix::vec3& logoPosition,
4494+ const float& currentTime, float& paperAlpha_out);
4495+ void drawUnder(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection);
4496+
4497+private:
4498+ // Text
4499+ LetterI i_;
4500+ LetterD d_;
4501+ LetterE e_;
4502+ LetterA a_;
4503+ LetterS s_;
4504+ LetterN n_;
4505+ LetterM m_;
4506+ LetterO o_;
4507+ LetterT t_;
4508+ Program tableProgram_;
4509+ Program paperProgram_;
4510+ Program textProgram_;
4511+ Program underProgram_;
4512+ std::string tableVertexShader_;
4513+ std::string tableFragmentShader_;
4514+ std::string paperVertexShader_;
4515+ std::string paperFragmentShader_;
4516+ std::string textVertexShader_;
4517+ std::string textFragmentShader_;
4518+ std::string underVertexShader_;
4519+ std::string underFragmentShader_;
4520+ static const std::string modelviewName_;
4521+ static const std::string projectionName_;
4522+ static const std::string lightPositionName_;
4523+ static const std::string logoDirectionName_;
4524+ static const std::string curTimeName_;
4525+ static const std::string vertexAttribName_;
4526+ static const unsigned int TABLERES_;
4527+ std::vector<LibMatrix::vec3> tableVertices_;
4528+ static const LibMatrix::vec3 paperVertices_[4];
4529+ struct VertexDataMap
4530+ {
4531+ unsigned int tvOffset;
4532+ unsigned int tvSize;
4533+ unsigned int pvOffset;
4534+ unsigned int pvSize;
4535+ unsigned int totalSize;
4536+ } dataMap_;
4537+ unsigned int bufferObjects_[2];
4538+ std::vector<unsigned int> indexData_;
4539+ int tableVertexIndex_;
4540+ int paperVertexIndex_;
4541+ int textVertexIndex_;
4542+ int underVertexIndex_;
4543+ bool valid_;
4544+};
4545+
4546+#endif // TABLE_H_
4547
4548=== modified file 'src/scene.h'
4549--- src/scene.h 2012-02-09 01:28:16 +0000
4550+++ src/scene.h 2012-05-09 20:57:19 +0000
4551@@ -477,4 +477,25 @@
4552 private:
4553 SceneBufferPrivate *priv_;
4554 };
4555+
4556+class SceneIdeasPrivate;
4557+
4558+class SceneIdeas : public Scene
4559+{
4560+public:
4561+ SceneIdeas(Canvas &pCanvas);
4562+ bool load();
4563+ void unload();
4564+ void setup();
4565+ void teardown();
4566+ void update();
4567+ void draw();
4568+ ValidationResult validate();
4569+
4570+ ~SceneIdeas();
4571+
4572+private:
4573+ SceneIdeasPrivate* priv_;
4574+};
4575+
4576 #endif
4577
4578=== modified file 'src/wscript_build'
4579--- src/wscript_build 2012-01-26 17:00:43 +0000
4580+++ src/wscript_build 2012-05-09 20:57:19 +0000
4581@@ -5,6 +5,7 @@
4582 glesv2_sources = ['canvas-x11.cpp', 'canvas-x11-egl.cpp']
4583 libmatrix_sources = [f for f in bld.path.ant_glob('libmatrix/*.cc')
4584 if not f.name.endswith('test.cc')]
4585+ideas_sources = bld.path.ant_glob('scene-ideas/*.cc')
4586
4587 if bld.env.USE_GL:
4588 bld(
4589@@ -18,10 +19,11 @@
4590 )
4591 bld(
4592 features = ['cxx', 'cprogram'],
4593- source = common_sources + gl_sources,
4594+ source = ideas_sources + common_sources + gl_sources,
4595 target = 'glmark2',
4596 use = ['x11', 'gl', 'matrix', 'libpng12'],
4597 lib = ['m'],
4598+ includes = ['.', 'scene-ideas'],
4599 defines = ['USE_GL', 'USE_EXCEPTIONS']
4600 )
4601
4602@@ -37,9 +39,10 @@
4603 )
4604 bld(
4605 features = ['cxx', 'cprogram'],
4606- source = common_sources + glesv2_sources,
4607+ source = ideas_sources + common_sources + glesv2_sources,
4608 target = 'glmark2-es2',
4609 use = ['x11', 'egl', 'glesv2', 'matrix-es2', 'libpng12'],
4610 lib = ['m', 'dl'],
4611+ includes = ['.', 'scene-ideas'],
4612 defines = ['USE_GLESv2', 'USE_EXCEPTIONS']
4613 )

Subscribers

People subscribed via source and target branches

to all changes: