SDL编程
一、简介
SDL是一个用C编写的跨平台的多媒体库,它通过OpenGL和Direct3D,提供了针对音频、视频、键盘、鼠标、控制杆及3D硬件的低级别的访问接口。它在MPEG播放软件、模拟器以及许多游戏中得到广泛的应用,其中包含了获得大奖的“文明:权力的呼唤”的Linux 版本。
参考:
二、编译安装
参考:
wget http://www.libsdl.org/release/SDL2-2.0.3.tar.gz
tar -zxvf SDL2-2.0.3.tar.gz
cd SDL2-2.0.3
mkdir build
cd build
../configure
make
make install
三、使用实例
example1.c
//Toggle line numbers
#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,
0); // 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;
}
编译
gcc example1.c -o example1 -I/root/workspace/exercise/languages/c/graph/sdl/SDL2-2.0.3/include -L/root/workspace/exercise/languages/c/graph/sdl/SDL2-2.0.3/build/build/.libs -lSDL2
运行

SDL编程的更多相关文章
- SDL简介(网络汇总)
摄像头视频播放采用sdl,下面简单介绍下.不保证正确及网址永远有效.后面文章采用tao框架http://sourceforge.net/projects/taoframework/ SDL. ...
- SDL文字和图形
SDL本身没有显示文字功能,它需要用扩展库SDL_ttf来显示文字.ttf是True Type Font的缩写,ttf是Windows下的缺省字体,它有美观,放大缩小不变形的优点,因此广泛应用很多场合 ...
- ffmpeg 和 SDL 的结合使用
FFmpeg是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.采用LGPL或GPL许可证.它提供了录制.转换以及流化音视 频的完整解决方案.它包含了非常先进的音频/视频编解码库 ...
- 第四章 跨平台图像显示库——SDL 第一节 与SDL第一次亲密接触
http://blog.csdn.net/visioncat/article/details/1596576 GCC for Win32 开发环境介绍(5) 第四章 跨平台图像显示库——SDL 第一节 ...
- 【转】Alsa音频编程【精华】
一.前序 这里了解一下各个参数的含义以及一些基本概念. 声音是连续模拟量,计算机将它离散化之后用数字表示,就有了以下几个名词术语. 样本长度(sample):样本是记录音频数据最基本的单位,计算机对每 ...
- python高级编程(第12章:优化学习)1
# -*- coding: utf-8 -*-# python:2.x__author__ = 'Administrator'#由于5,6,7,8,9,10,11主要是在包,测试之类的学习所以这边就不 ...
- 详细介绍Qt,ffmpeg 和SDL开发
Qt 与 ffmpeg 与 SDl 教程是本文要介绍的内容,从多个角度介绍本文,运用了qmake,先来看内容. 1. 注释 从“ #” 开始,到这一行结束. 2. 指定源文件 1. ...
- SDL 简介
SDL 简介 什么是SDL? 即 Simple DirectMedia Layer,使用 LGPL 许可证. 免费的跨平台多媒体应用编程接口 用于游戏.游戏开发工具.模拟器.样本演示.多媒体应用等 它 ...
- 【C++探索之旅】第一部分第二课:C++编程的必要软件
内容简介 1.第一部分第二课:C++编程的必要软件 2.第一部分第三课预告:第一个C++程序 C++编程的必要软件 经过上一课之后,大家是不是摩拳擦掌,准备大干一场了呢. 这一课我们来做一些C++开发 ...
随机推荐
- EM算法的思考
参考文献1: http://blog.sina.com.cn/s/blog_6c7b434d01013zwe.html 参考文献2: http://www.cnblogs.com/jerrylead/ ...
- ZetCode PyQt4 tutorial basic painting
#!/usr/bin/python # -*- coding: utf-8 -*- """ ZetCode PyQt4 tutorial In this example, ...
- 7-17 Hashing(25 分)
The task of this problem is simple: insert a sequence of distinct positive integers into a hash tabl ...
- nginx rewrite规则实例讲解
一.正则表达式匹配,其中: * ~ 为区分大小写匹配* ~* 为不区分大小写匹配* !~和!~*分别为区分大小写不匹配及不区分大小写不匹配 二.文件及目录匹配,其中:* -f和!-f用来判断是否存在文 ...
- bzoj 4372 烁烁的游戏——动态点分治+树状数组
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4372 和 bzoj 3070 震波 是一个套路.注意区间修改的话,树状数组不能表示 dis ...
- Windows Server 2012/win8 iis8 上安装 asp.net 4.5 当时用了mvc5 .net framework 4.5 所以得装下
vs2013+mvc5 +.net framework 4.5 本地 iisexpress 调试一点问题没有,当部署到本机iis时 出现 无法识别 modules错误,具体错误提示是: 锁定是默认设 ...
- generatorConfig.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...
- HDU 2201 熊猫阿波的故事
熊猫阿波的故事 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Sub ...
- [转]JAVA 反射及使用
<%@page contentType="text/html; charset=GBK"%> <%@page import="java.security ...
- Ubantu 网卡绑定固定IP
# The primary network interface auto eth0 #iface eth0 inet dhcp iface eth0 inet static address 192.1 ...