Skip to content

Commit

Permalink
Update to BBlocks for NDK 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitry Tomilovskiy committed Dec 13, 2011
1 parent da29162 commit a556bdb
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 55 deletions.
2 changes: 1 addition & 1 deletion BelligerentBlocks/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
1 change: 1 addition & 0 deletions BelligerentBlocks/.project
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 3 additions & 2 deletions BelligerentBlocks/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 0 additions & 8 deletions BelligerentBlocks/arm/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion BelligerentBlocks/arm/o.le.v7.g/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion BelligerentBlocks/arm/o.le.v7/Makefile

This file was deleted.

18 changes: 15 additions & 3 deletions BelligerentBlocks/bar-descriptor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,26 @@
<!-- 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>

<action system="true">run_native</action>

<!-- 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>
<asset path="${QNX_TARGET}\..\target-override\armle-v7\usr\lib\libalut.so.1" type="Qnx/Elf">lib/libalut.so.1</asset>
<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>
Expand All @@ -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>
96 changes: 62 additions & 34 deletions BelligerentBlocks/src/bbutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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];

Expand Down
10 changes: 5 additions & 5 deletions BelligerentBlocks/src/bbutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit a556bdb

Please sign in to comment.