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
=== added file 'COPYING.SGI'
--- COPYING.SGI 1970-01-01 00:00:00 +0000
+++ COPYING.SGI 2012-05-09 20:57:19 +0000
@@ -0,0 +1,40 @@
1The data and some of the control logic for the "ideas" scene was adapted from
2the "Ideas in Motion" GLUT demo. Per the rights granted by the source for that
3demo, the following notice is reproduced here:
4
5/*
6 * (c) Copyright 1993, Silicon Graphics, Inc.
7 * ALL RIGHTS RESERVED
8 * Permission to use, copy, modify, and distribute this software for
9 * any purpose and without fee is hereby granted, provided that the above
10 * copyright notice appear in all copies and that both the copyright notice
11 * and this permission notice appear in supporting documentation, and that
12 * the name of Silicon Graphics, Inc. not be used in advertising
13 * or publicity pertaining to distribution of the software without specific,
14 * written prior permission.
15 *
16 * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
17 * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
19 * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
20 * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
21 * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
22 * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
23 * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
24 * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
25 * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
27 * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
28 *
29 * US Government Users Restricted Rights
30 * Use, duplication, or disclosure by the Government is subject to
31 * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
32 * (c)(1)(ii) of the Rights in Technical Data and Computer Software
33 * clause at DFARS 252.227-7013 and/or in similar or successor
34 * clauses in the FAR or the DOD or NASA FAR Supplement.
35 * Unpublished-- rights reserved under the copyright laws of the
36 * United States. Contractor/manufacturer is Silicon Graphics,
37 * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
38 *
39 * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
40 */
041
=== modified file 'android/jni/Android.ndk.mk'
--- android/jni/Android.ndk.mk 2012-03-22 10:37:35 +0000
+++ android/jni/Android.ndk.mk 2012-05-09 20:57:19 +0000
@@ -19,14 +19,27 @@
1919
20include $(CLEAR_VARS)20include $(CLEAR_VARS)
2121
22LOCAL_CPP_EXTENSION := .cc
23LOCAL_MODULE := libglmark2-ideas
24LOCAL_CFLAGS := -DGLMARK_DATA_PATH="" -DUSE_GLESv2 -Werror -Wall -Wextra\
25 -Wnon-virtual-dtor
26LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \
27 $(LOCAL_PATH)/src/libmatrix
28LOCAL_SRC_FILES := $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/src/scene-ideas/*.cc))
29
30include $(BUILD_STATIC_LIBRARY)
31
32include $(CLEAR_VARS)
33
22LOCAL_MODULE_TAGS := optional34LOCAL_MODULE_TAGS := optional
23LOCAL_MODULE := libglmark2-android35LOCAL_MODULE := libglmark2-android
24LOCAL_STATIC_LIBRARIES := libglmark2-matrix libglmark2-png36LOCAL_STATIC_LIBRARIES := libglmark2-matrix libglmark2-png libglmark2-ideas
25LOCAL_CFLAGS := -DGLMARK_DATA_PATH="" -DGLMARK_VERSION="\"2012.03\"" \37LOCAL_CFLAGS := -DGLMARK_DATA_PATH="" -DGLMARK_VERSION="\"2012.03\"" \
26 -DUSE_GLESv2 -Werror -Wall -Wextra -Wnon-virtual-dtor38 -DUSE_GLESv2 -Werror -Wall -Wextra -Wnon-virtual-dtor
27LOCAL_LDLIBS := -landroid -llog -lGLESv2 -lEGL -lz39LOCAL_LDLIBS := -landroid -llog -lGLESv2 -lEGL -lz
28LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \40LOCAL_C_INCLUDES := $(LOCAL_PATH)/src \
29 $(LOCAL_PATH)/src/libmatrix \41 $(LOCAL_PATH)/src/libmatrix \
42 $(LOCAL_PATH)/src/scene-ideas \
30 $(LOCAL_PATH)/src/libpng43 $(LOCAL_PATH)/src/libpng
31LOCAL_SRC_FILES := $(filter-out src/canvas% src/main.cpp, \44LOCAL_SRC_FILES := $(filter-out src/canvas% src/main.cpp, \
32 $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/src/*.cpp))) \45 $(subst $(LOCAL_PATH)/,,$(wildcard $(LOCAL_PATH)/src/*.cpp))) \
3346
=== added file 'data/shaders/ideas-lamp-lit.frag'
--- data/shaders/ideas-lamp-lit.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-lamp-lit.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,68 @@
1struct LightSourceParameters
2{
3 vec4 ambient;
4 vec4 diffuse;
5 vec4 specular;
6 vec4 position;
7};
8LightSourceParameters lightSource[3];
9uniform mat4 modelview;
10uniform vec4 light0Position;
11uniform vec4 light1Position;
12uniform vec4 light2Position;
13varying vec3 vertex_normal;
14varying vec4 vertex_position;
15varying vec3 eye_direction;
16
17vec3 unitvec(vec4 v1, vec4 v2)
18{
19 if (v1.w == 0.0 && v2.w == 0.0)
20 return vec3(v2 - v1);
21 if (v1.w == 0.0)
22 return vec3(-v1);
23 if (v2.w == 0.0)
24 return vec3(v2);
25 return v2.xyz/v2.w - v1.xyz/v1.w;
26}
27
28void main()
29{
30 lightSource[0] = LightSourceParameters(
31 vec4(0.0, 0.0, 0.0, 1.0),
32 vec4(1.0, 1.0, 1.0, 1.0),
33 vec4(1.0, 1.0, 1.0, 1.0),
34 vec4(0.0, 1.0, 0.0, 0.0)
35 );
36 lightSource[1] = LightSourceParameters(
37 vec4(0.0, 0.0, 0.0, 1.0),
38 vec4(0.3, 0.3, 0.5, 1.0),
39 vec4(0.3, 0.3, 0.5, 1.0),
40 vec4(-1.0, 0.0, 0.0, 0.0)
41 );
42 lightSource[2] = LightSourceParameters(
43 vec4(0.2, 0.2, 0.2, 1.0),
44 vec4(0.2, 0.2, 0.2, 1.0),
45 vec4(0.2, 0.2, 0.2, 1.0),
46 vec4(0.0, -1.0, 0.0, 0.0)
47 );
48 vec4 matAmbient = vec4(0.0, 0.0, 0.0, 1.0);
49 vec4 matDiffuse = vec4(1.0, 0.2, 0.2, 1.0);
50 vec4 matSpecular = vec4(0.5, 0.5, 0.5, 1.0);
51 float matShininess = 20.0;
52 vec4 diffuseSum = vec4(0.0, 0.0, 0.0, 0.0);
53 vec4 specularSum = vec4(0.0, 0.0, 0.0, 0.0);
54 vec4 ambientSum = vec4(0.0, 0.0, 0.0, 0.0);
55 vec3 normalized_normal = normalize(vertex_normal);
56 lightSource[0].position = light0Position;
57 lightSource[1].position = light1Position;
58 lightSource[2].position = light2Position;
59 for (int light = 0; light < 3; light++) {
60 vec4 light_position = lightSource[light].position;
61 vec3 light_direction = normalize(unitvec(vertex_position, light_position));
62 vec3 reflection = reflect(-light_direction, normalized_normal);
63 specularSum += pow(max(0.0, dot(reflection, eye_direction)), matShininess) * lightSource[light].specular;
64 diffuseSum += max(0.0, dot(normalized_normal, light_direction)) * lightSource[light].diffuse;
65 ambientSum += lightSource[light].ambient;
66 }
67 gl_FragColor = (matSpecular * specularSum) + (matAmbient * ambientSum) + (matDiffuse * diffuseSum);
68}
069
=== added file 'data/shaders/ideas-lamp-lit.vert'
--- data/shaders/ideas-lamp-lit.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-lamp-lit.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,28 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3uniform mat3 normalMatrix;
4varying vec3 vertex_normal;
5varying vec4 vertex_position;
6varying vec3 eye_direction;
7attribute vec3 vertex;
8attribute vec3 normal;
9
10vec3 unitvec(vec4 v1, vec4 v2)
11{
12 if (v1.w == 0.0 && v2.w == 0.0)
13 return vec3(v2 - v1);
14 if (v1.w == 0.0)
15 return vec3(-v1);
16 if (v2.w == 0.0)
17 return vec3(v2);
18 return v2.xyz/v2.w - v1.xyz/v1.w;
19}
20
21void main()
22{
23 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
24 gl_Position = projection * modelview * curVertex;
25 vertex_normal = normalMatrix * normal;
26 vertex_position = modelview * curVertex;
27 eye_direction = normalize(unitvec(vertex_position, vec4(0.0, 0.0, 0.0, 1.0)));
28}
029
=== added file 'data/shaders/ideas-lamp-unlit.frag'
--- data/shaders/ideas-lamp-unlit.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-lamp-unlit.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,6 @@
1varying vec4 color;
2
3void main()
4{
5 gl_FragColor = color;
6}
07
=== added file 'data/shaders/ideas-lamp-unlit.vert'
--- data/shaders/ideas-lamp-unlit.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-lamp-unlit.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,11 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3attribute vec3 vertex;
4varying vec4 color;
5
6void main()
7{
8 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
9 gl_Position = projection * modelview * curVertex;
10 color = vec4(1.0, 1.0, 1.0, 1.0);
11}
012
=== added file 'data/shaders/ideas-logo-flat.frag'
--- data/shaders/ideas-logo-flat.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-logo-flat.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,6 @@
1uniform vec4 logoColor;
2
3void main()
4{
5 gl_FragColor = logoColor;
6}
07
=== added file 'data/shaders/ideas-logo-flat.vert'
--- data/shaders/ideas-logo-flat.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-logo-flat.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,9 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3attribute vec3 vertex;
4
5void main()
6{
7 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
8 gl_Position = projection * modelview * curVertex;
9}
010
=== added file 'data/shaders/ideas-logo-shadow.frag'
--- data/shaders/ideas-logo-shadow.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-logo-shadow.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,10 @@
1uniform sampler2D tex;
2
3void main()
4{
5 vec2 curPos = gl_FragCoord.xy / 32.0;
6 vec4 color = texture2D(tex, curPos);
7 if (color.w < 0.5)
8 discard;
9 gl_FragColor = color;
10}
011
=== added file 'data/shaders/ideas-logo-shadow.vert'
--- data/shaders/ideas-logo-shadow.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-logo-shadow.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,9 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3attribute vec3 vertex;
4
5void main()
6{
7 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
8 gl_Position = projection * modelview * curVertex;
9}
010
=== added file 'data/shaders/ideas-logo.frag'
--- data/shaders/ideas-logo.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-logo.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,35 @@
1uniform vec4 light0Position;
2varying vec3 vertex_normal;
3varying vec4 vertex_position;
4varying vec3 eye_direction;
5
6vec3 unitvec(vec4 v1, vec4 v2)
7{
8 if (v1.w == 0.0 && v2.w == 0.0)
9 return vec3(v2 - v1);
10 if (v1.w == 0.0)
11 return vec3(-v1);
12 if (v2.w == 0.0)
13 return vec3(v2);
14 return v2.xyz/v2.w - v1.xyz/v1.w;
15}
16
17void main()
18{
19 vec4 lightAmbient = vec4(0.0, 0.0, 0.0, 1.0);
20 vec4 lightDiffuse = vec4(1.0, 1.0, 1.0, 1.0);
21 vec4 lightSpecular = vec4(1.0, 1.0, 1.0, 1.0);
22 vec4 matAmbient = vec4(0.1, 0.1, 0.1, 1.0);
23 vec4 matDiffuse = vec4(0.5, 0.4, 0.7, 1.0);
24 vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0);
25 float matShininess = 30.0;
26 vec3 light_direction = normalize(unitvec(vertex_position, light0Position));
27 vec3 normalized_normal = normalize(vertex_normal);
28 vec3 reflection = reflect(-light_direction, normalized_normal);
29 float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess);
30 float diffuseTerm = max(0.0, dot(normalized_normal, light_direction));
31 vec4 specular = (lightSpecular * matSpecular);
32 vec4 ambient = (lightAmbient * matAmbient);
33 vec4 diffuse = (lightDiffuse * matDiffuse);
34 gl_FragColor = (specular * specularTerm) + ambient + (diffuse * diffuseTerm);
35}
036
=== added file 'data/shaders/ideas-logo.vert'
--- data/shaders/ideas-logo.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-logo.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,28 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3uniform mat3 normalMatrix;
4varying vec3 vertex_normal;
5varying vec4 vertex_position;
6varying vec3 eye_direction;
7attribute vec3 vertex;
8attribute vec3 normal;
9
10vec3 unitvec(vec4 v1, vec4 v2)
11{
12 if (v1.w == 0.0 && v2.w == 0.0)
13 return vec3(v2 - v1);
14 if (v1.w == 0.0)
15 return vec3(-v1);
16 if (v2.w == 0.0)
17 return vec3(v2);
18 return v2.xyz/v2.w - v1.xyz/v1.w;
19}
20
21void main()
22{
23 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
24 gl_Position = projection * modelview * curVertex;
25 vertex_normal = normalMatrix * normal;
26 vertex_position = modelview * curVertex;
27 eye_direction = normalize(unitvec(vertex_position, vec4(0.0, 0.0, 0.0, 1.0)));
28}
029
=== added file 'data/shaders/ideas-paper.frag'
--- data/shaders/ideas-paper.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-paper.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,6 @@
1varying vec4 color;
2
3void main()
4{
5 gl_FragColor = color;
6}
07
=== added file 'data/shaders/ideas-paper.vert'
--- data/shaders/ideas-paper.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-paper.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,22 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3uniform vec3 lightPosition;
4uniform vec3 logoDirection;
5uniform float currentTime;
6attribute vec3 vertex;
7varying vec4 color;
8
9void main()
10{
11 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
12 gl_Position = projection * modelview * curVertex;
13 float referenceTime = 15.0;
14 vec3 lightDirection = normalize(lightPosition - vertex);
15 float c = max(dot(lightDirection, logoDirection), 0.0);
16 c = c * c * c * lightDirection.y;
17 if ((currentTime > referenceTime - 5.0) && (currentTime < referenceTime - 3.0))
18 {
19 c *= 1.0 - (currentTime - (referenceTime - 5.0)) * 0.5;
20 }
21 color = vec4(c, c, (c * 0.78125), 1.0);
22}
023
=== added file 'data/shaders/ideas-table.frag'
--- data/shaders/ideas-table.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-table.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,6 @@
1varying vec4 color;
2
3void main()
4{
5 gl_FragColor = color;
6}
07
=== added file 'data/shaders/ideas-table.vert'
--- data/shaders/ideas-table.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-table.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,22 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3uniform vec3 lightPosition;
4uniform vec3 logoDirection;
5uniform float currentTime;
6attribute vec3 vertex;
7varying vec4 color;
8
9void main()
10{
11 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
12 gl_Position = projection * modelview * curVertex;
13 float referenceTime = 15.0;
14 vec3 lightDirection = normalize(lightPosition - vertex);
15 float c = max(dot(lightDirection, logoDirection), 0.0);
16 c = c * c * c * lightDirection.y;
17 if ((currentTime > referenceTime - 5.0) && (currentTime < referenceTime - 3.0))
18 {
19 c *= 1.0 - (currentTime - (referenceTime - 5.0)) * 0.5;
20 }
21 color = vec4(c, c, c, 1.0);
22}
023
=== added file 'data/shaders/ideas-text.frag'
--- data/shaders/ideas-text.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-text.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,6 @@
1varying vec4 color;
2
3void main()
4{
5 gl_FragColor = color;
6}
07
=== added file 'data/shaders/ideas-text.vert'
--- data/shaders/ideas-text.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-text.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,18 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3uniform float currentTime;
4attribute vec2 vertex;
5varying vec4 color;
6
7void main()
8{
9 vec4 curVertex = vec4(vertex.x, vertex.y, 0.0, 1.0);
10 gl_Position = projection * modelview * curVertex;
11 float referenceTime = 15.0;
12 float c = 0.0;
13 if (currentTime > referenceTime * 1.0 - 5.0)
14 {
15 c = (currentTime - (referenceTime * 1.0 - 5.0)) / 2.0;
16 }
17 color = vec4(c, c, c, 1.0);
18}
019
=== added file 'data/shaders/ideas-under-table.frag'
--- data/shaders/ideas-under-table.frag 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-under-table.frag 2012-05-09 20:57:19 +0000
@@ -0,0 +1,6 @@
1varying vec4 color;
2
3void main()
4{
5 gl_FragColor = color;
6}
07
=== added file 'data/shaders/ideas-under-table.vert'
--- data/shaders/ideas-under-table.vert 1970-01-01 00:00:00 +0000
+++ data/shaders/ideas-under-table.vert 2012-05-09 20:57:19 +0000
@@ -0,0 +1,11 @@
1uniform mat4 projection;
2uniform mat4 modelview;
3attribute vec3 vertex;
4varying vec4 color;
5
6void main()
7{
8 vec4 curVertex = vec4(vertex.x, vertex.y, vertex.z, 1.0);
9 gl_Position = projection * modelview * curVertex;
10 color = vec4(0.0, 0.0, 0.0, 1.0);
11}
012
=== modified file 'src/android.cpp'
--- src/android.cpp 2012-02-15 16:00:26 +0000
+++ src/android.cpp 2012-05-09 20:57:19 +0000
@@ -186,6 +186,7 @@
186 Benchmark::register_scene(*new ScenePulsar(*g_canvas));186 Benchmark::register_scene(*new ScenePulsar(*g_canvas));
187 Benchmark::register_scene(*new SceneDesktop(*g_canvas));187 Benchmark::register_scene(*new SceneDesktop(*g_canvas));
188 Benchmark::register_scene(*new SceneBuffer(*g_canvas));188 Benchmark::register_scene(*new SceneBuffer(*g_canvas));
189 Benchmark::register_scene(*new SceneIdeas(*g_canvas));
189190
190 g_benchmark_collection = new BenchmarkCollection();191 g_benchmark_collection = new BenchmarkCollection();
191 g_benchmark_collection->populate_from_options();192 g_benchmark_collection->populate_from_options();
192193
=== modified file 'src/default-benchmarks.h'
--- src/default-benchmarks.h 2011-11-14 12:39:08 +0000
+++ src/default-benchmarks.h 2012-05-09 20:57:19 +0000
@@ -60,6 +60,7 @@
60 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=false");60 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=false");
61 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=subdata:interleave=false");61 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=subdata:interleave=false");
62 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=true");62 benchmarks.push_back("buffer:update-fraction=0.5:update-dispersion=0.9:columns=200:update-method=map:interleave=true");
63 benchmarks.push_back("ideas:speed=max:duration=12");
63 benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=0");64 benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=0");
64 benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=5");65 benchmarks.push_back("conditionals:vertex-steps=0:fragment-steps=5");
65 benchmarks.push_back("conditionals:vertex-steps=5:fragment-steps=0");66 benchmarks.push_back("conditionals:vertex-steps=5:fragment-steps=0");
6667
=== modified file 'src/libmatrix/program.cc'
--- src/libmatrix/program.cc 2012-01-26 17:00:43 +0000
+++ src/libmatrix/program.cc 2012-05-09 20:57:19 +0000
@@ -19,6 +19,7 @@
1919
20using std::string;20using std::string;
21using LibMatrix::mat4;21using LibMatrix::mat4;
22using LibMatrix::mat3;
22using LibMatrix::vec2;23using LibMatrix::vec2;
23using LibMatrix::vec3;24using LibMatrix::vec3;
24using LibMatrix::vec4;25using LibMatrix::vec4;
@@ -275,6 +276,17 @@
275}276}
276277
277Program::Symbol&278Program::Symbol&
279Program::Symbol::operator=(const mat3& m)
280{
281 if (type_ == Uniform)
282 {
283 // Our matrix representation is column-major, so transpose is false here.
284 glUniformMatrix3fv(location_, 1, GL_FALSE, m);
285 }
286 return *this;
287}
288
289Program::Symbol&
278Program::Symbol::operator=(const vec2& v)290Program::Symbol::operator=(const vec2& v)
279{291{
280 if (type_ == Uniform)292 if (type_ == Uniform)
281293
=== modified file 'src/libmatrix/program.h'
--- src/libmatrix/program.h 2012-01-26 17:00:43 +0000
+++ src/libmatrix/program.h 2012-05-09 20:57:19 +0000
@@ -126,6 +126,7 @@
126 // These members cause data to be bound to program variables, so126 // These members cause data to be bound to program variables, so
127 // the program must be bound for use for these to be effective.127 // the program must be bound for use for these to be effective.
128 Symbol& operator=(const LibMatrix::mat4& m);128 Symbol& operator=(const LibMatrix::mat4& m);
129 Symbol& operator=(const LibMatrix::mat3& m);
129 Symbol& operator=(const LibMatrix::vec2& v);130 Symbol& operator=(const LibMatrix::vec2& v);
130 Symbol& operator=(const LibMatrix::vec3& v);131 Symbol& operator=(const LibMatrix::vec3& v);
131 Symbol& operator=(const LibMatrix::vec4& v);132 Symbol& operator=(const LibMatrix::vec4& v);
132133
=== modified file 'src/main.cpp'
--- src/main.cpp 2012-03-22 10:37:04 +0000
+++ src/main.cpp 2012-05-09 20:57:19 +0000
@@ -60,6 +60,7 @@
60 scenes.push_back(new ScenePulsar(canvas));60 scenes.push_back(new ScenePulsar(canvas));
61 scenes.push_back(new SceneDesktop(canvas));61 scenes.push_back(new SceneDesktop(canvas));
62 scenes.push_back(new SceneBuffer(canvas));62 scenes.push_back(new SceneBuffer(canvas));
63 scenes.push_back(new SceneIdeas(canvas));
6364
64 for (vector<Scene*>::const_iterator iter = scenes.begin();65 for (vector<Scene*>::const_iterator iter = scenes.begin();
65 iter != scenes.end();66 iter != scenes.end();
6667
=== added directory 'src/scene-ideas'
=== added file 'src/scene-ideas.cpp'
--- src/scene-ideas.cpp 1970-01-01 00:00:00 +0000
+++ src/scene-ideas.cpp 2012-05-09 20:57:19 +0000
@@ -0,0 +1,426 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#include "scene.h"
24#include "stack.h"
25#include "splines.h"
26#include "table.h"
27#include "logo.h"
28#include "lamp.h"
29#include "util.h"
30#include "log.h"
31#include <sys/time.h>
32
33using LibMatrix::Stack4;
34using LibMatrix::mat4;
35using LibMatrix::vec3;
36using LibMatrix::vec4;
37using LibMatrix::uvec3;
38using std::string;
39
40class SceneIdeasPrivate
41{
42public:
43 SceneIdeasPrivate() :
44 valid_(false),
45 currentSpeed_(SPEED_MAXIMUM),
46 currentTime_(START_TIME_),
47 timeOffset_(START_TIME_)
48 {
49 startTime_.tv_sec = 0;
50 startTime_.tv_usec = 0;
51 }
52 ~SceneIdeasPrivate()
53 {
54 }
55 void initialize(const string& speed);
56 void reset_time();
57 void update_time();
58 void update_projection(const mat4& proj);
59 void draw();
60
61private:
62 float speed_from_optval(const string& optval);
63 void postIdle();
64 void initLights();
65 bool valid_;
66 Stack4 projection_;
67 Stack4 modelview_;
68 float currentSpeed_;
69 float currentTime_;
70 float timeOffset_;
71 struct timeval startTime_;
72 static const float CYCLE_TIME_;
73 static const float TIME_;
74 static const float START_TIME_;
75 static const float SPEED_SLOW;
76 static const float SPEED_MEDIUM;
77 static const float SPEED_FAST;
78 static const float SPEED_MAXIMUM;
79 // Table
80 Table table_;
81 // Logo
82 SGILogo logo_;
83 // Lamp
84 Lamp lamp_;
85 // Light constants
86 static const vec4 light0_position_;
87 static const vec4 light1_position_;
88 static const vec4 light2_position_;
89 // Object constants
90 ViewFromSpline viewFromSpline_;
91 ViewToSpline viewToSpline_;
92 LightPositionSpline lightPosSpline_;
93 LogoPositionSpline logoPosSpline_;
94 LogoRotationSpline logoRotSpline_;
95 vec3 viewFrom_;
96 vec3 viewTo_;
97 vec3 lightPos_;
98 vec3 logoPos_;
99 vec3 logoRot_;
100 vec4 lightPositions_[3];
101};
102
103const float SceneIdeasPrivate::SPEED_SLOW(0.2);
104const float SceneIdeasPrivate::SPEED_MEDIUM(0.4);
105const float SceneIdeasPrivate::SPEED_FAST(0.7);
106const float SceneIdeasPrivate::SPEED_MAXIMUM(1.0);
107const float SceneIdeasPrivate::TIME_(15.0);
108const float SceneIdeasPrivate::CYCLE_TIME_(TIME_ * 1.0 - 3.0);
109const float SceneIdeasPrivate::START_TIME_(0.6);
110const vec4 SceneIdeasPrivate::light0_position_(0.0, 1.0, 0.0, 0.0);
111const vec4 SceneIdeasPrivate::light1_position_(-1.0, 0.0, 0.0, 0.0);
112const vec4 SceneIdeasPrivate::light2_position_(0.0, -1.0, 0.0, 0.0);
113
114void
115SceneIdeasPrivate::initLights()
116{
117 const mat4& curMV(modelview_.getCurrent());
118 lightPositions_[0] = curMV * light0_position_;
119 lightPositions_[1] = curMV * light1_position_;
120 lightPositions_[2] = curMV * light2_position_;
121}
122
123void
124SceneIdeasPrivate::initialize(const string& speed)
125{
126 // Initialize the positions for the lights we'll use.
127 initLights();
128
129 // Tell the objects in the scene to initialize themselves.
130 table_.init();
131 if (!table_.valid())
132 {
133 Log::debug("SceneIdeas: table object not properly initialized!\n");
134 return;
135 }
136 logo_.init();
137 if (!logo_.valid())
138 {
139 Log::debug("SceneIdeas: logo object not properly initialized!\n");
140 return;
141 }
142 lamp_.init();
143 if (!lamp_.valid())
144 {
145 Log::debug("SceneIdeas: lamp object not properly initialized!\n");
146 return;
147 }
148
149 reset_time();
150
151 currentSpeed_ = speed_from_optval(speed);
152
153 // If we're here, we're okay to run.
154 valid_ = true;
155}
156
157void
158SceneIdeasPrivate::reset_time()
159{
160 timeOffset_ = START_TIME_;
161 gettimeofday(&startTime_, NULL);
162}
163
164void
165SceneIdeasPrivate::update_time()
166{
167 // Compute new time
168 struct timeval current = {0, 0};
169 gettimeofday(&current, NULL);
170 float timediff = (current.tv_sec - startTime_.tv_sec) +
171 static_cast<double>(current.tv_usec - startTime_.tv_usec) / 1000000.0;
172 float sceneTime = timediff * currentSpeed_ + timeOffset_;
173
174 // Keep the current time in [START_TIME_..CYCLE_TIME_)
175 // Every other cycle starting with 0 start at the beginning and goes
176 // forward in time. Other cycles start at the end and go backwards.
177 currentTime_ = std::fmod(sceneTime, CYCLE_TIME_);
178 unsigned int cycle = sceneTime/CYCLE_TIME_;
179 if (cycle % 2)
180 {
181 currentTime_ = CYCLE_TIME_ - currentTime_;
182 }
183}
184
185void
186SceneIdeasPrivate::update_projection(const mat4& proj)
187{
188 // Projection hasn't changed since last frame.
189 if (projection_.getCurrent() == proj)
190 {
191 return;
192 }
193
194 projection_.loadIdentity();
195 projection_ *= proj;
196}
197
198float
199SceneIdeasPrivate::speed_from_optval(const string& optval)
200{
201 float retVal(SPEED_MAXIMUM);
202 if (optval == "slow")
203 {
204 retVal = SPEED_SLOW;
205 }
206 else if (optval == "medium")
207 {
208 retVal = SPEED_MEDIUM;
209 }
210 else if (optval == "fast")
211 {
212 retVal = SPEED_FAST;
213 }
214 else if (optval != "max")
215 {
216 Log::error("Unknown speed option '%s', using default.\n", optval.c_str());
217 }
218
219 return retVal;
220}
221
222SceneIdeas::SceneIdeas(Canvas& canvas) :
223 Scene(canvas, "ideas")
224{
225 options_["speed"] = Scene::Option("speed", "max",
226 "Rendering speed [slow, medium, fast, max]");
227}
228
229SceneIdeas::~SceneIdeas()
230{
231 delete priv_;
232}
233
234bool
235SceneIdeas::load()
236{
237 running_ = false;
238 return true;
239}
240
241void
242SceneIdeas::unload()
243{
244}
245
246void
247SceneIdeas::setup()
248{
249 Scene::setup();
250 priv_ = new SceneIdeasPrivate();
251 priv_->initialize(options_["speed"].value);
252 priv_->update_projection(canvas_.projection());
253
254 // Core Scene state
255 currentFrame_ = 0;
256 running_ = true;
257 startTime_ = Util::get_timestamp_us() / 1000000.0;
258 lastUpdateTime_ = startTime_;
259}
260
261void
262SceneIdeas::update()
263{
264 Scene::update();
265 priv_->update_time();
266 priv_->update_projection(canvas_.projection());
267}
268
269void
270SceneIdeasPrivate::draw()
271{
272 viewFromSpline_.getCurrentVec(currentTime_, viewFrom_);
273 viewToSpline_.getCurrentVec(currentTime_, viewTo_);
274 lightPosSpline_.getCurrentVec(currentTime_, lightPos_);
275 logoPosSpline_.getCurrentVec(currentTime_, logoPos_);
276 logoRotSpline_.getCurrentVec(currentTime_, logoRot_);
277
278 // Tell the logo its new position
279 logo_.setPosition(logoPos_);
280
281 vec4 lp4(lightPos_.x(), lightPos_.y(), lightPos_.z(), 0.0);
282
283 //
284 // SHADOW
285 //
286 modelview_.loadIdentity();
287 modelview_.lookAt(viewFrom_.x(), viewFrom_.y(), viewFrom_.z(),
288 viewTo_.x(), viewTo_.y(), viewTo_.z(),
289 0.0, 1.0, 0.0);
290
291 float pca(0.0);
292 if (viewFrom_.y() > 0.0)
293 {
294 table_.draw(modelview_, projection_, lightPos_, logoPos_, currentTime_, pca);
295 }
296
297 glEnable(GL_CULL_FACE);
298 glDisable(GL_DEPTH_TEST);
299
300 if (logoPos_.y() < 0.0)
301 {
302 // Set the color assuming we're still under the table.
303 uvec3 flatColor(128 / 2, 102 / 2, 179 / 2);
304 if (logoPos_.y() > -0.33)
305 {
306 // We're emerging from the table
307 float c(1.0 - logoPos_.y() / -0.33);
308 pca /= 4.0;
309 flatColor.x(static_cast<unsigned int>(128.0 * (1.0 - c) * 0.5 + 255.0 * pca * c));
310 flatColor.y(static_cast<unsigned int>(102.0 * (1.0 - c) * 0.5 + 255.0 * pca * c));
311 flatColor.z(static_cast<unsigned int>(179.0 * (1.0 - c) * 0.5 + 200.0 * pca * c));
312 }
313
314 modelview_.push();
315 modelview_.scale(0.04, 0.0, 0.04);
316 modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
317 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0);
318 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0);
319 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0);
320 modelview_.rotate(0.1 * 353, 1.0, 0.0, 0.0);
321 modelview_.rotate(0.1 * 450, 0.0, 1.0, 0.0);
322
323 logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_FLAT, flatColor);
324
325 modelview_.pop();
326 }
327
328 if (logoPos_.y() > 0.0)
329 {
330 modelview_.push();
331 modelview_.translate(lightPos_.x(), lightPos_.y(), lightPos_.z());
332 mat4 tv;
333 tv[3][1] = -1.0;
334 tv[3][3] = 0.0;
335 tv[0][0] = tv[1][1] = tv[2][2] = lightPos_.y();
336 modelview_ *= tv;
337 modelview_.translate(-lightPos_.x() + logoPos_.x(),
338 -lightPos_.y() + logoPos_.y(),
339 -lightPos_.z() + logoPos_.z());
340 modelview_.scale(0.04, 0.04, 0.04);
341 modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
342 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0);
343 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0);
344 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0);
345 modelview_.rotate(35.3, 1.0, 0.0, 0.0);
346 modelview_.rotate(45.0, 0.0, 1.0, 0.0);
347
348 logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_SHADOW);
349
350 modelview_.pop();
351 }
352 //
353 // DONE SHADOW
354 //
355
356 glEnable(GL_DEPTH_TEST);
357 glDisable(GL_CULL_FACE);
358
359 modelview_.loadIdentity();
360 modelview_.lookAt(viewFrom_.x(), viewFrom_.y(), viewFrom_.z(),
361 viewTo_.x(), viewTo_.y(), viewTo_.z(),
362 0.0, 1.0, 0.0);
363 modelview_.push();
364 modelview_.translate(lightPos_.x(), lightPos_.y(), lightPos_.z());
365 modelview_.scale(0.1, 0.1, 0.1);
366 float x(lightPos_.x() - logoPos_.x());
367 float y(lightPos_.y() - logoPos_.y());
368 float z(lightPos_.z() - logoPos_.z());
369 double a3(0.0);
370 if (x != 0.0)
371 {
372 a3 = -atan2(z, x) * 10.0 * 180.0 / M_PI;
373 }
374 double a4(-atan2(sqrt(x * x + z * z), y) * 10.0 * 180.0 / M_PI);
375 modelview_.rotate(0.1 * static_cast<int>(a3), 0.0, 1.0, 0.0);
376 modelview_.rotate(0.1 * static_cast<int>(a4), 0.0, 0.0, 1.0);
377 modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
378
379 lamp_.draw(modelview_, projection_, lightPositions_);
380
381 modelview_.pop();
382
383 lightPositions_[0] = modelview_.getCurrent() * lp4;
384
385 if (logoPos_.y() > -0.33)
386 {
387 modelview_.push();
388 modelview_.translate(logoPos_.x(), logoPos_.y(), logoPos_.z());
389 modelview_.scale(0.04, 0.04, 0.04);
390 modelview_.rotate(-90.0, 1.0, 0.0, 0.0);
391 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0);
392 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0);
393 modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0);
394 modelview_.rotate(35.3, 1.0, 0.0, 0.0);
395 modelview_.rotate(45.0, 0.0, 1.0, 0.0);
396
397 logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_NORMAL);
398
399 modelview_.pop();
400 }
401
402 if (viewFrom_.y() < 0.0)
403 {
404 table_.drawUnder(modelview_, projection_);
405 }
406}
407
408void
409SceneIdeas::draw()
410{
411 priv_->draw();
412}
413
414Scene::ValidationResult
415SceneIdeas::validate()
416{
417 return Scene::ValidationSuccess;
418}
419
420void
421SceneIdeas::teardown()
422{
423 delete priv_;
424 priv_ = 0;
425 Scene::teardown();
426}
0427
=== added file 'src/scene-ideas/a.cc'
--- src/scene-ideas/a.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/a.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,179 @@
1/*
2 * Vertex position data describing the letter 'a'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterA::LetterA()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(5.618949, 10.261048));
33 vertexData_.push_back(vec2(5.322348, 9.438848));
34 vertexData_.push_back(vec2(5.124614, 10.030832));
35 vertexData_.push_back(vec2(4.860968, 9.488181));
36 vertexData_.push_back(vec2(4.811534, 9.932169));
37 vertexData_.push_back(vec2(3.938208, 9.438848));
38 vertexData_.push_back(vec2(3.658084, 9.685509));
39 vertexData_.push_back(vec2(2.784758, 8.994862));
40 vertexData_.push_back(vec2(2.801236, 9.175745));
41 vertexData_.push_back(vec2(1.960865, 8.172662));
42 vertexData_.push_back(vec2(1.186406, 7.761562));
43 vertexData_.push_back(vec2(1.252317, 6.561151));
44 vertexData_.push_back(vec2(0.576725, 6.610483));
45 vertexData_.push_back(vec2(0.939238, 5.525180));
46 vertexData_.push_back(vec2(0.164779, 4.883864));
47 vertexData_.push_back(vec2(0.840371, 4.818089));
48 vertexData_.push_back(vec2(0.230690, 3.963001));
49 vertexData_.push_back(vec2(0.939238, 4.242549));
50 vertexData_.push_back(vec2(0.609681, 3.255909));
51 vertexData_.push_back(vec2(1.268795, 3.963001));
52 vertexData_.push_back(vec2(1.021627, 3.075026));
53 vertexData_.push_back(vec2(1.861998, 4.045221));
54 vertexData_.push_back(vec2(1.829042, 3.535457));
55 vertexData_.push_back(vec2(2.817714, 4.818089));
56 vertexData_.push_back(vec2(3.163749, 4.998972));
57 vertexData_.push_back(vec2(3.971164, 6.643371));
58 vertexData_.push_back(vec2(4.267765, 6.725591));
59 vertexData_.push_back(vec2(4.663234, 7.630010));
60 vertexData_.push_back(vec2(5.404737, 9.734840));
61 vertexData_.push_back(vec2(4.646756, 9.669065));
62 vertexData_.push_back(vec2(5.108136, 8.731757));
63 vertexData_.push_back(vec2(4.679712, 8.600205));
64 vertexData_.push_back(vec2(4.926879, 7.564234));
65 vertexData_.push_back(vec2(4.366632, 6.692703));
66 vertexData_.push_back(vec2(4.663234, 5.344296));
67 vertexData_.push_back(vec2(3.888774, 4.850976));
68 vertexData_.push_back(vec2(4.630278, 4.094553));
69 vertexData_.push_back(vec2(3.954686, 3.963001));
70 vertexData_.push_back(vec2(4.828012, 3.798561));
71 vertexData_.push_back(vec2(4.168898, 3.321686));
72 vertexData_.push_back(vec2(5.157569, 3.864337));
73 vertexData_.push_back(vec2(4.514933, 3.091470));
74 vertexData_.push_back(vec2(5.553038, 4.045221));
75 vertexData_.push_back(vec2(5.305870, 3.634121));
76 vertexData_.push_back(vec2(5.932029, 4.176773));
77
78 // Index data...
79 indexData_.push_back(0);
80 indexData_.push_back(1);
81 indexData_.push_back(2);
82 indexData_.push_back(3);
83 indexData_.push_back(4);
84 indexData_.push_back(5);
85 indexData_.push_back(6);
86 indexData_.push_back(7);
87 indexData_.push_back(8);
88 indexData_.push_back(9);
89 indexData_.push_back(10);
90 indexData_.push_back(11);
91 indexData_.push_back(12);
92 indexData_.push_back(13);
93 indexData_.push_back(14);
94 indexData_.push_back(15);
95 indexData_.push_back(16);
96 indexData_.push_back(17);
97 indexData_.push_back(18);
98 indexData_.push_back(19);
99 indexData_.push_back(20);
100 indexData_.push_back(21);
101 indexData_.push_back(22);
102 indexData_.push_back(23);
103 indexData_.push_back(24);
104 indexData_.push_back(25);
105 indexData_.push_back(26);
106 indexData_.push_back(27);
107 indexData_.push_back(28);
108 indexData_.push_back(29);
109 indexData_.push_back(30);
110 indexData_.push_back(31);
111 indexData_.push_back(32);
112 indexData_.push_back(33);
113 indexData_.push_back(34);
114 indexData_.push_back(35);
115 indexData_.push_back(36);
116 indexData_.push_back(37);
117 indexData_.push_back(38);
118 indexData_.push_back(39);
119 indexData_.push_back(40);
120 indexData_.push_back(41);
121 indexData_.push_back(42);
122 indexData_.push_back(43);
123 indexData_.push_back(44);
124 indexData_.push_back(0);
125 indexData_.push_back(2);
126 indexData_.push_back(4);
127 indexData_.push_back(6);
128 indexData_.push_back(8);
129 indexData_.push_back(10);
130 indexData_.push_back(12);
131 indexData_.push_back(14);
132 indexData_.push_back(16);
133 indexData_.push_back(18);
134 indexData_.push_back(20);
135 indexData_.push_back(22);
136 indexData_.push_back(24);
137 indexData_.push_back(26);
138 indexData_.push_back(27);
139 indexData_.push_back(25);
140 indexData_.push_back(23);
141 indexData_.push_back(21);
142 indexData_.push_back(19);
143 indexData_.push_back(17);
144 indexData_.push_back(15);
145 indexData_.push_back(13);
146 indexData_.push_back(11);
147 indexData_.push_back(9);
148 indexData_.push_back(7);
149 indexData_.push_back(5);
150 indexData_.push_back(3);
151 indexData_.push_back(1);
152 indexData_.push_back(28);
153 indexData_.push_back(30);
154 indexData_.push_back(32);
155 indexData_.push_back(34);
156 indexData_.push_back(36);
157 indexData_.push_back(38);
158 indexData_.push_back(40);
159 indexData_.push_back(42);
160 indexData_.push_back(44);
161 indexData_.push_back(43);
162 indexData_.push_back(41);
163 indexData_.push_back(39);
164 indexData_.push_back(37);
165 indexData_.push_back(35);
166 indexData_.push_back(33);
167 indexData_.push_back(31);
168 indexData_.push_back(29);
169
170 // Primitive state so that the draw call can issue the primitives we want.
171 unsigned int curOffset(0);
172 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 28, curOffset));
173 curOffset += (28 * sizeof(unsigned int));
174 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 17, curOffset));
175 curOffset += (17 * sizeof(unsigned int));
176 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 28, curOffset));
177 curOffset += (28 * sizeof(unsigned int));
178 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 17, curOffset));
179}
0180
=== added file 'src/scene-ideas/characters.h'
--- src/scene-ideas/characters.h 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/characters.h 2012-05-09 20:57:19 +0000
@@ -0,0 +1,157 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#ifndef CHARACTERS_H_
24#define CHARACTERS_H_
25
26#include <vector>
27#include "vec.h"
28#include "gl-headers.h"
29
30class PrimitiveState
31{
32public:
33 PrimitiveState(unsigned int type, unsigned int count, unsigned int offset) :
34 type_(type),
35 count_(count),
36 bufferOffset_(offset) {}
37 ~PrimitiveState() {}
38 void issue() const
39 {
40 glDrawElements(type_, count_, GL_UNSIGNED_INT,
41 reinterpret_cast<const GLvoid*>(bufferOffset_));
42 }
43private:
44 PrimitiveState();
45 unsigned int type_; // Primitive type (e.g. GL_TRIANGLE_STRIP)
46 unsigned int count_; // Number of primitives
47 unsigned int bufferOffset_; // Offset into the element array buffer
48};
49
50struct Character
51{
52 void draw()
53 {
54 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
55 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
56 glVertexAttribPointer(vertexIndex_, 2, GL_FLOAT, GL_FALSE, 0, 0);
57 glEnableVertexAttribArray(vertexIndex_);
58 for (std::vector<PrimitiveState>::const_iterator primIt = primVec_.begin();
59 primIt != primVec_.end();
60 primIt++)
61 {
62 primIt->issue();
63 }
64 glBindBuffer(GL_ARRAY_BUFFER, 0);
65 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
66 }
67 void init(int vertexAttribIndex)
68 {
69 vertexIndex_ = vertexAttribIndex;
70
71 // We need 2 buffers for our work here. One for the vertex data.
72 // and one for the index data.
73 glGenBuffers(2, &bufferObjects_[0]);
74
75 // First, setup the vertex data by binding the first buffer object,
76 // allocating its data store, and filling it in with our vertex data.
77 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
78 glBufferData(GL_ARRAY_BUFFER, vertexData_.size() * sizeof(LibMatrix::vec2),
79 &vertexData_.front(), GL_STATIC_DRAW);
80
81 // Finally, setup the pointer to our vertex data and enable this
82 // attribute array.
83 glVertexAttribPointer(vertexIndex_, 2, GL_FLOAT, GL_FALSE, 0, 0);
84 glEnableVertexAttribArray(vertexIndex_);
85
86 // Now repeat for our index data.
87 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
88 glBufferData(GL_ELEMENT_ARRAY_BUFFER,
89 indexData_.size() * sizeof(unsigned int), &indexData_.front(),
90 GL_STATIC_DRAW);
91
92 // Unbind our vertex buffer objects so that their state isn't affected
93 // by other objects.
94 glBindBuffer(GL_ARRAY_BUFFER, 0);
95 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
96 }
97 ~Character()
98 {
99 glDeleteBuffers(2, &bufferObjects_[0]);
100 }
101 Character() :
102 vertexIndex_(0),
103 vertexArray_(0) {}
104 unsigned int bufferObjects_[2];
105 std::vector<LibMatrix::vec2> vertexData_;
106 std::vector<unsigned int> indexData_;
107 int vertexIndex_;
108 unsigned int vertexArray_;
109 std::vector<PrimitiveState> primVec_;
110};
111
112struct LetterI : Character
113{
114 LetterI();
115};
116
117struct LetterD : Character
118{
119 LetterD();
120};
121
122struct LetterE : Character
123{
124 LetterE();
125};
126
127struct LetterA : Character
128{
129 LetterA();
130};
131
132struct LetterS : Character
133{
134 LetterS();
135};
136
137struct LetterN : Character
138{
139 LetterN();
140};
141
142struct LetterM : Character
143{
144 LetterM();
145};
146
147struct LetterO : Character
148{
149 LetterO();
150};
151
152struct LetterT : Character
153{
154 LetterT();
155};
156
157#endif // CHARACTERS_H_
0158
=== added file 'src/scene-ideas/d.cc'
--- src/scene-ideas/d.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/d.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,142 @@
1/*
2 * Vertex position data describing the letter 'd'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterD::LetterD()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(4.714579, 9.987679));
33 vertexData_.push_back(vec2(2.841889, 9.429158));
34 vertexData_.push_back(vec2(2.825462, 9.166325));
35 vertexData_.push_back(vec2(1.856263, 8.722793));
36 vertexData_.push_back(vec2(2.004107, 8.000000));
37 vertexData_.push_back(vec2(0.969199, 7.605750));
38 vertexData_.push_back(vec2(1.494866, 6.636550));
39 vertexData_.push_back(vec2(0.607803, 6.028748));
40 vertexData_.push_back(vec2(1.527721, 4.960986));
41 vertexData_.push_back(vec2(0.772074, 4.254620));
42 vertexData_.push_back(vec2(1.774127, 4.139630));
43 vertexData_.push_back(vec2(1.445585, 3.186858));
44 vertexData_.push_back(vec2(2.266940, 3.843942));
45 vertexData_.push_back(vec2(2.250513, 3.022587));
46 vertexData_.push_back(vec2(2.776181, 3.843942));
47 vertexData_.push_back(vec2(3.137577, 3.383984));
48 vertexData_.push_back(vec2(3.351129, 4.008214));
49 vertexData_.push_back(vec2(3.909651, 4.451746));
50 vertexData_.push_back(vec2(4.090349, 4.960986));
51 vertexData_.push_back(vec2(4.862423, 5.946612));
52 vertexData_.push_back(vec2(4.763860, 6.652977));
53 vertexData_.push_back(vec2(5.388090, 7.572895));
54 vertexData_.push_back(vec2(4.862423, 8.492813));
55 vertexData_.push_back(vec2(5.618070, 9.921971));
56 vertexData_.push_back(vec2(4.698152, 10.940452));
57 vertexData_.push_back(vec2(5.338809, 12.303902));
58 vertexData_.push_back(vec2(4.238193, 12.960985));
59 vertexData_.push_back(vec2(4.451746, 14.554415));
60 vertexData_.push_back(vec2(3.581109, 14.291581));
61 vertexData_.push_back(vec2(3.613963, 15.342916));
62 vertexData_.push_back(vec2(2.677618, 15.145790));
63 vertexData_.push_back(vec2(2.480493, 15.540041));
64 vertexData_.push_back(vec2(2.036961, 15.211499));
65 vertexData_.push_back(vec2(1.281314, 15.112936));
66
67 // Index data...
68 indexData_.push_back(0);
69 indexData_.push_back(1);
70 indexData_.push_back(2);
71 indexData_.push_back(3);
72 indexData_.push_back(4);
73 indexData_.push_back(5);
74 indexData_.push_back(6);
75 indexData_.push_back(7);
76 indexData_.push_back(8);
77 indexData_.push_back(9);
78 indexData_.push_back(10);
79 indexData_.push_back(11);
80 indexData_.push_back(12);
81 indexData_.push_back(13);
82 indexData_.push_back(14);
83 indexData_.push_back(15);
84 indexData_.push_back(16);
85 indexData_.push_back(17);
86 indexData_.push_back(18);
87 indexData_.push_back(19);
88 indexData_.push_back(20);
89 indexData_.push_back(21);
90 indexData_.push_back(22);
91 indexData_.push_back(23);
92 indexData_.push_back(24);
93 indexData_.push_back(25);
94 indexData_.push_back(26);
95 indexData_.push_back(27);
96 indexData_.push_back(28);
97 indexData_.push_back(29);
98 indexData_.push_back(30);
99 indexData_.push_back(31);
100 indexData_.push_back(32);
101 indexData_.push_back(33);
102 indexData_.push_back(0);
103 indexData_.push_back(2);
104 indexData_.push_back(4);
105 indexData_.push_back(6);
106 indexData_.push_back(8);
107 indexData_.push_back(10);
108 indexData_.push_back(12);
109 indexData_.push_back(14);
110 indexData_.push_back(16);
111 indexData_.push_back(18);
112 indexData_.push_back(20);
113 indexData_.push_back(22);
114 indexData_.push_back(24);
115 indexData_.push_back(26);
116 indexData_.push_back(28);
117 indexData_.push_back(30);
118 indexData_.push_back(32);
119 indexData_.push_back(33);
120 indexData_.push_back(31);
121 indexData_.push_back(29);
122 indexData_.push_back(27);
123 indexData_.push_back(25);
124 indexData_.push_back(23);
125 indexData_.push_back(21);
126 indexData_.push_back(19);
127 indexData_.push_back(17);
128 indexData_.push_back(15);
129 indexData_.push_back(13);
130 indexData_.push_back(11);
131 indexData_.push_back(9);
132 indexData_.push_back(7);
133 indexData_.push_back(5);
134 indexData_.push_back(3);
135 indexData_.push_back(1);
136
137 // Primitive state so that the draw call can issue the primitives we want.
138 unsigned int curOffset(0);
139 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 34, curOffset));
140 curOffset += (34 * sizeof(unsigned int));
141 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 34, curOffset));
142}
0143
=== added file 'src/scene-ideas/e.cc'
--- src/scene-ideas/e.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/e.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,139 @@
1/*
2 * Vertex position data describing the letter 'e'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterE::LetterE()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(1.095436, 6.190871));
33 vertexData_.push_back(vec2(2.107884, 6.970954));
34 vertexData_.push_back(vec2(2.556017, 7.020747));
35 vertexData_.push_back(vec2(3.020747, 7.867220));
36 vertexData_.push_back(vec2(3.518672, 8.033195));
37 vertexData_.push_back(vec2(3.269710, 8.531120));
38 vertexData_.push_back(vec2(4.165975, 8.929461));
39 vertexData_.push_back(vec2(3.302905, 9.062241));
40 vertexData_.push_back(vec2(4.331950, 9.626556));
41 vertexData_.push_back(vec2(3.286307, 9.344398));
42 vertexData_.push_back(vec2(4.116183, 9.958507));
43 vertexData_.push_back(vec2(3.004149, 9.510373));
44 vertexData_.push_back(vec2(3.518672, 9.991701));
45 vertexData_.push_back(vec2(2.705394, 9.493776));
46 vertexData_.push_back(vec2(2.091286, 9.311203));
47 vertexData_.push_back(vec2(2.041494, 9.062241));
48 vertexData_.push_back(vec2(1.178423, 8.514523));
49 vertexData_.push_back(vec2(1.443983, 8.165976));
50 vertexData_.push_back(vec2(0.481328, 7.535270));
51 vertexData_.push_back(vec2(1.045643, 6.904564));
52 vertexData_.push_back(vec2(0.149378, 6.091286));
53 vertexData_.push_back(vec2(1.095436, 5.410789));
54 vertexData_.push_back(vec2(0.464730, 4.232365));
55 vertexData_.push_back(vec2(1.377593, 4.497925));
56 vertexData_.push_back(vec2(1.261411, 3.136930));
57 vertexData_.push_back(vec2(1.925311, 3.950207));
58 vertexData_.push_back(vec2(2.240664, 3.037344));
59 vertexData_.push_back(vec2(2.589212, 3.834025));
60 vertexData_.push_back(vec2(3.087137, 3.269710));
61 vertexData_.push_back(vec2(3.236515, 3.867220));
62 vertexData_.push_back(vec2(3.684647, 3.867220));
63 vertexData_.push_back(vec2(3.867220, 4.448133));
64 vertexData_.push_back(vec2(4.398340, 5.128631));
65
66 // Index data...
67 indexData_.push_back(0);
68 indexData_.push_back(1);
69 indexData_.push_back(2);
70 indexData_.push_back(3);
71 indexData_.push_back(4);
72 indexData_.push_back(5);
73 indexData_.push_back(6);
74 indexData_.push_back(7);
75 indexData_.push_back(8);
76 indexData_.push_back(9);
77 indexData_.push_back(10);
78 indexData_.push_back(11);
79 indexData_.push_back(12);
80 indexData_.push_back(13);
81 indexData_.push_back(14);
82 indexData_.push_back(15);
83 indexData_.push_back(16);
84 indexData_.push_back(17);
85 indexData_.push_back(18);
86 indexData_.push_back(19);
87 indexData_.push_back(20);
88 indexData_.push_back(21);
89 indexData_.push_back(22);
90 indexData_.push_back(23);
91 indexData_.push_back(24);
92 indexData_.push_back(25);
93 indexData_.push_back(26);
94 indexData_.push_back(27);
95 indexData_.push_back(28);
96 indexData_.push_back(29);
97 indexData_.push_back(30);
98 indexData_.push_back(31);
99 indexData_.push_back(32);
100 indexData_.push_back(0);
101 indexData_.push_back(2);
102 indexData_.push_back(4);
103 indexData_.push_back(6);
104 indexData_.push_back(8);
105 indexData_.push_back(10);
106 indexData_.push_back(12);
107 indexData_.push_back(14);
108 indexData_.push_back(16);
109 indexData_.push_back(18);
110 indexData_.push_back(20);
111 indexData_.push_back(22);
112 indexData_.push_back(24);
113 indexData_.push_back(26);
114 indexData_.push_back(28);
115 indexData_.push_back(30);
116 indexData_.push_back(32);
117 indexData_.push_back(31);
118 indexData_.push_back(29);
119 indexData_.push_back(27);
120 indexData_.push_back(25);
121 indexData_.push_back(23);
122 indexData_.push_back(21);
123 indexData_.push_back(19);
124 indexData_.push_back(17);
125 indexData_.push_back(15);
126 indexData_.push_back(13);
127 indexData_.push_back(11);
128 indexData_.push_back(9);
129 indexData_.push_back(7);
130 indexData_.push_back(5);
131 indexData_.push_back(3);
132 indexData_.push_back(1);
133
134 // Primitive state so that the draw call can issue the primitives we want.
135 unsigned int curOffset(0);
136 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 33, curOffset));
137 curOffset += (33 * sizeof(unsigned int));
138 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 33, curOffset));
139}
0140
=== added file 'src/scene-ideas/i.cc'
--- src/scene-ideas/i.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/i.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,116 @@
1/*
2 * Vertex position data describing the letter 'i'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterI::LetterI()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(0.548767, 9.414791));
33 vertexData_.push_back(vec2(2.795284, 9.757771));
34 vertexData_.push_back(vec2(1.457663, 9.311897));
35 vertexData_.push_back(vec2(2.503751, 9.157557));
36 vertexData_.push_back(vec2(1.714898, 8.986067));
37 vertexData_.push_back(vec2(2.109325, 7.785638));
38 vertexData_.push_back(vec2(1.286174, 7.013934));
39 vertexData_.push_back(vec2(1.800643, 6.070740));
40 vertexData_.push_back(vec2(0.994641, 5.161843));
41 vertexData_.push_back(vec2(1.783494, 4.767417));
42 vertexData_.push_back(vec2(0.943194, 4.167202));
43 vertexData_.push_back(vec2(1.852090, 4.304394));
44 vertexData_.push_back(vec2(1.063237, 3.549839));
45 vertexData_.push_back(vec2(2.023580, 3.978564));
46 vertexData_.push_back(vec2(1.406217, 3.172562));
47 vertexData_.push_back(vec2(2.315113, 3.875670));
48 vertexData_.push_back(vec2(2.006431, 3.018221));
49 vertexData_.push_back(vec2(2.812433, 3.944266));
50 vertexData_.push_back(vec2(2.726688, 3.429796));
51 vertexData_.push_back(vec2(3.258307, 4.132905));
52 vertexData_.push_back(vec2(1.989282, 10.923902));
53 vertexData_.push_back(vec2(2.778135, 12.295820));
54 vertexData_.push_back(vec2(2.966774, 11.678456));
55 vertexData_.push_back(vec2(3.687031, 12.947481));
56
57 // Index data...
58 indexData_.push_back(0);
59 indexData_.push_back(1);
60 indexData_.push_back(2);
61 indexData_.push_back(3);
62 indexData_.push_back(4);
63 indexData_.push_back(5);
64 indexData_.push_back(6);
65 indexData_.push_back(7);
66 indexData_.push_back(8);
67 indexData_.push_back(9);
68 indexData_.push_back(10);
69 indexData_.push_back(11);
70 indexData_.push_back(12);
71 indexData_.push_back(13);
72 indexData_.push_back(14);
73 indexData_.push_back(15);
74 indexData_.push_back(16);
75 indexData_.push_back(17);
76 indexData_.push_back(18);
77 indexData_.push_back(19);
78 indexData_.push_back(20);
79 indexData_.push_back(21);
80 indexData_.push_back(22);
81 indexData_.push_back(23);
82 indexData_.push_back(0);
83 indexData_.push_back(2);
84 indexData_.push_back(4);
85 indexData_.push_back(6);
86 indexData_.push_back(8);
87 indexData_.push_back(10);
88 indexData_.push_back(12);
89 indexData_.push_back(14);
90 indexData_.push_back(16);
91 indexData_.push_back(18);
92 indexData_.push_back(19);
93 indexData_.push_back(17);
94 indexData_.push_back(15);
95 indexData_.push_back(13);
96 indexData_.push_back(11);
97 indexData_.push_back(9);
98 indexData_.push_back(7);
99 indexData_.push_back(5);
100 indexData_.push_back(3);
101 indexData_.push_back(1);
102 indexData_.push_back(20);
103 indexData_.push_back(22);
104 indexData_.push_back(23);
105 indexData_.push_back(21);
106
107 // Primitive state so that the draw call can issue the primitives we want.
108 unsigned int curOffset(0);
109 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 20, curOffset));
110 curOffset += (20 * sizeof(unsigned int));
111 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 4, curOffset));
112 curOffset += (4 * sizeof(unsigned int));
113 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 20, curOffset));
114 curOffset += (20 * sizeof(unsigned int));
115 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 4, curOffset));
116}
0117
=== added file 'src/scene-ideas/lamp.cc'
--- src/scene-ideas/lamp.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/lamp.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,258 @@
1/*
2 * Vertex position data describing the lamp
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "lamp.h"
26#include "shader-source.h"
27#include "log.h"
28#include "scene.h"
29
30using std::string;
31using LibMatrix::vec3;
32using LibMatrix::vec4;
33using LibMatrix::Stack4;
34
35const string Lamp::modelviewName_("modelview");
36const string Lamp::projectionName_("projection");
37const string Lamp::light0PositionName_("light0Position");
38const string Lamp::light1PositionName_("light1Position");
39const string Lamp::light2PositionName_("light2Position");
40const string Lamp::vertexAttribName_("vertex");
41const string Lamp::normalAttribName_("normal");
42const string Lamp::normalMatrixName_("normalMatrix");
43
44Lamp::Lamp() :
45 valid_(false)
46{
47 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
48 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
49 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
50 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
51 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
52 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
53 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
54 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
55 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
56 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
57 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
58 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
59 vertexData_.push_back(vec3(0.000000, 0.000000, 1.000000));
60 vertexData_.push_back(vec3(0.438371, 0.000000, 0.898794));
61 vertexData_.push_back(vec3(0.379641, 0.219186, 0.898794));
62 vertexData_.push_back(vec3(0.219186, 0.379641, 0.898794));
63 vertexData_.push_back(vec3(0.000000, 0.438371, 0.898794));
64 vertexData_.push_back(vec3(-0.219186, 0.379641, 0.898794));
65 vertexData_.push_back(vec3(-0.379641, 0.219186, 0.898794));
66 vertexData_.push_back(vec3(-0.438371, 0.000000, 0.898794));
67 vertexData_.push_back(vec3(-0.379641, -0.219186, 0.898794));
68 vertexData_.push_back(vec3(-0.219186, -0.379641, 0.898794));
69 vertexData_.push_back(vec3(0.000000, -0.438371, 0.898794));
70 vertexData_.push_back(vec3(0.219186, -0.379641, 0.898794));
71 vertexData_.push_back(vec3(0.379641, -0.219186, 0.898794));
72 vertexData_.push_back(vec3(0.438371, 0.000000, 0.898794));
73 vertexData_.push_back(vec3(0.788011, 0.000000, 0.615662));
74 vertexData_.push_back(vec3(0.682437, 0.394005, 0.615662));
75 vertexData_.push_back(vec3(0.394005, 0.682437, 0.615662));
76 vertexData_.push_back(vec3(0.000000, 0.788011, 0.615662));
77 vertexData_.push_back(vec3(-0.394005, 0.682437, 0.615662));
78 vertexData_.push_back(vec3(-0.682437, 0.394005, 0.615662));
79 vertexData_.push_back(vec3(-0.788011, 0.000000, 0.615662));
80 vertexData_.push_back(vec3(-0.682437, -0.394005, 0.615662));
81 vertexData_.push_back(vec3(-0.394005, -0.682437, 0.615662));
82 vertexData_.push_back(vec3(0.000000, -0.788011, 0.615662));
83 vertexData_.push_back(vec3(0.394005, -0.682437, 0.615662));
84 vertexData_.push_back(vec3(0.682437, -0.394005, 0.615662));
85 vertexData_.push_back(vec3(0.788011, 0.000000, 0.615662));
86 vertexData_.push_back(vec3(0.978148, 0.000000, 0.207912));
87 vertexData_.push_back(vec3(0.847101, 0.489074, 0.207912));
88 vertexData_.push_back(vec3(0.489074, 0.847101, 0.207912));
89 vertexData_.push_back(vec3(0.000000, 0.978148, 0.207912));
90 vertexData_.push_back(vec3(-0.489074, 0.847101, 0.207912));
91 vertexData_.push_back(vec3(-0.847101, 0.489074, 0.207912));
92 vertexData_.push_back(vec3(-0.978148, 0.000000, 0.207912));
93 vertexData_.push_back(vec3(-0.847101, -0.489074, 0.207912));
94 vertexData_.push_back(vec3(-0.489074, -0.847101, 0.207912));
95 vertexData_.push_back(vec3(0.000000, -0.978148, 0.207912));
96 vertexData_.push_back(vec3(0.489074, -0.847101, 0.207912));
97 vertexData_.push_back(vec3(0.847101, -0.489074, 0.207912));
98 vertexData_.push_back(vec3(0.978148, 0.000000, 0.207912));
99 vertexData_.push_back(vec3(0.970296, 0.000000, -0.241922));
100 vertexData_.push_back(vec3(0.840301, 0.485148, -0.241922));
101 vertexData_.push_back(vec3(0.485148, 0.840301, -0.241922));
102 vertexData_.push_back(vec3(0.000000, 0.970296, -0.241922));
103 vertexData_.push_back(vec3(-0.485148, 0.840301, -0.241922));
104 vertexData_.push_back(vec3(-0.840301, 0.485148, -0.241922));
105 vertexData_.push_back(vec3(-0.970296, 0.000000, -0.241922));
106 vertexData_.push_back(vec3(-0.840301, -0.485148, -0.241922));
107 vertexData_.push_back(vec3(-0.485148, -0.840301, -0.241922));
108 vertexData_.push_back(vec3(0.000000, -0.970296, -0.241922));
109 vertexData_.push_back(vec3(0.485148, -0.840301, -0.241922));
110 vertexData_.push_back(vec3(0.840301, -0.485148, -0.241922));
111 vertexData_.push_back(vec3(0.970296, 0.000000, -0.241922));
112 vertexData_.push_back(vec3(0.766044, 0.000000, -0.642788));
113 vertexData_.push_back(vec3(0.663414, 0.383022, -0.642788));
114 vertexData_.push_back(vec3(0.383022, 0.663414, -0.642788));
115 vertexData_.push_back(vec3(0.000000, 0.766044, -0.642788));
116 vertexData_.push_back(vec3(-0.383022, 0.663414, -0.642788));
117 vertexData_.push_back(vec3(-0.663414, 0.383022, -0.642788));
118 vertexData_.push_back(vec3(-0.766044, 0.000000, -0.642788));
119 vertexData_.push_back(vec3(-0.663414, -0.383022, -0.642788));
120 vertexData_.push_back(vec3(-0.383022, -0.663414, -0.642788));
121 vertexData_.push_back(vec3(0.000000, -0.766044, -0.642788));
122 vertexData_.push_back(vec3(0.383022, -0.663414, -0.642788));
123 vertexData_.push_back(vec3(0.663414, -0.383022, -0.642788));
124 vertexData_.push_back(vec3(0.766044, 0.000000, -0.642788));
125
126 //
127 // The original implementation of both the logo and the lamp represented
128 // the vertex and normal data in a triply-dimensioned array of floats and
129 // all of the calls referenced double-indexed arrays of vector data.
130 // To my mind, this made the code look clunky and overly verbose.
131 // Representing the data as a STL vector of vec3 (itself a 3-float vector
132 // quantity) provides both an efficient container and allows for more
133 // concise looking code. The slightly goofy loops (using the original 2
134 // dimensional indices to compute a single offset into the STL vector) are
135 // a compromise to avoid rearranging the original data.
136 //
137 // - jesse 2010/10/04
138 //
139 for (unsigned int i = 0; i < 5; i++)
140 {
141 for (unsigned int j = 0; j < 13; j++)
142 {
143 indexData_.push_back(i * 13 + j);
144 indexData_.push_back((i + 1) * 13 + j);
145 }
146 }
147 unsigned int curIndex(5 * 13);
148 for (unsigned int i = 0; i < 12; i++)
149 {
150 indexData_.push_back(curIndex + i);
151 }
152}
153
154Lamp::~Lamp()
155{
156 if (valid_)
157 {
158 glDeleteBuffers(2, &bufferObjects_[0]);
159 }
160}
161
162void
163Lamp::init()
164{
165 // Make sure we don't re-initialize...
166 if (valid_)
167 {
168 return;
169 }
170
171 // Initialize shader sources from input files and create programs from them
172 // The program for handling lighting...
173 string lit_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-lit.vert");
174 string lit_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-lit.frag");
175 ShaderSource lit_vtx_source(lit_vtx_filename);
176 ShaderSource lit_frg_source(lit_frg_filename);
177 if (!Scene::load_shaders_from_strings(litProgram_, lit_vtx_source.str(),
178 lit_frg_source.str()))
179 {
180 Log::error("No valid program for lit lamp rendering\n");
181 return;
182 }
183
184 // The simple program with no lighting...
185 string unlit_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-unlit.vert");
186 string unlit_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-lamp-unlit.frag");
187 ShaderSource unlit_vtx_source(unlit_vtx_filename);
188 ShaderSource unlit_frg_source(unlit_frg_filename);
189 if (!Scene::load_shaders_from_strings(unlitProgram_, unlit_vtx_source.str(),
190 unlit_frg_source.str()))
191 {
192 Log::error("No valid program for unlit lamp rendering.\n");
193 return;
194 }
195
196 // We need 2 buffers for our work here. One for the vertex data.
197 // and one for the index data.
198 glGenBuffers(2, &bufferObjects_[0]);
199
200 // First, setup the vertex data by binding the first buffer object,
201 // allocating its data store, and filling it in with our vertex data.
202 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
203 glBufferData(GL_ARRAY_BUFFER, vertexData_.size() * sizeof(vec3), &vertexData_.front(), GL_STATIC_DRAW);
204
205 // Now repeat for our index data.
206 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
207 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int), &indexData_.front(), GL_STATIC_DRAW);
208
209 // We're ready to go.
210 valid_ = true;
211}
212
213void
214Lamp::draw(Stack4& modelview, Stack4& projection, const vec4* lightPositions)
215{
216 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
217 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
218
219 litProgram_.start();
220 int vertexIndex(litProgram_[vertexAttribName_].location());
221 int normalIndex(litProgram_[normalAttribName_].location());
222 glVertexAttribPointer(vertexIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
223 glVertexAttribPointer(normalIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
224 glEnableVertexAttribArray(vertexIndex);
225 glEnableVertexAttribArray(normalIndex);
226 const LibMatrix::mat4& mv = modelview.getCurrent();
227 LibMatrix::mat3 normalMatrix(mv[0][0], mv[1][0], mv[2][0],
228 mv[0][1], mv[1][1], mv[2][1],
229 mv[0][2], mv[1][2], mv[2][2]);
230 normalMatrix.transpose().inverse();
231 litProgram_[normalMatrixName_] = normalMatrix;
232 litProgram_[modelviewName_] = mv;
233 litProgram_[projectionName_] = projection.getCurrent();
234 litProgram_[light0PositionName_] = lightPositions[0];
235 litProgram_[light1PositionName_] = lightPositions[1];
236 litProgram_[light2PositionName_] = lightPositions[2];
237 static const unsigned int sui(sizeof(unsigned int));
238 for (unsigned int i = 0; i < 5; i++)
239 {
240 glDrawElements(GL_TRIANGLE_STRIP, 26, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid*>(i * 26 * sui));
241 }
242 glDisableVertexAttribArray(normalIndex);
243 glDisableVertexAttribArray(vertexIndex);
244 litProgram_.stop();
245
246 unlitProgram_.start();
247 vertexIndex = unlitProgram_[vertexAttribName_].location();
248 glVertexAttribPointer(vertexIndex, 3, GL_FLOAT, GL_FALSE, 0, 0);
249 glEnableVertexAttribArray(vertexIndex);
250 unlitProgram_[modelviewName_] = mv;
251 unlitProgram_[projectionName_] = projection.getCurrent();
252 glDrawElements(GL_TRIANGLE_FAN, 12, GL_UNSIGNED_INT, reinterpret_cast<const GLvoid*>(5 * 26 * sui));
253 glDisableVertexAttribArray(vertexIndex);
254 unlitProgram_.stop();
255
256 glBindBuffer(GL_ARRAY_BUFFER, 0);
257 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
258}
0259
=== added file 'src/scene-ideas/lamp.h'
--- src/scene-ideas/lamp.h 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/lamp.h 2012-05-09 20:57:19 +0000
@@ -0,0 +1,64 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#ifndef LAMP_H_
24#define LAMP_H_
25
26#include <string>
27#include <vector>
28#include "vec.h"
29#include "stack.h"
30#include "gl-headers.h"
31#include "program.h"
32
33class Lamp
34{
35public:
36 Lamp();
37 ~Lamp();
38
39 void init();
40 bool valid() const { return valid_; }
41 void draw(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection,
42 const LibMatrix::vec4* lightPositions);
43private:
44 Program litProgram_;
45 Program unlitProgram_;
46 std::string litVertexShader_;
47 std::string litFragmentShader_;
48 std::string unlitVertexShader_;
49 std::string unlitFragmentShader_;
50 static const std::string modelviewName_;
51 static const std::string projectionName_;
52 static const std::string light0PositionName_;
53 static const std::string light1PositionName_;
54 static const std::string light2PositionName_;
55 static const std::string vertexAttribName_;
56 static const std::string normalAttribName_;
57 static const std::string normalMatrixName_;
58 std::vector<LibMatrix::vec3> vertexData_;
59 std::vector<unsigned int> indexData_;
60 unsigned int bufferObjects_[2];
61 bool valid_;
62};
63
64#endif // LAMP_H_
065
=== added file 'src/scene-ideas/logo.cc'
--- src/scene-ideas/logo.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/logo.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,789 @@
1/*
2 * Vertex position data describing the old Silicon Graphics logo
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "logo.h"
26#include "scene.h"
27#include "shader-source.h"
28#include "log.h"
29
30using std::string;
31using LibMatrix::vec3;
32using LibMatrix::uvec3;
33using LibMatrix::vec4;
34using LibMatrix::Stack4;
35using LibMatrix::mat4;
36
37const unsigned int SGILogo::textureResolution_(32);
38const string SGILogo::modelviewName_("modelview");
39const string SGILogo::projectionName_("projection");
40const string SGILogo::lightPositionName_("light0Position");
41const string SGILogo::logoColorName_("logoColor");
42const string SGILogo::vertexAttribName_("vertex");
43const string SGILogo::normalAttribName_("normal");
44const string SGILogo::normalMatrixName_("normalMatrix");
45
46SGILogo::SGILogo(void) :
47 normalNormalIndex_(0),
48 normalVertexIndex_(0),
49 flatVertexIndex_(0),
50 shadowVertexIndex_(0),
51 vertexIndex_(0),
52 valid_(false),
53 drawStyle_(LOGO_NORMAL)
54{
55 // Single cylinder data...
56 singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
57 singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 5.000000));
58 singleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
59 singleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 5.000000));
60 singleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
61 singleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 5.000000));
62 singleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
63 singleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 5.000000));
64 singleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
65 singleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 5.000000));
66 singleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
67 singleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 5.000000));
68 singleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
69 singleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 5.000000));
70 singleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
71 singleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 5.000000));
72 singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
73 singleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 5.000000));
74
75 singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
76 singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
77 singleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
78 singleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
79 singleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
80 singleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
81 singleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
82 singleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
83 singleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
84 singleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
85 singleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
86 singleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
87 singleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
88 singleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
89 singleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
90 singleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
91 singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
92 singleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
93
94 // Double cylinder data...
95 doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
96 doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 7.000000));
97 doubleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
98 doubleCylinderVertices_.push_back(vec3(0.707107, 0.707107, 7.000000));
99 doubleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
100 doubleCylinderVertices_.push_back(vec3(0.000000, 1.000000, 7.000000));
101 doubleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
102 doubleCylinderVertices_.push_back(vec3(-0.707107, 0.707107, 7.000000));
103 doubleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
104 doubleCylinderVertices_.push_back(vec3(-1.000000, 0.000000, 7.000000));
105 doubleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
106 doubleCylinderVertices_.push_back(vec3(-0.707107, -0.707107, 7.000000));
107 doubleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
108 doubleCylinderVertices_.push_back(vec3(0.000000, -1.000000, 7.000000));
109 doubleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
110 doubleCylinderVertices_.push_back(vec3(0.707107, -0.707107, 7.000000));
111 doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
112 doubleCylinderVertices_.push_back(vec3(1.000000, 0.000000, 7.000000));
113
114 doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
115 doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
116 doubleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
117 doubleCylinderNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
118 doubleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
119 doubleCylinderNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
120 doubleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
121 doubleCylinderNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
122 doubleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
123 doubleCylinderNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
124 doubleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
125 doubleCylinderNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
126 doubleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
127 doubleCylinderNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
128 doubleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
129 doubleCylinderNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
130 doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
131 doubleCylinderNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
132
133 // Elbow data...
134 elbowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
135 elbowVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
136 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
137 elbowVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
138 elbowVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
139 elbowVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
140 elbowVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
141 elbowVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
142 elbowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
143 elbowVertices_.push_back(vec3(1.000000, 0.034074, 0.258819));
144 elbowVertices_.push_back(vec3(0.707107, 0.717087, 0.075806));
145 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
146 elbowVertices_.push_back(vec3(-0.707107, 0.717087, 0.075806));
147 elbowVertices_.push_back(vec3(-1.000000, 0.034074, 0.258819));
148 elbowVertices_.push_back(vec3(-0.707107, -0.648939, 0.441832));
149 elbowVertices_.push_back(vec3(0.000000, -0.931852, 0.517638));
150 elbowVertices_.push_back(vec3(0.707107, -0.648939, 0.441832));
151 elbowVertices_.push_back(vec3(1.000000, 0.034074, 0.258819));
152 elbowVertices_.push_back(vec3(1.000000, 0.133975, 0.500000));
153 elbowVertices_.push_back(vec3(0.707107, 0.746347, 0.146447));
154 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
155 elbowVertices_.push_back(vec3(-0.707107, 0.746347, 0.146447));
156 elbowVertices_.push_back(vec3(-1.000000, 0.133975, 0.500000));
157 elbowVertices_.push_back(vec3(-0.707107, -0.478398, 0.853553));
158 elbowVertices_.push_back(vec3(0.000000, -0.732051, 1.000000));
159 elbowVertices_.push_back(vec3(0.707107, -0.478398, 0.853553));
160 elbowVertices_.push_back(vec3(1.000000, 0.133975, 0.500000));
161 elbowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
162 elbowVertices_.push_back(vec3(0.707107, 0.792893, 0.207107));
163 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
164 elbowVertices_.push_back(vec3(-0.707107, 0.792893, 0.207107));
165 elbowVertices_.push_back(vec3(-1.000000, 0.292893, 0.707107));
166 elbowVertices_.push_back(vec3(-0.707107, -0.207107, 1.207107));
167 elbowVertices_.push_back(vec3(0.000000, -0.414214, 1.414214));
168 elbowVertices_.push_back(vec3(0.707107, -0.207107, 1.207107));
169 elbowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
170 elbowVertices_.push_back(vec3(1.000000, 0.500000, 0.866025));
171 elbowVertices_.push_back(vec3(0.707107, 0.853553, 0.253653));
172 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
173 elbowVertices_.push_back(vec3(-0.707107, 0.853553, 0.253653));
174 elbowVertices_.push_back(vec3(-1.000000, 0.500000, 0.866025));
175 elbowVertices_.push_back(vec3(-0.707107, 0.146447, 1.478398));
176 elbowVertices_.push_back(vec3(0.000000, 0.000000, 1.732051));
177 elbowVertices_.push_back(vec3(0.707107, 0.146447, 1.478398));
178 elbowVertices_.push_back(vec3(1.000000, 0.500000, 0.866025));
179 elbowVertices_.push_back(vec3(1.000000, 0.741181, 0.965926));
180 elbowVertices_.push_back(vec3(0.707107, 0.924194, 0.282913));
181 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
182 elbowVertices_.push_back(vec3(-0.707107, 0.924194, 0.282913));
183 elbowVertices_.push_back(vec3(-1.000000, 0.741181, 0.965926));
184 elbowVertices_.push_back(vec3(-0.707107, 0.558168, 1.648939));
185 elbowVertices_.push_back(vec3(0.000000, 0.482362, 1.931852));
186 elbowVertices_.push_back(vec3(0.707107, 0.558168, 1.648939));
187 elbowVertices_.push_back(vec3(1.000000, 0.741181, 0.965926));
188 elbowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
189 elbowVertices_.push_back(vec3(0.707107, 1.000000, 0.292893));
190 elbowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
191 elbowVertices_.push_back(vec3(-0.707107, 1.000000, 0.292893));
192 elbowVertices_.push_back(vec3(-1.000000, 1.000000, 1.000000));
193 elbowVertices_.push_back(vec3(-0.707107, 1.000000, 1.707107));
194 elbowVertices_.push_back(vec3(0.000000, 1.000000, 2.000000));
195 elbowVertices_.push_back(vec3(0.707107, 1.000000, 1.707107));
196 elbowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
197
198 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
199 elbowNormals_.push_back(vec3(0.707107, 0.707107, 0.000000));
200 elbowNormals_.push_back(vec3(0.000000, 1.000000, 0.000000));
201 elbowNormals_.push_back(vec3(-0.707107, 0.707107, 0.000000));
202 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
203 elbowNormals_.push_back(vec3(-0.707107, -0.707107, 0.000000));
204 elbowNormals_.push_back(vec3(0.000000, -1.000000, 0.000000));
205 elbowNormals_.push_back(vec3(0.707107, -0.707107, 0.000000));
206 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
207 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
208 elbowNormals_.push_back(vec3(0.707107, 0.683013, -0.183013));
209 elbowNormals_.push_back(vec3(0.000000, 0.965926, -0.258819));
210 elbowNormals_.push_back(vec3(-0.707107, 0.683013, -0.183013));
211 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
212 elbowNormals_.push_back(vec3(-0.707107, -0.683013, 0.183013));
213 elbowNormals_.push_back(vec3(0.000000, -0.965926, 0.258819));
214 elbowNormals_.push_back(vec3(0.707107, -0.683013, 0.183013));
215 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
216 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
217 elbowNormals_.push_back(vec3(0.707107, 0.612372, -0.353553));
218 elbowNormals_.push_back(vec3(0.000000, 0.866025, -0.500000));
219 elbowNormals_.push_back(vec3(-0.707107, 0.612372, -0.353553));
220 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
221 elbowNormals_.push_back(vec3(-0.707107, -0.612372, 0.353553));
222 elbowNormals_.push_back(vec3(0.000000, -0.866025, 0.500000));
223 elbowNormals_.push_back(vec3(0.707107, -0.612372, 0.353553));
224 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
225 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
226 elbowNormals_.push_back(vec3(0.707107, 0.500000, -0.500000));
227 elbowNormals_.push_back(vec3(0.000000, 0.707107, -0.707107));
228 elbowNormals_.push_back(vec3(-0.707107, 0.500000, -0.500000));
229 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
230 elbowNormals_.push_back(vec3(-0.707107, -0.500000, 0.500000));
231 elbowNormals_.push_back(vec3(0.000000, -0.707107, 0.707107));
232 elbowNormals_.push_back(vec3(0.707107, -0.500000, 0.500000));
233 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
234 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
235 elbowNormals_.push_back(vec3(0.707107, 0.353553, -0.612372));
236 elbowNormals_.push_back(vec3(0.000000, 0.500000, -0.866025));
237 elbowNormals_.push_back(vec3(-0.707107, 0.353553, -0.612372));
238 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
239 elbowNormals_.push_back(vec3(-0.707107, -0.353553, 0.612372));
240 elbowNormals_.push_back(vec3(0.000000, -0.500000, 0.866025));
241 elbowNormals_.push_back(vec3(0.707107, -0.353553, 0.612372));
242 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
243 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
244 elbowNormals_.push_back(vec3(0.707107, 0.183013, -0.683013));
245 elbowNormals_.push_back(vec3(0.000000, 0.258819, -0.965926));
246 elbowNormals_.push_back(vec3(-0.707107, 0.183013, -0.683013));
247 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
248 elbowNormals_.push_back(vec3(-0.707107, -0.183013, 0.683013));
249 elbowNormals_.push_back(vec3(0.000000, -0.258819, 0.965926));
250 elbowNormals_.push_back(vec3(0.707107, -0.183013, 0.683013));
251 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
252 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
253 elbowNormals_.push_back(vec3(0.707107, 0.000000, -0.707107));
254 elbowNormals_.push_back(vec3(0.000000, 0.000000, -1.000000));
255 elbowNormals_.push_back(vec3(-0.707107, 0.000000, -0.707107));
256 elbowNormals_.push_back(vec3(-1.000000, 0.000000, 0.000000));
257 elbowNormals_.push_back(vec3(-0.707107, 0.000000, 0.707107));
258 elbowNormals_.push_back(vec3(0.000000, 0.000000, 1.000000));
259 elbowNormals_.push_back(vec3(0.707107, 0.000000, 0.707107));
260 elbowNormals_.push_back(vec3(1.000000, 0.000000, 0.000000));
261
262 elbowShadowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
263 elbowShadowVertices_.push_back(vec3(0.707107, 0.707107, 0.000000));
264 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
265 elbowShadowVertices_.push_back(vec3(-0.707107, 0.707107, 0.000000));
266 elbowShadowVertices_.push_back(vec3(-1.000000, 0.000000, 0.000000));
267 elbowShadowVertices_.push_back(vec3(-0.707107, -0.707107, 0.000000));
268 elbowShadowVertices_.push_back(vec3(0.000000, -1.000000, 0.000000));
269 elbowShadowVertices_.push_back(vec3(0.707107, -0.707107, 0.000000));
270 elbowShadowVertices_.push_back(vec3(1.000000, 0.000000, 0.000000));
271 elbowShadowVertices_.push_back(vec3(1.000000, 0.019215, 0.195090));
272 elbowShadowVertices_.push_back(vec3(0.707107, 0.712735, 0.057141));
273 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
274 elbowShadowVertices_.push_back(vec3(-0.707107, 0.712735, 0.057141));
275 elbowShadowVertices_.push_back(vec3(-1.000000, 0.019215, 0.195090));
276 elbowShadowVertices_.push_back(vec3(-0.707107, -0.674305, 0.333040));
277 elbowShadowVertices_.push_back(vec3(0.000000, -0.961571, 0.390181));
278 elbowShadowVertices_.push_back(vec3(0.707107, -0.674305, 0.333040));
279 elbowShadowVertices_.push_back(vec3(1.000000, 0.019215, 0.195090));
280 elbowShadowVertices_.push_back(vec3(1.000000, 0.076120, 0.382683));
281 elbowShadowVertices_.push_back(vec3(0.707107, 0.729402, 0.112085));
282 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
283 elbowShadowVertices_.push_back(vec3(-0.707107, 0.729402, 0.112085));
284 elbowShadowVertices_.push_back(vec3(-1.000000, 0.076120, 0.382683));
285 elbowShadowVertices_.push_back(vec3(-0.707107, -0.577161, 0.653282));
286 elbowShadowVertices_.push_back(vec3(0.000000, -0.847759, 0.765367));
287 elbowShadowVertices_.push_back(vec3(0.707107, -0.577161, 0.653282));
288 elbowShadowVertices_.push_back(vec3(1.000000, 0.076120, 0.382683));
289 elbowShadowVertices_.push_back(vec3(1.000000, 0.168530, 0.555570));
290 elbowShadowVertices_.push_back(vec3(0.707107, 0.756468, 0.162723));
291 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
292 elbowShadowVertices_.push_back(vec3(-0.707107, 0.756468, 0.162723));
293 elbowShadowVertices_.push_back(vec3(-1.000000, 0.168530, 0.555570));
294 elbowShadowVertices_.push_back(vec3(-0.707107, -0.419407, 0.948418));
295 elbowShadowVertices_.push_back(vec3(0.000000, -0.662939, 1.111140));
296 elbowShadowVertices_.push_back(vec3(0.707107, -0.419407, 0.948418));
297 elbowShadowVertices_.push_back(vec3(1.000000, 0.168530, 0.555570));
298 elbowShadowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
299 elbowShadowVertices_.push_back(vec3(0.707107, 0.792893, 0.207107));
300 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
301 elbowShadowVertices_.push_back(vec3(-0.707107, 0.792893, 0.207107));
302 elbowShadowVertices_.push_back(vec3(-1.000000, 0.292893, 0.707107));
303 elbowShadowVertices_.push_back(vec3(-0.707107, -0.207107, 1.207107));
304 elbowShadowVertices_.push_back(vec3(0.000000, -0.414214, 1.414214));
305 elbowShadowVertices_.push_back(vec3(0.707107, -0.207107, 1.207107));
306 elbowShadowVertices_.push_back(vec3(1.000000, 0.292893, 0.707107));
307 elbowShadowVertices_.push_back(vec3(1.000000, 0.444430, 0.831470));
308 elbowShadowVertices_.push_back(vec3(0.707107, 0.837277, 0.243532));
309 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
310 elbowShadowVertices_.push_back(vec3(-0.707107, 0.837277, 0.243532));
311 elbowShadowVertices_.push_back(vec3(-1.000000, 0.444430, 0.831470));
312 elbowShadowVertices_.push_back(vec3(-0.707107, 0.051582, 1.419407));
313 elbowShadowVertices_.push_back(vec3(0.000000, -0.111140, 1.662939));
314 elbowShadowVertices_.push_back(vec3(0.707107, 0.051582, 1.419407));
315 elbowShadowVertices_.push_back(vec3(1.000000, 0.444430, 0.831470));
316 elbowShadowVertices_.push_back(vec3(1.000000, 0.617317, 0.923880));
317 elbowShadowVertices_.push_back(vec3(0.707107, 0.887915, 0.270598));
318 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
319 elbowShadowVertices_.push_back(vec3(-0.707107, 0.887915, 0.270598));
320 elbowShadowVertices_.push_back(vec3(-1.000000, 0.617317, 0.923880));
321 elbowShadowVertices_.push_back(vec3(-0.707107, 0.346719, 1.577161));
322 elbowShadowVertices_.push_back(vec3(0.000000, 0.234633, 1.847759));
323 elbowShadowVertices_.push_back(vec3(0.707107, 0.346719, 1.577161));
324 elbowShadowVertices_.push_back(vec3(1.000000, 0.617317, 0.923880));
325 elbowShadowVertices_.push_back(vec3(1.000000, 0.804910, 0.980785));
326 elbowShadowVertices_.push_back(vec3(0.707107, 0.942859, 0.287265));
327 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
328 elbowShadowVertices_.push_back(vec3(-0.707107, 0.942859, 0.287265));
329 elbowShadowVertices_.push_back(vec3(-1.000000, 0.804910, 0.980785));
330 elbowShadowVertices_.push_back(vec3(-0.707107, 0.666960, 1.674305));
331 elbowShadowVertices_.push_back(vec3(0.000000, 0.609819, 1.961571));
332 elbowShadowVertices_.push_back(vec3(0.707107, 0.666960, 1.674305));
333 elbowShadowVertices_.push_back(vec3(1.000000, 0.804910, 0.980785));
334 elbowShadowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
335 elbowShadowVertices_.push_back(vec3(0.707107, 1.000000, 0.292893));
336 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 0.000000));
337 elbowShadowVertices_.push_back(vec3(-0.707107, 1.000000, 0.292893));
338 elbowShadowVertices_.push_back(vec3(-1.000000, 1.000000, 1.000000));
339 elbowShadowVertices_.push_back(vec3(-0.707107, 1.000000, 1.707107));
340 elbowShadowVertices_.push_back(vec3(0.000000, 1.000000, 2.000000));
341 elbowShadowVertices_.push_back(vec3(0.707107, 1.000000, 1.707107));
342 elbowShadowVertices_.push_back(vec3(1.000000, 1.000000, 1.000000));
343
344 // Now that we've setup the vertex data, we can setup the map of how
345 // that data will be laid out in the buffer object.
346 static const unsigned int sv3(sizeof(vec3));
347 dataMap_.scvOffset = 0;
348 dataMap_.scvSize = singleCylinderVertices_.size() * sv3;
349 dataMap_.totalSize = dataMap_.scvSize;
350 dataMap_.scnOffset = dataMap_.scvOffset + dataMap_.scvSize;
351 dataMap_.scnSize = singleCylinderNormals_.size() * sv3;
352 dataMap_.totalSize += dataMap_.scnSize;
353 dataMap_.dcvOffset = dataMap_.scnOffset + dataMap_.scnSize;
354 dataMap_.dcvSize = doubleCylinderVertices_.size() * sv3;
355 dataMap_.totalSize += dataMap_.dcvSize;
356 dataMap_.dcnOffset = dataMap_.dcvOffset + dataMap_.dcvSize;
357 dataMap_.dcnSize = doubleCylinderNormals_.size() * sv3;
358 dataMap_.totalSize += dataMap_.dcnSize;
359 dataMap_.evOffset = dataMap_.dcnOffset + dataMap_.dcnSize;
360 dataMap_.evSize = elbowVertices_.size() * sv3;
361 dataMap_.totalSize += dataMap_.evSize;
362 dataMap_.enOffset = dataMap_.evOffset + dataMap_.evSize;
363 dataMap_.enSize = elbowNormals_.size() * sv3;
364 dataMap_.totalSize += dataMap_.enSize;
365 dataMap_.esvOffset = dataMap_.enOffset + dataMap_.enSize;
366 dataMap_.esvSize = elbowShadowVertices_.size() * sv3;
367 dataMap_.totalSize += dataMap_.esvSize;
368
369 //
370 // The original implementation of both the logo and the lamp represented
371 // the vertex and normal data in a triply-dimensioned array of floats and
372 // all of the calls referenced double-indexed arrays of vector data.
373 // To my mind, this made the code look clunky and overly verbose.
374 // Representing the data as a STL vector of vec3 (itself a 3-float vector
375 // quantity) provides both an efficient container and allows for more
376 // concise looking code. The slightly goofy loops (using the original 2
377 // dimensional indices to compute a single offset into the STL vector) are
378 // a compromise to avoid rearranging the original data.
379 //
380 // - jesse 2010/10/04
381 //
382 for (unsigned int i = 0; i < 8; i++)
383 {
384 for (unsigned int j = 0; j < 9; j++)
385 {
386 unsigned int index1(i * 9 + j);
387 unsigned int index2((i + 1) * 9 + j);
388 indexData_.push_back(index1);
389 indexData_.push_back(index2);
390 }
391 }
392
393 // Initialize the stipple pattern
394 static const unsigned int patterns[] = { 0xaaaaaaaa, 0x55555555 };
395 for (unsigned int i = 0; i < textureResolution_; i++)
396 {
397 for (unsigned int j = 0; j < textureResolution_; j++)
398 {
399 // Alternate the pattern every other line.
400 unsigned int curMask(1 << j);
401 unsigned int curPattern(patterns[i % 2]);
402 textureImage_[i][j] = ((curPattern & curMask) >> j) * 255;
403 }
404 }
405}
406
407SGILogo::~SGILogo()
408{
409 if (valid_)
410 {
411 glDeleteBuffers(2, &bufferObjects_[0]);
412 }
413}
414
415void
416SGILogo::init()
417{
418 // Make sure we don't re-initialize...
419 if (valid_)
420 {
421 return;
422 }
423
424 // Initialize shader sources from input files and create programs from them
425 // The program for handling the main object with lighting...
426 string logo_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-logo.vert");
427 string logo_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-logo.frag");
428 ShaderSource logo_vtx_source(logo_vtx_filename);
429 ShaderSource logo_frg_source(logo_frg_filename);
430 if (!Scene::load_shaders_from_strings(normalProgram_, logo_vtx_source.str(),
431 logo_frg_source.str()))
432 {
433 Log::error("No valid program for normal logo rendering\n");
434 return;
435 }
436 normalVertexIndex_ = normalProgram_[vertexAttribName_].location();
437 normalNormalIndex_ = normalProgram_[normalAttribName_].location();
438
439 // The program for handling the flat object...
440 string logo_flat_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-flat.vert");
441 string logo_flat_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-flat.frag");
442 ShaderSource logo_flat_vtx_source(logo_flat_vtx_filename);
443 ShaderSource logo_flat_frg_source(logo_flat_frg_filename);
444 if (!Scene::load_shaders_from_strings(flatProgram_, logo_flat_vtx_source.str(),
445 logo_flat_frg_source.str()))
446 {
447 Log::error("No valid program for flat logo rendering\n");
448 return;
449 }
450 flatVertexIndex_ = flatProgram_[vertexAttribName_].location();
451
452 // The program for handling the shadow object with texturing...
453 string logo_shadow_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-shadow.vert");
454 string logo_shadow_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-logo-shadow.frag");
455 ShaderSource logo_shadow_vtx_source(logo_shadow_vtx_filename);
456 ShaderSource logo_shadow_frg_source(logo_shadow_frg_filename);
457 if (!Scene::load_shaders_from_strings(shadowProgram_, logo_shadow_vtx_source.str(),
458 logo_shadow_frg_source.str()))
459 {
460 Log::error("No valid program for shadow logo rendering\n");
461 return;
462 }
463 shadowVertexIndex_ = shadowProgram_[vertexAttribName_].location();
464
465 // We need 2 buffers for our work here. One for the vertex data.
466 // and one for the index data.
467 glGenBuffers(2, &bufferObjects_[0]);
468
469 // First, setup the vertex data by binding the first buffer object,
470 // allocating its data store, and filling it in with our vertex data.
471 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
472 glBufferData(GL_ARRAY_BUFFER, dataMap_.totalSize, 0, GL_STATIC_DRAW);
473 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.scvOffset, dataMap_.scvSize,
474 &singleCylinderVertices_.front());
475 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.scnOffset, dataMap_.scnSize,
476 &singleCylinderNormals_.front());
477 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.dcvOffset, dataMap_.dcvSize,
478 &doubleCylinderVertices_.front());
479 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.dcnOffset, dataMap_.dcnSize,
480 &doubleCylinderNormals_.front());
481 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.evOffset, dataMap_.evSize,
482 &elbowVertices_.front());
483 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.enOffset, dataMap_.enSize,
484 &elbowNormals_.front());
485 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.esvOffset, dataMap_.esvSize,
486 &elbowShadowVertices_.front());
487
488 // Now repeat for our index data.
489 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
490 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int),
491 &indexData_.front(), GL_STATIC_DRAW);
492
493 // Setup our the texture that the shadow program will use...
494 glGenTextures(1, &textureName_);
495 glBindTexture(GL_TEXTURE_2D, textureName_);
496 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
497 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
498 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
499 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
500 glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
501 textureResolution_, textureResolution_,
502 0, GL_ALPHA, GL_UNSIGNED_BYTE, textureImage_);
503
504 // We're ready to go.
505 valid_ = true;
506}
507
508void
509SGILogo::bendForward(Stack4& ms)
510{
511 ms.translate(0.0, 1.0, 0.0);
512 ms.rotate(90.0, 1.0, 0.0, 0.0);
513 ms.translate(0.0, -1.0, 0.0);
514}
515
516void
517SGILogo::bendLeft(Stack4& ms)
518{
519 ms.rotate(-90.0, 0.0, 0.0, 1.0);
520 ms.translate(0.0, 1.0, 0.0);
521 ms.rotate(90.0, 1.0, 0.0, 0.0);
522 ms.translate(0.0, -1.0, 0.0);
523}
524
525void
526SGILogo::bendRight(Stack4& ms)
527{
528 ms.rotate(90.0, 0.0, 0.0, 1.0);
529 ms.translate(0.0, 1.0, 0.0);
530 ms.rotate(90.0, 1.0, 0.0, 0.0);
531 ms.translate(0.0, -1.0, 0.0);
532}
533
534void
535SGILogo::drawDoubleCylinder(void)
536{
537 glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
538 reinterpret_cast<const GLvoid*>(dataMap_.dcvOffset));
539 if (drawStyle_ == LOGO_NORMAL)
540 {
541 glVertexAttribPointer(normalNormalIndex_, 3, GL_FLOAT, GL_FALSE, 0,
542 reinterpret_cast<const GLvoid*>(dataMap_.dcnOffset));
543 }
544 glDrawArrays(GL_TRIANGLE_STRIP, 0, 18);
545}
546
547void
548SGILogo::drawSingleCylinder(void)
549{
550 glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
551 reinterpret_cast<const GLvoid*>(dataMap_.scvOffset));
552 if (drawStyle_ == LOGO_NORMAL)
553 {
554 glVertexAttribPointer(normalNormalIndex_, 3, GL_FLOAT, GL_FALSE, 0,
555 reinterpret_cast<const GLvoid*>(dataMap_.scnOffset));
556 }
557 glDrawArrays(GL_TRIANGLE_STRIP, 0, 18);
558}
559
560void
561SGILogo::drawElbow(void)
562{
563 static const unsigned int sui(sizeof(unsigned int));
564 unsigned int startIdx(0);
565 unsigned int endIdx(6);
566 if (drawStyle_ == LOGO_NORMAL)
567 {
568 glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
569 reinterpret_cast<const GLvoid*>(dataMap_.evOffset));
570 glVertexAttribPointer(normalNormalIndex_, 3, GL_FLOAT, GL_FALSE, 0,
571 reinterpret_cast<const GLvoid*>(dataMap_.enOffset));
572 }
573 else
574 {
575 endIdx = 8;
576 glVertexAttribPointer(vertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
577 reinterpret_cast<const GLvoid*>(dataMap_.esvOffset));
578 }
579
580 for (unsigned int i = startIdx; i < endIdx; i++)
581 {
582 unsigned int curOffset(i * 18 * sui);
583 glDrawElements(GL_TRIANGLE_STRIP, 18, GL_UNSIGNED_INT,
584 reinterpret_cast<const GLvoid*>(curOffset));
585 }
586}
587
588// Generate a normal matrix from a modelview matrix
589//
590// Since we can't universally handle the normal matrix inside the
591// vertex shader (inverse() and transpose() built-ins not supported by
592// GLSL ES, for example), we'll generate it here, and load it as a
593// uniform.
594void
595SGILogo::updateXform(const mat4& mv, Program& program)
596{
597 if (drawStyle_ == LOGO_NORMAL)
598 {
599 LibMatrix::mat3 normalMatrix(mv[0][0], mv[1][0], mv[2][0],
600 mv[0][1], mv[1][1], mv[2][1],
601 mv[0][2], mv[1][2], mv[2][2]);
602 normalMatrix.transpose().inverse();
603 program[normalMatrixName_] = normalMatrix;
604 }
605 program[modelviewName_] = mv;
606}
607
608Program&
609SGILogo::getProgram()
610{
611 switch (drawStyle_)
612 {
613 case LOGO_NORMAL:
614 return normalProgram_;
615 break;
616 case LOGO_FLAT:
617 return flatProgram_;
618 break;
619 case LOGO_SHADOW:
620 return shadowProgram_;
621 break;
622 }
623
624 return normalProgram_;
625}
626
627void
628SGILogo::draw(Stack4& modelview,
629 Stack4& projection,
630 const vec4& lightPosition,
631 DrawStyle style,
632 const uvec3& currentColor)
633{
634 if (!valid_)
635 {
636 return;
637 }
638
639 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
640 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
641
642 // Setup the program to use based upon draw style and set it running.
643 drawStyle_ = style;
644 vec4 logoColor(currentColor.x() / 255.0, currentColor.y() / 255.0, currentColor.z() / 255.0, 1.0);
645 Program& curProgram = getProgram();
646 curProgram.start();
647 switch (drawStyle_)
648 {
649 case LOGO_NORMAL:
650 curProgram[lightPositionName_] = lightPosition;
651 vertexIndex_ = normalVertexIndex_;
652 glEnableVertexAttribArray(normalNormalIndex_);
653 break;
654 case LOGO_FLAT:
655 curProgram[logoColorName_] = logoColor;
656 vertexIndex_ = flatVertexIndex_;
657 break;
658 case LOGO_SHADOW:
659 vertexIndex_ = shadowVertexIndex_;
660 break;
661 }
662
663 glEnableVertexAttribArray(vertexIndex_);
664 curProgram[projectionName_] = projection.getCurrent();
665 modelview.translate(5.500000, -3.500000, 4.500000);
666 modelview.translate(0.0, 0.0, -7.000000);
667 updateXform(modelview.getCurrent(), curProgram);
668 drawDoubleCylinder();
669 bendForward(modelview);
670 updateXform(modelview.getCurrent(), curProgram);
671 drawElbow();
672 modelview.translate(0.0, 0.0, -7.000000);
673 updateXform(modelview.getCurrent(), curProgram);
674 drawDoubleCylinder();
675 bendForward(modelview);
676 updateXform(modelview.getCurrent(), curProgram);
677 drawElbow();
678 modelview.translate(0.0, 0.0, -5.000000);
679 updateXform(modelview.getCurrent(), curProgram);
680 drawSingleCylinder();
681 bendRight(modelview);
682 updateXform(modelview.getCurrent(), curProgram);
683 drawElbow();
684 modelview.translate(0.0, 0.0, -7.000000);
685 updateXform(modelview.getCurrent(), curProgram);
686 drawDoubleCylinder();
687 bendForward(modelview);
688 updateXform(modelview.getCurrent(), curProgram);
689 drawElbow();
690 modelview.translate(0.0, 0.0, -7.000000);
691 updateXform(modelview.getCurrent(), curProgram);
692 drawDoubleCylinder();
693 bendForward(modelview);
694 updateXform(modelview.getCurrent(), curProgram);
695 drawElbow();
696 modelview.translate(0.0, 0.0, -5.000000);
697 updateXform(modelview.getCurrent(), curProgram);
698 drawSingleCylinder();
699 bendLeft(modelview);
700 updateXform(modelview.getCurrent(), curProgram);
701 drawElbow();
702 modelview.translate(0.0, 0.0, -7.000000);
703 updateXform(modelview.getCurrent(), curProgram);
704 drawDoubleCylinder();
705 bendForward(modelview);
706 updateXform(modelview.getCurrent(), curProgram);
707 drawElbow();
708 modelview.translate(0.0, 0.0, -7.000000);
709 updateXform(modelview.getCurrent(), curProgram);
710 drawDoubleCylinder();
711 bendForward(modelview);
712 updateXform(modelview.getCurrent(), curProgram);
713 drawElbow();
714 modelview.translate(0.0, 0.0, -5.000000);
715 updateXform(modelview.getCurrent(), curProgram);
716 drawSingleCylinder();
717 bendRight(modelview);
718 updateXform(modelview.getCurrent(), curProgram);
719 drawElbow();
720 modelview.translate(0.0, 0.0, -7.000000);
721 updateXform(modelview.getCurrent(), curProgram);
722 drawDoubleCylinder();
723 bendForward(modelview);
724 updateXform(modelview.getCurrent(), curProgram);
725 drawElbow();
726 modelview.translate(0.0, 0.0, -7.000000);
727 updateXform(modelview.getCurrent(), curProgram);
728 drawDoubleCylinder();
729 bendForward(modelview);
730 updateXform(modelview.getCurrent(), curProgram);
731 drawElbow();
732 modelview.translate(0.0, 0.0, -5.000000);
733 updateXform(modelview.getCurrent(), curProgram);
734 drawSingleCylinder();
735 bendLeft(modelview);
736 updateXform(modelview.getCurrent(), curProgram);
737 drawElbow();
738 modelview.translate(0.0, 0.0, -7.000000);
739 updateXform(modelview.getCurrent(), curProgram);
740 drawDoubleCylinder();
741 bendForward(modelview);
742 updateXform(modelview.getCurrent(), curProgram);
743 drawElbow();
744 modelview.translate(0.0, 0.0, -7.000000);
745 updateXform(modelview.getCurrent(), curProgram);
746 drawDoubleCylinder();
747 bendForward(modelview);
748 updateXform(modelview.getCurrent(), curProgram);
749 drawElbow();
750 modelview.translate(0.0, 0.0, -5.000000);
751 updateXform(modelview.getCurrent(), curProgram);
752 drawSingleCylinder();
753 bendRight(modelview);
754 updateXform(modelview.getCurrent(), curProgram);
755 drawElbow();
756 modelview.translate(0.0, 0.0, -7.000000);
757 updateXform(modelview.getCurrent(), curProgram);
758 drawDoubleCylinder();
759 bendForward(modelview);
760 updateXform(modelview.getCurrent(), curProgram);
761 drawElbow();
762 modelview.translate(0.0, 0.0, -7.000000);
763 updateXform(modelview.getCurrent(), curProgram);
764 drawDoubleCylinder();
765 bendForward(modelview);
766 updateXform(modelview.getCurrent(), curProgram);
767 drawElbow();
768 modelview.translate(0.0, 0.0, -5.000000);
769 updateXform(modelview.getCurrent(), curProgram);
770 drawSingleCylinder();
771 bendLeft(modelview);
772 updateXform(modelview.getCurrent(), curProgram);
773 drawElbow();
774 glDisableVertexAttribArray(vertexIndex_);
775 switch (drawStyle_)
776 {
777 case LOGO_NORMAL:
778 glDisableVertexAttribArray(normalNormalIndex_);
779 break;
780 case LOGO_FLAT:
781 break;
782 case LOGO_SHADOW:
783 break;
784 }
785 curProgram.stop();
786
787 glBindBuffer(GL_ARRAY_BUFFER, 0);
788 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
789}
0790
=== added file 'src/scene-ideas/logo.h'
--- src/scene-ideas/logo.h 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/logo.h 2012-05-09 20:57:19 +0000
@@ -0,0 +1,126 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#ifndef LOGO_H_
24#define LOGO_H_
25
26#include <string>
27#include <vector>
28#include "vec.h"
29#include "stack.h"
30#include "gl-headers.h"
31#include "program.h"
32
33class SGILogo
34{
35public:
36 SGILogo();
37 ~SGILogo();
38
39 // Initialize the logo
40 void init();
41 bool valid() const { return valid_; }
42 void setPosition(const LibMatrix::vec3& position) { currentPosition_ = position; }
43 // Tell the logo to draw itself. DrawStyle tells it how.
44 // - LOGO_NORMAL renders the logo lit and shaded.
45 // - LOGO_FLAT renders the logo as if flattened onto a surface.
46 // - LOGO_SHADOW renders a stippled-looking shadow of the object.
47 enum DrawStyle
48 {
49 LOGO_NORMAL,
50 LOGO_FLAT,
51 LOGO_SHADOW
52 };
53 void draw(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection,
54 const LibMatrix::vec4& lightPosition, DrawStyle style,
55 const LibMatrix::uvec3& color = LibMatrix::uvec3());
56
57private:
58 void drawElbow();
59 void drawSingleCylinder();
60 void drawDoubleCylinder();
61 void bendLeft(LibMatrix::Stack4& ms);
62 void bendRight(LibMatrix::Stack4& ms);
63 void bendForward(LibMatrix::Stack4& ms);
64 void updateXform(const LibMatrix::mat4& mv, Program& program);
65 Program& getProgram();
66 LibMatrix::vec3 currentPosition_;
67 std::vector<LibMatrix::vec3> singleCylinderVertices_;
68 std::vector<LibMatrix::vec3> singleCylinderNormals_;
69 std::vector<LibMatrix::vec3> doubleCylinderVertices_;
70 std::vector<LibMatrix::vec3> doubleCylinderNormals_;
71 std::vector<LibMatrix::vec3> elbowVertices_;
72 std::vector<LibMatrix::vec3> elbowNormals_;
73 std::vector<LibMatrix::vec3> elbowShadowVertices_;
74 std::vector<unsigned int> indexData_;
75 // A simple map so we know where each section of our data starts within
76 // our vertex buffer object.
77 struct VertexDataMap
78 {
79 unsigned int scvOffset;
80 unsigned int scvSize;
81 unsigned int scnOffset;
82 unsigned int scnSize;
83 unsigned int dcvOffset;
84 unsigned int dcvSize;
85 unsigned int dcnOffset;
86 unsigned int dcnSize;
87 unsigned int evOffset;
88 unsigned int evSize;
89 unsigned int enOffset;
90 unsigned int enSize;
91 unsigned int esvOffset;
92 unsigned int esvSize;
93 unsigned int totalSize;
94 } dataMap_;
95 unsigned int bufferObjects_[2];
96 Program normalProgram_;
97 Program flatProgram_;
98 Program shadowProgram_;
99 std::string normalVertexShader_;
100 std::string normalFragmentShader_;
101 std::string flatVertexShader_;
102 std::string flatFragmentShader_;
103 std::string shadowVertexShader_;
104 std::string shadowFragmentShader_;
105 int normalNormalIndex_;
106 int normalVertexIndex_;
107 int flatVertexIndex_;
108 int shadowVertexIndex_;
109 int vertexIndex_;
110 static const std::string modelviewName_;
111 static const std::string projectionName_;
112 static const std::string lightPositionName_;
113 static const std::string logoColorName_;
114 static const std::string vertexAttribName_;
115 static const std::string normalAttribName_;
116 static const std::string normalMatrixName_;
117 // "Shadow" state
118 GLuint textureName_;
119 GLubyte textureImage_[32][32];
120 // This is the size in each direction of our texture image
121 static const unsigned int textureResolution_;
122 bool valid_;
123 DrawStyle drawStyle_;
124};
125
126#endif // LOGO_H_
0127
=== added file 'src/scene-ideas/m.cc'
--- src/scene-ideas/m.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/m.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,210 @@
1/*
2 * Vertex position data describing the letter 'm'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterM::LetterM()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(0.590769, 9.449335));
33 vertexData_.push_back(vec2(2.116923, 9.842375));
34 vertexData_.push_back(vec2(1.362051, 9.383828));
35 vertexData_.push_back(vec2(2.527179, 9.825998));
36 vertexData_.push_back(vec2(1.591795, 9.072672));
37 vertexData_.push_back(vec2(2.789744, 9.514841));
38 vertexData_.push_back(vec2(1.690256, 8.663255));
39 vertexData_.push_back(vec2(2.658462, 8.335722));
40 vertexData_.push_back(vec2(1.575385, 7.222108));
41 vertexData_.push_back(vec2(2.067692, 6.255886));
42 vertexData_.push_back(vec2(0.918974, 4.028659));
43 vertexData_.push_back(vec2(1.050256, 3.013306));
44 vertexData_.push_back(vec2(0.705641, 3.013306));
45 vertexData_.push_back(vec2(2.018461, 6.386899));
46 vertexData_.push_back(vec2(1.788718, 5.617196));
47 vertexData_.push_back(vec2(2.921026, 7.991812));
48 vertexData_.push_back(vec2(3.167180, 8.008188));
49 vertexData_.push_back(vec2(3.544615, 8.827022));
50 vertexData_.push_back(vec2(3.872821, 8.843398));
51 vertexData_.push_back(vec2(4.414359, 9.547595));
52 vertexData_.push_back(vec2(4.447179, 9.056294));
53 vertexData_.push_back(vec2(5.120000, 9.891504));
54 vertexData_.push_back(vec2(4.841026, 8.843398));
55 vertexData_.push_back(vec2(5.825641, 9.809621));
56 vertexData_.push_back(vec2(5.005128, 8.040941));
57 vertexData_.push_back(vec2(5.989744, 8.761515));
58 vertexData_.push_back(vec2(4.906667, 6.714432));
59 vertexData_.push_back(vec2(5.595897, 7.123848));
60 vertexData_.push_back(vec2(3.987692, 2.996929));
61 vertexData_.push_back(vec2(4.348718, 2.996929));
62 vertexData_.push_back(vec2(5.218462, 5.977482));
63 vertexData_.push_back(vec2(5.251282, 6.354146));
64 vertexData_.push_back(vec2(6.449231, 7.893552));
65 vertexData_.push_back(vec2(6.400000, 8.221085));
66 vertexData_.push_back(vec2(7.302564, 8.843398));
67 vertexData_.push_back(vec2(7.351795, 9.334698));
68 vertexData_.push_back(vec2(7.827693, 9.154554));
69 vertexData_.push_back(vec2(8.008205, 9.842375));
70 vertexData_.push_back(vec2(8.139487, 9.121801));
71 vertexData_.push_back(vec2(8.795897, 9.973388));
72 vertexData_.push_back(vec2(8.402051, 8.728762));
73 vertexData_.push_back(vec2(9.337436, 9.531218));
74 vertexData_.push_back(vec2(8.402051, 8.040941));
75 vertexData_.push_back(vec2(9.288205, 8.433982));
76 vertexData_.push_back(vec2(7.745641, 5.813715));
77 vertexData_.push_back(vec2(8.320000, 5.928352));
78 vertexData_.push_back(vec2(7.286154, 4.012282));
79 vertexData_.push_back(vec2(7.991795, 4.126919));
80 vertexData_.push_back(vec2(7.499487, 3.357216));
81 vertexData_.push_back(vec2(8.533334, 3.766633));
82 vertexData_.push_back(vec2(8.123077, 3.062436));
83 vertexData_.push_back(vec2(8.927179, 3.832139));
84 vertexData_.push_back(vec2(8.910769, 3.340839));
85 vertexData_.push_back(vec2(9.550769, 4.126919));
86
87 // Index data...
88 indexData_.push_back(0);
89 indexData_.push_back(2);
90 indexData_.push_back(4);
91 indexData_.push_back(6);
92 indexData_.push_back(8);
93 indexData_.push_back(10);
94 indexData_.push_back(12);
95 indexData_.push_back(11);
96 indexData_.push_back(9);
97 indexData_.push_back(7);
98 indexData_.push_back(5);
99 indexData_.push_back(3);
100 indexData_.push_back(1);
101 indexData_.push_back(14);
102 indexData_.push_back(16);
103 indexData_.push_back(18);
104 indexData_.push_back(20);
105 indexData_.push_back(22);
106 indexData_.push_back(24);
107 indexData_.push_back(26);
108 indexData_.push_back(28);
109 indexData_.push_back(29);
110 indexData_.push_back(27);
111 indexData_.push_back(25);
112 indexData_.push_back(23);
113 indexData_.push_back(21);
114 indexData_.push_back(19);
115 indexData_.push_back(17);
116 indexData_.push_back(15);
117 indexData_.push_back(13);
118 indexData_.push_back(30);
119 indexData_.push_back(32);
120 indexData_.push_back(34);
121 indexData_.push_back(36);
122 indexData_.push_back(38);
123 indexData_.push_back(40);
124 indexData_.push_back(42);
125 indexData_.push_back(44);
126 indexData_.push_back(46);
127 indexData_.push_back(48);
128 indexData_.push_back(50);
129 indexData_.push_back(52);
130 indexData_.push_back(53);
131 indexData_.push_back(51);
132 indexData_.push_back(49);
133 indexData_.push_back(47);
134 indexData_.push_back(45);
135 indexData_.push_back(43);
136 indexData_.push_back(41);
137 indexData_.push_back(39);
138 indexData_.push_back(37);
139 indexData_.push_back(35);
140 indexData_.push_back(33);
141 indexData_.push_back(31);
142 indexData_.push_back(0);
143 indexData_.push_back(1);
144 indexData_.push_back(2);
145 indexData_.push_back(3);
146 indexData_.push_back(4);
147 indexData_.push_back(5);
148 indexData_.push_back(6);
149 indexData_.push_back(7);
150 indexData_.push_back(8);
151 indexData_.push_back(9);
152 indexData_.push_back(10);
153 indexData_.push_back(11);
154 indexData_.push_back(12);
155 indexData_.push_back(13);
156 indexData_.push_back(14);
157 indexData_.push_back(15);
158 indexData_.push_back(16);
159 indexData_.push_back(17);
160 indexData_.push_back(18);
161 indexData_.push_back(19);
162 indexData_.push_back(20);
163 indexData_.push_back(21);
164 indexData_.push_back(22);
165 indexData_.push_back(23);
166 indexData_.push_back(24);
167 indexData_.push_back(25);
168 indexData_.push_back(26);
169 indexData_.push_back(27);
170 indexData_.push_back(28);
171 indexData_.push_back(29);
172 indexData_.push_back(30);
173 indexData_.push_back(31);
174 indexData_.push_back(32);
175 indexData_.push_back(33);
176 indexData_.push_back(34);
177 indexData_.push_back(35);
178 indexData_.push_back(36);
179 indexData_.push_back(37);
180 indexData_.push_back(38);
181 indexData_.push_back(39);
182 indexData_.push_back(40);
183 indexData_.push_back(41);
184 indexData_.push_back(42);
185 indexData_.push_back(43);
186 indexData_.push_back(44);
187 indexData_.push_back(45);
188 indexData_.push_back(46);
189 indexData_.push_back(47);
190 indexData_.push_back(48);
191 indexData_.push_back(49);
192 indexData_.push_back(50);
193 indexData_.push_back(51);
194 indexData_.push_back(52);
195 indexData_.push_back(53);
196
197 // Primitive state so that the draw call can issue the primitives we want.
198 unsigned int curOffset(0);
199 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 13, curOffset));
200 curOffset += (13 * sizeof(unsigned int));
201 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 17, curOffset));
202 curOffset += (17 * sizeof(unsigned int));
203 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 24, curOffset));
204 curOffset += (24 * sizeof(unsigned int));
205 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 13, curOffset));
206 curOffset += (13 * sizeof(unsigned int));
207 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 17, curOffset));
208 curOffset += (17 * sizeof(unsigned int));
209 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 24, curOffset));
210}
0211
=== added file 'src/scene-ideas/n.cc'
--- src/scene-ideas/n.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/n.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,146 @@
1/*
2 * Vertex position data describing the letter 'o'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterN::LetterN()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(1.009307, 9.444788));
33 vertexData_.push_back(vec2(2.548087, 9.742002));
34 vertexData_.push_back(vec2(1.737332, 9.213622));
35 vertexData_.push_back(vec2(2.994829, 9.659443));
36 vertexData_.push_back(vec2(1.985522, 8.751290));
37 vertexData_.push_back(vec2(3.127198, 9.180598));
38 vertexData_.push_back(vec2(1.935884, 7.975232));
39 vertexData_.push_back(vec2(2.481903, 6.571723));
40 vertexData_.push_back(vec2(1.472596, 5.019608));
41 vertexData_.push_back(vec2(1.439504, 2.988648));
42 vertexData_.push_back(vec2(1.025853, 2.988648));
43 vertexData_.push_back(vec2(2.283350, 6.059855));
44 vertexData_.push_back(vec2(2.035160, 5.366357));
45 vertexData_.push_back(vec2(3.292658, 7.711042));
46 vertexData_.push_back(vec2(3.540848, 7.744066));
47 vertexData_.push_back(vec2(4.384695, 9.031992));
48 vertexData_.push_back(vec2(4.699069, 8.916409));
49 vertexData_.push_back(vec2(5.609100, 9.808049));
50 vertexData_.push_back(vec2(5.145812, 8.982456));
51 vertexData_.push_back(vec2(6.155119, 9.791537));
52 vertexData_.push_back(vec2(5.410548, 8.635707));
53 vertexData_.push_back(vec2(6.337125, 9.312694));
54 vertexData_.push_back(vec2(5.360910, 7.991744));
55 vertexData_.push_back(vec2(6.088935, 8.090816));
56 vertexData_.push_back(vec2(4.947259, 5.977296));
57 vertexData_.push_back(vec2(5.261634, 4.804954));
58 vertexData_.push_back(vec2(4.616339, 4.028896));
59 vertexData_.push_back(vec2(5.211996, 3.962848));
60 vertexData_.push_back(vec2(4.732162, 3.318886));
61 vertexData_.push_back(vec2(5.559462, 3.814241));
62 vertexData_.push_back(vec2(5.228542, 3.038184));
63 vertexData_.push_back(vec2(5.940021, 3.814241));
64 vertexData_.push_back(vec2(5.906929, 3.335397));
65 vertexData_.push_back(vec2(6.684591, 4.094943));
66
67 // Index data...
68 indexData_.push_back(0);
69 indexData_.push_back(1);
70 indexData_.push_back(2);
71 indexData_.push_back(3);
72 indexData_.push_back(4);
73 indexData_.push_back(5);
74 indexData_.push_back(6);
75 indexData_.push_back(7);
76 indexData_.push_back(8);
77 indexData_.push_back(9);
78 indexData_.push_back(10);
79 indexData_.push_back(11);
80 indexData_.push_back(12);
81 indexData_.push_back(13);
82 indexData_.push_back(14);
83 indexData_.push_back(15);
84 indexData_.push_back(16);
85 indexData_.push_back(17);
86 indexData_.push_back(18);
87 indexData_.push_back(19);
88 indexData_.push_back(20);
89 indexData_.push_back(21);
90 indexData_.push_back(22);
91 indexData_.push_back(23);
92 indexData_.push_back(24);
93 indexData_.push_back(25);
94 indexData_.push_back(26);
95 indexData_.push_back(27);
96 indexData_.push_back(28);
97 indexData_.push_back(29);
98 indexData_.push_back(30);
99 indexData_.push_back(31);
100 indexData_.push_back(32);
101 indexData_.push_back(33);
102 indexData_.push_back(0);
103 indexData_.push_back(2);
104 indexData_.push_back(4);
105 indexData_.push_back(6);
106 indexData_.push_back(8);
107 indexData_.push_back(10);
108 indexData_.push_back(9);
109 indexData_.push_back(7);
110 indexData_.push_back(5);
111 indexData_.push_back(3);
112 indexData_.push_back(1);
113 indexData_.push_back(12);
114 indexData_.push_back(14);
115 indexData_.push_back(16);
116 indexData_.push_back(18);
117 indexData_.push_back(20);
118 indexData_.push_back(22);
119 indexData_.push_back(24);
120 indexData_.push_back(26);
121 indexData_.push_back(28);
122 indexData_.push_back(30);
123 indexData_.push_back(32);
124 indexData_.push_back(33);
125 indexData_.push_back(31);
126 indexData_.push_back(29);
127 indexData_.push_back(27);
128 indexData_.push_back(25);
129 indexData_.push_back(23);
130 indexData_.push_back(21);
131 indexData_.push_back(19);
132 indexData_.push_back(17);
133 indexData_.push_back(15);
134 indexData_.push_back(13);
135 indexData_.push_back(11);
136
137 // Primitive state so that the draw call can issue the primitives we want.
138 unsigned int curOffset(0);
139 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 11, curOffset));
140 curOffset += (11 * sizeof(unsigned int));
141 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 23, curOffset));
142 curOffset += (23 * sizeof(unsigned int));
143 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 11, curOffset));
144 curOffset += (11 * sizeof(unsigned int));
145 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 23, curOffset));
146}
0147
=== added file 'src/scene-ideas/o.cc'
--- src/scene-ideas/o.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/o.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,139 @@
1/*
2 * Vertex position data describing the letter 'o'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterO::LetterO()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(2.975610, 9.603255));
33 vertexData_.push_back(vec2(2.878049, 9.342828));
34 vertexData_.push_back(vec2(2.292683, 9.131231));
35 vertexData_.push_back(vec2(2.048780, 8.691760));
36 vertexData_.push_back(vec2(1.707317, 8.528993));
37 vertexData_.push_back(vec2(1.658537, 7.731434));
38 vertexData_.push_back(vec2(0.878049, 7.047813));
39 vertexData_.push_back(vec2(1.349594, 5.550356));
40 vertexData_.push_back(vec2(0.569106, 5.029501));
41 vertexData_.push_back(vec2(1.528455, 4.443540));
42 vertexData_.push_back(vec2(0.991870, 3.434385));
43 vertexData_.push_back(vec2(1.967480, 3.955239));
44 vertexData_.push_back(vec2(1.772358, 2.994914));
45 vertexData_.push_back(vec2(2.422764, 3.825025));
46 vertexData_.push_back(vec2(2.829268, 3.092574));
47 vertexData_.push_back(vec2(3.154472, 3.971516));
48 vertexData_.push_back(vec2(3.512195, 3.727365));
49 vertexData_.push_back(vec2(3.772358, 4.264496));
50 vertexData_.push_back(vec2(4.130081, 4.524924));
51 vertexData_.push_back(vec2(4.162601, 4.996948));
52 vertexData_.push_back(vec2(4.699187, 5.403866));
53 vertexData_.push_back(vec2(4.471545, 6.461852));
54 vertexData_.push_back(vec2(5.219512, 7.243133));
55 vertexData_.push_back(vec2(4.439024, 8.105799));
56 vertexData_.push_back(vec2(5.235772, 8.756866));
57 vertexData_.push_back(vec2(4.065041, 8.870804));
58 vertexData_.push_back(vec2(4.991870, 9.391658));
59 vertexData_.push_back(vec2(3.853658, 9.228891));
60 vertexData_.push_back(vec2(4.390244, 9.912513));
61 vertexData_.push_back(vec2(3.463415, 9.407935));
62 vertexData_.push_back(vec2(3.674797, 9.912513));
63 vertexData_.push_back(vec2(2.829268, 9.342828));
64 vertexData_.push_back(vec2(2.959350, 9.603255));
65
66 // Index data...
67 indexData_.push_back(0);
68 indexData_.push_back(1);
69 indexData_.push_back(2);
70 indexData_.push_back(3);
71 indexData_.push_back(4);
72 indexData_.push_back(5);
73 indexData_.push_back(6);
74 indexData_.push_back(7);
75 indexData_.push_back(8);
76 indexData_.push_back(9);
77 indexData_.push_back(10);
78 indexData_.push_back(11);
79 indexData_.push_back(12);
80 indexData_.push_back(13);
81 indexData_.push_back(14);
82 indexData_.push_back(15);
83 indexData_.push_back(16);
84 indexData_.push_back(17);
85 indexData_.push_back(18);
86 indexData_.push_back(19);
87 indexData_.push_back(20);
88 indexData_.push_back(21);
89 indexData_.push_back(22);
90 indexData_.push_back(23);
91 indexData_.push_back(24);
92 indexData_.push_back(25);
93 indexData_.push_back(26);
94 indexData_.push_back(27);
95 indexData_.push_back(28);
96 indexData_.push_back(29);
97 indexData_.push_back(30);
98 indexData_.push_back(31);
99 indexData_.push_back(32);
100 indexData_.push_back(0);
101 indexData_.push_back(2);
102 indexData_.push_back(4);
103 indexData_.push_back(6);
104 indexData_.push_back(8);
105 indexData_.push_back(10);
106 indexData_.push_back(12);
107 indexData_.push_back(14);
108 indexData_.push_back(16);
109 indexData_.push_back(18);
110 indexData_.push_back(20);
111 indexData_.push_back(22);
112 indexData_.push_back(24);
113 indexData_.push_back(26);
114 indexData_.push_back(28);
115 indexData_.push_back(30);
116 indexData_.push_back(32);
117 indexData_.push_back(31);
118 indexData_.push_back(29);
119 indexData_.push_back(27);
120 indexData_.push_back(25);
121 indexData_.push_back(23);
122 indexData_.push_back(21);
123 indexData_.push_back(19);
124 indexData_.push_back(17);
125 indexData_.push_back(15);
126 indexData_.push_back(13);
127 indexData_.push_back(11);
128 indexData_.push_back(9);
129 indexData_.push_back(7);
130 indexData_.push_back(5);
131 indexData_.push_back(3);
132 indexData_.push_back(1);
133
134 // Primitive state so that the draw call can issue the primitives we want.
135 unsigned int curOffset(0);
136 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 33, curOffset));
137 curOffset += (33 * sizeof(unsigned int));
138 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 33, curOffset));
139}
0140
=== added file 'src/scene-ideas/s.cc'
--- src/scene-ideas/s.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/s.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,130 @@
1/*
2 * Vertex position data describing the letter 's'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterS::LetterS()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(0.860393, 5.283798));
33 vertexData_.push_back(vec2(0.529473, 3.550052));
34 vertexData_.push_back(vec2(0.992761, 4.491228));
35 vertexData_.push_back(vec2(0.910031, 3.368421));
36 vertexData_.push_back(vec2(1.240951, 3.830753));
37 vertexData_.push_back(vec2(1.456050, 3.104231));
38 vertexData_.push_back(vec2(1.935884, 3.517028));
39 vertexData_.push_back(vec2(2.002068, 2.988648));
40 vertexData_.push_back(vec2(2.763185, 3.533540));
41 vertexData_.push_back(vec2(3.061013, 3.120743));
42 vertexData_.push_back(vec2(3.391934, 3.748194));
43 vertexData_.push_back(vec2(4.053774, 3.632611));
44 vertexData_.push_back(vec2(3.822130, 4.540764));
45 vertexData_.push_back(vec2(4.550155, 4.590299));
46 vertexData_.push_back(vec2(3.656670, 5.465428));
47 vertexData_.push_back(vec2(4.517063, 5.713106));
48 vertexData_.push_back(vec2(3.276112, 5.894737));
49 vertexData_.push_back(vec2(3.921407, 6.538700));
50 vertexData_.push_back(vec2(2.299896, 6.736842));
51 vertexData_.push_back(vec2(3.044467, 7.430341));
52 vertexData_.push_back(vec2(1.886246, 7.496388));
53 vertexData_.push_back(vec2(2.581179, 8.222910));
54 vertexData_.push_back(vec2(1.902792, 8.751290));
55 vertexData_.push_back(vec2(2.680455, 8.883385));
56 vertexData_.push_back(vec2(2.283350, 9.312694));
57 vertexData_.push_back(vec2(3.358842, 9.609907));
58 vertexData_.push_back(vec2(3.507756, 9.907121));
59 vertexData_.push_back(vec2(4.285419, 9.758514));
60 vertexData_.push_back(vec2(5.112720, 9.973168));
61 vertexData_.push_back(vec2(4.748707, 9.593395));
62
63 // Index data...
64 indexData_.push_back(0);
65 indexData_.push_back(1);
66 indexData_.push_back(2);
67 indexData_.push_back(3);
68 indexData_.push_back(4);
69 indexData_.push_back(5);
70 indexData_.push_back(6);
71 indexData_.push_back(7);
72 indexData_.push_back(8);
73 indexData_.push_back(9);
74 indexData_.push_back(10);
75 indexData_.push_back(11);
76 indexData_.push_back(12);
77 indexData_.push_back(13);
78 indexData_.push_back(14);
79 indexData_.push_back(15);
80 indexData_.push_back(16);
81 indexData_.push_back(17);
82 indexData_.push_back(18);
83 indexData_.push_back(19);
84 indexData_.push_back(20);
85 indexData_.push_back(21);
86 indexData_.push_back(22);
87 indexData_.push_back(23);
88 indexData_.push_back(24);
89 indexData_.push_back(25);
90 indexData_.push_back(26);
91 indexData_.push_back(27);
92 indexData_.push_back(28);
93 indexData_.push_back(29);
94 indexData_.push_back(0);
95 indexData_.push_back(2);
96 indexData_.push_back(4);
97 indexData_.push_back(6);
98 indexData_.push_back(8);
99 indexData_.push_back(10);
100 indexData_.push_back(12);
101 indexData_.push_back(14);
102 indexData_.push_back(16);
103 indexData_.push_back(18);
104 indexData_.push_back(20);
105 indexData_.push_back(22);
106 indexData_.push_back(24);
107 indexData_.push_back(26);
108 indexData_.push_back(28);
109 indexData_.push_back(29);
110 indexData_.push_back(27);
111 indexData_.push_back(25);
112 indexData_.push_back(23);
113 indexData_.push_back(21);
114 indexData_.push_back(19);
115 indexData_.push_back(17);
116 indexData_.push_back(15);
117 indexData_.push_back(13);
118 indexData_.push_back(11);
119 indexData_.push_back(9);
120 indexData_.push_back(7);
121 indexData_.push_back(5);
122 indexData_.push_back(3);
123 indexData_.push_back(1);
124
125 // Primitive state so that the draw call can issue the primitives we want.
126 unsigned int curOffset(0);
127 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 30, curOffset));
128 curOffset += (30 * sizeof(unsigned int));
129 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 30, curOffset));
130}
0131
=== added file 'src/scene-ideas/splines.cc'
--- src/scene-ideas/splines.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/splines.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,200 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#include "splines.h"
24
25using LibMatrix::vec3;
26
27void
28Spline::calcParams()
29{
30 unsigned int numParams(controlData_.size() - 3);
31 paramData_ = new param[numParams];
32 for (unsigned int i = 0; i < numParams; i++)
33 {
34 float x3(controlData_[i + 1].x());
35 float x2(controlData_[i + 2].x() - controlData_[i].x());
36 float x1(2.0 * controlData_[i].x() +
37 -2.0 * controlData_[i+1].x() +
38 1.0 * controlData_[i+2].x() +
39 -1.0 * controlData_[i+3].x());
40 float x0(-1.0 * controlData_[i].x() +
41 1.0 * controlData_[i+1].x() +
42 -1.0 * controlData_[i+2].x() +
43 1.0 * controlData_[i+3].x());
44 float y3(controlData_[i + 1].y());
45 float y2(controlData_[i + 2].y() - controlData_[i].y());
46 float y1(2.0 * controlData_[i].y() +
47 -2.0 * controlData_[i+1].y() +
48 1.0 * controlData_[i+2].y() +
49 -1.0 * controlData_[i+3].y());
50 float y0(-1.0 * controlData_[i].y() +
51 1.0 * controlData_[i+1].y() +
52 -1.0 * controlData_[i+2].y() +
53 1.0 * controlData_[i+3].y());
54 float z3(controlData_[i + 1].z());
55 float z2(controlData_[i + 2].z() - controlData_[i].z());
56 float z1(2.0 * controlData_[i].z() +
57 -2.0 * controlData_[i+1].z() +
58 1.0 * controlData_[i+2].z() +
59 -1.0 * controlData_[i+3].z());
60 float z0(-1.0 * controlData_[i].z() +
61 1.0 * controlData_[i+1].z() +
62 -1.0 * controlData_[i+2].z() +
63 1.0 * controlData_[i+3].z());
64 paramData_[i][3].x(x3);
65 paramData_[i][2].x(x2);
66 paramData_[i][1].x(x1);
67 paramData_[i][0].x(x0);
68 paramData_[i][3].y(y3);
69 paramData_[i][2].y(y2);
70 paramData_[i][1].y(y1);
71 paramData_[i][0].y(y0);
72 paramData_[i][3].z(z3);
73 paramData_[i][2].z(z2);
74 paramData_[i][1].z(z1);
75 paramData_[i][0].z(z0);
76 }
77}
78
79void
80Spline::getCurrentVec(float currentTime, vec3& v) const
81{
82 unsigned int integerTime(static_cast<unsigned int>(currentTime));
83 float t(currentTime - static_cast<float>(integerTime));
84 v.x(paramData_[integerTime][3].x() +
85 paramData_[integerTime][2].x() * t +
86 paramData_[integerTime][1].x() * t * t +
87 paramData_[integerTime][0].x() * t * t * t);
88 v.y(paramData_[integerTime][3].y() +
89 paramData_[integerTime][2].y() * t +
90 paramData_[integerTime][1].y() * t * t +
91 paramData_[integerTime][0].y() * t * t * t);
92 v.z(paramData_[integerTime][3].z() +
93 paramData_[integerTime][2].z() * t +
94 paramData_[integerTime][1].z() * t * t +
95 paramData_[integerTime][0].z() * t * t * t);
96}
97
98ViewFromSpline::ViewFromSpline()
99{
100 addControlPoint(vec3(-1.0, 1.0, -4.0));
101 addControlPoint(vec3(-1.0, -3.0, -4.0));
102 addControlPoint(vec3(-3.0, 1.0, -3.0));
103 addControlPoint(vec3(-1.8, 2.0, 5.4));
104 addControlPoint(vec3(-0.4, 2.0, 1.2));
105 addControlPoint(vec3(-0.2, 1.5, 0.6));
106 addControlPoint(vec3(-0.2, 1.2, 0.6));
107 addControlPoint(vec3(-0.8, 1.0, 2.4));
108 addControlPoint(vec3(-1.0, 2.0, 3.0));
109 addControlPoint(vec3(0.0, 4.0, 3.6));
110 addControlPoint(vec3(-0.8, 4.0, 1.2));
111 addControlPoint(vec3(-0.2, 3.0, 0.6));
112 addControlPoint(vec3(-0.1, 2.0, 0.3));
113 addControlPoint(vec3(-0.1, 2.0, 0.3));
114 addControlPoint(vec3(-0.1, 2.0, 0.3));
115 addControlPoint(vec3(-0.1, 2.0, 0.3));
116 calcParams();
117}
118
119ViewToSpline::ViewToSpline()
120{
121 addControlPoint(vec3(-1.0, 1.0, 0.0));
122 addControlPoint(vec3(-1.0, -3.0, 0.0));
123 addControlPoint(vec3(-1.0, 1.0, 0.0));
124 addControlPoint(vec3(0.1, 0.0, -0.3));
125 addControlPoint(vec3(0.1, 0.0, -0.3));
126 addControlPoint(vec3(0.1, 0.0, -0.3));
127 addControlPoint(vec3(0.0, 0.2, 0.0));
128 addControlPoint(vec3(0.0, 0.6, 0.0));
129 addControlPoint(vec3(0.0, 0.8, 0.0));
130 addControlPoint(vec3(0.0, 0.8, 0.0));
131 addControlPoint(vec3(0.0, 0.8, 0.0));
132 addControlPoint(vec3(0.0, 0.8, 0.0));
133 addControlPoint(vec3(0.0, 0.8, 0.0));
134 addControlPoint(vec3(0.0, 0.8, 0.0));
135 addControlPoint(vec3(0.0, 0.8, 0.0));
136 addControlPoint(vec3(0.0, 0.8, 0.0));
137 calcParams();
138}
139
140LightPositionSpline::LightPositionSpline()
141{
142 addControlPoint(vec3(0.0, 1.8, 0.0));
143 addControlPoint(vec3(0.0, 1.8, 0.0));
144 addControlPoint(vec3(0.0, 1.6, 0.0));
145 addControlPoint(vec3(0.0, 1.6, 0.0));
146 addControlPoint(vec3(0.0, 1.6, 0.0));
147 addControlPoint(vec3(0.0, 1.6, 0.0));
148 addControlPoint(vec3(0.0, 1.4, 0.0));
149 addControlPoint(vec3(0.0, 1.3, 0.0));
150 addControlPoint(vec3(-0.2, 1.5, 2.0));
151 addControlPoint(vec3(0.8, 1.5, -0.4));
152 addControlPoint(vec3(-0.8, 1.5, -0.4));
153 addControlPoint(vec3(0.8, 2.0, 1.0));
154 addControlPoint(vec3(1.8, 5.0, -1.8));
155 addControlPoint(vec3(8.0, 10.0, -4.0));
156 addControlPoint(vec3(8.0, 10.0, -4.0));
157 addControlPoint(vec3(8.0, 10.0, -4.0));
158 calcParams();
159}
160
161LogoPositionSpline::LogoPositionSpline()
162{
163 addControlPoint(vec3(0.0, -0.5, 0.0));
164 addControlPoint(vec3(0.0, -0.5, 0.0));
165 addControlPoint(vec3(0.0, -0.5, 0.0));
166 addControlPoint(vec3(0.0, -0.5, 0.0));
167 addControlPoint(vec3(0.0, -0.5, 0.0));
168 addControlPoint(vec3(0.0, -0.5, 0.0));
169 addControlPoint(vec3(0.0, 0.0, 0.0));
170 addControlPoint(vec3(0.0, 0.6, 0.0));
171 addControlPoint(vec3(0.0, 0.75, 0.0));
172 addControlPoint(vec3(0.0, 0.8, 0.0));
173 addControlPoint(vec3(0.0, 0.8, 0.0));
174 addControlPoint(vec3(0.0, 0.5, 0.0));
175 addControlPoint(vec3(0.0, 0.5, 0.0));
176 addControlPoint(vec3(0.0, 0.5, 0.0));
177 addControlPoint(vec3(0.0, 0.5, 0.0));
178 addControlPoint(vec3(0.0, 0.5, 0.0));
179 calcParams();
180}
181
182LogoRotationSpline::LogoRotationSpline()
183{
184 addControlPoint(vec3(0.0, 0.0, -18.4));
185 addControlPoint(vec3(0.0, 0.0, -18.4));
186 addControlPoint(vec3(0.0, 0.0, -18.4));
187 addControlPoint(vec3(0.0, 0.0, -18.4));
188 addControlPoint(vec3(0.0, 0.0, -18.4));
189 addControlPoint(vec3(0.0, 0.0, -18.4));
190 addControlPoint(vec3(0.0, 0.0, -18.4));
191 addControlPoint(vec3(0.0, 0.0, -18.4));
192 addControlPoint(vec3(240.0, 360.0, 180.0));
193 addControlPoint(vec3(90.0, 180.0, 90.0));
194 addControlPoint(vec3(11.9, 0.0, -18.4));
195 addControlPoint(vec3(11.9, 0.0, -18.4));
196 addControlPoint(vec3(11.9, 0.0, -18.4));
197 addControlPoint(vec3(11.9, 0.0, -18.4));
198 addControlPoint(vec3(11.9, 0.0, -18.4));
199 calcParams();
200}
0201
=== added file 'src/scene-ideas/splines.h'
--- src/scene-ideas/splines.h 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/splines.h 2012-05-09 20:57:19 +0000
@@ -0,0 +1,83 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#ifndef SPLINES_H_
24#define SPLINES_H_
25
26#include <vector>
27#include "vec.h"
28
29class Spline
30{
31public:
32 Spline() :
33 paramData_(0) {}
34 ~Spline()
35 {
36 delete [] paramData_;
37 }
38 void addControlPoint(const LibMatrix::vec3& point) { controlData_.push_back(point); }
39 void getCurrentVec(float currentTime, LibMatrix::vec3& v) const;
40 void calcParams();
41
42private:
43 std::vector<LibMatrix::vec3> controlData_;
44 typedef LibMatrix::vec3 param[4];
45 param* paramData_;
46};
47
48class ViewFromSpline : public Spline
49{
50public:
51 ViewFromSpline();
52 ~ViewFromSpline() {}
53};
54
55class ViewToSpline : public Spline
56{
57public:
58 ViewToSpline();
59 ~ViewToSpline() {}
60};
61
62class LightPositionSpline : public Spline
63{
64public:
65 LightPositionSpline();
66 ~LightPositionSpline() {}
67};
68
69class LogoPositionSpline : public Spline
70{
71public:
72 LogoPositionSpline();
73 ~LogoPositionSpline() {}
74};
75
76class LogoRotationSpline : public Spline
77{
78public:
79 LogoRotationSpline();
80 ~LogoRotationSpline() {}
81};
82
83#endif // SPLINES_H_
084
=== added file 'src/scene-ideas/t.cc'
--- src/scene-ideas/t.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/t.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,147 @@
1/*
2 * Vertex position data describing the letter 't'
3 *
4 * (c) Copyright 1993, Silicon Graphics, Inc.
5 * Copyright © 2012 Linaro Limited
6 *
7 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
8 *
9 * glmark2 is free software: you can redistribute it and/or modify it under the
10 * terms of the GNU General Public License as published by the Free Software
11 * Foundation, either version 3 of the License, or (at your option) any later
12 * version.
13 *
14 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along with
20 * glmark2. If not, see <http://www.gnu.org/licenses/>.
21 *
22 * Authors:
23 * Jesse Barker
24 */
25#include "characters.h"
26
27using LibMatrix::vec2;
28
29LetterT::LetterT()
30{
31 // Vertex data...
32 vertexData_.push_back(vec2(2.986667, 14.034801));
33 vertexData_.push_back(vec2(2.445128, 10.088024));
34 vertexData_.push_back(vec2(1.788718, 9.236438));
35 vertexData_.push_back(vec2(2.264615, 7.664279));
36 vertexData_.push_back(vec2(1.165128, 5.666326));
37 vertexData_.push_back(vec2(2.034872, 4.945752));
38 vertexData_.push_back(vec2(1.132308, 3.766633));
39 vertexData_.push_back(vec2(2.182564, 3.570113));
40 vertexData_.push_back(vec2(1.411282, 2.309109));
41 vertexData_.push_back(vec2(2.510769, 2.341863));
42 vertexData_.push_back(vec2(2.149744, 1.048106));
43 vertexData_.push_back(vec2(3.364103, 1.375640));
44 vertexData_.push_back(vec2(3.167180, 0.327533));
45 vertexData_.push_back(vec2(4.381538, 0.736950));
46 vertexData_.push_back(vec2(5.005128, 0.032753));
47 vertexData_.push_back(vec2(5.612308, 0.638690));
48 vertexData_.push_back(vec2(6.235898, 0.540430));
49 vertexData_.push_back(vec2(7.187692, 1.162743));
50 vertexData_.push_back(vec2(1.985641, 9.039918));
51 vertexData_.push_back(vec2(2.133333, 10.186285));
52 vertexData_.push_back(vec2(1.509744, 9.023541));
53 vertexData_.push_back(vec2(1.608205, 9.662231));
54 vertexData_.push_back(vec2(1.050256, 9.023541));
55 vertexData_.push_back(vec2(1.050256, 9.334698));
56 vertexData_.push_back(vec2(0.196923, 9.007165));
57 vertexData_.push_back(vec2(2.363077, 9.711361));
58 vertexData_.push_back(vec2(2.264615, 9.023541));
59 vertexData_.push_back(vec2(3.282051, 9.563972));
60 vertexData_.push_back(vec2(3.446154, 9.023541));
61 vertexData_.push_back(vec2(4.069744, 9.531218));
62 vertexData_.push_back(vec2(4.299487, 9.236438));
63 vertexData_.push_back(vec2(4.644103, 9.613101));
64 vertexData_.push_back(vec2(5.251282, 9.875128));
65
66 // Index data...
67 indexData_.push_back(0);
68 indexData_.push_back(1);
69 indexData_.push_back(2);
70 indexData_.push_back(3);
71 indexData_.push_back(4);
72 indexData_.push_back(5);
73 indexData_.push_back(6);
74 indexData_.push_back(7);
75 indexData_.push_back(8);
76 indexData_.push_back(9);
77 indexData_.push_back(10);
78 indexData_.push_back(11);
79 indexData_.push_back(12);
80 indexData_.push_back(13);
81 indexData_.push_back(14);
82 indexData_.push_back(15);
83 indexData_.push_back(16);
84 indexData_.push_back(17);
85 indexData_.push_back(18);
86 indexData_.push_back(19);
87 indexData_.push_back(20);
88 indexData_.push_back(21);
89 indexData_.push_back(22);
90 indexData_.push_back(23);
91 indexData_.push_back(24);
92 indexData_.push_back(25);
93 indexData_.push_back(26);
94 indexData_.push_back(27);
95 indexData_.push_back(28);
96 indexData_.push_back(29);
97 indexData_.push_back(30);
98 indexData_.push_back(31);
99 indexData_.push_back(32);
100 indexData_.push_back(0);
101 indexData_.push_back(2);
102 indexData_.push_back(4);
103 indexData_.push_back(6);
104 indexData_.push_back(8);
105 indexData_.push_back(10);
106 indexData_.push_back(12);
107 indexData_.push_back(14);
108 indexData_.push_back(16);
109 indexData_.push_back(17);
110 indexData_.push_back(15);
111 indexData_.push_back(13);
112 indexData_.push_back(11);
113 indexData_.push_back(9);
114 indexData_.push_back(7);
115 indexData_.push_back(5);
116 indexData_.push_back(3);
117 indexData_.push_back(1);
118 indexData_.push_back(18);
119 indexData_.push_back(20);
120 indexData_.push_back(22);
121 indexData_.push_back(24);
122 indexData_.push_back(23);
123 indexData_.push_back(21);
124 indexData_.push_back(19);
125 indexData_.push_back(26);
126 indexData_.push_back(28);
127 indexData_.push_back(30);
128 indexData_.push_back(32);
129 indexData_.push_back(31);
130 indexData_.push_back(29);
131 indexData_.push_back(27);
132 indexData_.push_back(25);
133
134 // Primitive state so that the draw call can issue the primitives we want.
135 unsigned int curOffset(0);
136 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 18, curOffset));
137 curOffset += (18 * sizeof(unsigned int));
138 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 7, curOffset));
139 curOffset += (7 * sizeof(unsigned int));
140 primVec_.push_back(PrimitiveState(GL_TRIANGLE_STRIP, 8, curOffset));
141 curOffset += (8 * sizeof(unsigned int));
142 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 18, curOffset));
143 curOffset += (18 * sizeof(unsigned int));
144 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 7, curOffset));
145 curOffset += (7 * sizeof(unsigned int));
146 primVec_.push_back(PrimitiveState(GL_LINE_STRIP, 8, curOffset));
147}
0148
=== added file 'src/scene-ideas/table.cc'
--- src/scene-ideas/table.cc 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/table.cc 2012-05-09 20:57:19 +0000
@@ -0,0 +1,353 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#include "table.h"
24#include "scene.h"
25#include "shader-source.h"
26#include "log.h"
27
28using std::string;
29using LibMatrix::vec3;
30using LibMatrix::Stack4;
31
32const string Table::modelviewName_("modelview");
33const string Table::projectionName_("projection");
34const string Table::lightPositionName_("lightPosition");
35const string Table::logoDirectionName_("logoDirection");
36const string Table::curTimeName_("currentTime");
37const string Table::vertexAttribName_("vertex");
38const unsigned int Table::TABLERES_(12);
39const vec3 Table::paperVertices_[4] = {
40 vec3(-0.8, 0.0, 0.4),
41 vec3(-0.2, 0.0, -1.4),
42 vec3(0.4, 0.0, 0.8),
43 vec3(1.0, 0.0, -1.0),
44};
45
46Table::Table() :
47 tableVertexIndex_(0),
48 paperVertexIndex_(0),
49 textVertexIndex_(0),
50 underVertexIndex_(0),
51 valid_(false)
52{
53 tableVertices_.reserve((TABLERES_ + 1) * (TABLERES_ + 1));
54 for (unsigned int i = 0; i <= TABLERES_; i++)
55 {
56 for (unsigned int j = 0; j <= TABLERES_; j++)
57 {
58 float x((static_cast<float>(i) - static_cast<float>(TABLERES_) * 1.0 / 2.0) / 2.0);
59 float z((static_cast<float>(j) - static_cast<float>(TABLERES_) * 1.0 / 2.0) / 2.0);
60 tableVertices_.push_back(vec3(x, 0.0, z));
61 }
62 }
63
64 // Now that we've setup the vertex data, we can setup the map of how
65 // that data will be laid out in the buffer object.
66 dataMap_.tvOffset = 0;
67 dataMap_.tvSize = tableVertices_.size() * sizeof(vec3);
68 dataMap_.totalSize = dataMap_.tvSize;
69 dataMap_.pvOffset = dataMap_.tvOffset + dataMap_.tvSize;
70 dataMap_.pvSize = 4 * sizeof(vec3);
71 dataMap_.totalSize += dataMap_.pvSize;
72
73 for (unsigned int i = 0; i < TABLERES_; i++)
74 {
75 for (unsigned int j = 0; j <= TABLERES_; j++)
76 {
77 unsigned int curIndex1(i * (TABLERES_ + 1) + j);
78 unsigned int curIndex2((i + 1) * (TABLERES_ + 1) + j);
79 indexData_.push_back(curIndex1);
80 indexData_.push_back(curIndex2);
81 }
82 }
83}
84
85Table::~Table(void)
86{
87 if (valid_)
88 {
89 glDeleteBuffers(2, &bufferObjects_[0]);
90 }
91}
92
93void
94Table::init(void)
95{
96 // Make sure we don't re-initialize...
97 if (valid_)
98 {
99 return;
100 }
101
102 // Initialize shader sources from input files and create programs from them
103 // Program to render the table with lighting and a time-based fade...
104 string table_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-table.vert");
105 string table_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-table.frag");
106 ShaderSource table_vtx_source(table_vtx_filename);
107 ShaderSource table_frg_source(table_frg_filename);
108 if (!Scene::load_shaders_from_strings(tableProgram_, table_vtx_source.str(),
109 table_frg_source.str()))
110 {
111 Log::error("No valid program for table rendering.\n");
112 return;
113 }
114 textVertexIndex_ = tableProgram_[vertexAttribName_].location();
115
116 // Program to render the paper with lighting and a time-based fade...
117 string paper_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-paper.vert");
118 string paper_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-paper.frag");
119 ShaderSource paper_vtx_source(paper_vtx_filename);
120 ShaderSource paper_frg_source(paper_frg_filename);
121 if (!Scene::load_shaders_from_strings(paperProgram_, paper_vtx_source.str(),
122 paper_frg_source.str()))
123 {
124 Log::error("No valid program for paper rendering.\n");
125 return;
126 }
127 paperVertexIndex_ = paperProgram_[vertexAttribName_].location();
128
129 // Program to handle the text (time-based color fade)...
130 string text_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-text.vert");
131 string text_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-text.frag");
132 ShaderSource text_vtx_source(text_vtx_filename);
133 ShaderSource text_frg_source(text_frg_filename);
134 if (!Scene::load_shaders_from_strings(textProgram_, text_vtx_source.str(),
135 text_frg_source.str()))
136 {
137 Log::error("No valid program for text rendering.\n");
138 return;
139 }
140 textVertexIndex_ = textProgram_[vertexAttribName_].location();
141
142 // Program for the drawUnder functionality (just paint it black)...
143 string under_table_vtx_filename(GLMARK_DATA_PATH"/shaders/ideas-under-table.vert");
144 string under_table_frg_filename(GLMARK_DATA_PATH"/shaders/ideas-under-table.frag");
145 ShaderSource under_table_vtx_source(under_table_vtx_filename);
146 ShaderSource under_table_frg_source(under_table_frg_filename);
147 if (!Scene::load_shaders_from_strings(underProgram_, under_table_vtx_source.str(),
148 under_table_frg_source.str()))
149 {
150 Log::error("No valid program for under table rendering.\n");
151 return;
152 }
153 underVertexIndex_ = underProgram_[vertexAttribName_].location();
154
155 // Tell all of the characters to initialize themselves...
156 i_.init(textVertexIndex_);
157 d_.init(textVertexIndex_);
158 e_.init(textVertexIndex_);
159 a_.init(textVertexIndex_);
160 s_.init(textVertexIndex_);
161 n_.init(textVertexIndex_);
162 m_.init(textVertexIndex_);
163 o_.init(textVertexIndex_);
164 t_.init(textVertexIndex_);
165
166 // We need 2 buffers for our work here. One for the vertex data.
167 // and one for the index data.
168 glGenBuffers(2, &bufferObjects_[0]);
169
170 // First, setup the vertex data by binding the first buffer object,
171 // allocating its data store, and filling it in with our vertex data.
172 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
173 glBufferData(GL_ARRAY_BUFFER, dataMap_.totalSize, 0, GL_STATIC_DRAW);
174 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.tvOffset, dataMap_.tvSize,
175 &tableVertices_.front());
176 glBufferSubData(GL_ARRAY_BUFFER, dataMap_.pvOffset, dataMap_.pvSize,
177 &paperVertices_[0]);
178
179 // Now repeat for our index data.
180 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
181 glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexData_.size() * sizeof(unsigned int),
182 &indexData_.front(), GL_STATIC_DRAW);
183
184 // We're ready to go.
185 valid_ = true;
186}
187
188void
189Table::draw(Stack4& modelview,
190 Stack4& projection,
191 const vec3& lightPos,
192 const vec3& logoPos,
193 const float& currentTime,
194 float& paperAlpha_out)
195{
196 glDisable(GL_DEPTH_TEST);
197
198 // Compute the light direction with respect to the logo...
199 vec3 logoDirection(lightPos.x() - logoPos.x(), lightPos.y() - logoPos.y(),
200 lightPos.z() - logoPos.z());
201 logoDirection.normalize();
202
203 // Compute the alpha component based upon drawing the paper (all of this will
204 // be done in the shader, but we need to pass this back so that the logo's
205 // shadow will look right).
206 for (unsigned int i = 0; i < 4; i++)
207 {
208 vec3 lightDirection(lightPos.x() - paperVertices_[i].x(),
209 lightPos.y() - paperVertices_[i].y(),
210 lightPos.z() - paperVertices_[i].z());
211 lightDirection.normalize();
212 float c = vec3::dot(lightDirection, logoDirection);
213 if (c < 0.0)
214 {
215 c = 0.0;
216 }
217 c = c * c * c * lightDirection.y();
218 if ((currentTime > 10.0) && (currentTime < 12.0))
219 {
220 c *= 1.0 - (currentTime - 10.0) * 0.5;
221 }
222 paperAlpha_out += c;
223 }
224
225 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
226 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
227
228 // Draw the table top
229 tableProgram_.start();
230 tableProgram_[projectionName_] = projection.getCurrent();
231 tableProgram_[modelviewName_] = modelview.getCurrent();
232 tableProgram_[lightPositionName_] = lightPos;
233 tableProgram_[logoDirectionName_] = logoDirection;
234 tableProgram_[curTimeName_] = currentTime;
235 glVertexAttribPointer(tableVertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
236 reinterpret_cast<const GLvoid*>(dataMap_.tvOffset));
237 glEnableVertexAttribArray(tableVertexIndex_);
238 static const unsigned int twiceRes(2 * (TABLERES_ + 1));
239 for (unsigned int i = 0; i < TABLERES_; i++)
240 {
241 glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_INT,
242 reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned int)));
243 }
244 glDisableVertexAttribArray(tableVertexIndex_);
245 tableProgram_.stop();
246
247 if (logoPos.y() > -0.33 && logoPos.y() < 0.33)
248 {
249 glEnable(GL_DEPTH_TEST);
250 }
251
252 // Draw the paper lying on the table top
253 paperProgram_.start();
254 paperProgram_[projectionName_] = projection.getCurrent();
255 paperProgram_[modelviewName_] = modelview.getCurrent();
256 paperProgram_[lightPositionName_] = lightPos;
257 paperProgram_[logoDirectionName_] = logoDirection;
258 paperProgram_[curTimeName_] = currentTime;
259 glVertexAttribPointer(paperVertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
260 reinterpret_cast<const GLvoid*>(dataMap_.pvOffset));
261 glEnableVertexAttribArray(paperVertexIndex_);
262 glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
263 glDisableVertexAttribArray(paperVertexIndex_);
264 paperProgram_.stop();
265
266 glBindBuffer(GL_ARRAY_BUFFER, 0);
267 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
268
269 glDisable(GL_DEPTH_TEST);
270
271 modelview.push();
272 modelview.rotate(-18.4, 0.0, 1.0, 0.0);
273 modelview.translate(-0.3, 0.0, -0.8);
274 modelview.rotate(-90.0, 1.0, 0.0, 0.0);
275 modelview.scale(0.015, 0.015, 0.015);
276
277 // Draw the text on the paper lying on the table top.
278 // Each character has its own array and element buffers, and they have
279 // been initialized with the vertex attrib location for this program.
280 textProgram_.start();
281 textProgram_[projectionName_] = projection.getCurrent();
282 textProgram_[modelviewName_] = modelview.getCurrent();
283 textProgram_[curTimeName_] = currentTime;
284 i_.draw();
285 modelview.translate(3.0, 0.0, 0.0);
286 textProgram_[modelviewName_] = modelview.getCurrent();
287 d_.draw();
288 modelview.translate(6.0, 0.0, 0.0);
289 textProgram_[modelviewName_] = modelview.getCurrent();
290 e_.draw();
291 modelview.translate(5.0, 0.0, 0.0);
292 textProgram_[modelviewName_] = modelview.getCurrent();
293 a_.draw();
294 modelview.translate(6.0, 0.0, 0.0);
295 textProgram_[modelviewName_] = modelview.getCurrent();
296 s_.draw();
297 modelview.translate(10.0, 0.0, 0.0);
298 textProgram_[modelviewName_] = modelview.getCurrent();
299 i_.draw();
300 modelview.translate(3.0, 0.0, 0.0);
301 textProgram_[modelviewName_] = modelview.getCurrent();
302 n_.draw();
303 modelview.translate(-31.0, -13.0, 0.0);
304 textProgram_[modelviewName_] = modelview.getCurrent();
305 m_.draw();
306 modelview.translate(10.0, 0.0, 0.0);
307 textProgram_[modelviewName_] = modelview.getCurrent();
308 o_.draw();
309 modelview.translate(5.0, 0.0, 0.0);
310 textProgram_[modelviewName_] = modelview.getCurrent();
311 t_.draw();
312 modelview.translate(4.0, 0.0, 0.0);
313 textProgram_[modelviewName_] = modelview.getCurrent();
314 i_.draw();
315 modelview.translate(3.5, 0.0, 0.0);
316 textProgram_[modelviewName_] = modelview.getCurrent();
317 o_.draw();
318 modelview.translate(5.0, 0.0, 0.0);
319 textProgram_[modelviewName_] = modelview.getCurrent();
320 n_.draw();
321 textProgram_.stop();
322
323 modelview.pop();
324}
325
326void
327Table::drawUnder(Stack4& modelview, Stack4& projection)
328{
329 glDisable(GL_DEPTH_TEST);
330
331 glBindBuffer(GL_ARRAY_BUFFER, bufferObjects_[0]);
332 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferObjects_[1]);
333
334 underProgram_.start();
335 underProgram_[modelviewName_] = modelview.getCurrent();
336 underProgram_[projectionName_] = projection.getCurrent();
337 glVertexAttribPointer(underVertexIndex_, 3, GL_FLOAT, GL_FALSE, 0,
338 reinterpret_cast<const GLvoid*>(dataMap_.tvOffset));
339 glEnableVertexAttribArray(underVertexIndex_);
340 static const unsigned int twiceRes(2 * (TABLERES_ + 1));
341 for (unsigned int i = 0; i < TABLERES_; i++)
342 {
343 glDrawElements(GL_TRIANGLE_STRIP, twiceRes, GL_UNSIGNED_INT,
344 reinterpret_cast<const GLvoid*>(i * twiceRes * sizeof(unsigned int)));
345 }
346 glDisableVertexAttribArray(underVertexIndex_);
347 underProgram_.stop();
348
349 glBindBuffer(GL_ARRAY_BUFFER, 0);
350 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
351
352 glEnable(GL_DEPTH_TEST);
353}
0354
=== added file 'src/scene-ideas/table.h'
--- src/scene-ideas/table.h 1970-01-01 00:00:00 +0000
+++ src/scene-ideas/table.h 2012-05-09 20:57:19 +0000
@@ -0,0 +1,94 @@
1/*
2 * (c) Copyright 1993, Silicon Graphics, Inc.
3 * Copyright © 2012 Linaro Limited
4 *
5 * This file is part of the glmark2 OpenGL (ES) 2.0 benchmark.
6 *
7 * glmark2 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU General Public License as published by the Free Software
9 * Foundation, either version 3 of the License, or (at your option) any later
10 * version.
11 *
12 * glmark2 is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
15 * details.
16 *
17 * You should have received a copy of the GNU General Public License along with
18 * glmark2. If not, see <http://www.gnu.org/licenses/>.
19 *
20 * Authors:
21 * Jesse Barker
22 */
23#ifndef TABLE_H_
24#define TABLE_H_
25
26#include <string>
27#include <vector>
28#include "characters.h"
29#include "program.h"
30#include "stack.h"
31
32class Table
33{
34public:
35 Table();
36 ~Table();
37
38 void init();
39 bool valid() const { return valid_; }
40 void draw(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection,
41 const LibMatrix::vec3& lightPosition, const LibMatrix::vec3& logoPosition,
42 const float& currentTime, float& paperAlpha_out);
43 void drawUnder(LibMatrix::Stack4& modelview, LibMatrix::Stack4& projection);
44
45private:
46 // Text
47 LetterI i_;
48 LetterD d_;
49 LetterE e_;
50 LetterA a_;
51 LetterS s_;
52 LetterN n_;
53 LetterM m_;
54 LetterO o_;
55 LetterT t_;
56 Program tableProgram_;
57 Program paperProgram_;
58 Program textProgram_;
59 Program underProgram_;
60 std::string tableVertexShader_;
61 std::string tableFragmentShader_;
62 std::string paperVertexShader_;
63 std::string paperFragmentShader_;
64 std::string textVertexShader_;
65 std::string textFragmentShader_;
66 std::string underVertexShader_;
67 std::string underFragmentShader_;
68 static const std::string modelviewName_;
69 static const std::string projectionName_;
70 static const std::string lightPositionName_;
71 static const std::string logoDirectionName_;
72 static const std::string curTimeName_;
73 static const std::string vertexAttribName_;
74 static const unsigned int TABLERES_;
75 std::vector<LibMatrix::vec3> tableVertices_;
76 static const LibMatrix::vec3 paperVertices_[4];
77 struct VertexDataMap
78 {
79 unsigned int tvOffset;
80 unsigned int tvSize;
81 unsigned int pvOffset;
82 unsigned int pvSize;
83 unsigned int totalSize;
84 } dataMap_;
85 unsigned int bufferObjects_[2];
86 std::vector<unsigned int> indexData_;
87 int tableVertexIndex_;
88 int paperVertexIndex_;
89 int textVertexIndex_;
90 int underVertexIndex_;
91 bool valid_;
92};
93
94#endif // TABLE_H_
095
=== modified file 'src/scene.h'
--- src/scene.h 2012-02-09 01:28:16 +0000
+++ src/scene.h 2012-05-09 20:57:19 +0000
@@ -477,4 +477,25 @@
477private:477private:
478 SceneBufferPrivate *priv_;478 SceneBufferPrivate *priv_;
479};479};
480
481class SceneIdeasPrivate;
482
483class SceneIdeas : public Scene
484{
485public:
486 SceneIdeas(Canvas &pCanvas);
487 bool load();
488 void unload();
489 void setup();
490 void teardown();
491 void update();
492 void draw();
493 ValidationResult validate();
494
495 ~SceneIdeas();
496
497private:
498 SceneIdeasPrivate* priv_;
499};
500
480#endif501#endif
481502
=== modified file 'src/wscript_build'
--- src/wscript_build 2012-01-26 17:00:43 +0000
+++ src/wscript_build 2012-05-09 20:57:19 +0000
@@ -5,6 +5,7 @@
5glesv2_sources = ['canvas-x11.cpp', 'canvas-x11-egl.cpp']5glesv2_sources = ['canvas-x11.cpp', 'canvas-x11-egl.cpp']
6libmatrix_sources = [f for f in bld.path.ant_glob('libmatrix/*.cc')6libmatrix_sources = [f for f in bld.path.ant_glob('libmatrix/*.cc')
7 if not f.name.endswith('test.cc')]7 if not f.name.endswith('test.cc')]
8ideas_sources = bld.path.ant_glob('scene-ideas/*.cc')
89
9if bld.env.USE_GL:10if bld.env.USE_GL:
10 bld(11 bld(
@@ -18,10 +19,11 @@
18 )19 )
19 bld(20 bld(
20 features = ['cxx', 'cprogram'],21 features = ['cxx', 'cprogram'],
21 source = common_sources + gl_sources,22 source = ideas_sources + common_sources + gl_sources,
22 target = 'glmark2',23 target = 'glmark2',
23 use = ['x11', 'gl', 'matrix', 'libpng12'],24 use = ['x11', 'gl', 'matrix', 'libpng12'],
24 lib = ['m'],25 lib = ['m'],
26 includes = ['.', 'scene-ideas'],
25 defines = ['USE_GL', 'USE_EXCEPTIONS']27 defines = ['USE_GL', 'USE_EXCEPTIONS']
26 )28 )
2729
@@ -37,9 +39,10 @@
37 )39 )
38 bld(40 bld(
39 features = ['cxx', 'cprogram'],41 features = ['cxx', 'cprogram'],
40 source = common_sources + glesv2_sources,42 source = ideas_sources + common_sources + glesv2_sources,
41 target = 'glmark2-es2',43 target = 'glmark2-es2',
42 use = ['x11', 'egl', 'glesv2', 'matrix-es2', 'libpng12'],44 use = ['x11', 'egl', 'glesv2', 'matrix-es2', 'libpng12'],
43 lib = ['m', 'dl'],45 lib = ['m', 'dl'],
46 includes = ['.', 'scene-ideas'],
44 defines = ['USE_GLESv2', 'USE_EXCEPTIONS']47 defines = ['USE_GLESv2', 'USE_EXCEPTIONS']
45 )48 )

Subscribers

People subscribed via source and target branches

to all changes: