Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix native screen initialization for BB10 #46

Merged
merged 2 commits into from

2 participants

@nlandry
Collaborator

Also includes some minor changes to BelligerentBlock's use of Scoreloop (to reflect underlying Scoreloop API improvements).

nlandry added some commits
@nlandry nlandry Fix native screen initialization for BB10
Screen initialization has simplified from PlayBook.  Update samples that
aren't using glview to reflect the proper way.

Also, stop calling navigator_rotation_lock().  It is rarely needed as long
as the proper rotation behaviour is specified in the bar-descriptor.xml
file.
fdc9905
@nlandry nlandry Update the use of scoreloop
Some Scoreloop calls have changed in R9.  Update BelligerentBlocks so that
it works again.
4e31274
@nlandry nlandry merged commit 662dd02 into from
@doturner

Is there any chance you could elaborate a bit on why you shouldn't use navigator_rotation_lock? As far as I can make out, if your application is locked to a given aspect ratio by specifying in the bar-descriptor.xml, you must also use navigator_rotation_lock(true) so that the 'swipe up' gesture does not move around the screen when the device is rotated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 24, 2012
  1. @nlandry

    Fix native screen initialization for BB10

    nlandry authored
    Screen initialization has simplified from PlayBook.  Update samples that
    aren't using glview to reflect the proper way.
    
    Also, stop calling navigator_rotation_lock().  It is rarely needed as long
    as the proper rotation behaviour is specified in the bar-descriptor.xml
    file.
  2. @nlandry

    Update the use of scoreloop

    nlandry authored
    Some Scoreloop calls have changed in R9.  Update BelligerentBlocks so that
    it works again.
This page is out of date. Refresh to see the latest.
View
5 BelligerentBlocks/src/Platform.cpp
@@ -135,8 +135,7 @@ bool Platform::init() {
}
SC_ScoresController_SetMode(m_scoresController, 0);
- SC_ScoresController_SetSearchList(m_scoresController, SC_SCORE_SEARCH_LIST_GLOBAL);
- SC_ScoresController_SetTimeInterval(m_scoresController, SC_TIME_INTERVAL_GLOBAL);
+ SC_ScoresController_SetSearchList(m_scoresController, SC_SCORES_SEARCH_LIST_ALL);
struct stat fileInfo;
if (stat("data/scores.db", &fileInfo) == -1) {
@@ -372,7 +371,7 @@ void Platform::fetchLeaderboard() {
return;
}
- SC_Error_t rc = SC_ScoresController_LoadRange(m_scoresController, scores);
+ SC_Error_t rc = SC_ScoresController_LoadScores(m_scoresController, scores);
if (rc != SC_OK) {
fprintf(stderr, "Error loading leaderboard score range: %d\n", rc);
return;
View
58 BelligerentBlocks/src/bbutil.c
@@ -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>
#include <stdio.h>
@@ -202,61 +201,28 @@ bbutil_init_egl(screen_context_t ctx) {
return EXIT_FAILURE;
}
- int screen_resolution[2];
+ const char *env = getenv("WIDTH");
- rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
- if (rc) {
- perror("screen_get_display_property_iv");
+ if (0 == env) {
+ perror("failed getenv for WIDTH");
bbutil_terminate();
return EXIT_FAILURE;
}
- int angle = atoi(getenv("ORIENTATION"));
+ int width = atoi(env);
- 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;
- }
+ env = getenv("HEIGHT");
- int size[2];
- rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
- if (rc) {
- perror("screen_get_window_property_iv");
+ if (0 == env) {
+ perror("failed getenv for HEIGHT");
bbutil_terminate();
return EXIT_FAILURE;
}
- int buffer_size[2] = {size[0], size[1]};
+ int height = atoi(env);
+ int size[2] = { width, height };
- 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);
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
if (rc) {
perror("screen_set_window_property_iv");
bbutil_terminate();
@@ -483,7 +449,7 @@ void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r
int i, c;
GLfloat *vertices;
GLfloat *texture_coords;
- GLshort* indices;
+ GLushort* indices;
float pen_x = 0.0f;
@@ -506,7 +472,7 @@ void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r
vertices = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
texture_coords = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
- indices = (GLshort*) malloc(sizeof(GLfloat) * 6 * msg_len);
+ indices = (GLushort*) malloc(sizeof(GLushort) * 6 * msg_len);
for(i = 0; i < msg_len; ++i) {
c = msg[i];
View
53 GoodCitizen/bbutil.c
@@ -201,61 +201,28 @@ bbutil_init_egl(screen_context_t ctx) {
return EXIT_FAILURE;
}
- int screen_resolution[2];
+ const char *env = getenv("WIDTH");
- rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
- if (rc) {
- perror("screen_get_display_property_iv");
+ if (0 == env) {
+ perror("failed getenv for WIDTH");
bbutil_terminate();
return EXIT_FAILURE;
}
- int angle = atoi(getenv("ORIENTATION"));
+ int width = atoi(env);
- 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;
- }
+ env = getenv("HEIGHT");
- int size[2];
- rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
- if (rc) {
- perror("screen_get_window_property_iv");
+ if (0 == env) {
+ perror("failed getenv for HEIGHT");
bbutil_terminate();
return EXIT_FAILURE;
}
- int buffer_size[2] = {size[0], size[1]};
+ int height = atoi(env);
+ int size[2] = { width, height };
- 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);
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
if (rc) {
perror("screen_set_window_property_iv");
bbutil_terminate();
View
23 GoodCitizen/main.c
@@ -14,23 +14,24 @@
* limitations under the License.
*/
-#include <screen/screen.h>
+#include "bbutil.h"
+
#include <bps/navigator.h>
#include <bps/screen.h>
#include <bps/bps.h>
#include <bps/event.h>
-#include <bps/orientation.h>
+
+#include <screen/screen.h>
+
+#include <EGL/egl.h>
+#include <GLES/gl.h>
+
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
-#include <EGL/egl.h>
-#include <GLES/gl.h>
-
-#include "bbutil.h"
-
static GLfloat radio_btn_unselected_vertices[8], radio_btn_selected_vertices[8],
background_portrait_vertices[8], background_landscape_vertices[8],
*background_vertices;
@@ -752,14 +753,6 @@ int main(int argc, char *argv[]) {
return 0;
}
- //Signal BPS library that navigator orientation is not to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(false)) {
- fprintf(stderr, "navigator_rotation_lock failed\n");
- bbutil_terminate();
- screen_destroy_context(screen_cxt);
- return 0;
- }
-
while (!shutdown) {
// Handle user input and accelerometer
handle_events();
View
53 HelloWorldDisplay/bbutil.c
@@ -201,61 +201,28 @@ bbutil_init_egl(screen_context_t ctx) {
return EXIT_FAILURE;
}
- int screen_resolution[2];
+ const char *env = getenv("WIDTH");
- rc = screen_get_display_property_iv(screen_disp, SCREEN_PROPERTY_SIZE, screen_resolution);
- if (rc) {
- perror("screen_get_display_property_iv");
+ if (0 == env) {
+ perror("failed getenv for WIDTH");
bbutil_terminate();
return EXIT_FAILURE;
}
- int angle = atoi(getenv("ORIENTATION"));
+ int width = atoi(env);
- 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;
- }
+ env = getenv("HEIGHT");
- int size[2];
- rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
- if (rc) {
- perror("screen_get_window_property_iv");
+ if (0 == env) {
+ perror("failed getenv for HEIGHT");
bbutil_terminate();
return EXIT_FAILURE;
}
- int buffer_size[2] = {size[0], size[1]};
+ int height = atoi(env);
+ int size[2] = { width, height };
- 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);
+ rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
if (rc) {
perror("screen_set_window_property_iv");
bbutil_terminate();
View
34 HelloWorldDisplay/main.c
@@ -14,26 +14,28 @@
* limitations under the License.
*/
-#include <ctype.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/keycodes.h>
-#include <screen/screen.h>
+#include "bbutil.h"
+
+#include <png.h>
+
#include <bps/navigator.h>
#include <bps/screen.h>
#include <bps/bps.h>
#include <bps/event.h>
-#include <bps/orientation.h>
-#include <math.h>
-#include <time.h>
+
#include <screen/screen.h>
+#include <sys/keycodes.h>
+
#include <EGL/egl.h>
#include <GLES/gl.h>
-#include "png.h"
-#include "bbutil.h"
+#include <math.h>
+#include <time.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
static float width, height;
static GLuint background;
@@ -177,14 +179,6 @@ int main(int argc, char **argv) {
return 0;
}
- //Signal BPS library that navigator orientation is to be locked
- if (BPS_SUCCESS != navigator_rotation_lock(true)) {
- fprintf(stderr, "navigator_rotation_lock failed\n");
- bbutil_terminate();
- screen_destroy_context(screen_cxt);
- return 0;
- }
-
//Signal BPS library that navigator and screen events will be requested
if (BPS_SUCCESS != screen_request_events(screen_cxt)) {
fprintf(stderr, "screen_request_events failed\n");
Something went wrong with that request. Please try again.