Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update NDK-Samples next for NDK 2.0

  • Loading branch information...
commit bca4b2a4351b3b1f5d9e100a8921cfcfda7219be 1 parent 38b89ca
@jhoffmannrim jhoffmannrim authored
Showing with 8,447 additions and 5,494 deletions.
  1. +6 −4 .gitignore
  2. +1 −1  Accelerometer/NOTICE
  3. +12 −12 Accelerometer/bar-descriptor.xml
  4. +1 −1  Accelerometer/dialogutil.c
  5. +2 −2 Accelerometer/dialogutil.h
  6. +1 −1  Accelerometer/main.c
  7. +10 −10 Accelerometer/readme.txt
  8. +1 −1  AudioControl/NOTICE
  9. +12 −12 AudioControl/bar-descriptor.xml
  10. +1 −1  AudioControl/dialogutil.c
  11. +2 −2 AudioControl/dialogutil.h
  12. +33 −33 AudioControl/main.c
  13. +12 −12 AudioControl/readme.txt
  14. +11 −2 BelligerentBlocks/.cproject
  15. +1 −1  BelligerentBlocks/NOTICE
  16. +0 −1  BelligerentBlocks/README.txt
  17. +2 −2 BelligerentBlocks/bar-descriptor.xml
  18. +36 −32 BelligerentBlocks/src/GameLogic.cpp
  19. +1 −1  BelligerentBlocks/src/GameLogic.h
  20. +1 −1  BelligerentBlocks/src/Main.cpp
  21. +4 −2 BelligerentBlocks/src/Platform.cpp
  22. +1 −1  BelligerentBlocks/src/Platform.h
  23. +1 −1  BelligerentBlocks/src/Sound.cpp
  24. +1 −1  BelligerentBlocks/src/Sound.h
  25. +1 −1  BelligerentBlocks/src/Sprite.cpp
  26. +1 −1  BelligerentBlocks/src/Sprite.h
  27. +241 −96 BelligerentBlocks/src/bbutil.c
  28. +4 −6 BelligerentBlocks/src/bbutil.h
  29. +1 −1  Channels/NOTICE
  30. +12 −12 Channels/bar-descriptor.xml
  31. +1 −1  Channels/dialogutil.c
  32. +2 −2 Channels/dialogutil.h
  33. +19 −19 Channels/main.c
  34. +20 −21 Channels/readme.txt
  35. +4 −0 CubeRotate/.cproject
  36. +1 −1  CubeRotate/NOTICE
  37. +12 −12 CubeRotate/bar-descriptor.xml
  38. +290 −145 CubeRotate/bbutil.c
  39. +4 −6 CubeRotate/bbutil.h
  40. +3 −0  CubeRotate/common.mk
  41. +109 −109 CubeRotate/main.c
  42. +2 −0  CubeRotate/manifest.properties
  43. +12 −11 CubeRotate/readme.txt
  44. +1 −1  Dialog/NOTICE
  45. +12 −12 Dialog/bar-descriptor.xml
  46. +11 −6 Dialog/main.c
  47. +14 −13 Dialog/readme.txt
  48. +5 −1 FallingBlocks/.cproject
  49. +1 −1  FallingBlocks/NOTICE
  50. +12 −12 FallingBlocks/bar-descriptor.xml
  51. +290 −145 FallingBlocks/bbutil.c
  52. +4 −6 FallingBlocks/bbutil.h
  53. +3 −0  FallingBlocks/common.mk
  54. +378 −378 FallingBlocks/main.c
  55. +3 −1 FallingBlocks/manifest.properties
  56. +16 −15 FallingBlocks/readme.txt
  57. +15 −12 {OpenGLES11Template → GLES11Template}/.cproject
  58. +1 −1  {OpenGLES11Template → GLES11Template}/.project
  59. 0  {OpenGLES11Template → GLES11Template}/LICENSE
  60. 0  {VideoWindow/src → GLES11Template}/Makefile
  61. +2 −2 {OpenGLES11Template → GLES11Template}/NOTICE
  62. 0  {OpenGLES11Template/x86 → GLES11Template/arm}/Makefile
  63. 0  {OpenGLES11Template/x86/o-g → GLES11Template/arm/o.le-v7-g}/Makefile
  64. 0  {OpenGLES11Template → GLES11Template}/arm/o.le-v7/Makefile
  65. +19 −19 {OpenGLES11Template → GLES11Template}/bar-descriptor.xml
  66. +290 −145 {OpenGLES11Template → GLES11Template}/bbutil.c
  67. +4 −6 {OpenGLES11Template → GLES11Template}/bbutil.h
  68. +4 −1 {OpenGLES11Template → GLES11Template}/common.mk
  69. +225 −0 GLES11Template/main.c
  70. +5 −3 {OpenGLES11Template → GLES11Template}/manifest.properties
  71. +14 −12 {OpenGLES11Template → GLES11Template}/readme.txt
  72. 0  {OpenGLES11Template/arm → GLES11Template/x86}/Makefile
  73. 0  {OpenGLES11Template/arm/o.le-v7-g → GLES11Template/x86/o-g}/Makefile
  74. +178 −0 GLES20Template/.cproject
  75. +84 −0 GLES20Template/.project
  76. +232 −0 GLES20Template/LICENSE
  77. 0  {OpenGLES11Template → GLES20Template}/Makefile
  78. +73 −0 GLES20Template/NOTICE
  79. +8 −0 GLES20Template/arm/Makefile
  80. +1 −0  GLES20Template/arm/o.le-v7-g/Makefile
  81. +1 −0  GLES20Template/arm/o.le-v7/Makefile
  82. +93 −0 GLES20Template/bar-descriptor.xml
  83. +1,052 −0 GLES20Template/bbutil.c
  84. +132 −0 GLES20Template/bbutil.h
  85. +39 −0 GLES20Template/common.mk
  86. +350 −0 GLES20Template/main.c
  87. +57 −0 GLES20Template/manifest.properties
  88. +35 −0 GLES20Template/readme.txt
  89. +8 −0 GLES20Template/x86/Makefile
  90. +1 −0  GLES20Template/x86/o-g/Makefile
  91. +1 −1  Geolocation/NOTICE
  92. +12 −12 Geolocation/bar-descriptor.xml
  93. +1 −1  Geolocation/dialogutil.c
  94. +2 −2 Geolocation/dialogutil.h
  95. +6 −6 Geolocation/main.c
  96. +11 −10 Geolocation/readme.txt
  97. +1 −1  Gesture/NOTICE
  98. +12 −12 Gesture/bar-descriptor.xml
  99. +8 −9 Gesture/main.c
  100. +1 −1  Gesture/manifest.properties
  101. +14 −14 Gesture/readme.txt
  102. +15 −12 GoodCitizen/.cproject
  103. +1 −1  GoodCitizen/NOTICE
  104. +12 −12 GoodCitizen/bar-descriptor.xml
  105. +290 −145 GoodCitizen/bbutil.c
  106. +4 −6 GoodCitizen/bbutil.h
  107. +3 −0  GoodCitizen/common.mk
  108. +618 −613 GoodCitizen/main.c
  109. +3 −1 GoodCitizen/manifest.properties
  110. +14 −13 GoodCitizen/readme.txt
  111. +1 −1  HelloWorldConsole/NOTICE
  112. +12 −12 HelloWorldConsole/bar-descriptor.xml
  113. +3 −3 HelloWorldConsole/main.c
  114. +1 −1  HelloWorldConsole/manifest.properties
  115. +11 −11 HelloWorldConsole/readme.txt
  116. +1 −1  HelloWorldDisplay/NOTICE
  117. +12 −12 HelloWorldDisplay/bar-descriptor.xml
  118. +290 −145 HelloWorldDisplay/bbutil.c
  119. +4 −6 HelloWorldDisplay/bbutil.h
  120. +3 −0  HelloWorldDisplay/common.mk
  121. +166 −169 HelloWorldDisplay/main.c
  122. +3 −1 HelloWorldDisplay/manifest.properties
  123. +14 −13 HelloWorldDisplay/readme.txt
  124. +1 −1  HttpProxy/NOTICE
  125. +12 −12 HttpProxy/bar-descriptor.xml
  126. +1 −1  HttpProxy/dialogutil.c
  127. +2 −2 HttpProxy/dialogutil.h
  128. +3 −3 HttpProxy/main.c
  129. +1 −1  HttpProxy/manifest.properties
  130. +12 −12 HttpProxy/readme.txt
  131. +1 −1  Keyboard/NOTICE
  132. +12 −12 Keyboard/bar-descriptor.xml
  133. +744 −492 Keyboard/bbutil.c
  134. +65 −76 Keyboard/bbutil.h
  135. +3 −0  Keyboard/common.mk
  136. +131 −74 Keyboard/main.c
  137. +12 −13 Keyboard/readme.txt
  138. +1 −1  LocaleSample/NOTICE
  139. +12 −12 LocaleSample/bar-descriptor.xml
  140. +1 −1  LocaleSample/dialogutil.c
  141. +2 −2 LocaleSample/dialogutil.h
  142. +1 −1  LocaleSample/main.c
  143. +1 −1  LocaleSample/manifest.properties
  144. +13 −13 LocaleSample/readme.txt
  145. +1 −1  NetworkStatus/NOTICE
  146. +12 −12 NetworkStatus/bar-descriptor.xml
  147. +1 −1  NetworkStatus/dialogutil.c
  148. +2 −2 NetworkStatus/dialogutil.h
  149. +1 −1  NetworkStatus/main.c
  150. +1 −1  NetworkStatus/manifest.properties
  151. +12 −11 NetworkStatus/readme.txt
  152. +0 −221 OpenGLES11Template/main.c
  153. +1 −1  PaymentService/NOTICE
  154. +12 −12 PaymentService/bar-descriptor.xml
  155. +9 −1 PaymentService/main.c
  156. +1 −1  PaymentService/manifest.properties
  157. +15 −14 PaymentService/readme.txt
  158. +1 −1  PlayAudio/NOTICE
  159. +12 −12 PlayAudio/bar-descriptor.xml
  160. +1 −1  PlayAudio/dialogutil.c
  161. +2 −2 PlayAudio/dialogutil.h
  162. +1 −1  PlayAudio/main.c
  163. +13 −13 PlayAudio/readme.txt
  164. +1 −1  PlayWav/NOTICE
  165. +12 −12 PlayWav/bar-descriptor.xml
  166. +1 −1  PlayWav/dialogutil.c
  167. +2 −2 PlayWav/dialogutil.h
  168. +1 −1  PlayWav/main.c
  169. +9 −9 PlayWav/readme.txt
  170. +1 −1  ScreenTemplate/NOTICE
  171. +12 −12 ScreenTemplate/bar-descriptor.xml
  172. +1 −1  ScreenTemplate/common.mk
  173. +1 −1  ScreenTemplate/main.c
  174. +2 −2 ScreenTemplate/manifest.properties
  175. +9 −9 ScreenTemplate/readme.txt
  176. +1 −1  VideoPlayback/NOTICE
  177. +12 −12 VideoPlayback/bar-descriptor.xml
  178. +156 −156 VideoPlayback/main.c
  179. +12 −12 VideoPlayback/readme.txt
  180. +203 −203 VideoWindow/LICENSE
  181. +5 −5 VideoWindow/NOTICE
  182. +95 −95 VideoWindow/bar-descriptor.xml
  183. +631 −631 VideoWindow/main.c
  184. +1 −1  VideoWindow/manifest.properties
  185. +35 −35 VideoWindow/readme.txt
  186. +0 −631 VideoWindow/src/main.c
View
10 .gitignore
@@ -40,6 +40,12 @@ FallingBlocks/arm/o.le-v7-g/FallingBlocks
FallingBlocks/arm/o.le-v7/FallingBlocks
FallingBlocks/x86/o-g/FallingBlocks
FallingBlocks/x86/o/FallingBlocks
+GLES11Template/arm/o.le-v7-g/GLES11Template
+GLES11Template/arm/o.le-v7/GLES11Template
+GLES11Template/x86/o-g/GLES11Template
+GLES20Template/arm/o.le-v7-g/GLES20Template
+GLES20Template/arm/o.le-v7/GLES20Template
+GLES20Template/x86/o-g/GLES20Template
Geolocation/arm/o.le-v7-g/Geolocation
Geolocation/arm/o.le-v7/Geolocation
Geolocation/x86/o-g/Geolocation
@@ -76,10 +82,6 @@ NetworkStatus/arm/o.le-v7-g/NetworkStatus
NetworkStatus/arm/o.le-v7/NetworkStatus
NetworkStatus/x86/o-g/NetworkStatus
NetworkStatus/x86/o/NetworkStatus
-OpenGLES11Template/arm/o.le-v7-g/OpenGLES11Template
-OpenGLES11Template/arm/o.le-v7/OpenGLES11Template
-OpenGLES11Template/x86/o-g/OpenGLES11Template
-OpenGLES11Template/x86/o/OpenGLES11Template
PaymentService/arm/o.le-v7-g/PaymentService
PaymentService/arm/o.le-v7/PaymentService
PaymentService/x86/o-g/PaymentService
View
2  Accelerometer/NOTICE
@@ -1,5 +1,5 @@
Accelerometer
-Copyright (c) 2011 Research In Motion Limited.
+Copyright (c) 2011-2012 Research In Motion Limited.
This product includes software developed at
Research In Motion Limited (http://www.rim.com/).
View
24 Accelerometer/bar-descriptor.xml
@@ -11,19 +11,19 @@
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>com.example.Accelerometer</id>
- <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
+ <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
May have multiple values for each language. See samples or xsd schema file. Optional. -->
<name>Accelerometer</name>
-
- <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
+
+ <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
An updated version of application must have a versionNumber value higher than the previous version. Required. -->
<versionNumber>1.0.0</versionNumber>
- <!-- Fourth digit segment of the package version. First three segments are taken from the
+ <!-- Fourth digit segment of the package version. First three segments are taken from the
<versionNumber> element. Must be an integer from 0 to 2^16-1 -->
<buildId>1</buildId>
-
+
<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
<!-- <versionLabel></versionLabel> -->
@@ -37,17 +37,17 @@
<!-- Name of author which is used for signing. Must match the developer name of your development certificate. -->
<author>Example Inc.</author>
<splashscreen>sample-splashscreen-landscape.png:sample-splashscreen-portrait.png</splashscreen>
-
+
<!-- Unique author ID assigned by signing authority. Required if using debug tokens. -->
<!-- <authorId>ABC1234YjsnUk235h</authorId> -->
-
+
<initialWindow>
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
</initialWindow>
-
+
<!-- The category where the application appears. Either core.games or core.media. -->
<category>core.games</category>
<asset path="icon.png">icon.png</asset>
@@ -71,18 +71,18 @@
<platformArchitecture>x86</platformArchitecture>
<asset path="x86/o-g/Accelerometer" entry="true" type="Qnx/Elf">Accelerometer</asset>
</configuration>
-
+
<!-- The icon for the application, which should be 86x86. -->
<icon>
<image>icon.png</image>
</icon>
-
+
<!-- The splash screen that will appear when your application is launching. Should be 1024x600. -->
<!-- <splashscreen></splashscreen> -->
<!-- Request permission to execute native code. Required for native applications. -->
<action system="true">run_native</action>
-
+
<!-- The permissions requested by your application. -->
<!-- <action>access_shared</action> -->
<!-- <action>record_audio</action> -->
@@ -96,5 +96,5 @@
<!-- Ensure that shared libraries in the package are found at run-time. -->
<env var="LD_LIBRARY_PATH" value="app/native/lib"/>
-
+
</qnx>
View
2  Accelerometer/dialogutil.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
4 Accelerometer/dialogutil.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ void destroy_dialog();
/**
* Displays a message to the dialog created by create_dialog() and
- * outputs that message to stderr. This means it will get added
+ * outputs that message to stderr. This means it will get added
* to the log file in the sandbox and output to the console.
*
* @param msg the message to be displayed.
View
2  Accelerometer/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
20 Accelerometer/readme.txt
@@ -2,13 +2,13 @@ Accelerometer
========================================================================
Sample Description:
-
- The Accelerometer sample is an application that is designed to show you how to
+
+ The Accelerometer sample is an application that is designed to show you how to
handle updates from the accelerometer sensor
-
+
When you run the application, the value of the pitch and roll of the device is
printed to the console, and updated every 25 milliseconds.
-
+
Feature summary
- Handling navigator events
- Handling accelerometer updates
@@ -16,19 +16,19 @@ Sample Description:
========================================================================
Requirements:
- - BlackBerry Native SDK for Tablet OS 1.0 or later
+ - BlackBerry Native SDK for Tablet OS 2.0 or later
- One of the following:
- - BlackBerry PlayBook tablet running BlackBerry Tablet OS 1.0 or later
- - BlackBerry Tablet Simulator 1.0 or later
-
+ - BlackBerry PlayBook tablet running BlackBerry Tablet OS 2.0 or later
+ - BlackBerry Tablet Simulator 2.0 or later
+
========================================================================
Importing a project into the Native SDK:
-
+
1. From the the Sample apps page, download and extract the sample application.
2. Launch the Native SDK.
3. On the File menu, click Import.
4. Expand General, and select Existing Projects into Workspace. Click Next.
5. Browse to the location where you extracted the sample app, and click OK.
- The sample project should display in the the Projects section.
+ The sample project should display in the the Projects section.
6. Click Finish to import the project into your workspace.
View
2  AudioControl/NOTICE
@@ -1,5 +1,5 @@
AudioControl
-Copyright (c) 2011 Research In Motion Limited.
+Copyright (c) 2011-2012 Research In Motion Limited.
This product includes software developed at
Research In Motion Limited (http://www.rim.com/).
View
24 AudioControl/bar-descriptor.xml
@@ -11,19 +11,19 @@
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>com.example.AudioControl</id>
- <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
+ <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
May have multiple values for each language. See samples or xsd schema file. Optional. -->
<name>AudioControl</name>
-
- <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
+
+ <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
An updated version of application must have a versionNumber value higher than the previous version. Required. -->
<versionNumber>1.0.0</versionNumber>
- <!-- Fourth digit segment of the package version. First three segments are taken from the
+ <!-- Fourth digit segment of the package version. First three segments are taken from the
<versionNumber> element. Must be an integer from 0 to 2^16-1 -->
<buildId>1</buildId>
-
+
<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
<!-- <versionLabel></versionLabel> -->
@@ -37,17 +37,17 @@
<!-- Name of author which is used for signing. Must match the developer name of your development certificate. -->
<author>Example Inc.</author>
<splashscreen>sample-splashscreen-landscape.png:sample-splashscreen-portrait.png</splashscreen>
-
+
<!-- Unique author ID assigned by signing authority. Required if using debug tokens. -->
<!-- <authorId>ABC1234YjsnUk235h</authorId> -->
-
+
<initialWindow>
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
</initialWindow>
-
+
<!-- The category where the application appears. Either core.games or core.media. -->
<category>core.games</category>
<asset path="icon.png">icon.png</asset>
@@ -71,18 +71,18 @@
<platformArchitecture>x86</platformArchitecture>
<asset path="x86/o-g/AudioControl" entry="true" type="Qnx/Elf">AudioControl</asset>
</configuration>
-
+
<!-- The icon for the application, which should be 86x86. -->
<icon>
<image>icon.png</image>
</icon>
-
+
<!-- The splash screen that will appear when your application is launching. Should be 1024x600. -->
<!-- <splashscreen></splashscreen> -->
<!-- Request permission to execute native code. Required for native applications. -->
<action system="true">run_native</action>
-
+
<!-- The permissions requested by your application. -->
<!-- <action>access_shared</action> -->
<!-- <action>record_audio</action> -->
@@ -96,5 +96,5 @@
<!-- Ensure that shared libraries in the package are found at run-time. -->
<env var="LD_LIBRARY_PATH" value="app/native/lib"/>
-
+
</qnx>
View
2  AudioControl/dialogutil.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
4 AudioControl/dialogutil.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ void destroy_dialog();
/**
* Displays a message to the dialog created by create_dialog() and
- * outputs that message to stderr. This means it will get added
+ * outputs that message to stderr. This means it will get added
* to the log file in the sandbox and output to the console.
*
* @param msg the message to be displayed.
View
66 AudioControl/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -144,38 +144,38 @@ main(int argc, char *argv[])
if (BPS_FAILURE == audiomixer_request_events(0)) {
show_dialog_message("Unable to request audio mixer events.");
} else {
- /*
- * Retrieve and display the current audio mixer status
- */
- float headphone_volume;
- audiomixer_get_output_level(AUDIOMIXER_OUTPUT_HEADPHONE, &headphone_volume);
- float speaker_volume;
- audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &speaker_volume);
- float input_gain;
- audiomixer_get_input_level(AUDIOMIXER_INPUT, &input_gain);
-
- bool is_headphone_muted;
- audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_HEADPHONE, &is_headphone_muted);
- bool is_speaker_muted;
- audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_SPEAKER, &is_speaker_muted);
- bool is_input_muted;
- audiomixer_get_input_mute(AUDIOMIXER_INPUT, &is_input_muted);
-
- char tmp[MSG_SIZE];
- snprintf(msg, MSG_SIZE, "Audio Mixer Status\n");
- snprintf(tmp, MSG_SIZE, "Headphone Volume: %f\n", headphone_volume);
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Speaker Volume: %f\n", speaker_volume);
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Input Gain: %f\n", input_gain);
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Headphone Muted: %s\n", bool_str(is_headphone_muted));
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Speaker Muted: %s\n", bool_str(is_speaker_muted));
- strlcat(msg, tmp, MSG_SIZE);
- snprintf(tmp, MSG_SIZE, "Input Muted: %s\n\n", bool_str(is_input_muted));
- strlcat(msg, tmp, MSG_SIZE);
- show_dialog_message(msg);
+ /*
+ * Retrieve and display the current audio mixer status
+ */
+ float headphone_volume;
+ audiomixer_get_output_level(AUDIOMIXER_OUTPUT_HEADPHONE, &headphone_volume);
+ float speaker_volume;
+ audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &speaker_volume);
+ float input_gain;
+ audiomixer_get_input_level(AUDIOMIXER_INPUT, &input_gain);
+
+ bool is_headphone_muted;
+ audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_HEADPHONE, &is_headphone_muted);
+ bool is_speaker_muted;
+ audiomixer_get_output_mute(AUDIOMIXER_OUTPUT_SPEAKER, &is_speaker_muted);
+ bool is_input_muted;
+ audiomixer_get_input_mute(AUDIOMIXER_INPUT, &is_input_muted);
+
+ char tmp[MSG_SIZE];
+ snprintf(msg, MSG_SIZE, "Audio Mixer Status\n");
+ snprintf(tmp, MSG_SIZE, "Headphone Volume: %f\n", headphone_volume);
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Speaker Volume: %f\n", speaker_volume);
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Input Gain: %f\n", input_gain);
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Headphone Muted: %s\n", bool_str(is_headphone_muted));
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Speaker Muted: %s\n", bool_str(is_speaker_muted));
+ strlcat(msg, tmp, MSG_SIZE);
+ snprintf(tmp, MSG_SIZE, "Input Muted: %s\n\n", bool_str(is_input_muted));
+ strlcat(msg, tmp, MSG_SIZE);
+ show_dialog_message(msg);
}
/*
View
24 AudioControl/readme.txt
@@ -2,15 +2,15 @@ Audio control - Determine audio control settings
========================================================================
Sample Description:
-
+
The Audio Control Sample is an application that is designed to show you how to
- query the device for audio control settings, such as headphone volume,
- speaker volume, input gain, and mute status. This sample uses the audio mixer
- service, which is a service in the BlackBerry Platform Services library.
-
+ query the device for audio control settings, such as headphone volume, speaker
+ volume, input gain, and mute status. This sample uses the audio mixer service,
+ which is a service in the BlackBerry Platform Services library.
+
When you run the application, you can change one of the properties of the audio
mixer and the updated audio mixer status is printed to the console.
-
+
Feature summary
- Handling audio mixer events
- Querying the audio mixer service
@@ -18,19 +18,19 @@ Sample Description:
========================================================================
Requirements:
- - BlackBerry Native SDK for Tablet OS 1.0 or later
+ - BlackBerry Native SDK for Tablet OS 2.0 or later
- One of the following:
- - BlackBerry PlayBook tablet running BlackBerry Tablet OS 1.0 or later
- - BlackBerry Tablet Simulator 1.0 or later
-
+ - BlackBerry PlayBook tablet running BlackBerry Tablet OS 2.0 or later
+ - BlackBerry Tablet Simulator 2.0 or later
+
========================================================================
Importing a project into the Native SDK:
-
+
1. From the the Sample apps page, download and extract the sample application.
2. Launch the Native SDK.
3. On the File menu, click Import.
4. Expand General, and select Existing Projects into Workspace. Click Next.
5. Browse to the location where you extracted the sample app, and click OK.
- The sample project should display in the the Projects section.
+ The sample project should display in the the Projects section.
6. Click Finish to import the project into your workspace.
View
13 BelligerentBlocks/.cproject
@@ -26,6 +26,9 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/box2d}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QNX_TARGET}/usr/include/freetype2&quot;"/>
</option>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.374920975" name="QCC Options" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList">
+ <listOptionValue builtIn="false" value="-DUSING_GL11"/>
+ </option>
<inputType id="com.qnx.qcc.inputType.compiler.306305974" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool id="com.qnx.qcc.tool.assembler.1877792982" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
@@ -60,7 +63,7 @@
</option>
<option id="com.qnx.qcc.option.linker.defLibraryPaths.1516517177" superClass="com.qnx.qcc.option.linker.defLibraryPaths"/>
<option id="com.qnx.qcc.option.linker.libraryPaths.519401205" name="Library Paths (-L)" superClass="com.qnx.qcc.option.linker.libraryPaths" valueType="libPaths">
- <listOptionValue builtIn="false" value="&quot;${workspace_loc:/box2d/Device-Debug}&quot;"/>
+ <listOptionValue builtIn="false" value="&quot;${workspace_loc:/box2d/Device-Release}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/box2d/arm/a-le-v7}&quot;"/>
</option>
<inputType id="com.qnx.qcc.inputType.linker.1617475221" superClass="com.qnx.qcc.inputType.linker">
@@ -81,7 +84,7 @@
<externalSettings containerId="box2d;" factoryId="org.eclipse.cdt.core.cfg.export.settings.sipplier">
<externalSetting>
<entry flags="VALUE_WORKSPACE_PATH" kind="includePath" name="/box2d"/>
- <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/box2d/Device-Debug"/>
+ <entry flags="VALUE_WORKSPACE_PATH" kind="libraryPath" name="/box2d/Device-Release"/>
<entry flags="RESOLVED" kind="libraryFile" name="box2d"/>
</externalSetting>
</externalSettings>
@@ -111,6 +114,9 @@
<listOptionValue builtIn="false" value="&quot;${QNX_TARGET}/../target-override/usr/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QNX_TARGET}/usr/include/freetype2&quot;"/>
</option>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.1186023828" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList">
+ <listOptionValue builtIn="false" value="-DUSING_GL11"/>
+ </option>
<inputType id="com.qnx.qcc.inputType.compiler.1394666629" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool command="qcc" commandLinePattern="${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}" errorParsers="" id="com.qnx.qcc.tool.assembler.639841342" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
@@ -180,6 +186,9 @@
<listOptionValue builtIn="false" value="&quot;${QNX_TARGET}/../target-override/usr/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${QNX_TARGET}/usr/include/freetype2&quot;"/>
</option>
+ <option id="com.qnx.qcc.option.compiler.qccoptions.1718995789" superClass="com.qnx.qcc.option.compiler.qccoptions" valueType="stringList">
+ <listOptionValue builtIn="false" value="-DUSING_GL11"/>
+ </option>
<inputType id="com.qnx.qcc.inputType.compiler.153315798" superClass="com.qnx.qcc.inputType.compiler"/>
</tool>
<tool command="qcc" commandLinePattern="${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}" errorParsers="" id="com.qnx.qcc.tool.assembler.1917723023" name="QCC Assembler" superClass="com.qnx.qcc.tool.assembler">
View
2  BelligerentBlocks/NOTICE
@@ -1,5 +1,5 @@
Belligerent Blocks
-Copyright (c) 2011 Research In Motion Limited.
+Copyright (c) 2011-2012 Research In Motion Limited.
This product contains software, images, and sounds developed at Research In
Motion Limited (http://www.rim.com/).
View
1  BelligerentBlocks/README.txt
@@ -22,7 +22,6 @@ Requirements:
- BlackBerry Native SDK for Tablet OS 2.0 or later
- BlackBerry PlayBook tablet running BlackBerry Tablet OS 2.0 or later
- Box2D installed or added as a project dependency
- - Scoreloop's SDK installed from the beta site
========================================================================
Importing a project into the Native SDK:
View
4 BelligerentBlocks/bar-descriptor.xml
@@ -56,9 +56,9 @@
<!-- Permission needed for Scoreloop -->
<action>read_device_identifying_information</action>
<action>play_audio</action>
-
+
<env var="LD_LIBRARY_PATH" value="app/native/lib"/>
-
+
<configuration id="com.qnx.qcc.configuration.exe.release.1871319401" name="Device-Release">
<asset path="Device-Release/BelligerentBlocks" entry="true" type="Qnx/Elf">Blocks</asset>
</configuration>
View
68 BelligerentBlocks/src/GameLogic.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -274,16 +274,16 @@ void GameLogic::renderFetchUser() {
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- m_background.draw();
- glColor4f(0.75f, 0.75f, 0.75f, 1.0f);
- bbutil_render_text(m_font, m_message, m_messagePosX, m_messagePosY);
+ m_background.draw();
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
+ bbutil_render_text(m_font, m_message, m_messagePosX, m_messagePosY, 0.75f, 0.75f, 0.75f, 1.0f);
+
m_platform.finishRender();
}
@@ -304,14 +304,13 @@ void GameLogic::renderGame() {
m_background.draw();
if (m_gamePaused) {
- glColor4f(0.75f, 0.75f, 0.75f, 1.0f);
- bbutil_render_text(m_font, m_message, m_messagePosX, m_messagePosY);
-
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
+ bbutil_render_text(m_font, m_message, m_messagePosX, m_messagePosY, 0.75f, 0.75f, 0.75f, 1.0f);
+
m_platform.finishRender();
return;
@@ -320,8 +319,6 @@ void GameLogic::renderGame() {
//Draw ground
m_ground.draw();
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-
//Draw in game blocks
for (unsigned int i = 0; i < m_numBlocks; i++) {
glPushMatrix();
@@ -353,25 +350,22 @@ void GameLogic::renderGame() {
pos += 0.55f * m_blocks[i - 1].Width() / 2 + 1.5f;
}
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+
//Display score
char buf[100];
sprintf(buf, "%i\0", m_score);
- glColor4f(0.75f, 0.75f, 0.75f, 1.0f);
- bbutil_render_text(m_scoreFont, buf, m_scorePosX, m_scorePosY);
+ bbutil_render_text(m_scoreFont, buf, m_scorePosX, m_scorePosY, 0.75f, 0.75f, 0.75f, 1.0f);
//Display timer if it is available
if (m_showClock) {
sprintf(buf, "Time left %i\0", m_time - m_scoreTime - 1l);
- glColor4f(0.75f, 0.75f, 0.75f, 1.0f);
- bbutil_render_text(m_font, buf, m_timerPosX, m_timerPosY);
+ bbutil_render_text(m_font, buf, m_timerPosX, m_timerPosY, 0.75f, 0.75f, 0.75f, 1.0f);
}
-
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
-
m_platform.finishRender();
}
@@ -391,8 +385,12 @@ void GameLogic::renderLeadBoard() {
m_background.draw();
m_leaderBoard.draw();
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- bbutil_render_text(m_font, m_message, m_messagePosX, m_messagePosY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+
+ bbutil_render_text(m_font, m_message, m_messagePosX, m_messagePosY, 1.0f, 1.0f, 1.0f, 1.0f);
if (m_leaderBoardReady) {
m_playButton.draw();
@@ -405,24 +403,19 @@ void GameLogic::renderLeadBoard() {
for (int i = 0; i < static_cast<int>(m_leaderboard.size()); i++) {
sprintf(buf, "%i. %s", m_leaderboard[i].rank(), m_leaderboard[i].name().c_str());
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- bbutil_render_text(m_leaderboardFont, buf, m_leaderBoard.PosX() - m_leaderBoard.Width() / 2 + LEADERBOARD_LINE_OFFSET_X, posY);
+ bbutil_render_text(m_leaderboardFont, buf, m_leaderBoard.PosX() - m_leaderBoard.Width() / 2 + LEADERBOARD_LINE_OFFSET_X, posY,
+ 1.0f, 1.0f, 1.0f, 1.0f);
sprintf(buf, "%i", m_leaderboard[i].score());
bbutil_measure_text(m_leaderboardFont, buf, &sizeX, &sizeY);
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- bbutil_render_text(m_leaderboardFont, buf, m_leaderBoard.PosX() + m_leaderBoard.Width() / 2 - sizeX - LEADERBOARD_LINE_OFFSET_X, posY);
+ bbutil_render_text(m_leaderboardFont, buf, m_leaderBoard.PosX() + m_leaderBoard.Width() / 2 - sizeX - LEADERBOARD_LINE_OFFSET_X, posY,
+ 1.0f, 1.0f, 1.0f, 1.0f);
posY -= sizeY + 10.0f;
}
}
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisable(GL_TEXTURE_2D);
- glDisable(GL_BLEND);
-
m_platform.finishRender();
}
@@ -536,14 +529,25 @@ void GameLogic::button::setPosition(float x, float y) {
}
void GameLogic::button::draw() const {
+ glEnable(GL_TEXTURE_2D);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+
if (isPressed == true) {
pressed->draw();
} else {
regular->draw();
}
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- bbutil_render_text(font, text, posX + textX, posY + textY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+
+ bbutil_render_text(font, text, posX + textX, posY + textY, 1.0f, 1.0f, 1.0f, 1.0f);
}
void GameLogic::onExit() {
View
2  BelligerentBlocks/src/GameLogic.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2  BelligerentBlocks/src/Main.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
6 BelligerentBlocks/src/Platform.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@ namespace blocks {
static const char SCORELOOP_GAME_ID[] = "d346c484-12aa-49a2-a0a0-de2f87492d72";
static const char SCORELOOP_GAME_SECRET[] = "aAa+DehBfyGO/CYaE3nWomgu7SIbWFczUih+Qwf3/n7u0y3nyq5Hag==";
+static const char SCORELOOP_GAME_VERSION[] = "1.0";
static const char SCORELOOP_GAME_CURRENCY[] = "ASC";
static const char SCORELOOP_GAME_LANGUAGE[] = "en";
@@ -75,7 +76,7 @@ Platform::Platform()
// Lock in landscape mode.
navigator_rotation_lock(true);
- bbutil_init_egl(m_screenContext, GL_ES_1);
+ bbutil_init_egl(m_screenContext);
}
Platform::~Platform() {
@@ -101,6 +102,7 @@ bool Platform::init() {
&m_scoreloopInitData,
SCORELOOP_GAME_ID,
SCORELOOP_GAME_SECRET,
+ SCORELOOP_GAME_VERSION,
SCORELOOP_GAME_CURRENCY,
SCORELOOP_GAME_LANGUAGE);
View
2  BelligerentBlocks/src/Platform.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2  BelligerentBlocks/src/Sound.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2  BelligerentBlocks/src/Sound.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2  BelligerentBlocks/src/Sprite.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
2  BelligerentBlocks/src/Sprite.h
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Research In Motion Limited
+ * Copyright 2011-2012 Research In Motion Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
337 BelligerentBlocks/src/bbutil.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#include <assert.h>
#include <ctype.h>
#include <unistd.h>
@@ -27,8 +26,14 @@
#include "bbutil.h"
+#ifdef USING_GL11
#include <GLES/gl.h>
#include <GLES/glext.h>
+#elif defined(USING_GL20)
+#include <GLES2/gl2.h>
+#else
+#error bbutil must be compiled with either USING_GL11 or USING_GL20 flags
+#endif
#include <ft2build.h>
#include FT_FREETYPE_H
@@ -47,6 +52,15 @@ static screen_display_t screen_disp;
static int nbuffers = 2;
static int initialized = 0;
+#ifdef USING_GL20
+static GLuint text_rendering_program;
+static int text_program_initialized = 0;
+static GLint positionLoc;
+static GLint texcoordLoc;
+static GLint textureLoc;
+static GLint colorLoc;
+#endif
+
struct font_t {
unsigned int font_texture;
float pt;
@@ -81,39 +95,42 @@ bbutil_egl_perror(const char *msg) {
"one or more argument values are invalid",
"an EGLSurface argument does not name a valid surface configured for rendering",
"a power management event has occurred",
+ "unknown error code"
};
- fprintf(stderr, "%s: %s\n", msg, errmsg[eglGetError() - EGL_SUCCESS]);
+ int message_index = eglGetError() - EGL_SUCCESS;
+
+ if (message_index < 0 || message_index > 14)
+ message_index = 15;
+
+ fprintf(stderr, "%s: %s\n", msg, errmsg[message_index]);
}
int
-bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
+bbutil_init_egl(screen_context_t ctx) {
int usage;
int format = SCREEN_FORMAT_RGBX8888;
EGLint interval = 1;
int rc, num_configs;
- EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
EGLint attrib_list[]= { EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
- EGL_BLUE_SIZE, 8,
EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT,
+ EGL_RENDERABLE_TYPE, 0,
EGL_NONE};
- if (api == GL_ES_1) {
- usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
- } else if (api == GL_ES_2) {
- attrib_list[11] = EGL_OPENGL_ES2_BIT;
- usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
- } else if (api == VG) {
- attrib_list[11] = EGL_OPENVG_BIT;
- usage = SCREEN_USAGE_OPENVG | SCREEN_USAGE_ROTATION;
- } else {
- fprintf(stderr, "invalid api setting\n");
- return EXIT_FAILURE;
- }
+#ifdef USING_GL11
+ usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_ROTATION;
+ attrib_list[9] = EGL_OPENGL_ES_BIT;
+#elif defined(USING_GL20)
+ usage = SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_ROTATION;
+ attrib_list[9] = EGL_OPENGL_ES2_BIT;
+ EGLint attributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
+#else
+ fprintf(stderr, "bbutil should be compiled with either USING_GL11 or USING_GL20 -D flags\n");
+ return EXIT_FAILURE;
+#endif
//Simple egl initialization
screen_ctx = ctx;
@@ -132,11 +149,7 @@ bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
return EXIT_FAILURE;
}
- if ((api == GL_ES_1) || (api == GL_ES_2)) {
- rc = eglBindAPI(EGL_OPENGL_ES_API);
- } else if (api == VG) {
- rc = eglBindAPI(EGL_OPENVG_API);
- }
+ rc = eglBindAPI(EGL_OPENGL_ES_API);
if (rc != EGL_TRUE) {
bbutil_egl_perror("eglBindApi");
@@ -149,11 +162,11 @@ bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
return EXIT_FAILURE;
}
- if (api == GL_ES_2) {
+#ifdef USING_GL20
egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, attributes);
- } else {
+#elif defined(USING_GL11)
egl_ctx = eglCreateContext(egl_disp, egl_conf, EGL_NO_CONTEXT, NULL);
- }
+#endif
if (egl_ctx == EGL_NO_CONTEXT) {
bbutil_egl_perror("eglCreateContext");
@@ -189,6 +202,15 @@ bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
return EXIT_FAILURE;
}
+ int screen_resolution[2];
+
+ rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
+ if (rc) {
+ perror("screen_get_display_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
int angle = atoi(getenv("ORIENTATION"));
screen_display_mode_t screen_mode;
@@ -348,7 +370,14 @@ font_t* bbutil_load_font(const char* path, int point_size, int dpi) {
}
font = (font_t*) malloc(sizeof(font_t));
+
+ if (!font) {
+ fprintf(stderr, "Unable to allocate memory for font structure\n");
+ return NULL;
+ }
+
font->initialized = 0;
+ font->pt = point_size;
glGenTextures(1, &(font->font_texture));
@@ -372,9 +401,6 @@ font_t* bbutil_load_font(const char* path, int point_size, int dpi) {
slot = face->glyph;
bmp = slot->bitmap;
- //glyph_width = nextp2(bmp.width);
- //glyph_height = nextp2(bmp.rows);
-
glyph_width = bmp.width;
glyph_height = bmp.rows;
@@ -392,8 +418,7 @@ font_t* bbutil_load_font(const char* path, int point_size, int dpi) {
int bitmap_offset_x = 0, bitmap_offset_y = 0;
- GLubyte* font_texture_data = (GLubyte*) malloc(sizeof(GLubyte) * 2 * font_tex_width * font_tex_height);
- memset((void*)font_texture_data, 0, sizeof(GLubyte) * 2 * font_tex_width * font_tex_height);
+ GLubyte* font_texture_data = (GLubyte*) calloc(2 * font_tex_width * font_tex_height, sizeof(GLubyte));
if (!font_texture_data) {
fprintf(stderr, "Failed to allocate memory for font texture\n");
@@ -412,8 +437,8 @@ font_t* bbutil_load_font(const char* path, int point_size, int dpi) {
slot = face->glyph;
bmp = slot->bitmap;
- glyph_width = nextp2(bmp.width);
- glyph_height = nextp2(bmp.rows);
+ glyph_width = bmp.width;
+ glyph_height = bmp.rows;
div_t temp = div(c, num_segments_x);
@@ -445,24 +470,16 @@ font_t* bbutil_load_font(const char* path, int point_size, int dpi) {
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE_ALPHA, font_tex_width, font_tex_height, 0, GL_LUMINANCE_ALPHA , GL_UNSIGNED_BYTE, font_texture_data);
- int err = glGetError();
-
free(font_texture_data);
FT_Done_Face(face);
FT_Done_FreeType(library);
- if (err != 0) {
- fprintf(stderr, "GL Error 0x%x", err);
- free(font);
- return NULL;
- }
-
font->initialized = 1;
return font;
}
-void bbutil_render_text(font_t* font, const char* msg, float x, float y) {
+void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r, float g, float b, float a) {
int i, c;
GLfloat *vertices;
GLfloat *texture_coords;
@@ -484,43 +501,14 @@ void bbutil_render_text(font_t* font, const char* msg, float x, float y) {
return;
}
- int texture_enabled;
- glGetIntegerv(GL_TEXTURE_2D, &texture_enabled);
- if (!texture_enabled) {
- glEnable(GL_TEXTURE_2D);
- }
-
- int blend_enabled;
- glGetIntegerv(GL_BLEND, &blend_enabled);
- if (!blend_enabled) {
- glEnable(GL_BLEND);
- }
-
- int gl_blend_src, gl_blend_dst;
- glGetIntegerv(GL_BLEND_SRC, &gl_blend_src);
- glGetIntegerv(GL_BLEND_DST, &gl_blend_dst);
+ const int msg_len = strlen(msg);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- int vertex_array_enabled;
- glGetIntegerv(GL_VERTEX_ARRAY, &vertex_array_enabled);
- if (!vertex_array_enabled) {
- glEnableClientState(GL_VERTEX_ARRAY);
- }
-
- int texture_array_enabled;
- glGetIntegerv(GL_TEXTURE_COORD_ARRAY, &texture_array_enabled);
- if (!texture_array_enabled) {
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- }
+ vertices = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
+ texture_coords = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
- vertices = (GLfloat*) malloc(sizeof(GLfloat) * 8 * strlen(msg));
- texture_coords = (GLfloat*) malloc(sizeof(GLfloat) * 8 * strlen(msg));
+ indices = (GLshort*) malloc(sizeof(GLfloat) * 6 * msg_len);
- indices = (GLshort*) malloc(sizeof(GLfloat) * 5 * strlen(msg));
-
- for(i = 0; i < strlen(msg); ++i) {
+ for(i = 0; i < msg_len; ++i) {
c = msg[i];
vertices[8 * i + 0] = x + pen_x + font->offset_x[c];
@@ -551,31 +539,182 @@ void bbutil_render_text(font_t* font, const char* msg, float x, float y) {
//Assume we are only working with typewriter fonts
pen_x += font->advance[c];
}
+#ifdef USING_GL11
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_BLEND);
+
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+
+ glColor4f(r, g, b, a);
glVertexPointer(2, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texture_coords);
glBindTexture(GL_TEXTURE_2D, font->font_texture);
- glDrawElements(GL_TRIANGLES, 6 * strlen(msg), GL_UNSIGNED_SHORT, indices);
+ glDrawElements(GL_TRIANGLES, 6 * msg_len, GL_UNSIGNED_SHORT, indices);
+
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_VERTEX_ARRAY);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+#elif defined USING_GL20
+ if (!text_program_initialized) {
+ GLint status;
+
+ // Create shaders if this hasn't been done already
+ const char* v_source =
+ "precision mediump float;"
+ "attribute vec2 a_position;"
+ "attribute vec2 a_texcoord;"
+ "varying vec2 v_texcoord;"
+ "void main()"
+ "{"
+ " gl_Position = vec4(a_position, 0.0, 1.0);"
+ " v_texcoord = a_texcoord;"
+ "}";
+
+ const char* f_source =
+ "precision lowp float;"
+ "varying vec2 v_texcoord;"
+ "uniform sampler2D u_font_texture;"
+ "uniform vec4 u_col;"
+ "void main()"
+ "{"
+ " vec4 temp = texture2D(u_font_texture, v_texcoord);"
+ " gl_FragColor = u_col * temp;"
+ "}";
+
+ // Compile the vertex shader
+ GLuint vs = glCreateShader(GL_VERTEX_SHADER);
+
+ if (!vs) {
+ fprintf(stderr, "Failed to create vertex shader: %d\n", glGetError());
+ return;
+ } else {
+ glShaderSource(vs, 1, &v_source, 0);
+ glCompileShader(vs);
+ glGetShaderiv(vs, GL_COMPILE_STATUS, &status);
+ if (GL_FALSE == status) {
+ GLchar log[256];
+ glGetShaderInfoLog(vs, 256, NULL, log);
+
+ fprintf(stderr, "Failed to compile vertex shader: %s\n", log);
+
+ glDeleteShader(vs);
+ }
+ }
- if (!texture_array_enabled) {
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- }
+ // Compile the fragment shader
+ GLuint fs = glCreateShader(GL_FRAGMENT_SHADER);
- if (!vertex_array_enabled) {
- glDisableClientState(GL_VERTEX_ARRAY);
- }
+ if (!fs) {
+ fprintf(stderr, "Failed to create fragment shader: %d\n", glGetError());
+ return;
+ } else {
+ glShaderSource(fs, 1, &f_source, 0);
+ glCompileShader(fs);
+ glGetShaderiv(fs, GL_COMPILE_STATUS, &status);
+ if (GL_FALSE == status) {
+ GLchar log[256];
+ glGetShaderInfoLog(fs, 256, NULL, log);
+
+ fprintf(stderr, "Failed to compile fragment shader: %s\n", log);
+
+ glDeleteShader(vs);
+ glDeleteShader(fs);
- if (!texture_enabled) {
- glDisable(GL_TEXTURE_2D);
+ return;
+ }
+ }
+
+ // Create and link the program
+ text_rendering_program = glCreateProgram();
+ if (text_rendering_program)
+ {
+ glAttachShader(text_rendering_program, vs);
+ glAttachShader(text_rendering_program, fs);
+ glLinkProgram(text_rendering_program);
+
+ glGetProgramiv(text_rendering_program, GL_LINK_STATUS, &status);
+ if (status == GL_FALSE) {
+ GLchar log[256];
+ glGetProgramInfoLog(fs, 256, NULL, log);
+
+ fprintf(stderr, "Failed to link text rendering shader program: %s\n", log);
+
+ glDeleteProgram(text_rendering_program);
+ text_rendering_program = 0;
+
+ return;
+ }
+ } else {
+ fprintf(stderr, "Failed to create a shader program\n");
+
+ glDeleteShader(vs);
+ glDeleteShader(fs);
+ return;
+ }
+
+ // We don't need the shaders anymore - the program is enough
+ glDeleteShader(fs);
+ glDeleteShader(vs);
+
+ glUseProgram(text_rendering_program);
+
+ // Store the locations of the shader variables we need later
+ positionLoc = glGetAttribLocation(text_rendering_program, "a_position");
+ texcoordLoc = glGetAttribLocation(text_rendering_program, "a_texcoord");
+ textureLoc = glGetUniformLocation(text_rendering_program, "u_font_texture");
+ colorLoc = glGetUniformLocation(text_rendering_program, "u_col");
+
+ text_program_initialized = 1;
}
- glBlendFunc(gl_blend_src, gl_blend_dst);
+ glEnable(GL_BLEND);
+
+ //Map text coordinates from (0...surface width, 0...surface height) to (-1...1, -1...1)
+ //this make our vertex shader very simple and also works irrespective of orientation changes
+ EGLint surface_width, surface_height;
- if (!blend_enabled) {
- glDisable(GL_BLEND);
+ eglQuerySurface(egl_disp, egl_surf, EGL_WIDTH, &surface_width);
+ eglQuerySurface(egl_disp, egl_surf, EGL_HEIGHT, &surface_height);
+
+ for(i = 0; i < 4 * msg_len; ++i) {
+ vertices[2 * i + 0] = 2 * vertices[2 * i + 0] / surface_width - 1.0f;
+ vertices[2 * i + 1] = 2 * vertices[2 * i + 1] / surface_height - 1.0f;
}
+ //Render text
+ glUseProgram(text_rendering_program);
+
+ glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, font->font_texture);
+ glUniform1i(textureLoc, 0);
+
+ glUniform4f(colorLoc, r, g, b, a);
+
+ glEnableVertexAttribArray(positionLoc);
+ glVertexAttribPointer(positionLoc, 2, GL_FLOAT, GL_FALSE, 0, vertices);
+
+ glEnableVertexAttribArray(texcoordLoc);
+ glVertexAttribPointer(texcoordLoc, 2, GL_FLOAT, GL_FALSE, 0, texture_coords);
+
+ //Draw the string
+ glDrawElements(GL_TRIANGLES, 6 * msg_len, GL_UNSIGNED_SHORT, indices);
+
+ glDisableVertexAttribArray(positionLoc);
+ glDisableVertexAttribArray(texcoordLoc);
+#else
+ fprintf(stderr, "bbutil should be compiled with either USING_GL11 or USING_GL20 -D flags\n");
+#endif
+
free(vertices);
free(texture_coords);
free(indices);
@@ -598,11 +737,13 @@ void bbutil_measure_text(font_t* font, const char* msg, float* width, float* hei
return;
}
+ const int msg_len =strlen(msg);
+
if (width) {
//Width of a text rectangle is a sum advances for every glyph in a string
*width = 0.0f;
- for(i = 0; i < strlen(msg); ++i) {
+ for(i = 0; i < msg_len; ++i) {
c = msg[i];
*width += font->advance[c];
}
@@ -612,7 +753,7 @@ void bbutil_measure_text(font_t* font, const char* msg, float* width, float* hei
//Height of a text rectangle is a high of a tallest glyph in a string
*height = 0.0f;
- for(i = 0; i < strlen(msg); ++i) {
+ for(i = 0; i < msg_len; ++i) {
c = msg[i];
if (*height < font->height[c]) {
@@ -757,8 +898,12 @@ int bbutil_load_texture(const char* filename, int* width, int* height, float* te
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
- glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, NULL);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height, format, GL_UNSIGNED_BYTE, image_data);
+ if ((tex_width != image_width) || (tex_height != image_height) ) {
+ glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, NULL);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, image_width, image_height, format, GL_UNSIGNED_BYTE, image_data);
+ } else {
+ glTexImage2D(GL_TEXTURE_2D, 0, format, tex_width, tex_height, 0, format, GL_UNSIGNED_BYTE, image_data);
+ }
GLint err = glGetError();
@@ -812,10 +957,10 @@ int bbutil_calculate_dpi(screen_context_t ctx) {
bbutil_terminate();
return EXIT_FAILURE;
}
+ double diagonal_pixels = sqrt(screen_resolution[0] * screen_resolution[0] + screen_resolution[1] * screen_resolution[1]);
+ double diagonal_inches = 0.0393700787 * sqrt(screen_phys_size[0] * screen_phys_size[0] + screen_phys_size[1] * screen_phys_size[1]);
+ return (int)(diagonal_pixels / diagonal_inches + 0.5);
- int diagonal_pixels = sqrt(screen_resolution[0] * screen_resolution[0] + screen_resolution[1] * screen_resolution[1]);
- int diagontal_inches = 0.0393700787 * sqrt(screen_phys_size[0] * screen_phys_size[0] + screen_phys_size[1] * screen_phys_size[1]);
- return (int)(diagonal_pixels / diagontal_inches);
}
}
View
10 BelligerentBlocks/src/bbutil.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +26,6 @@ extern EGLSurface egl_surf;
typedef struct font_t font_t;
-enum RENDERING_API {GL_ES_1 = EGL_OPENGL_ES_BIT, GL_ES_2 = EGL_OPENGL_ES2_BIT, VG = EGL_OPENVG_BIT};
-
#define BBUTIL_DEFAULT_FONT "/usr/fonts/font_repository/monotype/arial.ttf"
#ifdef __cplusplus
@@ -38,10 +36,9 @@ extern "C" {
* Initializes EGL
*
* @param libscreen context that will be used for EGL setup
- * @param rendering API that will be used
* @return EXIT_SUCCESS if initialization succeeded otherwise EXIT_FAILURE
*/
-int bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api);
+int bbutil_init_egl(screen_context_t ctx);
/**
* Terminates EGL
@@ -78,8 +75,9 @@ void bbutil_destroy_font(font_t* font);
* @param font to use for rendering
* @param msg the message to display
* @param x, y position of the bottom-left corner of text string in world coordinate space
+ * @param rgba color for the text to render with
*/
-void bbutil_render_text(font_t* font, const char* msg, float x, float y);
+void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r, float g, float b, float a);
/**
* Returns the non-scaled width and height of a string
View
2  Channels/NOTICE
@@ -1,5 +1,5 @@
Channels
-Copyright (c) 2011 Research In Motion Limited.
+Copyright (c) 2011-2012 Research In Motion Limited.
This product includes software developed at
Research In Motion Limited (http://www.rim.com/).
View
24 Channels/bar-descriptor.xml
@@ -11,19 +11,19 @@
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>com.example.Channels</id>
- <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
+ <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
May have multiple values for each language. See samples or xsd schema file. Optional. -->
<name>Channels</name>
-
- <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
+
+ <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
An updated version of application must have a versionNumber value higher than the previous version. Required. -->
<versionNumber>1.0.0</versionNumber>
- <!-- Fourth digit segment of the package version. First three segments are taken from the
+ <!-- Fourth digit segment of the package version. First three segments are taken from the
<versionNumber> element. Must be an integer from 0 to 2^16-1 -->
<buildId>1</buildId>
-
+
<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
<!-- <versionLabel></versionLabel> -->
@@ -37,17 +37,17 @@
<!-- Name of author which is used for signing. Must match the developer name of your development certificate. -->
<author>Example Inc.</author>
<splashscreen>sample-splashscreen-landscape.png:sample-splashscreen-portrait.png</splashscreen>
-
+
<!-- Unique author ID assigned by signing authority. Required if using debug tokens. -->
<!-- <authorId>ABC1234YjsnUk235h</authorId> -->
-
+
<initialWindow>
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
</initialWindow>
-
+
<!-- The category where the application appears. Either core.games or core.media. -->
<category>core.games</category>
<asset path="icon.png">icon.png</asset>
@@ -71,19 +71,19 @@
<platformArchitecture>x86</platformArchitecture>
<asset path="x86/o-g/Channels" entry="true" type="Qnx/Elf">Channels</asset>
</configuration>
-
+
<!-- The icon for the application, which should be 86x86. -->
<icon>
<image>icon.png</image>
</icon>
-
+
<!-- The splash screen that will appear when your application is launching. Should be 1024x600. -->
<!-- <splashscreen></splashscreen> -->
<!-- Request permission to execute native code. Required for native applications. -->
<action system="true">run_native</action>
<action>read_geolocation</action>
-
+
<!-- The permissions requested by your application. -->
<!-- <action>access_shared</action> -->
<!-- <action>record_audio</action> -->
@@ -97,5 +97,5 @@
<!-- Ensure that shared libraries in the package are found at run-time. -->
<env var="LD_LIBRARY_PATH" value="app/native/lib"/>
-
+
</qnx>
View
2  Channels/dialogutil.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
View
4 Channels/dialogutil.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,7 +52,7 @@ void show_top_dialog_message(const char *msg);
/**
* Displays a message to the bottom dialog created by create_dialogs() and
- * outputs that message to stderr. This means it will get added
+ * outputs that message to stderr. This means it will get added
* to the log file in the sandbox and output to the console.
*
* @param msg the message to be displayed.
View
38 Channels/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,16 @@
*/
/**
- * Sample showing how to use BlackBerry Native APIs for channels to
+ * Sample showing how to use BlackBerry Native APIs for channels to
* allow different threads to handle events from different services.
- *
- * Note that the main purpose of this sample is to show channels working
- * with services. Please see the Accelerometer sample and the Geolocation
+ *
+ * Note that the main purpose of this sample is to show channels working
+ * with services. Please see the Accelerometer sample and the Geolocation
* sample for a better understanding of how to use the accelerometer and
- * geolocation services.
+ * geolocation services.
*
*/
-
+
#include <bps/bps.h>
#include <bps/dialog.h>
#include <bps/geolocation.h>
@@ -58,7 +58,7 @@ static const int STOP_REQUEST = 1;
static int accel_chid = -1;
/**
- * A place to store the requested event domain
+ * A place to store the requested event domain
*/
static int local_event_domain;
@@ -84,7 +84,7 @@ display_accelerometer_reading(float x, float y, float z)
/*
* Display the accelerometer values
*/
- snprintf(accel_msg, MSG_SIZE, "x: %f, y: %f, z: %f\n", x, y, z);
+ snprintf(accel_msg, MSG_SIZE, "\n\nx: %f, y: %f, z: %f\n", x, y, z);
show_bottom_dialog_message(accel_msg);
}
@@ -127,7 +127,7 @@ handle_geolocation_response(bps_event_t *event)
double latitude = geolocation_event_get_latitude(event);
double longitude = geolocation_event_get_longitude(event);
double accuracy = geolocation_event_get_accuracy(event);
-
+
snprintf(msg, MSG_SIZE,
"Geolocation report #%d\n"
"\tlatitude: % 13.8f degrees\n"
@@ -141,9 +141,9 @@ handle_geolocation_response(bps_event_t *event)
}
/**
- * Thread that handles accelerometer events and
- * sends relevant information to a dialog.
- *
+ * Thread that handles accelerometer events and
+ * sends relevant information to a dialog.
+ *
* @param p Unused.
*/
static void *
@@ -155,10 +155,10 @@ accel_main (void *p) {
bps_initialize();
/*
- * Each thread that calls bps_initialize() will have its
+ * Each thread that calls bps_initialize() will have its
* own unique channel ID. Protect it inside a mutex and
* condition variable to avoid race condition where main
- * thread tries to use it before we assign it.
+ * thread tries to use it before we assign it.
*/
pthread_mutex_lock(&chidMutex);
accel_chid = bps_channel_get_active();
@@ -221,7 +221,7 @@ main(int argc, char *argv[])
bps_initialize();
/*
- * Initialize the screen so that the window group Id is properly set,
+ * Initialize the screen so that the window group Id is properly set,
* to allow the dialogs to be displayed.
*/
if (setup_screen() != EXIT_SUCCESS) {
@@ -234,7 +234,7 @@ main(int argc, char *argv[])
* events from the various BlackBerry Tablet OS platform services. The
* Navigator service manages and delivers application life cycle and
* visibility events.
- *
+ *
* We register a custom event domain so that we can communicate with the
* the accelerometer thread. We will need to tell it to quit once we get
* the NAVIGATOR_EXIT.
@@ -268,7 +268,7 @@ main(int argc, char *argv[])
*/
create_dialogs();
show_top_dialog_message("Geolocation getting first fix");
- show_bottom_dialog_message("This is the Accelerometer Dialog");
+ show_bottom_dialog_message("\n\nThis is the Accelerometer Dialog");
/*
* Before initializing the accelerometer service we must ensure the device
@@ -322,7 +322,7 @@ main(int argc, char *argv[])
geolocation_stop_events(0);
/*
- * Avoid a possible race condition where accel_chid has not yet
+ * Avoid a possible race condition where accel_chid has not yet
* been assigned a valid channel ID.
*/
pthread_mutex_lock(&chidMutex);
View
41 Channels/readme.txt
@@ -2,23 +2,22 @@ Channels - Display current location data
========================================================================
Sample Description:
-
- The Channels application demonstrates how to two different threads can
- communicate by sending events through channels.
-
- We retrieve and display geolocation specific information, such as
- the latitude, longitude, altitude, and bearing of the tablet from
- the default channel of the main thread. This thread also listens
- for the navigator's event telling it to exit. Before joining on the
- child thread, it sends a custom event to the child thread's channel
- letting it know that it should exit.
-
- We retrieve and display the x, y and z values of the accelerometer
- device of the tablet from the default channel of the child thread.
-
- When the application is executed, geolocation data is displayed in a
- dialog and accelerometer data is displayed in another.
-
+
+ The Channels application demonstrates how to two different threads can
+ communicate by sending events through channels.
+
+ We retrieve and display geolocation specific information, such as the latitude,
+ longitude, altitude, and bearing of the tablet from the default channel of the
+ main thread. This thread also listens for the navigator's event telling it to
+ exit. Before joining on the child thread, it sends a custom event to the child
+ thread's channel letting it know that it should exit.
+
+ We retrieve and display the x, y and z values of the accelerometer device of
+ the tablet from the default channel of the child thread.
+
+ When the application is executed, geolocation data is displayed in a dialog and
+ accelerometer data is displayed in another.
+
Feature summary
- Requesting events from different channels
- Multiple dialogs
@@ -28,17 +27,17 @@ Requirements:
- BlackBerry Native SDK for Tablet OS 2.0 or later
- One of the following:
- - BlackBerry PlayBook tablet running BlackBerry Tablet OS 2.0 or later
+ - BlackBerry PlayBook tablet running BlackBerry Tablet OS 2.0 or later
- BlackBerry Tablet Simulator 2.0 or later
-
+
========================================================================
Importing a project into the Native SDK:
-
+
1. From the the Sample apps page, download and extract the sample application.
2. Launch the Native SDK.
3. On the File menu, click Import.
4. Expand General, and select Existing Projects into Workspace. Click Next.
5. Browse to the location where you extracted the sample app, and click OK.
- The sample project should display in the the Projects section.
+ The sample project should display in the the Projects section.
6. Click Finish to import the project into your workspace.
View
4 CubeRotate/.cproject
@@ -77,6 +77,7 @@
</folderInfo>
</configuration>
</storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.qnx.qcc.toolChain.1567721122">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.1567721122" moduleId="org.eclipse.cdt.core.settings" name="Device-Release">
@@ -114,6 +115,7 @@
</folderInfo>
</configuration>
</storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
<cconfiguration id="com.qnx.qcc.toolChain.1107315697">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="com.qnx.qcc.toolChain.1107315697" moduleId="org.eclipse.cdt.core.settings" name="Simulator-Debug">
@@ -151,6 +153,7 @@
</folderInfo>
</configuration>
</storageModule>
+ <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
@@ -171,4 +174,5 @@
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="com.qnx.tools.ide.qde.managedbuilder.core.qccScannerInfo"/>
</scannerConfigBuildInfo>
</storageModule>
+ <storageModule moduleId="refreshScope"/>
</cproject>
View
2  CubeRotate/NOTICE
@@ -1,5 +1,5 @@
CubeRotate
-Copyright (c) 2011 Research In Motion Limited.
+Copyright (c) 2011-2012 Research In Motion Limited.
This product includes software developed at
Research In Motion Limited (http://www.rim.com/).
View
24 CubeRotate/bar-descriptor.xml
@@ -11,19 +11,19 @@
Using a reverse DNS-style name as the id is recommended. (Eg. com.example.ExampleApplication.) Required. -->
<id>com.example.CubeRotate</id>
- <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
+ <!-- The name that is displayed in the BlackBerry Tablet OS application installer.
May have multiple values for each language. See samples or xsd schema file. Optional. -->
<name>CubeRotate</name>
-
- <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
+
+ <!-- A string value of the format <0-999>.<0-999>.<0-999> that represents application version which can be used to check for application upgrade.
Values can also be 1-part or 2-part. It is not necessary to have a 3-part value.
An updated version of application must have a versionNumber value higher than the previous version. Required. -->
<versionNumber>1.0.0</versionNumber>
- <!-- Fourth digit segment of the package version. First three segments are taken from the
+ <!-- Fourth digit segment of the package version. First three segments are taken from the
<versionNumber> element. Must be an integer from 0 to 2^16-1 -->
<buildId>1</buildId>
-
+
<!-- A string value (such as "v1", "2.5", or "Alpha 1") that represents the version of the application, as it should be shown to users. Optional. -->
<!-- <versionLabel></versionLabel> -->
@@ -37,16 +37,16 @@
<!-- Name of author which is used for signing. Must match the developer name of your development certificate. -->
<author>Example Inc.</author>
<splashscreen>sample-splashscreen-landscape.png:sample-splashscreen-portrait.png</splashscreen>
-
+
<!-- Unique author ID assigned by signing authority. Required if using debug tokens. -->
<!-- <authorId>ABC1234YjsnUk235h</authorId> -->
-
+
<initialWindow>
<autoOrients>true</autoOrients>
<systemChrome>none</systemChrome>
<transparent>false</transparent>
</initialWindow>
-
+
<!-- The category where the application appears. Either core.games or core.media. -->
<category>core.games</category>
<asset path="icon.png">icon.png</asset>
@@ -70,18 +70,18 @@
<platformArchitecture>x86</platformArchitecture>
<asset path="x86/o-g/CubeRotate" entry="true" type="Qnx/Elf">CubeRotate</asset>
</configuration>
-
+
<!-- The icon for the application, which should be 86x86. -->
<icon>
<image>icon.png</image>
</icon>
-
+
<!-- The splash screen that will appear when your application is launching. Should be 1024x600. -->
<!-- <splashscreen></splashscreen> -->
<!-- Request permission to execute native code. Required for native applications. -->
<action system="true">run_native</action>
-
+
<!-- The permissions requested by your application. -->
<!-- <action>access_shared</action> -->
<!-- <action>record_audio</action> -->
@@ -95,5 +95,5 @@
<!-- Ensure that shared libraries in the package are found at run-time. -->
<env var="LD_LIBRARY_PATH" value="app/native/lib"/>
-
+
</qnx>
View
435 CubeRotate/bbutil.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Research In Motion Limited.
+ * Copyright (c) 2011-2012 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#include <assert.h>
#include <ctype.h>
#include <unistd.h>
@@ -27,8 +26,14 @@
#include "bbutil.h"
+#ifdef USING_GL11
#include <GLES/gl.h>
#include <GLES/glext.h>
+#elif defined(USING_GL20)
+#include <GLES2/gl2.h>
+#else
+#error bbutil must be compiled with either USING_GL11 or USING_GL20 flags