Declarative 2D camera (viewport center + zoom). 更多...
#include <RenderSystem.h>
类 | |
| struct | Data |
| Data public API. 更多... | |
Public 成员函数 | |
| void | release () override |
| Entity. | |
| void | setAmbient (float r, float g, float b) |
| void | setPosition (float x, float y) |
| World-space look-at center and zoom (1 = identity). | |
| float | getX () |
| float | getY () |
| void | setZoom (float zoom) |
| float | getZoom () |
| Result< void > | setPixelConfig (float pixelsPerUnit, int refWidth=0, int refHeight=0) |
| Store perfect-pixel sizing (pixels-per-unit and optional reference resolution). | |
| void | clearPixelConfig () |
| Clear reference resolution and restore default pixels-per-unit of 1. | |
| void | setPixelPerfect (bool enabled) |
| Enable or disable automatic perfect-pixel zoom resolution. | |
| bool | getPixelPerfect () |
| Return whether perfect-pixel resolution is enabled. | |
| void | setPixelSnap (bool enabled) |
| Enable or disable snapping the camera center onto the pixel grid. | |
| bool | getPixelSnap () |
| Return whether pixel-grid snapping is enabled. | |
| Result< void > | applyPixelPerfect (int viewWidth, int viewHeight) |
| Resolve integer zoom (and optional position snap) from the live viewport. | |
| float | getPixelsPerUnit () |
| Return configured pixels per world unit. | |
| int | getPixelRefWidth () |
| Return reference width, or 0 when unset. | |
| int | getPixelRefHeight () |
| Return reference height, or 0 when unset. | |
| int | getPixelScale () |
| Return the last integer upscale from applyPixelPerfect. | |
| float | screenToWorldX (float screenX, float screenY, float viewW, float viewH) |
| Convert screen pixel (origin top-left of viewport) to world coordinates. viewW/viewH are the current drawable size (e.g. gfx.getWidth/Height). | |
| float | screenToWorldY (float screenX, float screenY, float viewW, float viewH) |
| float | worldToScreenX (float worldX, float worldY, float viewW, float viewH) |
| float | worldToScreenY (float worldX, float worldY, float viewW, float viewH) |
静态 Public 成员函数 | |
| static Camera2D * | createCamera (ecs::Table &table= *ecs::current()) |
| Create an active camera in the current ECS table. | |
详细描述
Declarative 2D camera (viewport center + zoom).
在文件 RenderSystem.h 第 20 行定义.
成员函数说明
◆ applyPixelPerfect()
| Result< void > eve::graphics::Camera2D::applyPixelPerfect | ( | int | viewWidth, |
| int | viewHeight | ||
| ) |
Resolve integer zoom (and optional position snap) from the live viewport.
- 参数
-
viewWidth Drawable width in pixels; must be > 0. viewHeight Drawable height in pixels; must be > 0.
- 返回
- InvalidArgument for a non-positive viewport. @cost O(1).
在文件 RenderSystem.cpp 第 154 行定义.
引用了 eve::graphics::computePixelPerfectScale(), d, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::graphics::snapWorldToPixel() , 以及 eve::Result< T >::success().
◆ clearPixelConfig()
| void eve::graphics::Camera2D::clearPixelConfig | ( | ) |
Clear reference resolution and restore default pixels-per-unit of 1.
在文件 RenderSystem.cpp 第 141 行定义.
引用了 d.
◆ createCamera()
|
static |
Create an active camera in the current ECS table.
- 参数
-
table ECS table owning the result; defaults to the calling thread's current table.
- 返回
- ECS-owned camera with its self reference initialized. @ownership ECS owns the result. @lifetime Valid until ECS destroys the entity.
- 注解
- Call on the current ECS table owner thread; no external callbacks are invoked. @cost Allocates entity/component storage per camera creation.
在文件 CameraFactory.cpp 第 7 行定义.
引用了 c.
◆ getPixelPerfect()
| bool eve::graphics::Camera2D::getPixelPerfect | ( | ) |
Return whether perfect-pixel resolution is enabled.
在文件 RenderSystem.cpp 第 150 行定义.
◆ getPixelRefHeight()
| int eve::graphics::Camera2D::getPixelRefHeight | ( | ) |
Return reference height, or 0 when unset.
在文件 RenderSystem.cpp 第 173 行定义.
◆ getPixelRefWidth()
| int eve::graphics::Camera2D::getPixelRefWidth | ( | ) |
Return reference width, or 0 when unset.
在文件 RenderSystem.cpp 第 172 行定义.
◆ getPixelScale()
| int eve::graphics::Camera2D::getPixelScale | ( | ) |
Return the last integer upscale from applyPixelPerfect.
在文件 RenderSystem.cpp 第 174 行定义.
◆ getPixelSnap()
| bool eve::graphics::Camera2D::getPixelSnap | ( | ) |
Return whether pixel-grid snapping is enabled.
在文件 RenderSystem.cpp 第 152 行定义.
◆ getPixelsPerUnit()
| float eve::graphics::Camera2D::getPixelsPerUnit | ( | ) |
Return configured pixels per world unit.
在文件 RenderSystem.cpp 第 171 行定义.
◆ getX()
| float eve::graphics::Camera2D::getX | ( | ) |
在文件 RenderSystem.cpp 第 117 行定义.
◆ getY()
| float eve::graphics::Camera2D::getY | ( | ) |
在文件 RenderSystem.cpp 第 118 行定义.
◆ getZoom()
| float eve::graphics::Camera2D::getZoom | ( | ) |
在文件 RenderSystem.cpp 第 121 行定义.
◆ release()
|
inlineoverride |
◆ screenToWorldX()
| float eve::graphics::Camera2D::screenToWorldX | ( | float | screenX, |
| float | screenY, | ||
| float | viewW, | ||
| float | viewH | ||
| ) |
Convert screen pixel (origin top-left of viewport) to world coordinates. viewW/viewH are the current drawable size (e.g. gfx.getWidth/Height).
在文件 RenderSystem.cpp 第 176 行定义.
◆ screenToWorldY()
| float eve::graphics::Camera2D::screenToWorldY | ( | float | screenX, |
| float | screenY, | ||
| float | viewW, | ||
| float | viewH | ||
| ) |
在文件 RenderSystem.cpp 第 182 行定义.
◆ setAmbient()
| void eve::graphics::Camera2D::setAmbient | ( | float | r, |
| float | g, | ||
| float | b | ||
| ) |
◆ setPixelConfig()
| Result< void > eve::graphics::Camera2D::setPixelConfig | ( | float | pixelsPerUnit, |
| int | refWidth = 0, |
||
| int | refHeight = 0 |
||
| ) |
Store perfect-pixel sizing (pixels-per-unit and optional reference resolution).
- 参数
-
pixelsPerUnit Screen pixels per world unit at scale 1; must be finite and > 0. refWidth Virtual width in pixels; 0 skips integer fitting. refHeight Virtual height in pixels; 0 skips integer fitting.
- 返回
- InvalidArgument when pixelsPerUnit or a positive reference size is invalid.
在文件 RenderSystem.cpp 第 123 行定义.
引用了 d, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument , 以及 eve::Result< T >::success().
◆ setPixelPerfect()
| void eve::graphics::Camera2D::setPixelPerfect | ( | bool | enabled | ) |
Enable or disable automatic perfect-pixel zoom resolution.
在文件 RenderSystem.cpp 第 149 行定义.
引用了 enabled.
◆ setPixelSnap()
| void eve::graphics::Camera2D::setPixelSnap | ( | bool | enabled | ) |
Enable or disable snapping the camera center onto the pixel grid.
在文件 RenderSystem.cpp 第 151 行定义.
引用了 enabled.
◆ setPosition()
| void eve::graphics::Camera2D::setPosition | ( | float | x, |
| float | y | ||
| ) |
World-space look-at center and zoom (1 = identity).
在文件 RenderSystem.cpp 第 111 行定义.
◆ setZoom()
| void eve::graphics::Camera2D::setZoom | ( | float | zoom | ) |
在文件 RenderSystem.cpp 第 120 行定义.
引用了 zoom.
◆ worldToScreenX()
| float eve::graphics::Camera2D::worldToScreenX | ( | float | worldX, |
| float | worldY, | ||
| float | viewW, | ||
| float | viewH | ||
| ) |
在文件 RenderSystem.cpp 第 188 行定义.
◆ worldToScreenY()
| float eve::graphics::Camera2D::worldToScreenY | ( | float | worldX, |
| float | worldY, | ||
| float | viewW, | ||
| float | viewH | ||
| ) |
在文件 RenderSystem.cpp 第 194 行定义.
该类的文档由以下文件生成:
- src/modules/graphics/RenderSystem.h
- src/modules/graphics/CameraFactory.cpp
- src/modules/graphics/RenderSystem.cpp