关于在iOS下使用SDL的问题,求教
黄舟
黄舟 2017-04-17 15:51:27
0
2
309
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

Antworte allen(2)
PHPzhong

自己折腾了好久,下面是正确的姿势,然后还在研究画线,有用过SDL的大神求指点求鞭挞,不要怜惜我是一朵娇花

static SDL_Texture *texture = 0;
///更新界面
void render(SDL_Renderer *renderer) {
    /* fill background in with black */
    SDL_RenderClear(renderer);
    SDL_RenderCopy(renderer, texture, NULL, NULL);
    /* update screen */
    SDL_RenderPresent(renderer);
}
///初始化纹理
void initializeTexture(SDL_Renderer *renderer) {
    SDL_Surface *bmp_surface;
    /* load the bmp */
    bmp_surface = SDL_LoadBMP("space.bmp");
    if (bmp_surface == NULL) {
        fatalError("could not load bmp");
    }
    texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
    if (texture == 0) {
        fatalError("could not create texture");
    }
    SDL_SetColorKey(bmp_surface, 1,
                    SDL_MapRGB(bmp_surface->format, 0, 0, 255));
    SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
    /* free up allocated memory */
    SDL_FreeSurface(bmp_surface);
}

void loadBMP(void) {
    SDL_Window *window;
    SDL_Renderer *renderer;
    
    /* 初始化 SDL */
    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        fatalError("Could not initialize SDL");
    }
    /* 创建window */
    window = SDL_CreateWindow("加载背景图", 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT,
                              SDL_WINDOW_OPENGL |
                              SDL_WINDOW_BORDERLESS);

    /* 设置渲染器 */
    renderer = SDL_CreateRenderer(window, -1, 0);
    
    initializeTexture(renderer);
    
    int done = 0;
    while (!done) {
        SDL_Event event;
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_QUIT) {
                done = 1;
            }
        }
        render(renderer);
        SDL_Delay(1000);
    }
    /* cleanup */
    SDL_DestroyTexture(texture);
    /* shutdown SDL */
    SDL_Quit();
}
刘奇

请问你是用什么打包SDL静态库的,安照官方文档的做法,打包会提示gcc不能用

Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage