Permalink
Browse files

Merge pull request #46 from nlandry/next

Fix native screen initialization for BB10
  • Loading branch information...
2 parents 6b9f355 + 4e31274 commit 662dd02e57fa4f58cc8c22d82200a9c4c03d8463 @nlandry nlandry committed Oct 24, 2012
Showing with 56 additions and 170 deletions.
  1. +2 −3 BelligerentBlocks/src/Platform.cpp
  2. +12 −46 BelligerentBlocks/src/bbutil.c
  3. +10 −43 GoodCitizen/bbutil.c
  4. +8 −15 GoodCitizen/main.c
  5. +10 −43 HelloWorldDisplay/bbutil.c
  6. +14 −20 HelloWorldDisplay/main.c
@@ -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;
@@ -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
@@ -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
@@ -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();
@@ -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();
@@ -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");

0 comments on commit 662dd02

Please sign in to comment.