【转】Hello SDL
from:http://lazyfoo.net/tutorials/SDL/01_hello_SDL/index.php
Last Updated 6/11/19
So you learned the basics of C++, but you're sick of making little text based programs. In order to use things like graphics, sound, keyboards, joysticks, etc you need an API (Application Programmer's Interface) that takes all those hardware features and turns it into something C++ can interact with.
That's what SDL does. It takes the Windows/Linux/Mac/Android/iOS/etc tools and wraps them in a way that you can code something in SDL and compile it to what ever platform it supports. In order to use it, you need to install it.
SDL as a dynamically linked library. A dynamically linked library has 3 parts:
- The header files (Library.h)
- The library files (Library.lib for windows or libLibrary.a for *nix)
- The binary files (Library.dll for windows or Library.so for *nix)
Your compiler needs to be able to find the header files when compiling so it knows what SDL_Init() and the other SDL functions and structures are. You can either configure your compiler to search in an additional directory where the SDL header files are located, or put the header files in with the rest of header files that your compiler comes with. If the compiler complains that it can't find SDL.h, it means the header files aren't in a place that the compiler looks for header files.
After your compiler compiles all your source files it has to link them together. In order for the program to link properly, it needs to know the addresses of all your functions including the ones for SDL. For a dynamically linked library, these addresses are in the library file. The library file has the Import Address Table so your program can import the functions at runtime. Like with header files, You can either configure your compiler to search in an additional directory where the SDL library files are located, or put the library files in with the rest of library files that your compiler comes with. You also have to tell the linker to link against the library file in the linker. If the linker complains that it can't find -lSDL or SDL2.lib, it means the library files aren't in a place that the linker looks for library files. If the linker complains about an undefined reference, it probably means it was never told to link the library.
After your program is compiled and linked, you need to be able to link against the library when you run it. In order to run a dynamically linked application, you need to be able to import the library binaries at runtime. Your operating system needs to be able to find the library binary when you run your program. You can either put the library binaries in the same directory as your executable, or a directory that your operating system keeps library binary files.
After you set up SDL, we'll cover how to create an SDL 2 window.
【转】Hello SDL的更多相关文章
- Visual studio 通用开发环境配置:SDL,FFMPEG为例
引言 每一个C++库的使用都是从开发环境的配置开始的,其实每个库的配置过程都是大同小异,总结下来有下面几个步骤: 下载库文件,这里假定是已经预先编译完成的. 配置库文件的包含目录(include)和库 ...
- SDL 1.2.15 issue
SDL 1.2.15中,对于X11的函数,默认采用动态加载的方式 但相应的X11函数名在SDL中并没有重新命名(SDL2中都添加了前缀X11_) 这样在SDL与其他库混合静态编译链接时,X11的函数就 ...
- SDL简介(网络汇总)
摄像头视频播放采用sdl,下面简单介绍下.不保证正确及网址永远有效.后面文章采用tao框架http://sourceforge.net/projects/taoframework/ SDL. ...
- SDL第一个程序:加载一张图片
直接看代码吧 using System; using System.Collections.Generic; using System.ComponentModel; using System.Dat ...
- SDL文字和图形
SDL本身没有显示文字功能,它需要用扩展库SDL_ttf来显示文字.ttf是True Type Font的缩写,ttf是Windows下的缺省字体,它有美观,放大缩小不变形的优点,因此广泛应用很多场合 ...
- SDL鼠标事件
鼠标事件有这么多种,手柄的可以忽视,Sdl.SDL_KEYDOWN,Sdl.SDL_KEYUP,Sdl.SDL_MOUSEMOTION,Sdl.SDL_MOUSEBUTTONDOWN,Sdl.SDL_ ...
- SDL绑定播放窗口 及 视频窗口缩放
绑定播放窗口 必须在Sdl.SDL_Init之前执行 Sdl.SDL_putenv 同时SDL_SetVideoMode里播放窗口长宽不能大于绑定窗口的长宽 int i = Sdl.SDL_puten ...
- SDL 显示解码后的yuv12数据
在上篇h264解码为yuv12后http://jhlong12345.blog.163.com/blog/static/1230631292015725115058709/ ,需要显示出来,使用sdl ...
- SDL 截图、录像、录像播放
截图 使用sdl很简单,视频显示窗口大小,不是视频分辨率大小 int i = Sdl.SDL_SaveBMP(surfacePtr, path); if(i != 0) { MessageBox.Sh ...
- 简单播放器(增加sdl事件控制)
#include <libavcodec/avcodec.h> #include <libavformat/avformat.h> #include <libswscal ...
随机推荐
- js自动生成条形码插件-JsBarcode
JsBarcode.html <!DOCTYPE html> <html lang="en"> <head> <meta charset= ...
- spring+springmvc+mybatis+shiro
创建maven框架https://blog.csdn.net/Ajax_mt/article/details/78549119 具体下边 https://blog.csdn.net/w2222288/ ...
- RabbitMq如何确保消息不丢失
上篇写了掌握Rabbitmq几个重要概念,从一条消息说起,这篇来总结关于消息丢失让人头痛的事情.网络故障.服务器重启.硬盘损坏等都会导致消息的丢失.消息从生产到消费主要结果以下几个阶段如下图. ①生产 ...
- day61:Linux:权限管理&rpm软件包管理&yum工具
目录 1.权限管理 2.rpm软件包管理 3.yum工具(联网) 权限管理 1.什么是权限? 权限主要用来约束用户能对系统所做的操作 2.为什么要使用权限? 因为系统中不可能只存在一个root用户,一 ...
- Python其他数据结构collection模块-namtuple defaultdict deque Queue Counter OrderDict arrary
nametuple 是tuple扩展子类,命名元组,其实本质上简单类对象 from collections import namedtuple info = namedtuple("Info ...
- matlab中的polyfit函数。
来源:https://blog.csdn.net/zhaluo0051/article/details/77949170 :https://blog.csdn.net/g28_gwf/article/ ...
- 版本控制系统之git
一.简介 git是Linux内核项目发起者linus用C语言写的,主要用来做项目的版本控制追踪:git是无中心节点的分布式版本控制系统,也是目前很流行的版本控制系统:其安装简单,使用简单:相比传统的c ...
- Java bean 链式获取成员变量无需判空的工具设计
Java bean 链式获取成员变量无需判空的工具设计 本篇文章已发布至公众号 Hollis 对于Java程序员来说,null是令人头痛的东西.时常会受到空指针异常(NPE)的骚扰.连Java的发明者 ...
- Dubbo部分知识点总结
Dubbo部分 Dubbo工作原理 dubbo工作原理第一层:service层,接口层,给服务提供者和消费者来实现的第二层:config层,配置层,主要是对dubbo进行各种配置的第三层:proxy层 ...
- JavaWeb01_html&css
一. html简介 1. 什么是html ①. HyperText Markup Language:超文本标记语言,是最基本的网页语言 ②. 超文本:超出文本范畴 ③. 标记:标记就是标签,html所 ...