表面和纹理之间的区别(SDL /一般) [英] Difference between surface and texture (SDL / general)

查看:240
本文介绍了表面和纹理之间的区别(SDL /一般)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以用简单的语言向我解释纹理和表面之间的区别?我看到它在 SDL2 中用作 SDL_Surface SDL_Texture SDL_Texture 是从 SDL_Surface 创建的,而后者又是从图像/位图创建的。两者都是像素的集合。但我没有看到他们之间的主要区别(必须与GPU做些什么?)

我试图谷歌它,但我发现所有解释太复杂,无法理解它们而不是深入研究计算机图形学的东西。

解决方案

基本上你的假设必须用GPU做点什么?是正确的。



SDL_Surface 用于软件渲染。使用软件渲染,正确地注意到 saloomi2012 ,您正在使用常规RAM来存储图像数据。因此,在大多数情况下,您可以直接访问与表面相关的数据缓冲区,修改其内容,即使用CPU,因此使用软件名称。



<另一方面,在硬件 渲染中使用了 c> SDL_Texture ,纹理存储在VRAM中,并且您无法直接访问它与 SDL_Surface 一样。渲染操作由GPU加速,内部使用OpenGL或DirectX(仅在Windows上提供)API,后者反过来使用您的视频硬件,因此使用硬件渲染名称。 b
$ b

毋庸置疑,硬件渲染比软件渲染快几个数量级,应该始终被视为主要选择。


Can anyone explain to me in simple words what is the difference between texture and surface? I saw it used in SDL2 as SDL_Surface and SDL_Texture. SDL_Textureis created from SDL_Surface which in turn is created from image/bitmap. Both are collection of pixels. But I do not see the main difference between them (has to do something with GPU?)

I tried to google it but all explanations I found were too complex to understand them without digging deeper into computer graphics stuff.

解决方案

Basically your assumption "has to do something with GPU?" is right.

SDL_Surface is used in software rendering. With software rendering, as saloomi2012 correctly noticed, you are using regular RAM to store image data. Thus, in most cases you can access data buffer associated with surface directly, modifying its content, i.e. it is using CPU, hence the software name.

SDL_Texture on the other hand, is used in a hardware rendering, textures are stored in VRAM and you don't have access to it directly as with SDL_Surface. The rendering operations are accelerated by GPU, using, internally, either OpenGL or DirectX (available only on Windows) API, which in turn are using your video hardware, hence hardware rendering name.

Needless to say that hardware rendering is by orders of magnitude faster than software rendering and should be always be considered as primary option.

这篇关于表面和纹理之间的区别(SDL /一般)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆