c - SDL 相对位置

标签 c sdl

我有一个关于 SDL Surface 光标的理论问题。 如果我想在屏幕上显示 surface_A,我将使用通过 SDL_Rectcursor; 创建的光标,并将其与 SDL_BlitSurface(); 一起使用。 光标将包含相对于窗口左上角的位置。

但是如果我想在surface_A内显示surface_B,我是否必须指示相对于窗口左上角或surface_A左上角的光标?

最佳答案

您可能对光标的相对位置做出了一些错误的假设。链接位置有一套非常好的、详细的教程,可以帮助您解决问题...

来自 HERE ...

Using the first tutorial as our base, we'll delve more into the world of SDL surfaces. As I attempted to explain in the last lesson, SDL Surfaces are basically images stored in memory. Imagine we have a blank 320x240 pixel surface. Illustrating the SDL coordinate system, we have something like this:

enter image description here

This coordinate system is quite different than the normal one you are familiar with. Notice how the Y coordinate increases going down, and the X coordinate increases going right. Understanding the SDL coordinate system is important in order to properly draw images on the screen.

一些可能有助于澄清的附加术语:

SDL Window :您可以将其视为物理像素,或您的显示器
SDL Renderer :控制在该窗口中创建的内容的属性/设置。

关于c - SDL 相对位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50837849/

相关文章:

c - 不适用于 gcc 的代码

c - typedef 枚举 : Different values for one member

SDL:在非全屏模式下查找最大窗口大小

c++ - 与类中的变量混淆

c++ - 带有 SDL 的对话框/消息框?

c - 为什么这个带有 "abort()"的 C 程序不会崩溃?

c - 这些类型 (int (*ptr)[3]) = a; (其中 a => int a[][3] = {1,2,3,4,5,6})的语句在 C 中有效吗?增量 "ptr"给出了意外的结果

xcode - Sdl objective c++ 和 xcode 在游戏中包含 sdl 框架

c - 为什么gsl没有单独的 vector *矩阵乘法函数?

c++ - 在定义后包含时, header 中的值设置为 NULL