Cairo, SDL compilation and running on iOS platform

Source: Internet
Author: User
Tags cairo

I wrote blobsalad code from the Internet (click to open the link), which is interesting. I want to transplant it to the iOS platform.

The program requires Cairo and SDL. First, compile their iOS platform library.

SDL 1.3 supports IOS compilation.

Compile Cairo:

Cairo depends on libpng and pixman again to download the source code of these two libraries.

Simulator compilation and installation libpng pixman

. /Configure cc = "/developer/platforms/iphonesimulator. platform/developer/usr/bin/GCC-STD = c99-arch i386-isysroot/developer/platforms/iphonesimulator. platform/developer/sdks/iphonesimulator5.0.sdk/"Ar ="/developer/platforms/iphonesimulator. platform/developer/usr/bin/AR"

Everything went well, but it was not suitable for Cairo compilation. So, after trying again and turning off n multiple features, the compilation was successful:

. /Configure cc = "/developer/platforms/iphonesimulator. platform/developer/usr/bin/GCC-STD = gnu99-arch i386-isysroot/developer/platforms/iphonesimulator. platform/developer/sdks/iphonesimulator5.0.sdk/-miphoneos-version-min = 5.0 "Ar ="/developer/platforms/iphonesimulator. platform/developer/usr/bin/AR"
-- Enable-xlib = No -- enable-xlib-xrender = No -- enable-FT = No -- enable-script = No -- enable-PS = No -- enable-PDF = No -- enable -SVG = No -- enable-trace = No -- enable-interpreter = No -- enable-PNG = No

Real machine Compilation:

Armv6:

. /Configure -- Host = arm-apple-darwin10 cc = "/developer/platforms/iphoneos. platform/developer/usr/bin/GCC-STD = gnu99-arch armv6-isysroot/developer/platforms/iphoneos. platform/developer/sdks/iphoneos4.2.sdk"

. /Configure -- Host = arm-apple-darwin10 cc = "/developer/platforms/iphoneos. platform/developer/usr/bin/GCC-STD = gnu99-arch armv6-isysroot/developer/platforms/iphoneos. platform/developer/sdks/iphoneos4.2.sdk/"-- enable-xlib = No -- enable-xlib-xrender = No
-- Enable-FT = No -- enable-script = No -- enable-PS = No -- enable-PDF = No -- enable-SVG = No -- enable-trace = No -- enable-Interpreter = No -- enable-PNG = No

Armv7:

. /Configure -- Host = arm-apple-darwin10 cc = "/developer/platforms/iphoneos. platform/developer/usr/bin/GCC-STD = gnu99-arch armv7-isysroot/developer/platforms/iphoneos. platform/developer/sdks/iphoneos4.2.sdk"

. /Configure -- Host = arm-apple-darwin10 cc = "/developer/platforms/iphoneos. platform/developer/usr/bin/GCC-STD = gnu99-arch armv7-isysroot/developer/platforms/iphoneos. platform/developer/sdks/iphoneos4.2.sdk/"-- enable-xlib = No -- enable-xlib-xrender = No
-- Enable-FT = No -- enable-script = No -- enable-PS = No -- enable-PDF = No -- enable-SVG = No -- enable-trace = No -- enable-Interpreter = No -- enable-PNG = No

Create an iOS project.

Drag the compiled Cairo. A, SDL. A, and pixman. A to the project.

Add several frameworks: audiotoolbox, audiocore, quartzcore, and opengles.

An error occurred while compiling the code for the first time.

The reason is that SDL 1.2 is used for blob, and some APIs are modified on 1.3.

I have learned how to use it. I have made some changes based on the API name and can run it. However, the method may not be standard. please correct me.

1.3 does not support direct surface painting, but uses Windows and render control.

No direct connection was found between surface and render, so texture was used.

1. In bs_cairo.c, create a screen and modify it:

    SDL_Window *window = SDL_CreateWindow(NULL, 0, 0, width, height,                     SDL_WINDOW_SHOWN);        pCairoSdl->pRender = SDL_CreateRenderer(window, -1, 0);        if (pCairoSdl->pRender == NULL) {        fprintf(stderr, "SDL_CreateSoftwareRenderer failed: %s\n", SDL_GetError());         exit(1);     }        pCairoSdl->pScreen = SDL_CreateRGBSurface (SDL_SWSURFACE,  width,  height, 32, 0,0,0,0);      if(pCairoSdl->pScreen == NULL)  {    fprintf(stderr, "SDL_SetVideoMode failed: %s\n", SDL_GetError());     exit(1);   }        pCairoSdl->pTexture = SDL_CreateTextureFromSurface(pCairoSdl->pRender, pCairoSdl->pScreen);    if(pCairoSdl->pTexture == NULL)    {        fprintf(stderr, "SDL_CreateTextureFromSurface failed: %s\n", SDL_GetError());         exit(1);     }

2. bs_main:

    SDL_DestroyTexture(pMainData->pCairoSdl->pTexture);    pMainData->pCairoSdl->pTexture = SDL_CreateTextureFromSurface( pMainData->pCairoSdl->pRender, pMainData->pCairoSdl->pScreen);        SDL_RenderCopy(pMainData->pCairoSdl->pRender, pMainData->pCairoSdl->pTexture, &srcRect, &dstRect);            SDL_RenderPresent(pMainData->pCairoSdl->pRender);

Success:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.