#include <iostream>
#include "../include/SDL.h"
#undef main
using namespace std;
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
int main()
{
//The window we'll be rendering to
SDL_Window* gWindow = NULL;
//The surface contained by the window
SDL_Surface* gScreenSurface = NULL;
//The image we will load and show on the screen
SDL_Surface* gHelloWorld = NULL;
//首先初始化 初始化SD视频子系统
if(SDL_Init(SDL_INIT_VIDEO)<0)
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
return false;
}
//创建窗口
gWindow=SDL_CreateWindow("SHOW BMP",//窗口标题
SDL_WINDOWPOS_UNDEFINED,//窗口位置设置
SDL_WINDOWPOS_UNDEFINED,
SCREEN_WIDTH,//窗口的宽度
SCREEN_HEIGHT,//窗口的高度
SDL_WINDOW_SHOWN//显示窗口
);
if(gWindow==NULL)
{
printf( "Window could not be created! SDL_Error: %s\n", SDL_GetError() );
return false;
}
//Use this function to get the SDL surface associated with the window.
//获取窗口对应的surface
gScreenSurface=SDL_GetWindowSurface(gWindow);
//加载图片
gHelloWorld = SDL_LoadBMP("../Hello_World.bmp");//加载图片
if( gHelloWorld == NULL )
{
printf( "Unable to load image %s! SDL Error: %s\n", "Hello_World.bmp", SDL_GetError() );
return false;
}
//Use this function to perform a fast surface copy to a destination surface.
//surface的快速复制
//下面函数的参数分别为: SDL_Surface* src ,const SDL_Rect* srcrect , SDL_Surface* dst , SDL_Rect* dstrect
SDL_BlitSurface( gHelloWorld , NULL , gScreenSurface , NULL);
SDL_UpdateWindowSurface(gWindow);//更新显示copy the window surface to the screen
SDL_Delay(2000);//延时2000毫秒
//释放内存
SDL_FreeSurface( gHelloWorld );//释放空间
gHelloWorld = NULL;
SDL_DestroyWindow(gWindow);//销毁窗口
gWindow = NULL ;
SDL_Quit();//退出SDL
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
QT_SDL.rar (82个子文件)
QT_SDL
SDL_Test
SDL_Test.pro.user 18KB
main.cpp 2KB
SDL_Test.pro 874B
deployment.pri 7KB
Hello_World.bmp 900KB
include
SDL_power.h 2KB
SDL_pixels.h 15KB
SDL_revision.h 77B
SDL_test_assert.h 3KB
SDL_system.h 7KB
SDL_haptic.h 38KB
SDL_scancode.h 15KB
SDL_blendmode.h 2KB
SDL_test_crc32.h 3KB
SDL_quit.h 2KB
SDL_log.h 6KB
SDL_filesystem.h 5KB
SDL_test_harness.h 4KB
SDL_mouse.h 7KB
SDL_loadso.h 3KB
SDL_version.h 5KB
SDL_messagebox.h 5KB
SDL_test_images.h 2KB
SDL_bits.h 2KB
SDL_audio.h 20KB
begin_code.h 4KB
SDL_rwops.h 7KB
SDL_opengles.h 1KB
SDL_test.h 2KB
SDL_video.h 33KB
SDL_touch.h 2KB
close_code.h 1KB
SDL_error.h 2KB
SDL_test_random.h 3KB
SDL_render.h 32KB
SDL_hints.h 19KB
SDL_gamecontroller.h 10KB
SDL_cpuinfo.h 4KB
SDL_test_compare.h 2KB
SDL_assert.h 10KB
SDL_keycode.h 14KB
SDL_opengles2.h 129KB
SDL_events.h 26KB
SDL_endian.h 6KB
SDL_gesture.h 2KB
SDL_config.h 5KB
SDL_mutex.h 7KB
SDL_atomic.h 9KB
SDL_stdinc.h 14KB
SDL_test_md5.h 5KB
SDL_platform.h 4KB
SDL.h 5KB
SDL_test_common.h 5KB
SDL_main.h 4KB
SDL_opengl.h 622KB
SDL_test_fuzzer.h 13KB
SDL_keyboard.h 6KB
SDL_test_log.h 2KB
SDL_clipboard.h 2KB
SDL_shape.h 6KB
SDL_thread.h 10KB
SDL_syswm.h 7KB
SDL_name.h 1KB
SDL_rect.h 4KB
SDL_test_font.h 2KB
SDL_joystick.h 8KB
SDL_types.h 1KB
SDL_timer.h 3KB
SDL_surface.h 18KB
lib
x86
SDL2main.lib 40KB
SDL2.dll 984KB
SDL2test.lib 802KB
SDL2.lib 114KB
x64
SDL2main.lib 42KB
SDL2.dll 1.14MB
SDL2test.lib 823KB
SDL2.lib 111KB
build-SDL_Test-Desktop_Qt_5_4_1_MinGW_32bit-Debug
Makefile.Debug 12KB
Makefile.Release 12KB
debug
SDL_Test.exe 99KB
main.o 20KB
Makefile 19KB
release
共 82 条
- 1
资源评论
- hshy1227302015-12-13有用,借鉴和收藏了
- darrenX_X2016-07-03有用,可以学习借鉴
hjl240
- 粉丝: 142
- 资源: 28
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功