Skip to content

Commit fc1aa56

Browse files
author
Dom Cobley
committed
Add hello_videocube demo. Thanks to OtherCrashOverride.
1 parent 4697c2b commit fc1aa56

File tree

12 files changed

+2046
-0
lines changed

12 files changed

+2046
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
OBJS=triangle.o video.o
2+
BIN=hello_videocube.bin
3+
LDFLAGS+=-lilclient
4+
5+
CFLAGS+=-DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g -DHAVE_LIBOPENMAX=2 -DOMX -DOMX_SKIP64BIT -ftree-vectorize -pipe -DUSE_EXTERNAL_OMX -DHAVE_LIBBCM_HOST -DUSE_EXTERNAL_LIBBCM_HOST -DUSE_VCHIQ_ARM -Wno-psabi
6+
7+
LDFLAGS+=-L$(SDKSTAGE)/opt/vc/lib/ -lGLESv2 -lEGL -lopenmaxil -lvcos -lvchiq_arm -lpthread -lrt -lbcm_host -L/opt/vc/src/hello_pi/libs/ilclient -L../libs/vgfont
8+
9+
INCLUDES+=-I$(SDKSTAGE)/opt/vc/include/ -I$(SDKSTAGE)/opt/vc/include/interface/vcos/pthreads -I$(SDKSTAGE)/opt/vc/include/interface/vmcs_host/linux -I./ -I/opt/vc/src/hello_pi/libs/ilclient -I../libs/vgfont
10+
11+
all: $(BIN) $(LIB)
12+
13+
%.o: %.c
14+
@rm -f $@
15+
$(CC) $(CFLAGS) $(INCLUDES) -g -c $< -o $@ -Wno-deprecated-declarations
16+
17+
%.o: %.cpp
18+
@rm -f $@
19+
$(CXX) $(CFLAGS) $(INCLUDES) -g -c $< -o $@ -Wno-deprecated-declarations
20+
21+
%.bin: $(OBJS)
22+
$(CC) -o $@ -Wl,--whole-archive $(OBJS) $(LDFLAGS) -Wl,--no-whole-archive -rdynamic
23+
24+
%.a: $(OBJS)
25+
$(AR) r $@ $^
26+
27+
clean:
28+
for i in $(OBJS); do (if test -e "$$i"; then ( rm $$i ); fi ); done
29+
@rm -f $(BIN) $(LIB)
30+
31+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
hello_videocube
2+
===============
3+
4+
Sample for Raspberry Pi that uses egl_render to display video on an animated cube.
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
/*
2+
Copyright (c) 2012, Broadcom Europe Ltd
3+
All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in the
11+
documentation and/or other materials provided with the distribution.
12+
* Neither the name of the copyright holder nor the
13+
names of its contributors may be used to endorse or promote products
14+
derived from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
28+
// Spatial coordinates for the cube
29+
30+
static const GLbyte quadx[6*4*3] = {
31+
/* FRONT */
32+
-10, -10, 10,
33+
10, -10, 10,
34+
-10, 10, 10,
35+
10, 10, 10,
36+
37+
/* BACK */
38+
-10, -10, -10,
39+
-10, 10, -10,
40+
10, -10, -10,
41+
10, 10, -10,
42+
43+
/* LEFT */
44+
-10, -10, 10,
45+
-10, 10, 10,
46+
-10, -10, -10,
47+
-10, 10, -10,
48+
49+
/* RIGHT */
50+
10, -10, -10,
51+
10, 10, -10,
52+
10, -10, 10,
53+
10, 10, 10,
54+
55+
/* TOP */
56+
-10, 10, 10,
57+
10, 10, 10,
58+
-10, 10, -10,
59+
10, 10, -10,
60+
61+
/* BOTTOM */
62+
-10, -10, 10,
63+
-10, -10, -10,
64+
10, -10, 10,
65+
10, -10, -10,
66+
};
67+
68+
/** Texture coordinates for the quad. */
69+
static const GLfloat texCoords[6 * 4 * 2] = {
70+
0.f, 0.f,
71+
0.f, 1.f,
72+
1.f, 0.f,
73+
1.f, 1.f,
74+
75+
0.f, 0.f,
76+
0.f, 1.f,
77+
1.f, 0.f,
78+
1.f, 1.f,
79+
80+
0.f, 0.f,
81+
0.f, 1.f,
82+
1.f, 0.f,
83+
1.f, 1.f,
84+
85+
0.f, 0.f,
86+
0.f, 1.f,
87+
1.f, 0.f,
88+
1.f, 1.f,
89+
90+
0.f, 0.f,
91+
0.f, 1.f,
92+
1.f, 0.f,
93+
1.f, 1.f,
94+
95+
0.f, 0.f,
96+
0.f, 1.f,
97+
1.f, 0.f,
98+
1.f, 1.f
99+
};
100+
101+
// Colors are invisible when textures appear on all 6 faces.
102+
// If textures are disabled, e.g. by commenting out glEnable(GL_TEXTURE_2D),
103+
// the colours will appear.
104+
105+
static const GLfloat colorsf[6*4*4] = {
106+
1.f, 0.f, 0.f, 1.f, //red
107+
1.f, 0.f, 0.f, 1.f,
108+
1.f, 0.f, 0.f, 1.f,
109+
1.f, 0.f, 0.f, 1.f,
110+
111+
0.f, 1.f, 0.f, 1.f, // blue
112+
0.f, 1.f, 0.f, 1.f,
113+
0.f, 1.f, 0.f, 1.f,
114+
0.f, 1.f, 0.f, 1.f,
115+
116+
0.f, 0.f, 1.f, 1.f, // green
117+
0.f, 0.f, 1.f, 1.f,
118+
0.f, 0.f, 1.f, 1.f,
119+
0.f, 0.f, 1.f, 1.f,
120+
121+
0.f, 0.5f, 0.5f, 1.f, // teal
122+
0.f, 0.5f, 0.5f, 1.f,
123+
0.f, 0.5f, 0.5f, 1.f,
124+
0.f, 0.5f, 0.5f, 1.f,
125+
126+
0.5f, 0.5f, 0.f, 1.f, // yellow
127+
0.5f, 0.5f, 0.f, 1.f,
128+
0.5f, 0.5f, 0.f, 1.f,
129+
0.5f, 0.5f, 0.f, 1.f,
130+
131+
0.5f, 0.f, 0.5f, 1.f, // purple
132+
0.5f, 0.f, 0.5f, 1.f,
133+
0.5f, 0.f, 0.5f, 1.f,
134+
0.5f, 0.f, 0.5f, 1.f
135+
};

0 commit comments

Comments
 (0)