Android SDL2.0 编译

1,下载:

wget http://www.libsdl.org/tmp/SDL-2.0.tar.gz  


2, 解压:

tar -xvf  SDL-2.0.tar.gz   

3,
cd SDL-2.0.0-6609/android-project/jni  && mkdir SDL   

4,
将$SDL-2.0.0-7420根目录下的 include src 和 Android.mk文件拷贝到
$SDL-2.0.0-7420/android-project/jni/SDL 目录下
cp ../../src/ SDL/ -R &&   cp ../../include/ SDL/ -R &&  cp ../../Android.mk SDL/  



5,修改 $SDL-2.0.0-7420/android-project/jni/SDL/src/Android.mk文件
vim src/Android.mk 将  YourSourceHere.c 改成main.c

6, 在src在建立main.c内容如下:

#include "SDL.h"

int main(int argc, char* argv[])
{
        SDL_Window* window;
        SDL_Renderer* renderer;

        // Initialize SDL.
        if (SDL_Init(SDL_INIT_VIDEO) < 0)
                return 1;

        // Create the window where we will draw.
        window = SDL_CreateWindow("SDL_RenderClear",
                        SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
                        512, 512,
                        SDL_WINDOW_SHOWN);

        // We must call SDL_CreateRenderer in order for draw calls to affect this window.
        renderer = SDL_CreateRenderer(window, -1, 0);

        // Select the color for drawing. It is set to red here.
        SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255);

        // Clear the entire screen to our selected color.
        SDL_RenderClear(renderer);

        // Up until now everything was drawn behind the scenes.
        // This will show the new, red contents of the window.
        SDL_RenderPresent(renderer);

        // Give us time to see the window.
        SDL_Delay(5000);

        // Always be sure to clean up
        SDL_Quit();
        return 0;
}


7, ndk-build -j4
8, 编译完成以后,创建eclipse工程启动,看到红色activity及成功。

你可能感兴趣的:(android)