sdl显示一张bmp图片示例

Caltha ·
更新时间:2024-09-20
· 778 次阅读

lesson01.cpp

代码如下:
/*This source code copyrighted by Lazy Foo' Productions (2004-2013)
and may not be redistributed without written permission.*/

//Include SDL functions and datatypes
#include "SDL/SDL.h"

int main( int argc, char* args[] )
{
    //The images
    SDL_Surface* hello = NULL;
    SDL_Surface* screen = NULL;

    //Start SDL
    SDL_Init( SDL_INIT_EVERYTHING );

    //Set up screen
    screen = SDL_SetVideoMode( 640, 480, 32, SDL_SWSURFACE );

    //Load image
    hello = SDL_LoadBMP( "hello.bmp" );

    //Apply image to screen
    SDL_BlitSurface( hello, NULL, screen, NULL );

    //Update Screen
    SDL_Flip( screen );

    //Pause
    SDL_Delay( 2000 );

    //Free the loaded image
    SDL_FreeSurface( hello );

    //Quit SDL
    SDL_Quit();

    return 0;
}

您可能感兴趣的文章:Android下SDL2实现五子棋游戏Android利用OpenGLES绘制天空盒实例教程android使用OPENGL ES绘制圆柱体opengl实现任意两点间画圆柱体OpenGL ES纹理详解Android开发之OpenGL绘制2D图形的方法分析VS2015下OpenGL库配置教程SDL2和OpenGL使用踩坑笔记经验分享



bmp图片 sdl 示例

需要 登录 后方可回复, 如果你还没有账号请 注册新账号