Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update to BBlocks for NDK1.0 #3

Merged
merged 1 commit into from

2 participants

@dtomilovskiy
Collaborator

I have updated BelligerentBlocks to work with the latest revision of bbutil. This fixes several minor glitches in this sample related to orientation locking and splashcreens.

@nlandry nlandry merged commit de83054 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2011
  1. @dtomilovskiy
This page is out of date. Refresh to see the latest.
View
2  BelligerentBlocks/.cproject
@@ -19,7 +19,7 @@
<toolChain id="com.qnx.qcc.toolChain.exe.debug.1335340190" name="QNX QCC" superClass="com.qnx.qcc.toolChain">
<option id="com.qnx.qcc.option.cpu.1211616888" name="Target CPU:" superClass="com.qnx.qcc.option.cpu" value="com.qnx.qcc.option.gen.cpu.armle-v7" valueType="enumerated"/>
<targetPlatform archList="all" binaryParser="com.qnx.tools.ide.qde.core.QDEBynaryParser" id="com.qnx.qcc.targetPlatform.1408902953" osList="all" superClass="com.qnx.qcc.targetPlatform"/>
- <builder buildPath="${workspace_loc:/BelligerentBlocks/Device-Debug}" id="com.qnx.nto.2101376621" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="com.qnx.nto"/>
+ <builder buildPath="${workspace_loc:/BelligerentBlocks/Device-Debug}" id="org.eclipse.cdt.build.core.internal.builder.1142774569" superClass="org.eclipse.cdt.build.core.internal.builder"/>
<tool id="com.qnx.qcc.tool.compiler.868577170" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
<option id="com.qnx.qcc.option.compile.debug.875162179" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
<option id="com.qnx.qcc.option.compiler.security.583437287" name="Enhanced Security (-fstack-protector-all)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
View
1  BelligerentBlocks/.project
@@ -70,6 +70,7 @@
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
+ <nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>com.qnx.tools.ide.bbt.core.bbtnature</nature>
View
5 BelligerentBlocks/README.txt
@@ -4,7 +4,8 @@ Belligerent Blocks
Sample Description:
Belligerent Blocks is a 1 level game created as part of a presentation
- made at DevCon.
+ made at DevCon. Please note that this version is not compatible with
+ NDK 2.0 due to changes in Scoreloop API.
Feature summary
- Rendering 2D graphics
@@ -19,7 +20,7 @@ Sample Description:
========================================================================
Requirements:
- - BlackBerry Native SDK for Tablet OS 1.0 or later
+ - BlackBerry Native SDK for Tablet OS 1.0
- BlackBerry PlayBook tablet running BlackBerry Tablet OS 1.0 or later
- Box2D installed or added as a project dependency
- Scoreloop's SDK installed from the beta site
View
8 BelligerentBlocks/arm/Makefile
@@ -1,8 +0,0 @@
-LIST=VARIANT
-ifndef QRECURSE
-QRECURSE=recurse.mk
-ifdef QCONFIG
-QRDIR=$(dir $(QCONFIG))
-endif
-endif
-include $(QRDIR)$(QRECURSE)
View
1  BelligerentBlocks/arm/o.le.v7.g/Makefile
@@ -1 +0,0 @@
-include ../../common.mk
View
1  BelligerentBlocks/arm/o.le.v7/Makefile
@@ -1 +0,0 @@
-include ../../common.mk
View
18 BelligerentBlocks/bar-descriptor.xml
@@ -46,8 +46,6 @@
<!-- High score database -->
<asset path="Assets/scores.db">data/scores.db</asset>
-
- <!-- target-override libraries that need to be bundled onto the device -->
<icon><image>icon.png</image></icon>
<splashscreen>splash.png</splashscreen>
@@ -55,9 +53,11 @@
<!-- Permission needed for Scoreloop -->
<action>read_device_identifying_information</action>
+ <action>play_audio</action>
<env var="LD_LIBRARY_PATH" value="app/native/lib"/>
+ <!-- target-override libraries that need to be bundled onto the device -->
<configuration id="com.qnx.qcc.configuration.exe.debug.286133895" name="Device-Debug">
<asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
<asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libOpenAL.so.1" type="Qnx/Elf">lib/libOpenAL.so.1</asset>
@@ -65,7 +65,7 @@
<asset path="Device-Debug/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
</configuration>
<configuration id="com.qnx.qcc.configuration.exe.release.1268219428" name="Device-Release">
- <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
<asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libOpenAL.so.1" type="Qnx/Elf">lib/libOpenAL.so.1</asset>
<asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libalut.so.1" type="Qnx/Elf">lib/libalut.so.1</asset>
<asset path="Device-Release/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
@@ -77,15 +77,27 @@
<asset path="Simulator/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
</configuration>
<configuration id="com.qnx.qcc.configuration.exe.profile.568639964" name="Device-Profile">
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libOpenAL.so.1" type="Qnx/Elf">lib/libOpenAL.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libalut.so.1" type="Qnx/Elf">lib/libalut.so.1</asset>
<asset path="Device-Profile/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
</configuration>
<configuration id="com.qnx.qcc.configuration.exe.profile.coverage.1490198268" name="Device-Coverage">
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libOpenAL.so.1" type="Qnx/Elf">lib/libOpenAL.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libalut.so.1" type="Qnx/Elf">lib/libalut.so.1</asset>
<asset path="Device-Coverage/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
</configuration>
<configuration id="com.qnx.qcc.configuration.exe.profile.113216683" name="Simulator-Profile">
+ <asset path="${QNX_TARGET}\..\target-override\x86\usr\lib\libOpenAL.so.1" type="Qnx/Elf">lib/libOpenAL.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\x86\usr\lib\libalut.so.1" type="Qnx/Elf">lib/libalut.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\x86\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
<asset path="Simulator-Profile/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
</configuration>
<configuration id="com.qnx.qcc.configuration.exe.profile.coverage.339504475" name="Simulator-Coverage">
+ <asset path="${QNX_TARGET}\..\target-override\x86\usr\lib\libOpenAL.so.1" type="Qnx/Elf">lib/libOpenAL.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\x86\usr\lib\libalut.so.1" type="Qnx/Elf">lib/libalut.so.1</asset>
+ <asset path="${QNX_TARGET}\..\target-override\x86\usr\lib\libbps.so.1" type="Qnx/Elf">lib/libbps.so.1</asset>
<asset path="Simulator-Coverage/BelligerentBlocks" entry="true" type="Qnx/Elf">BelligerentBlocks</asset>
</configuration>
</qnx>
View
96 BelligerentBlocks/src/bbutil.c
@@ -48,18 +48,18 @@ static int nbuffers = 2;
static int initialized = 0;
struct font_t {
- unsigned int font_texture;
- float pt;
- float advance[128];
- float width[128];
- float height[128];
- float tex_x1[128];
- float tex_x2[128];
- float tex_y1[128];
- float tex_y2[128];
- float offset_x[128];
- float offset_y[128];
- int initialized;
+ unsigned int font_texture;
+ float pt;
+ float advance[128];
+ float width[128];
+ float height[128];
+ float tex_x1[128];
+ float tex_x2[128];
+ float tex_y1[128];
+ float tex_y2[128];
+ float offset_x[128];
+ float offset_y[128];
+ int initialized;
};
@@ -105,8 +105,10 @@ bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
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");
@@ -187,31 +189,57 @@ bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api) {
return EXIT_FAILURE;
}
- int screen_resolution[2];
+ int angle = atoi(getenv("ORIENTATION"));
- 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;
- }
+ screen_display_mode_t screen_mode;
+ rc = screen_get_display_property_pv(screen_disp, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
+ if (rc) {
+ perror("screen_get_display_property_pv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
- int angle = atoi(getenv("ORIENTATION"));
- int buffer_size[2] = {screen_resolution[0], screen_resolution[1]};
+ int size[2];
+ rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
+ if (rc) {
+ perror("screen_get_window_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
- rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);
- if (rc) {
- perror("screen_set_window_property_iv");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
+ int buffer_size[2] = {size[0], size[1]};
- rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
- if (rc) {
- perror("screen_set_window_property_iv");
- bbutil_terminate();
- return EXIT_FAILURE;
- }
+ if ((angle == 0) || (angle == 180)) {
+ if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
+ ((screen_mode.width < screen_mode.height) && (size[0] > size[1]))) {
+ buffer_size[1] = size[0];
+ buffer_size[0] = size[1];
+ }
+ } else if ((angle == 90) || (angle == 270)){
+ if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
+ ((screen_mode.width < screen_mode.height && size[0] < size[1]))) {
+ buffer_size[1] = size[0];
+ buffer_size[0] = size[1];
+ }
+ } else {
+ fprintf(stderr, "Navigator returned an unexpected orientation angle.\n");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, buffer_size);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
+
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_ROTATION, &angle);
+ if (rc) {
+ perror("screen_set_window_property_iv");
+ bbutil_terminate();
+ return EXIT_FAILURE;
+ }
rc = screen_create_window_buffers(screen_win, nbuffers);
if (rc) {
@@ -792,7 +820,7 @@ int bbutil_calculate_dpi(screen_context_t ctx) {
}
int bbutil_rotate_screen_surface(int angle) {
- int rc, rotation, skip = 1, temp;;
+ int rc, rotation, skip = 1, temp;
EGLint interval = 1;
int size[2];
View
10 BelligerentBlocks/src/bbutil.h
@@ -39,7 +39,7 @@ extern "C" {
*
* @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
+ * @return EXIT_SUCCESS if initialization succeeded otherwise EXIT_FAILURE
*/
int bbutil_init_egl(screen_context_t ctx, enum RENDERING_API api);
@@ -59,7 +59,7 @@ void bbutil_swap();
* @param font_file string indicating the absolute path of the font file
* @param point_size used for glyph generation
* @param dpi used for glyph generation
- * \return pointer to font_t structure on success or NULL on failure
+ * @return pointer to font_t structure on success or NULL on failure
*/
font_t* bbutil_load_font(const char* font_file, int point_size, int dpi);
@@ -102,7 +102,7 @@ void bbutil_measure_text(font_t* font, const char* msg, float* width, float* he
* @param return width of texture
* @param return height of texture
* @param return gl texture handle
- * \return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE
+ * @return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE
*/
int bbutil_load_texture(const char* filename, int* width, int* height, float* tex_x, float* tex_y, unsigned int* tex);
@@ -112,7 +112,7 @@ int bbutil_load_texture(const char* filename, int* width, int* height, float* te
*
* @param ctx path libscreen context that corresponds to display of interest
- * \return dpi for a given screen
+ * @return dpi for a given screen
*/
int bbutil_calculate_dpi(screen_context_t ctx);
@@ -122,7 +122,7 @@ int bbutil_calculate_dpi(screen_context_t ctx);
*
* @param angle to rotate screen surface to, must by 0, 90, 180, or 270
- * \return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE
+ * @return EXIT_SUCCESS if texture loading succeeded otherwise EXIT_FAILURE
*/
int bbutil_rotate_screen_surface(int angle);
Something went wrong with that request. Please try again.