帧缓冲#
FrameBuffer#
- class arcade.gl.Framebuffer(ctx: Context, *, color_attachments=None, depth_attachment=None)[源代码]#
基类:
object
屏幕外渲染目标在OpenGL中也称为帧缓冲区对象。此实现使用的是纹理附件。创建帧缓冲区时,我们为其提供要将场景渲染到其中的纹理。使用纹理附件的优势是我们能够继续处理帧缓冲区的内容。
创建帧缓冲区的最佳方式是通过
arcade.gl.Context.framebuffer()
::# Create a 100 x 100 framebuffer with one attachment ctx.framebuffer(color_attachments=[ctx.texture((100, 100), components=4)]) # Create a 100 x 100 framebuffer with two attachments # Shaders can be configured writing to the different layers ctx.framebuffer( color_attachments=[ ctx.texture((100, 100), components=4), ctx.texture((100, 100), components=4), ] )
- 参数
ctx (Context) -- 此帧缓冲区所属的上下文
color_attachments (List[arcade.gl.Texture]) -- 颜色附件列表。
depth_attachment (arcade.gl.Texture) -- 深度附件(可选)
- is_default = False#
这是默认的帧缓冲区吗?(窗口缓冲区)
- property glo: ctypes.c_uint#
帧缓冲区的OpenGL ID/名称
- 类型
GLuint
- property viewport: Tuple[int, int, int, int]#
获取或设置帧缓冲区的视区。视区参数为
(x, y, width, height)
。它确定应渲染到帧缓冲区的哪个部分。默认情况下,该视口为(0, 0, width, height)
。每次绑定帧缓冲区时,都会自动应用视口值为永久的所有内容。
示例::
# 100, x 100 lower left with size 200 x 200px fb.viewport = 100, 100, 200, 200
- property scissor: Optional[Tuple[int, int, int, int]]#
获取或设置此帧缓冲区的剪贴框。
默认情况下,剪裁框处于禁用状态,不起作用,初始值为
None
。设置值时启用剪贴框,设置为时禁用剪贴框None
#在100 x 100像素的左下角区域#设置并启用剪贴框仅绘制#ctx.scissor=0,0,100,100#禁用剪裁ctx.scissor=无
- 类型
元组(x,y,宽度,高度)
- property color_attachments: List[arcade.gl.texture.Texture]#
颜色附件列表
- 类型
- property depth_attachment: arcade.gl.texture.Texture#
深度依恋
- property depth_mask: bool#
获取或设置深度蒙版(默认:
True
)。它确定启用深度测试时是否应将深度值写入深度纹理。每次绑定帧缓冲区时,将自动应用所有深度遮罩值。
- 类型
布尔尔
- clear(color=(0.0, 0.0, 0.0, 0.0), *, depth: float = 1.0, normalized: bool = False, viewport: Optional[Tuple[int, int, int, int]] = None)[源代码]#
清除帧缓冲区::
# Clear framebuffer using the color red in normalized form fbo.clear(color=(1.0, 0.0, 0.0, 1.0), normalized=True) # Clear the framebuffer using arcade's colors (not normalized) fb.clear(color=arcade.color.WHITE)
如果背景颜色为
RGB
值而不是RGBA
‘我们假设alpha值为255。
DefaultFrameBuffer#
- class arcade.gl.framebuffer.DefaultFrameBuffer(ctx: Context)[源代码]#
基类:
arcade.gl.framebuffer.Framebuffer
表示默认的帧缓冲区。这是窗口本身的帧缓冲区,需要进行一些特殊处理。
我们不允许销毁此帧缓冲区,因为它属于侏儒所有。该帧缓冲区还可以在任何点更改大小和像素比例。
我们正在进行一些初步的内省,以猜测一些合理的初始值。因为这是一个动态帧缓冲区,所以我们不能信任内部值。我们只能信任侏儒窗口本身报告的与窗口大小和帧缓冲区大小相关的内容。这应该在
on_resize
回拨。- is_default = True#
这是默认的帧缓冲区吗?(窗口缓冲区)