Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Fix native screen initialization for BB10 #46

Merged
merged 2 commits into from Oct 24, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions BelligerentBlocks/src/Platform.cpp
Expand Up @@ -135,8 +135,7 @@ bool Platform::init() {
} }


SC_ScoresController_SetMode(m_scoresController, 0); SC_ScoresController_SetMode(m_scoresController, 0);
SC_ScoresController_SetSearchList(m_scoresController, SC_SCORE_SEARCH_LIST_GLOBAL); SC_ScoresController_SetSearchList(m_scoresController, SC_SCORES_SEARCH_LIST_ALL);
SC_ScoresController_SetTimeInterval(m_scoresController, SC_TIME_INTERVAL_GLOBAL);


struct stat fileInfo; struct stat fileInfo;
if (stat("data/scores.db", &fileInfo) == -1) { if (stat("data/scores.db", &fileInfo) == -1) {
Expand Down Expand Up @@ -372,7 +371,7 @@ void Platform::fetchLeaderboard() {
return; 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) { if (rc != SC_OK) {
fprintf(stderr, "Error loading leaderboard score range: %d\n", rc); fprintf(stderr, "Error loading leaderboard score range: %d\n", rc);
return; return;
Expand Down
58 changes: 12 additions & 46 deletions BelligerentBlocks/src/bbutil.c
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
Expand Down Expand Up @@ -202,61 +201,28 @@ bbutil_init_egl(screen_context_t ctx) {
return EXIT_FAILURE; 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 (0 == env) {
if (rc) { perror("failed getenv for WIDTH");
perror("screen_get_display_property_iv");
bbutil_terminate(); bbutil_terminate();
return EXIT_FAILURE; return EXIT_FAILURE;
} }


int angle = atoi(getenv("ORIENTATION")); int width = atoi(env);


screen_display_mode_t screen_mode; env = getenv("HEIGHT");
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 size[2]; if (0 == env) {
rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); perror("failed getenv for HEIGHT");
if (rc) {
perror("screen_get_window_property_iv");
bbutil_terminate(); bbutil_terminate();
return EXIT_FAILURE; 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)) { rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
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) { if (rc) {
perror("screen_set_window_property_iv"); perror("screen_set_window_property_iv");
bbutil_terminate(); bbutil_terminate();
Expand Down Expand Up @@ -483,7 +449,7 @@ void bbutil_render_text(font_t* font, const char* msg, float x, float y, float r
int i, c; int i, c;
GLfloat *vertices; GLfloat *vertices;
GLfloat *texture_coords; GLfloat *texture_coords;
GLshort* indices; GLushort* indices;


float pen_x = 0.0f; float pen_x = 0.0f;


Expand All @@ -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); vertices = (GLfloat*) malloc(sizeof(GLfloat) * 8 * msg_len);
texture_coords = (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) { for(i = 0; i < msg_len; ++i) {
c = msg[i]; c = msg[i];
Expand Down
53 changes: 10 additions & 43 deletions GoodCitizen/bbutil.c
Expand Up @@ -201,61 +201,28 @@ bbutil_init_egl(screen_context_t ctx) {
return EXIT_FAILURE; 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 (0 == env) {
if (rc) { perror("failed getenv for WIDTH");
perror("screen_get_display_property_iv");
bbutil_terminate(); bbutil_terminate();
return EXIT_FAILURE; return EXIT_FAILURE;
} }


int angle = atoi(getenv("ORIENTATION")); int width = atoi(env);


screen_display_mode_t screen_mode; env = getenv("HEIGHT");
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 size[2]; if (0 == env) {
rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); perror("failed getenv for HEIGHT");
if (rc) {
perror("screen_get_window_property_iv");
bbutil_terminate(); bbutil_terminate();
return EXIT_FAILURE; 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)) { rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
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) { if (rc) {
perror("screen_set_window_property_iv"); perror("screen_set_window_property_iv");
bbutil_terminate(); bbutil_terminate();
Expand Down
23 changes: 8 additions & 15 deletions GoodCitizen/main.c
Expand Up @@ -14,23 +14,24 @@
* limitations under the License. * limitations under the License.
*/ */


#include <screen/screen.h> #include "bbutil.h"

#include <bps/navigator.h> #include <bps/navigator.h>
#include <bps/screen.h> #include <bps/screen.h>
#include <bps/bps.h> #include <bps/bps.h>
#include <bps/event.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 <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <math.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], static GLfloat radio_btn_unselected_vertices[8], radio_btn_selected_vertices[8],
background_portrait_vertices[8], background_landscape_vertices[8], background_portrait_vertices[8], background_landscape_vertices[8],
*background_vertices; *background_vertices;
Expand Down Expand Up @@ -752,14 +753,6 @@ int main(int argc, char *argv[]) {
return 0; 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) { while (!shutdown) {
// Handle user input and accelerometer // Handle user input and accelerometer
handle_events(); handle_events();
Expand Down
53 changes: 10 additions & 43 deletions HelloWorldDisplay/bbutil.c
Expand Up @@ -201,61 +201,28 @@ bbutil_init_egl(screen_context_t ctx) {
return EXIT_FAILURE; 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 (0 == env) {
if (rc) { perror("failed getenv for WIDTH");
perror("screen_get_display_property_iv");
bbutil_terminate(); bbutil_terminate();
return EXIT_FAILURE; return EXIT_FAILURE;
} }


int angle = atoi(getenv("ORIENTATION")); int width = atoi(env);


screen_display_mode_t screen_mode; env = getenv("HEIGHT");
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 size[2]; if (0 == env) {
rc = screen_get_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size); perror("failed getenv for HEIGHT");
if (rc) {
perror("screen_get_window_property_iv");
bbutil_terminate(); bbutil_terminate();
return EXIT_FAILURE; 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)) { rc = screen_set_window_property_iv(screen_win, SCREEN_PROPERTY_BUFFER_SIZE, size);
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) { if (rc) {
perror("screen_set_window_property_iv"); perror("screen_set_window_property_iv");
bbutil_terminate(); bbutil_terminate();
Expand Down
34 changes: 14 additions & 20 deletions HelloWorldDisplay/main.c
Expand Up @@ -14,26 +14,28 @@
* limitations under the License. * limitations under the License.
*/ */


#include <ctype.h> #include "bbutil.h"
#include <unistd.h>
#include <stdio.h> #include <png.h>
#include <stdlib.h>
#include <string.h>
#include <sys/keycodes.h>
#include <screen/screen.h>
#include <bps/navigator.h> #include <bps/navigator.h>
#include <bps/screen.h> #include <bps/screen.h>
#include <bps/bps.h> #include <bps/bps.h>
#include <bps/event.h> #include <bps/event.h>
#include <bps/orientation.h>
#include <math.h>
#include <time.h>
#include <screen/screen.h> #include <screen/screen.h>
#include <sys/keycodes.h>

#include <EGL/egl.h> #include <EGL/egl.h>
#include <GLES/gl.h> #include <GLES/gl.h>


#include "png.h" #include <math.h>
#include "bbutil.h" #include <time.h>
#include <ctype.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


static float width, height; static float width, height;
static GLuint background; static GLuint background;
Expand Down Expand Up @@ -177,14 +179,6 @@ int main(int argc, char **argv) {
return 0; 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 //Signal BPS library that navigator and screen events will be requested
if (BPS_SUCCESS != screen_request_events(screen_cxt)) { if (BPS_SUCCESS != screen_request_events(screen_cxt)) {
fprintf(stderr, "screen_request_events failed\n"); fprintf(stderr, "screen_request_events failed\n");
Expand Down