Blackberry Passport >> Core Native (C/C++) >> SDL 1.2

Image


main.cpp

#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <SDL.h>
#include <SDL_image.h>

int main(int argc, char* args[])
{
  if(SDL_Init(SDL_INIT_VIDEO) != 0){
    printf("%s, failed to SDL_Init\n", __func__);
    return -1;
  }

  SDL_Surface* screen;
  screen = SDL_SetVideoMode(1440, 1440, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
  if(screen == NULL){
    printf("%s, failed to SDL_SetVideMode\n", __func__);
    return -1;
  }

  SDL_Surface* png = IMG_Load("app/native/main.png");
  if(png == NULL){
    printf("%s, failed to IMG_Load\n", __func__);
    return -1;
  }

  SDL_ShowCursor(0);
  SDL_BlitSurface(png, NULL, screen, NULL);
  SDL_Flip(screen);
  SDL_Delay(30000);
  SDL_FreeSurface(png);
  SDL_Quit();
  return 0;    
}

bar-descriptor.xml

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<qnx xmlns="http://www.qnx.com/schemas/application/1.0">
  <id>com.steward.sdl.ch3</id>
  <name>ch3</name>
  <filename>ch3</filename>
  <versionNumber>1.0.0</versionNumber>
  <buildId>1</buildId>
  <description>Lesson 3. Extension Libraries and Loading Other Image Formats</description>

  <author>Steward</author>
  <authorId>gYAAgGE4qaHzBnzEAu8JKe4G1OI</authorId>

  <asset path="main" entry="true" type="Qnx/Elf">main</asset>
  <asset path="main.png">main.png</asset>
  <asset path="lib" type="Qnx/Elf">lib</asset>

  <permission system="true">run_native</permission>
  <env var="LD_LIBRARY_PATH" value="app/native/lib"/>
</qnx>

Makefile

main: main.cpp
	ntoarmv7-gcc main.cpp -g -o main lib/libSDL-1.2.so.11 -Iinclude lib/libSDL_image-1.2.so.8 libwebp.a
	blackberry-nativepackager -package main.bar bar-descriptor.xml -devMode -debugToken ${HOME}/.rim/debugtoken_q30.bar
	#gcc main.cpp -o main -lSDL -I/usr/include/SDL

clean:
	rm -rf main
	rm -rf main.bar

完成


返回上一頁