866 lines
75 KiB
Diff
866 lines
75 KiB
Diff
|
|
From 03053b119a625a03e28a86be0f0ab2aa9e2a6a49 Mon Sep 17 00:00:00 2001
|
|||
|
|
From: Tomeu Vizoso <tomeu.vizoso@collabora.com>
|
|||
|
|
Date: Tue, 1 Oct 2013 13:19:20 +0200
|
|||
|
|
Subject: [PATCH] wayland: Add Wayland example
|
|||
|
|
|
|||
|
|
---
|
|||
|
|
Upstream-Status: Pending
|
|||
|
|
|
|||
|
|
.../linux/apps/hello_pi/CMakeLists.txt | 1 +
|
|||
|
|
.../linux/apps/hello_pi/Makefile | 2 +
|
|||
|
|
.../hello_pi/hello_wayland/CMakeLists.txt | 8 +
|
|||
|
|
.../hello_pi/hello_wayland/Djenne_128_128.raw | 3 +
|
|||
|
|
.../apps/hello_pi/hello_wayland/Makefile | 5 +
|
|||
|
|
.../hello_wayland/cube_texture_and_coords.h | 100 +++
|
|||
|
|
.../apps/hello_pi/hello_wayland/triangle.c | 666 ++++++++++++++++++
|
|||
|
|
7 files changed, 785 insertions(+)
|
|||
|
|
create mode 100644 host_applications/linux/apps/hello_pi/hello_wayland/CMakeLists.txt
|
|||
|
|
create mode 100644 host_applications/linux/apps/hello_pi/hello_wayland/Djenne_128_128.raw
|
|||
|
|
create mode 100644 host_applications/linux/apps/hello_pi/hello_wayland/Makefile
|
|||
|
|
create mode 100644 host_applications/linux/apps/hello_pi/hello_wayland/cube_texture_and_coords.h
|
|||
|
|
create mode 100644 host_applications/linux/apps/hello_pi/hello_wayland/triangle.c
|
|||
|
|
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/CMakeLists.txt b/host_applications/linux/apps/hello_pi/CMakeLists.txt
|
|||
|
|
index b28a94a..2849fad 100644
|
|||
|
|
--- a/host_applications/linux/apps/hello_pi/CMakeLists.txt
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/CMakeLists.txt
|
|||
|
|
@@ -25,6 +25,7 @@ add_subdirectory(hello_encode)
|
|||
|
|
add_subdirectory(hello_jpeg)
|
|||
|
|
add_subdirectory(hello_videocube)
|
|||
|
|
add_subdirectory(hello_teapot)
|
|||
|
|
+add_subdirectory(hello_wayland)
|
|||
|
|
|
|||
|
|
if(BUILD_FONT)
|
|||
|
|
set(VGFONT_SRCS libs/vgfont/font.c libs/vgfont/vgft.c libs/vgfont/graphics.c)
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/Makefile b/host_applications/linux/apps/hello_pi/Makefile
|
|||
|
|
index 4c2b2ef..d2b2555 100644
|
|||
|
|
--- a/host_applications/linux/apps/hello_pi/Makefile
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/Makefile
|
|||
|
|
@@ -24,6 +24,7 @@ apps: libs/ilclient/libilclient.a libs/vgfont/libvgfont.a libs/revision/librevis
|
|||
|
|
$(MAKE) -C hello_teapot
|
|||
|
|
$(MAKE) -C hello_fft
|
|||
|
|
$(MAKE) -C hello_mmal_encode
|
|||
|
|
+ $(MAKE) -C hello_wayland
|
|||
|
|
|
|||
|
|
clean:
|
|||
|
|
$(MAKE) -C libs/ilclient clean
|
|||
|
|
@@ -43,4 +44,5 @@ clean:
|
|||
|
|
$(MAKE) -C hello_teapot clean
|
|||
|
|
$(MAKE) -C hello_fft clean
|
|||
|
|
$(MAKE) -C hello_mmal_encode clean
|
|||
|
|
+ $(MAKE) -C hello_wayland clean
|
|||
|
|
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/hello_wayland/CMakeLists.txt b/host_applications/linux/apps/hello_pi/hello_wayland/CMakeLists.txt
|
|||
|
|
new file mode 100644
|
|||
|
|
index 0000000..9a2f75c
|
|||
|
|
--- /dev/null
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/hello_wayland/CMakeLists.txt
|
|||
|
|
@@ -0,0 +1,8 @@
|
|||
|
|
+set(EXEC hello_wayland.bin)
|
|||
|
|
+set(SRCS triangle.c)
|
|||
|
|
+
|
|||
|
|
+add_executable(${EXEC} ${SRCS})
|
|||
|
|
+target_link_libraries(${EXEC} ${HELLO_PI_LIBS} -lwayland-client -lwayland-egl)
|
|||
|
|
+
|
|||
|
|
+install(TARGETS ${EXEC}
|
|||
|
|
+ RUNTIME DESTINATION bin)
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/hello_wayland/Djenne_128_128.raw b/host_applications/linux/apps/hello_pi/hello_wayland/Djenne_128_128.raw
|
|||
|
|
new file mode 100644
|
|||
|
|
index 0000000..de9173c
|
|||
|
|
--- /dev/null
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/hello_wayland/Djenne_128_128.raw
|
|||
|
|
@@ -0,0 +1,3 @@
|
|||
|
|
+�雛彑�潜愾毖丁效毖丁效喆濁拌喆濁拌喆濁拌喆濁拌荿茸拌荿茸拌櫢霜愾櫢霜愾�杉彑咩煽愾櫢霜愾櫢霜愾咩煎彑咩煎彑�蒸嵜咩煎彑�穣嫋�穣嫋�穣嫋�穣嫋�穣嫋�叙埆�穣嫋�穣嫋�呪埆�助喙�飼匯�飼匯�窄从�窄从�窄从�窄从�候儿�侯亳鯲虞老麩剣儿駘挙老麩倦裕鯲具裕駘拒裕駘拒裕靆基夢靆器乏鑠鰹乏酲猿鳳酲猿鳳酲猿鳳酲燕憤鑛逸憤酩�逼軾�猫貲㈹猫詁�頭詁�笛蠹�笛詁�頭菽�暢蘢�辿菽�辿菽�即喆諾效毖兆枋飯糖榲飯糖榲菶訂枋菶訂枋菶訂枋菶訂枋�蹄枋�蹄枋�蹄枋�蹄枋顗凋效顗凋效顗凋效顗凋效顗凋效顗凋效荿茸拌荿茸拌櫢霜愾櫢霜愾咩煎彑咩煎彑櫢鎗彑咩煎彑�据嵜�据嵜�据嵜�雛嫋�穣嫋�穣嫋�序喀�序喀�寿匱�寿匱�索啝�似啝�獄匣�策匣�候儿�鵠亳�侯亳�佼老�佼老麩兼老麩健龍鯲愚龍駑奇隆駑奇隆駑奇隆靈叶由鰺椛眠駝会眠靄縁憤鑛逸憤酩�逼酩�溌酩�溌軾�猫貲㍾溌軾�猫詁�頭蠹�笛菶訂枋菶訂枋飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲菶訂枋菶訂枋�蹄枋顗凋效顗凋效顗凋效顗凋效顗凋效顗凋效荿諾愾荿茸拌荿茸拌櫢霜愾櫢霜愾櫢霜愾咩煎彑�据嵜�据嵜�杉彑�雛嫋�穣嫋�穣嫋�序喀�序喀�寿匱�寿匱�索啝�事匣�策匣�策匣�黒儿�黒儿�黒儿�侯亳�侯亳�佼老麩兼老鯲愚龍駑奇隆駑奇隆駑奇隆靈叶由鰺椛眠駝会眠靄艶鳳鑛逸憤鑛溢逼酩�逼鑛溢逼軾�猫貲㈹猫貲㈲頭貲㈲頭詁�頭飯糖榲飯糖榲�乳歹�乳歹飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲菶訂枋菶訂枋顗喋枋�蹄枋顗凋效顗凋效顗凋效顗凋效荿茸拌荿茸拌荿茸拌荿茸拌櫢霜愾櫢霜愾櫢霜愾咩煎彑咩煎彑咩煎彑�杉彑�雛嫋�穣嫋�穣嫋�序喀�序喀�寿匱�寿匱�索啝�事匣�似啝�策匣�鵠亳�獄匣�黒儿�侯亳�鵠亳�侯亳麩兼老麩健龍鯱拠狼鯱拠狼駑奇隆靈叶由鰺椛眠駝会眠靄艶鳳靄縁憤鑛逸憤酩�逼酩�逼酩�逼軾�逼酩�溌貲㈹猫詁�頭葈糖歹�莫歹飼日歹飼日歹葈筒榲葈筒榲葈筒榲葈筒榲菶訂枋菶訂枋飯糖榲飯糖榲菶訂枋菶訂枋毖兆枋菶訂枋�喋枌�喋枌顗凧畋顗凧畋顗凋效顗凋效荿茸拌荿茸拌櫢煽慇櫢煎弯�恕慇櫢煎弯�据嵜�雛嫋�譲彑咩洗埔�授埃咜恕崗�腰埃咜徐媾�似啝�似啝�策匣�策匣�黒儿�黒儿�黒儿�黒儿�黒儿�黒儿�侯亳麩兼老麸愚狼鯱拠狼駑奇隆靈叶由駝会眠駝会眠駝会眠靄艶鳳靄艶鳳靄縁憤鑛溢逼酩�逼鑛溢逼酩�逼貲㈹猫貲㈲頭葈糖歹�駁淒飼日歹飼日歹葈筒榲葈筒榲葈筒榲葈筒榲飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲飯糖榲菶訂枋飯筒枋�喋枌�喋枌�喋枌�喋枌�蹄枋�蹄枋顗凋效顗凋效顗凧畋顗茸拜櫢煽慇櫢煎弯咩煎彑咩潜嵜咩煎彑咩染嫂橳醸崗茁菅弯�樹媾咜序埃咜徐媾咜徐媾�授埃�授埃�似啝�似啝�似啝�似啝�黒儿�黒儿�鵠亳�侯亳麸虞亢麸愚狼麸虞亢鯱拠狼麥寄隆麥寄隆鰺椛眠駝会眠駝会眠靄艶鳳靄縁憤鑛逸憤鑛逸憤酩�逼酩�逼酩�溌飼乳淒�駁淒�駁淒�駁淒飼日歹飼日歹飼日歹飼日歹飼日歹飼日歹葈筒榲葈筒榲�乳歹�乳歹菶諦榲飯糖榲�逓楪�逓楪�喋枌�喋枌�蹄枋�蹄枋�蹄枋�蹄枋顗凧畋顗茸拜顗茸拜荿霜慇荿茸拌櫢霜愾櫢霜愾咩煎彑茁菅弯茁菅弯茁椙崗咜徐媾咜徐媾咜徐媾�授埃�授埃�授埃�授埃�似啝�似啝�似啝�似啝�策匣�黒儿�侯儼�券儼麸虞亢鯱拠狼�喰狼�渠狼麥寄隆鰺樺由鰺樺由鰺椛眠駝会眠靄艶鳳靄艶鳳靄縁憤鑛逸憤酩�溌飼乳淒�眉淒�駁淒�駁淒�駁淒�駁淒�駁淒�駁淒飼日歹飼日歹飼日歹飼日歹�乳歹�乳歹飯統歹�日榲�歸�歸�歸�歸�逓楪�逓楪�到榲�到榲�蹄枋�蹄枋�蹄枌�喋枌顗茸拜荿増枌顗凋效顗兆拌顗兆拌櫢騒拌�穿慇靑旋弯靑煽崗橳錠弯橳醸崗橳醸崗咜徐媾咜徐媾咜徐媾咜徐媾�授埃�授埃�授埃�授埃�似啝�策匣�黒匕�候匕�券儼�兼亢�空亢�挙隆�渠狼麥寄隆麥寄隆麥嬉由鰺樺由鰺椛眠駝会眠駝介鳳靄苑眠靄縁憤�駁淒�駁淒飼日歹飼日歹�駁淒�駁淒飼乳淒�駁淒�麦淒�麦淒�麦淒�麦淒�駁淒�駁淒飼日歹飼日歹�乳歹�乳歹飯糖榲飯糖榲葈凧歡飼訂榁葈兆榁葈兆榁�蛸楝�蛸楝�蛸楝�蛸楝顗凧畋顗凧畋顗凧畋顗凧畋櫤椙擔櫤椙擔櫤椙擔櫤杉愍櫢霜愾櫢霜愾�据嵜�据嵜�穣媾�女媾�女媾�女媾�寿媾�受啝�歯啝�飼匣麪鵠匣麪穀亳麪穀亳鯰交亳�佼老麩兼老�侯亳�侯亳駭倦老駭倹龍靂駒龍鑞居裕靈叶由靈鰹眠鑢駕眠酲猿鳳�美瀏�美瀏�美瀏�美瀏�美瀏�美瀏�駁淒�眉淒�駁淒�駁淒�駁淒�駁淒�駁淒�駁淒�駁淒�駁淒�乳歹�乳歹飯糖榲飯糖榲葈凋歡飼諦歡飼諦歡飼諦歡�寵歟�寵歟�蛸楝�蛸楝�喋枌�喋枌�喋枌�喋枌顥像杼顥像杼�蛸楝顥像楞櫢霜愾櫢霜愾櫢霜愾櫢霜愾櫢煽慇咩杉弯�蒸崗�蒸崗�序崗�叙埃�穣媾�叙埃�呪埃�飼匣�歯啝�柵匣�窄儿�黒儿麩兼老麩兼老駭倦老靂駒龍駭倹龍靂駒龍鯱拠狼鯱拒隆駑奇隆靈叶由�美瀏�美瀏�美瀏�美瀏�美瀏�美瀏�美瀏�猊�眉淒�駁淒�駁淒�駁淒�駁淒�駁淒�莫歹飼日歹飼入淒�麦淒�駁歹�乳歹�日歡�統淌飼蹄淌�統淌�統淌�統淌�糖歡飼諦歡飼訂榁葈兆榁葈兆榁葈兆榁葈兆榁葈兆榁葈兆榁葈兆榁葈丁效毖丁效毖貯拌喆濁拌喆鐸收�潜拈�染�
|
|||
|
|
+bepSaiYfnYfn[hpWdlZgo\iq]iqYhrWfoYhq[ktUdm[jsZir[js[jr]ktZjrZirZir[js[js]lu\fo^hr]ir_kw^jv\kv\iwYftWgsQamO_kRbnM]iM]iM]iN^jgsy=IQDOY:HT6FS4IX/HX〆����BWc6JU8JU:LW7IT6KV4IS0<M8DR0@M7FS8HT(9ANah���t��Ws�OhzNdsL`lr����������z��{���Ν�揃鍍�サk��[q�AXhF\fO`gI[a@RX%7>&;B(9A)<C-@G5HO7JP?QX@RYBRZ<QX1@Ks���固�各k��Tl�酉���5NZ<LX@ITAISALR>KR9LM@MVAITHQ^1CO火��澗`}�BWj@QaNbmYjsYhm]gmbjr���41@gu|gt|cpxanvcpxamvZkqSdkZhpWfn[irZhq]ktXiqWhq[ltZlxYlvaq}`p|^o{ao{_ny^lxem{fm{amxbl{_hv\huZeuR]nL_lL_lL_lL_lJ^kI\iG[hFYgOjp2IN;LU8FR6FS3HW/JZ��v��>V\8MU3HP7IT4ER1AN1AN18;MX]ozey�k��j}�h~�PfsE]iG\gJ[eO_l^n~�������す�����さ�術�吃�����r��w��OfvI`pG^n{����ィ����音�┻���������・�����Σ�^δ勸累�歳�����Ur�袴�v��Gam>LT?HPESXAQWHV[HSY[ggO^cZp{d~���嫁d�@Yi7R^FakXkr`pyv��,1>kp~3YhpWgo\gr_ls]jqanu_ltbntWkyWkx[o{Xmx[ny^p{]oz\nz[nx^nz`p|aq}dqdqer�er�crz^nz[jvVgsPcrL`rKcsNfvOeqNepRerWguVfrUeqZgtWfoPjp;PV5HO;KW@P]2ET�荏�塞Yqw:PU6KS4IQ:LW5FSN^kbr~t��\nyRdoL`kM`mK^k>T`>T`4LX=S_\lyZkx>Raax����t��� ̄ャ������Ш���w��w��h~�\s�Yq�~������������\t�������┷�袷�Ⅸ���蛎�呼α��監��ゼt��y��宋�Σ<VbCR^ET\K[d>SZFXcQ]jK\aN`jXq�遮��栽�┝i��CZi=Vb9P[Ymt`kuYclX`mt{�06Ebs�_o|_o{_o{`nz^lxao{_lx[kxUfsTenTenSdmTfoTfoZirZjv]mxYiuScpScpYiuZhxVduTfpXhtUhuSfuSftRgxThyThzRhtPcpPdqSepXhuZjv\ktXgp\v|=T[3EP5DQ8HUL`l��p��G]b7LT5JR6GS9KV8IV8HU:IY7JT9KV>P[<P[ATb5HU9P[8OZ7M]9OZ粧�RboBVe9QaRl}���s」y�����������さ��y��n��n��Wp�t��y�����ザ�げ9JWl���ザ����管������竿�吃�嫁����Юs���Ю�桂�╋<Vd>MZ\myy������こ�安�古�屮置夷��砧���^t�DYh=T`9MXWhqbnxCLWHS\DMZ%,;as�^o|]n{Zkx_p}YjwQboYjx]jq]jr^ksbowiv~dqybowhu|ev�jz�jz�fw�`o�[m|TixPetPfuOfuQetNbsOctRduPbsM_qOcnPdoUfr_q}XiqRclRakQ`i^w�CYd/DN6HR8IV6GTl�H^j>QY9LT5IP6IT5FS8IU8HY:JZ7JT;MW8JU9LY6IV7JV7L[7L[4N]:Q`��@S`BUb=Ra7Qas��x�|��o�����x�����}��k��y��d}�h��[v�|��t���┿��DP`AUf������せ|��������曲�緩��だ{��z���Ь�そu��B\l?Q`Pdu�袷�叡�暇�����蕉�礒呑�戸t��]q�GVg<P]GYdTcl\iq`ksLU`8DNco|_itdoygr|hs}lt�eq~hu�iv�lu|nx~jt{ku}r}�v��r|�oyap�[jzSbrM`oK_pKbrIbrHaqGbrF_oGaqKcsMasPctTduTdvPbmYkvfz�\mvPajL_fIZ`EU\VnzDZf=P]<MZ:LW4FQ>P[9KV7HQ6GP7GS2BN7HU7GW9IX5EU8JT:KX8IV3FS6IV;M]5JY4IX3K]E^n��Rhs7MY6K[<Sc<Scay�x��{��������{��p��f��~��a}�f��j��y��t���吉m��Uaq2FXs��z���ぜw����機系�せ�暇���{��y��������泳|��AXh:K])=N�袷}���永���Ю�訊��v��l��Ul~M`oK\iCVcDUc?NWeszgrzZem1=Gkx���{�x~�u{x��z��w~�ox�t~�s~�s}�o{�lw�it}anz[hsTctN`qM^oI\mI_pI`rGbrF`pD_oIasJ`rOcuQds]m~aq~dt�\mvZjtVgqN`gL_fIY`FV]BRX]t�@Wf8NY7JW9KV5ER7FO7FO<KS7EQ5FR7GU5EQ,<L2BR5EW5FS5FS3DQ3GS3FV5GV2HV5JY+DX=Ug��Pfv@Va6LX:LY7JZ8PcMex������y��z��k��q�o��i��]y�h��z��p」�����O_lAVf3I\^w����黍����仝����ーw����n�ォ畜�稽k��AVgGVe8K]t��v�������y��p��GauB[n>VfCYhBTbFWaBWg>Q^>OXiv~v��}��$/7S_h������z��{��v}�w��x��x�n}�mz�iy�]lxWgsN`oObpM^oNasJ_rI_qG_pG_sHbuJcwFbvPfxNdwShy[o~`q~eu�Yiu]luK\eJ]dHZaEX_FV\AQWAPWBRXI`pNeu9N^=P]<NY?NW=JR<FN2@M1?K2@L0AN#2B#3C-=N4DU7HU6GT4ER6IX7JY3FU/DU/CT3Kb�弧���D_l=Ua5LX2ER;LY7N^7M]Ibr{��w��n��q��n��x��q��h��f}�y��o��巾��2Zr|>T`?QbQ^u������~���㌢��々}��x��x��}�堪否��c{�IXgETd8KZUp~�¨e}�L^tCXjEYl=OaG[h@R]DUa=RZAV]8O`8N[=QY[gox��jt|":CMclsgsxis{lw�iw�`o{[kwZjvUhwQcrQftLcrG^pG_sG`sG^uF`pFaqHauIbvIcvKcyMe|Nf}Xi}[n~aq�ZkxXhu[luN`gK[bL\cFV]M\dGV\CSYDTZ=PS;NQLctAXh=Ra9KXCT^DQYEQXIRZDO[6CO-:F,9G$+;-<M1@R5ER6FS3DQ2FU4GV1DS1DU*=N.E\暇����Zu�<T`FYd9JU@O\0JV;S_=VgB]nw�s��p��u��y��l��d~�h��~���������UtyLbm@N^NTiz�����Ь�|���┥}��y�����影�按~��Shw@OaBM[?P]*FQ2O]9Qa<K\AP`>M^BM\ANZ<MU?RY=RZ<QW6Ra9R^@RYCRXq{tyqv|gkoVdoTdpTdoK]kM`qJ`rI]sD\qI`oF`oE]nF^rE`tD`y=]tFeDcuHcwJexKg{Tl�Um�Un�Vo�lw�]i}_nWguM^hEW^GW]DUWDS[HX_>NTCTYCSYASU;OR@SVf��D_h6P\6P\5O[>YgB]kHcqTjtATaq�����o~�y�����t��r�������������x���`��E撻置��Vm|BXdATa?Rb8KZ>TXBZcF\i?ZjF`tk��p��m��w��s��j��g��}���㌢�吉�┝���7MY=P_.BSx�����せ�せ�B��y��{������映���d��FX^>QY@R]=OZ7HU=NZ9IY;K[;J[<MZ9JW:KX=N[<NY;MX<MX4IY3K[5M`/J[Gcx>ZoA]rB^q9Xr>Yt>XqBZsF^tBZqC[qF`sM_tK_tG_rB_tFcwFbzMgSi�Nk�Yt�Lg}^y�Wq�Wo~WlxLanHfkQjoEX_IY`IU]GW^ASZBT[=VV?TV>NTDOWEPXDOUCQT>OR_x�Piu7Q]4N\5O]:TbE^nOhx����げ���������������尭�����������������紘�鈎�奏�嘉���Vm|F\gI[h@Rb;N]DXXCV[K^fNaoVi|F`pv。}��|��z��o��q
|
|||
|
|
+!" &'%&$$/(%$OD=k��y…�詠�ぢ��������������仨���歌{/���と{��r��o������g��|―������w��E\dCV]7FT>K[9FM3CP*<M$<R�果������㌧�Ю���仝�����{��|��s��r��m��k��>Ym=Yj:Te8Rc6Pb1KQ/FO9IR>KX����Ⅵ}��^x�[v�f}�Oct:L]BQbAN\;GSDMW;MV5GO1AM5EQ5EQ5ER9IV3BO1BO/@M3DQ/@L3CS/?O0@P2BR0@P0@P2BR3CS0@P1AQ1AQ1AQ,9I0=M1>N'4D+5F1;L'1B'1C"-;!*7$.$*&+/&*+"'((,-".+%-,#"%$#!!,+'/+*=98%-&
|
|||
|
|
\ No newline at end of file
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/hello_wayland/Makefile b/host_applications/linux/apps/hello_pi/hello_wayland/Makefile
|
|||
|
|
new file mode 100644
|
|||
|
|
index 0000000..c9ddf23
|
|||
|
|
--- /dev/null
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/hello_wayland/Makefile
|
|||
|
|
@@ -0,0 +1,5 @@
|
|||
|
|
+OBJS=triangle.o
|
|||
|
|
+BIN=hello_wayland.bin
|
|||
|
|
+LDFLAGS+=-lwayland-client -lwayland-egl
|
|||
|
|
+
|
|||
|
|
+include ../Makefile.include
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/hello_wayland/cube_texture_and_coords.h b/host_applications/linux/apps/hello_pi/hello_wayland/cube_texture_and_coords.h
|
|||
|
|
new file mode 100644
|
|||
|
|
index 0000000..663e23b
|
|||
|
|
--- /dev/null
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/hello_wayland/cube_texture_and_coords.h
|
|||
|
|
@@ -0,0 +1,100 @@
|
|||
|
|
+/*
|
|||
|
|
+Copyright (c) 2012, Broadcom Europe Ltd
|
|||
|
|
+All rights reserved.
|
|||
|
|
+
|
|||
|
|
+Redistribution and use in source and binary forms, with or without
|
|||
|
|
+modification, are permitted provided that the following conditions are met:
|
|||
|
|
+ * Redistributions of source code must retain the above copyright
|
|||
|
|
+ notice, this list of conditions and the following disclaimer.
|
|||
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|||
|
|
+ notice, this list of conditions and the following disclaimer in the
|
|||
|
|
+ documentation and/or other materials provided with the distribution.
|
|||
|
|
+ * Neither the name of the copyright holder nor the
|
|||
|
|
+ names of its contributors may be used to endorse or promote products
|
|||
|
|
+ derived from this software without specific prior written permission.
|
|||
|
|
+
|
|||
|
|
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
|
|
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|||
|
|
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|||
|
|
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
|||
|
|
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|||
|
|
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|||
|
|
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|||
|
|
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
|
|
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|||
|
|
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|
+*/
|
|||
|
|
+
|
|||
|
|
+// Spatial coordinates for the cube
|
|||
|
|
+
|
|||
|
|
+static const GLbyte quadx[6*4*3] = {
|
|||
|
|
+ /* FRONT */
|
|||
|
|
+ -10, -10, 10,
|
|||
|
|
+ 10, -10, 10,
|
|||
|
|
+ -10, 10, 10,
|
|||
|
|
+ 10, 10, 10,
|
|||
|
|
+
|
|||
|
|
+ /* BACK */
|
|||
|
|
+ -10, -10, -10,
|
|||
|
|
+ -10, 10, -10,
|
|||
|
|
+ 10, -10, -10,
|
|||
|
|
+ 10, 10, -10,
|
|||
|
|
+
|
|||
|
|
+ /* LEFT */
|
|||
|
|
+ -10, -10, 10,
|
|||
|
|
+ -10, 10, 10,
|
|||
|
|
+ -10, -10, -10,
|
|||
|
|
+ -10, 10, -10,
|
|||
|
|
+
|
|||
|
|
+ /* RIGHT */
|
|||
|
|
+ 10, -10, -10,
|
|||
|
|
+ 10, 10, -10,
|
|||
|
|
+ 10, -10, 10,
|
|||
|
|
+ 10, 10, 10,
|
|||
|
|
+
|
|||
|
|
+ /* TOP */
|
|||
|
|
+ -10, 10, 10,
|
|||
|
|
+ 10, 10, 10,
|
|||
|
|
+ -10, 10, -10,
|
|||
|
|
+ 10, 10, -10,
|
|||
|
|
+
|
|||
|
|
+ /* BOTTOM */
|
|||
|
|
+ -10, -10, 10,
|
|||
|
|
+ -10, -10, -10,
|
|||
|
|
+ 10, -10, 10,
|
|||
|
|
+ 10, -10, -10,
|
|||
|
|
+};
|
|||
|
|
+
|
|||
|
|
+/** Texture coordinates for the quad. */
|
|||
|
|
+static const GLfloat texCoords[6 * 4 * 2] = {
|
|||
|
|
+ 0.f, 0.f,
|
|||
|
|
+ 1.f, 0.f,
|
|||
|
|
+ 0.f, 1.f,
|
|||
|
|
+ 1.f, 1.f,
|
|||
|
|
+
|
|||
|
|
+ 0.f, 0.f,
|
|||
|
|
+ 1.f, 0.f,
|
|||
|
|
+ 0.f, 1.f,
|
|||
|
|
+ 1.f, 1.f,
|
|||
|
|
+
|
|||
|
|
+ 0.f, 0.f,
|
|||
|
|
+ 1.f, 0.f,
|
|||
|
|
+ 0.f, 1.f,
|
|||
|
|
+ 1.f, 1.f,
|
|||
|
|
+
|
|||
|
|
+ 0.f, 0.f,
|
|||
|
|
+ 1.f, 0.f,
|
|||
|
|
+ 0.f, 1.f,
|
|||
|
|
+ 1.f, 1.f,
|
|||
|
|
+
|
|||
|
|
+ 0.f, 0.f,
|
|||
|
|
+ 1.f, 0.f,
|
|||
|
|
+ 0.f, 1.f,
|
|||
|
|
+ 1.f, 1.f,
|
|||
|
|
+
|
|||
|
|
+ 0.f, 0.f,
|
|||
|
|
+ 1.f, 0.f,
|
|||
|
|
+ 0.f, 1.f,
|
|||
|
|
+ 1.f, 1.f,
|
|||
|
|
+};
|
|||
|
|
+
|
|||
|
|
diff --git a/host_applications/linux/apps/hello_pi/hello_wayland/triangle.c b/host_applications/linux/apps/hello_pi/hello_wayland/triangle.c
|
|||
|
|
new file mode 100644
|
|||
|
|
index 0000000..1a7bfc4
|
|||
|
|
--- /dev/null
|
|||
|
|
+++ b/host_applications/linux/apps/hello_pi/hello_wayland/triangle.c
|
|||
|
|
@@ -0,0 +1,666 @@
|
|||
|
|
+/*
|
|||
|
|
+Copyright (c) 2012, Broadcom Europe Ltd
|
|||
|
|
+All rights reserved.
|
|||
|
|
+
|
|||
|
|
+Redistribution and use in source and binary forms, with or without
|
|||
|
|
+modification, are permitted provided that the following conditions are met:
|
|||
|
|
+ * Redistributions of source code must retain the above copyright
|
|||
|
|
+ notice, this list of conditions and the following disclaimer.
|
|||
|
|
+ * Redistributions in binary form must reproduce the above copyright
|
|||
|
|
+ notice, this list of conditions and the following disclaimer in the
|
|||
|
|
+ documentation and/or other materials provided with the distribution.
|
|||
|
|
+ * Neither the name of the copyright holder nor the
|
|||
|
|
+ names of its contributors may be used to endorse or promote products
|
|||
|
|
+ derived from this software without specific prior written permission.
|
|||
|
|
+
|
|||
|
|
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|||
|
|
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|||
|
|
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|||
|
|
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
|||
|
|
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|||
|
|
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|||
|
|
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|||
|
|
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
|
|
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|||
|
|
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|
+*/
|
|||
|
|
+
|
|||
|
|
+// A rotating cube rendered with OpenGL|ES. Three images used as textures on the cube faces.
|
|||
|
|
+
|
|||
|
|
+#define _GNU_SOURCE
|
|||
|
|
+
|
|||
|
|
+#include <stdio.h>
|
|||
|
|
+#include <stdlib.h>
|
|||
|
|
+#include <string.h>
|
|||
|
|
+#include <math.h>
|
|||
|
|
+#include <assert.h>
|
|||
|
|
+#include <unistd.h>
|
|||
|
|
+#include <sys/socket.h>
|
|||
|
|
+#include <sys/un.h>
|
|||
|
|
+
|
|||
|
|
+#include <wayland-egl.h>
|
|||
|
|
+#include <wayland-client.h>
|
|||
|
|
+
|
|||
|
|
+#include "GLES/gl.h"
|
|||
|
|
+#include "EGL/egl.h"
|
|||
|
|
+#include "EGL/eglext.h"
|
|||
|
|
+
|
|||
|
|
+#include "cube_texture_and_coords.h"
|
|||
|
|
+
|
|||
|
|
+#define PATH "./"
|
|||
|
|
+
|
|||
|
|
+#define IMAGE_SIZE 128
|
|||
|
|
+
|
|||
|
|
+#ifndef M_PI
|
|||
|
|
+ #define M_PI 3.141592654
|
|||
|
|
+#endif
|
|||
|
|
+
|
|||
|
|
+
|
|||
|
|
+typedef struct
|
|||
|
|
+{
|
|||
|
|
+ uint32_t screen_width;
|
|||
|
|
+ uint32_t screen_height;
|
|||
|
|
+// OpenGL|ES objects
|
|||
|
|
+ EGLDisplay display;
|
|||
|
|
+ EGLSurface surface;
|
|||
|
|
+ EGLContext context;
|
|||
|
|
+ GLuint tex[6];
|
|||
|
|
+// model rotation vector and direction
|
|||
|
|
+ GLfloat rot_angle_x_inc;
|
|||
|
|
+ GLfloat rot_angle_y_inc;
|
|||
|
|
+ GLfloat rot_angle_z_inc;
|
|||
|
|
+// current model rotation angles
|
|||
|
|
+ GLfloat rot_angle_x;
|
|||
|
|
+ GLfloat rot_angle_y;
|
|||
|
|
+ GLfloat rot_angle_z;
|
|||
|
|
+// current distance from camera
|
|||
|
|
+ GLfloat distance;
|
|||
|
|
+ GLfloat distance_inc;
|
|||
|
|
+// pointers to texture buffers
|
|||
|
|
+ char *tex_buf1;
|
|||
|
|
+ char *tex_buf2;
|
|||
|
|
+ char *tex_buf3;
|
|||
|
|
+ struct wl_display *wl_display;
|
|||
|
|
+ struct wl_registry *wl_registry;
|
|||
|
|
+ struct wl_shell *wl_shell;
|
|||
|
|
+ struct wl_shell_surface *wl_shell_surface;
|
|||
|
|
+ struct wl_compositor *wl_compositor;
|
|||
|
|
+ struct wl_surface *wl_surface;
|
|||
|
|
+ struct wl_callback *wl_callback;
|
|||
|
|
+ struct wl_egl_window *wl_egl_window;
|
|||
|
|
+ int needs_update;
|
|||
|
|
+ int ellapsed_frames;
|
|||
|
|
+ int kill_compositor;
|
|||
|
|
+ int single_frame;
|
|||
|
|
+ int terminate_abruptly;
|
|||
|
|
+} CUBE_STATE_T;
|
|||
|
|
+
|
|||
|
|
+static void init_ogl(CUBE_STATE_T *state);
|
|||
|
|
+static void init_model_proj(CUBE_STATE_T *state);
|
|||
|
|
+static void reset_model(CUBE_STATE_T *state);
|
|||
|
|
+static GLfloat inc_and_wrap_angle(GLfloat angle, GLfloat angle_inc);
|
|||
|
|
+static GLfloat inc_and_clip_distance(GLfloat distance, GLfloat distance_inc);
|
|||
|
|
+static void redraw_scene(CUBE_STATE_T *state);
|
|||
|
|
+static void update_model(CUBE_STATE_T *state);
|
|||
|
|
+static void init_textures(CUBE_STATE_T *state);
|
|||
|
|
+static void load_tex_images(CUBE_STATE_T *state);
|
|||
|
|
+static void exit_func(CUBE_STATE_T *state);
|
|||
|
|
+
|
|||
|
|
+static void
|
|||
|
|
+registry_handle_global(void *data, struct wl_registry *registry,
|
|||
|
|
+ uint32_t name, const char *interface, uint32_t version)
|
|||
|
|
+{
|
|||
|
|
+ CUBE_STATE_T *state = data;
|
|||
|
|
+
|
|||
|
|
+ if (strcmp(interface, "wl_compositor") == 0) {
|
|||
|
|
+ state->wl_compositor =
|
|||
|
|
+ wl_registry_bind(registry, name,
|
|||
|
|
+ &wl_compositor_interface, 1);
|
|||
|
|
+ } else if (strcmp(interface, "wl_shell") == 0) {
|
|||
|
|
+ state->wl_shell = wl_registry_bind(registry, name,
|
|||
|
|
+ &wl_shell_interface, 1);
|
|||
|
|
+ }
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+static void
|
|||
|
|
+registry_handle_global_remove(void *data, struct wl_registry *registry,
|
|||
|
|
+ uint32_t name)
|
|||
|
|
+{
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+static const struct wl_registry_listener registry_listener = {
|
|||
|
|
+ registry_handle_global,
|
|||
|
|
+ registry_handle_global_remove
|
|||
|
|
+};
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: init_ogl
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * CUBE_STATE_T *state - holds OGLES model info
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Sets the display, OpenGL|ES context and screen stuff
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void init_ogl(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ EGLBoolean result;
|
|||
|
|
+ EGLint num_config;
|
|||
|
|
+
|
|||
|
|
+ static const EGLint attribute_list[] =
|
|||
|
|
+ {
|
|||
|
|
+ EGL_RED_SIZE, 8,
|
|||
|
|
+ EGL_GREEN_SIZE, 8,
|
|||
|
|
+ EGL_BLUE_SIZE, 8,
|
|||
|
|
+ EGL_ALPHA_SIZE, 8,
|
|||
|
|
+ EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
|
|||
|
|
+ EGL_NONE
|
|||
|
|
+ };
|
|||
|
|
+
|
|||
|
|
+ EGLConfig config;
|
|||
|
|
+
|
|||
|
|
+ state->wl_display = wl_display_connect(NULL);
|
|||
|
|
+
|
|||
|
|
+ state->wl_registry = wl_display_get_registry(state->wl_display);
|
|||
|
|
+ wl_registry_add_listener(state->wl_registry, ®istry_listener, state);
|
|||
|
|
+
|
|||
|
|
+ wl_display_dispatch(state->wl_display);
|
|||
|
|
+
|
|||
|
|
+ // get an EGL display connection
|
|||
|
|
+ state->display = eglGetDisplay(state->wl_display);
|
|||
|
|
+ assert(state->display!=EGL_NO_DISPLAY);
|
|||
|
|
+
|
|||
|
|
+ // initialize the EGL display connection
|
|||
|
|
+ result = eglInitialize(state->display, NULL, NULL);
|
|||
|
|
+ assert(EGL_FALSE != result);
|
|||
|
|
+
|
|||
|
|
+ // get an appropriate EGL frame buffer configuration
|
|||
|
|
+ result = eglChooseConfig(state->display, attribute_list, &config, 1, &num_config);
|
|||
|
|
+ assert(EGL_FALSE != result);
|
|||
|
|
+
|
|||
|
|
+ // create an EGL rendering context
|
|||
|
|
+ state->context = eglCreateContext(state->display, config, EGL_NO_CONTEXT, NULL);
|
|||
|
|
+ assert(state->context!=EGL_NO_CONTEXT);
|
|||
|
|
+
|
|||
|
|
+ // create an EGL window surface
|
|||
|
|
+ state->screen_width = 1024;
|
|||
|
|
+ state->screen_height = 860;
|
|||
|
|
+
|
|||
|
|
+ state->wl_surface = wl_compositor_create_surface(state->wl_compositor);
|
|||
|
|
+ state->wl_shell_surface = wl_shell_get_shell_surface(state->wl_shell, state->wl_surface);
|
|||
|
|
+
|
|||
|
|
+ wl_shell_surface_set_toplevel(state->wl_shell_surface);
|
|||
|
|
+ wl_shell_surface_set_title(state->wl_shell_surface, "triangle.c");
|
|||
|
|
+
|
|||
|
|
+ state->wl_egl_window = wl_egl_window_create(state->wl_surface, state->screen_width, state->screen_height);
|
|||
|
|
+
|
|||
|
|
+ state->surface = eglCreateWindowSurface( state->display, config, state->wl_egl_window, NULL );
|
|||
|
|
+ assert(state->surface != EGL_NO_SURFACE);
|
|||
|
|
+
|
|||
|
|
+ // connect the context to the surface
|
|||
|
|
+ result = eglMakeCurrent(state->display, state->surface, state->surface, state->context);
|
|||
|
|
+ assert(EGL_FALSE != result);
|
|||
|
|
+
|
|||
|
|
+ // Set background color and clear buffers
|
|||
|
|
+ glClearColor(0.15f, 0.25f, 0.35f, 1.0f);
|
|||
|
|
+
|
|||
|
|
+ // Enable back face culling.
|
|||
|
|
+ glEnable(GL_CULL_FACE);
|
|||
|
|
+
|
|||
|
|
+ glMatrixMode(GL_MODELVIEW);
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: init_model_proj
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * CUBE_STATE_T *state - holds OGLES model info
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Sets the OpenGL|ES model to default values
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void init_model_proj(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ float nearp = 1.0f;
|
|||
|
|
+ float farp = 500.0f;
|
|||
|
|
+ float hht;
|
|||
|
|
+ float hwd;
|
|||
|
|
+
|
|||
|
|
+ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );
|
|||
|
|
+
|
|||
|
|
+ glViewport(0, 0, (GLsizei)state->screen_width, (GLsizei)state->screen_height);
|
|||
|
|
+
|
|||
|
|
+ glMatrixMode(GL_PROJECTION);
|
|||
|
|
+ glLoadIdentity();
|
|||
|
|
+
|
|||
|
|
+ hht = nearp * (float)tan(45.0 / 2.0 / 180.0 * M_PI);
|
|||
|
|
+ hwd = hht * (float)state->screen_width / (float)state->screen_height;
|
|||
|
|
+
|
|||
|
|
+ glFrustumf(-hwd, hwd, -hht, hht, nearp, farp);
|
|||
|
|
+
|
|||
|
|
+ glEnableClientState( GL_VERTEX_ARRAY );
|
|||
|
|
+ glVertexPointer( 3, GL_BYTE, 0, quadx );
|
|||
|
|
+
|
|||
|
|
+ reset_model(state);
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: reset_model
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * CUBE_STATE_T *state - holds OGLES model info
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Resets the Model projection and rotation direction
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void reset_model(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ // reset model position
|
|||
|
|
+ glMatrixMode(GL_MODELVIEW);
|
|||
|
|
+ glLoadIdentity();
|
|||
|
|
+ glTranslatef(0.f, 0.f, -50.f);
|
|||
|
|
+
|
|||
|
|
+ // reset model rotation
|
|||
|
|
+ state->rot_angle_x = 45.f; state->rot_angle_y = 30.f; state->rot_angle_z = 0.f;
|
|||
|
|
+ state->rot_angle_x_inc = 0.5f; state->rot_angle_y_inc = 0.5f; state->rot_angle_z_inc = 0.f;
|
|||
|
|
+ state->distance = 40.f;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: update_model
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * CUBE_STATE_T *state - holds OGLES model info
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Updates model projection to current position/rotation
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void update_model(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ // update position
|
|||
|
|
+ state->rot_angle_x = inc_and_wrap_angle(state->rot_angle_x, state->rot_angle_x_inc);
|
|||
|
|
+ state->rot_angle_y = inc_and_wrap_angle(state->rot_angle_y, state->rot_angle_y_inc);
|
|||
|
|
+ state->rot_angle_z = inc_and_wrap_angle(state->rot_angle_z, state->rot_angle_z_inc);
|
|||
|
|
+ state->distance = inc_and_clip_distance(state->distance, state->distance_inc);
|
|||
|
|
+
|
|||
|
|
+ glLoadIdentity();
|
|||
|
|
+ // move camera back to see the cube
|
|||
|
|
+ glTranslatef(0.f, 0.f, -state->distance);
|
|||
|
|
+
|
|||
|
|
+ // Rotate model to new position
|
|||
|
|
+ glRotatef(state->rot_angle_x, 1.f, 0.f, 0.f);
|
|||
|
|
+ glRotatef(state->rot_angle_y, 0.f, 1.f, 0.f);
|
|||
|
|
+ glRotatef(state->rot_angle_z, 0.f, 0.f, 1.f);
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: inc_and_wrap_angle
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * GLfloat angle current angle
|
|||
|
|
+ * GLfloat angle_inc angle increment
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Increments or decrements angle by angle_inc degrees
|
|||
|
|
+ * Wraps to 0 at 360 deg.
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: new value of angle
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static GLfloat inc_and_wrap_angle(GLfloat angle, GLfloat angle_inc)
|
|||
|
|
+{
|
|||
|
|
+ angle += angle_inc;
|
|||
|
|
+
|
|||
|
|
+ if (angle >= 360.0)
|
|||
|
|
+ angle -= 360.f;
|
|||
|
|
+ else if (angle <=0)
|
|||
|
|
+ angle += 360.f;
|
|||
|
|
+
|
|||
|
|
+ return angle;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: inc_and_clip_distance
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * GLfloat distance current distance
|
|||
|
|
+ * GLfloat distance_inc distance increment
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Increments or decrements distance by distance_inc units
|
|||
|
|
+ * Clips to range
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: new value of angle
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static GLfloat inc_and_clip_distance(GLfloat distance, GLfloat distance_inc)
|
|||
|
|
+{
|
|||
|
|
+ distance += distance_inc;
|
|||
|
|
+
|
|||
|
|
+ if (distance >= 120.0f)
|
|||
|
|
+ distance = 120.f;
|
|||
|
|
+ else if (distance <= 40.0f)
|
|||
|
|
+ distance = 40.0f;
|
|||
|
|
+
|
|||
|
|
+ return distance;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+static pid_t get_server_pid(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ struct ucred ucred;
|
|||
|
|
+ socklen_t len;
|
|||
|
|
+ int fd;
|
|||
|
|
+
|
|||
|
|
+ fd = wl_display_get_fd(state->wl_display);
|
|||
|
|
+ len = sizeof ucred;
|
|||
|
|
+ getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &len);
|
|||
|
|
+
|
|||
|
|
+ return ucred.pid;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+static void
|
|||
|
|
+frame(void *data, struct wl_callback *callback, uint32_t time)
|
|||
|
|
+{
|
|||
|
|
+ CUBE_STATE_T *state = (CUBE_STATE_T *) data;
|
|||
|
|
+
|
|||
|
|
+ state->needs_update = 1;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+static const struct wl_callback_listener frame_listener = {
|
|||
|
|
+ frame
|
|||
|
|
+};
|
|||
|
|
+
|
|||
|
|
+static void
|
|||
|
|
+update(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ if (!state->single_frame || state->ellapsed_frames == 0) {
|
|||
|
|
+ update_model(state);
|
|||
|
|
+ redraw_scene(state);
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ state->wl_callback = wl_surface_frame(state->wl_surface);
|
|||
|
|
+ wl_callback_add_listener(state->wl_callback, &frame_listener, state);
|
|||
|
|
+
|
|||
|
|
+ if (state->ellapsed_frames == 100) {
|
|||
|
|
+ if (state->kill_compositor) {
|
|||
|
|
+ fprintf(stderr, "reached frame 100, killing compositor\n");
|
|||
|
|
+ pid_t pid = get_server_pid(state);
|
|||
|
|
+ kill(pid, SIGTERM);
|
|||
|
|
+ } else if (state->terminate_abruptly) {
|
|||
|
|
+ fprintf(stderr, "reached frame 100, terminating right away\n");
|
|||
|
|
+ exit_func(state);
|
|||
|
|
+ exit(0);
|
|||
|
|
+ }
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ if (!state->single_frame || state->ellapsed_frames == 0)
|
|||
|
|
+ eglSwapBuffers(state->display, state->surface);
|
|||
|
|
+ else {
|
|||
|
|
+ wl_surface_damage(state->wl_surface, 0, 0, state->screen_width,
|
|||
|
|
+ state->screen_height);
|
|||
|
|
+ wl_surface_commit(state->wl_surface);
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ state->ellapsed_frames++;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: redraw_scene
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * CUBE_STATE_T *state - holds OGLES model info
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Draws the model and calls eglSwapBuffers
|
|||
|
|
+ * to render to screen
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void redraw_scene(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ // Start with a clear screen
|
|||
|
|
+ glClear( GL_COLOR_BUFFER_BIT );
|
|||
|
|
+
|
|||
|
|
+ // Draw first (front) face:
|
|||
|
|
+ // Bind texture surface to current vertices
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[0]);
|
|||
|
|
+
|
|||
|
|
+ // Need to rotate textures - do this by rotating each cube face
|
|||
|
|
+ glRotatef(270.f, 0.f, 0.f, 1.f ); // front face normal along z axis
|
|||
|
|
+
|
|||
|
|
+ // draw first 4 vertices
|
|||
|
|
+ glDrawArrays( GL_TRIANGLE_STRIP, 0, 4);
|
|||
|
|
+
|
|||
|
|
+ // same pattern for other 5 faces - rotation chosen to make image orientation 'nice'
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[1]);
|
|||
|
|
+ glRotatef(90.f, 0.f, 0.f, 1.f ); // back face normal along z axis
|
|||
|
|
+ glDrawArrays( GL_TRIANGLE_STRIP, 4, 4);
|
|||
|
|
+
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[2]);
|
|||
|
|
+ glRotatef(90.f, 1.f, 0.f, 0.f ); // left face normal along x axis
|
|||
|
|
+ glDrawArrays( GL_TRIANGLE_STRIP, 8, 4);
|
|||
|
|
+
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[3]);
|
|||
|
|
+ glRotatef(90.f, 1.f, 0.f, 0.f ); // right face normal along x axis
|
|||
|
|
+ glDrawArrays( GL_TRIANGLE_STRIP, 12, 4);
|
|||
|
|
+
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[4]);
|
|||
|
|
+ glRotatef(270.f, 0.f, 1.f, 0.f ); // top face normal along y axis
|
|||
|
|
+ glDrawArrays( GL_TRIANGLE_STRIP, 16, 4);
|
|||
|
|
+
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[5]);
|
|||
|
|
+ glRotatef(90.f, 0.f, 1.f, 0.f ); // bottom face normal along y axis
|
|||
|
|
+ glDrawArrays( GL_TRIANGLE_STRIP, 20, 4);
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: init_textures
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * CUBE_STATE_T *state - holds OGLES model info
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Initialise OGL|ES texture surfaces to use image
|
|||
|
|
+ * buffers
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void init_textures(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ // load three texture buffers but use them on six OGL|ES texture surfaces
|
|||
|
|
+ load_tex_images(state);
|
|||
|
|
+ glGenTextures(6, &state->tex[0]);
|
|||
|
|
+
|
|||
|
|
+ // setup first texture
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[0]);
|
|||
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, IMAGE_SIZE, IMAGE_SIZE, 0,
|
|||
|
|
+ GL_RGB, GL_UNSIGNED_BYTE, state->tex_buf1);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+
|
|||
|
|
+ // setup second texture - reuse first image
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[1]);
|
|||
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, IMAGE_SIZE, IMAGE_SIZE, 0,
|
|||
|
|
+ GL_RGB, GL_UNSIGNED_BYTE, state->tex_buf1);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+
|
|||
|
|
+ // third texture
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[2]);
|
|||
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, IMAGE_SIZE, IMAGE_SIZE, 0,
|
|||
|
|
+ GL_RGB, GL_UNSIGNED_BYTE, state->tex_buf2);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+
|
|||
|
|
+ // fourth texture - reuse second image
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[3]);
|
|||
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, IMAGE_SIZE, IMAGE_SIZE, 0,
|
|||
|
|
+ GL_RGB, GL_UNSIGNED_BYTE, state->tex_buf2);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+
|
|||
|
|
+ //fifth texture
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[4]);
|
|||
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, IMAGE_SIZE, IMAGE_SIZE, 0,
|
|||
|
|
+ GL_RGB, GL_UNSIGNED_BYTE, state->tex_buf3);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+
|
|||
|
|
+ // sixth texture - reuse third image
|
|||
|
|
+ glBindTexture(GL_TEXTURE_2D, state->tex[5]);
|
|||
|
|
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, IMAGE_SIZE, IMAGE_SIZE, 0,
|
|||
|
|
+ GL_RGB, GL_UNSIGNED_BYTE, state->tex_buf3);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLfloat)GL_NEAREST);
|
|||
|
|
+
|
|||
|
|
+ // setup overall texture environment
|
|||
|
|
+ glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
|
|||
|
|
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|||
|
|
+
|
|||
|
|
+ glEnable(GL_TEXTURE_2D);
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+/***********************************************************
|
|||
|
|
+ * Name: load_tex_images
|
|||
|
|
+ *
|
|||
|
|
+ * Arguments:
|
|||
|
|
+ * void
|
|||
|
|
+ *
|
|||
|
|
+ * Description: Loads three raw images to use as textures on faces
|
|||
|
|
+ *
|
|||
|
|
+ * Returns: void
|
|||
|
|
+ *
|
|||
|
|
+ ***********************************************************/
|
|||
|
|
+static void load_tex_images(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ FILE *tex_file1 = NULL, *tex_file2=NULL, *tex_file3 = NULL;
|
|||
|
|
+ int bytes_read, image_sz = IMAGE_SIZE*IMAGE_SIZE*3;
|
|||
|
|
+
|
|||
|
|
+ state->tex_buf1 = malloc(image_sz);
|
|||
|
|
+ state->tex_buf2 = malloc(image_sz);
|
|||
|
|
+ state->tex_buf3 = malloc(image_sz);
|
|||
|
|
+
|
|||
|
|
+ tex_file1 = fopen(PATH "Lucca_128_128.raw", "rb");
|
|||
|
|
+ if (tex_file1 && state->tex_buf1)
|
|||
|
|
+ {
|
|||
|
|
+ bytes_read=fread(state->tex_buf1, 1, image_sz, tex_file1);
|
|||
|
|
+ assert(bytes_read == image_sz); // some problem with file?
|
|||
|
|
+ fclose(tex_file1);
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ tex_file2 = fopen(PATH "Djenne_128_128.raw", "rb");
|
|||
|
|
+ if (tex_file2 && state->tex_buf2)
|
|||
|
|
+ {
|
|||
|
|
+ bytes_read=fread(state->tex_buf2, 1, image_sz, tex_file2);
|
|||
|
|
+ assert(bytes_read == image_sz); // some problem with file?
|
|||
|
|
+ fclose(tex_file2);
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ tex_file3 = fopen(PATH "Gaudi_128_128.raw", "rb");
|
|||
|
|
+ if (tex_file3 && state->tex_buf3)
|
|||
|
|
+ {
|
|||
|
|
+ bytes_read=fread(state->tex_buf3, 1, image_sz, tex_file3);
|
|||
|
|
+ assert(bytes_read == image_sz); // some problem with file?
|
|||
|
|
+ fclose(tex_file3);
|
|||
|
|
+ }
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+//------------------------------------------------------------------------------
|
|||
|
|
+
|
|||
|
|
+static void exit_func(CUBE_STATE_T *state)
|
|||
|
|
+{
|
|||
|
|
+ // clear screen
|
|||
|
|
+ glClear( GL_COLOR_BUFFER_BIT );
|
|||
|
|
+ eglSwapBuffers(state->display, state->surface);
|
|||
|
|
+
|
|||
|
|
+ // Release OpenGL resources
|
|||
|
|
+ eglMakeCurrent( state->display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT );
|
|||
|
|
+
|
|||
|
|
+ wl_egl_window_destroy(state->wl_egl_window);
|
|||
|
|
+ wl_shell_surface_destroy(state->wl_shell_surface);
|
|||
|
|
+ wl_surface_destroy(state->wl_surface);
|
|||
|
|
+
|
|||
|
|
+ eglDestroySurface( state->display, state->surface );
|
|||
|
|
+ eglDestroyContext( state->display, state->context );
|
|||
|
|
+ eglTerminate( state->display );
|
|||
|
|
+
|
|||
|
|
+ wl_display_flush(state->wl_display);
|
|||
|
|
+
|
|||
|
|
+ // release texture buffers
|
|||
|
|
+ free(state->tex_buf1);
|
|||
|
|
+ free(state->tex_buf2);
|
|||
|
|
+ free(state->tex_buf3);
|
|||
|
|
+
|
|||
|
|
+ printf("\ncube closed\n");
|
|||
|
|
+} // exit_func()
|
|||
|
|
+
|
|||
|
|
+static int running = 1;
|
|||
|
|
+
|
|||
|
|
+static void
|
|||
|
|
+signal_int(int signum)
|
|||
|
|
+{
|
|||
|
|
+ running = 0;
|
|||
|
|
+}
|
|||
|
|
+
|
|||
|
|
+//==============================================================================
|
|||
|
|
+
|
|||
|
|
+int main (int argc, char *argv[])
|
|||
|
|
+{
|
|||
|
|
+ struct sigaction sigint;
|
|||
|
|
+ CUBE_STATE_T state = {0,};
|
|||
|
|
+ int ret = 0;
|
|||
|
|
+ int i;
|
|||
|
|
+
|
|||
|
|
+ for (i = 0; i < argc; i++) {
|
|||
|
|
+ if (strcmp(argv[i], "--kill-compositor") == 0)
|
|||
|
|
+ state.kill_compositor = 1;
|
|||
|
|
+ if (strcmp(argv[i], "--single-frame") == 0)
|
|||
|
|
+ state.single_frame = 1;
|
|||
|
|
+ if (strcmp(argv[i], "--terminate-abruptly") == 0)
|
|||
|
|
+ state.terminate_abruptly = 1;
|
|||
|
|
+ else if (strcmp(argv[i], "--help") == 0 ||
|
|||
|
|
+ strcmp(argv[i], "-h") == 0) {
|
|||
|
|
+ printf("Usage: hello_wayland.bin [OPTION]\n\n");
|
|||
|
|
+ printf("\t--kill-compositor\tkill the Wayland compositor after 100 frames\n");
|
|||
|
|
+ printf("\t-h, --help\t\tshow this text\n");
|
|||
|
|
+ printf("\t--single-frame\t\tupdate the display only once\n");
|
|||
|
|
+ printf("\t--terminate-abruptly\texit right after rendering the 100th frame\n");
|
|||
|
|
+ return 0;
|
|||
|
|
+ }
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ // Start OGLES
|
|||
|
|
+ init_ogl(&state);
|
|||
|
|
+
|
|||
|
|
+ // Setup the model world
|
|||
|
|
+ init_model_proj(&state);
|
|||
|
|
+
|
|||
|
|
+ // initialise the OGLES texture(s)
|
|||
|
|
+ init_textures(&state);
|
|||
|
|
+
|
|||
|
|
+ sigint.sa_handler = signal_int;
|
|||
|
|
+ sigemptyset(&sigint.sa_mask);
|
|||
|
|
+ sigint.sa_flags = SA_RESETHAND;
|
|||
|
|
+ sigaction(SIGINT, &sigint, NULL);
|
|||
|
|
+
|
|||
|
|
+ state.needs_update = 1;
|
|||
|
|
+ while (running && ret != -1) {
|
|||
|
|
+ if (state.needs_update) {
|
|||
|
|
+ update(&state);
|
|||
|
|
+ state.needs_update = 0;
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ ret = wl_display_dispatch(state.wl_display);
|
|||
|
|
+ }
|
|||
|
|
+
|
|||
|
|
+ exit_func(&state);
|
|||
|
|
+
|
|||
|
|
+ return 0;
|
|||
|
|
+}
|
|||
|
|
+
|