2021SC@SDUSC
Go语言的简单2D游戏库-Ebiten
目录
type replacePixelsCommand struct
type disposeImageCommand struct
func InitializeGraphicsDriverState
概览
包 graphicscommand 表示使用 OpenGL 的图形的低层。
主要围绕几个主要的结构体和函数展开分析
type command interface
命令表示图形命令。
是在调用图像函数(如DrawTriangles)或填充时创建的绘图命令,
命令创建后不会立即执行。已安装,创建后将排队,只有在必要时才执行。
type commandQueue struct
commandQueue是用于图形命令的命令队列。
commands是图形命令的队列。
vertices表示OpenGL数组缓冲区中的顶点数据
nvertices表示顶点的当前长度 nvertices必须<=len(vertices)。
vertices永远不会收缩,因为重新扩展顶点缓冲区很费力。同时,这是一些float32值,而不是一些顶点 重命名或修复程序。
theCommandQueue
var theCommandQueue = &commandQueue{}
theCommandQueue是当前进程的命令队列
func appendVertices
func appendVertices将顶点附加到队列。
当使用着色器且没有指定的图像时,src为nil。
func Enqueue
将图形命令(而不是“绘制三角形”命令)排入队列。对于“绘制三角形”命令,使用、
EnqueueDrawTrianglesCommand。
如果dst是屏幕,将命令重新排序为最后一个。
func Flush
刷新命令队列。
type replacePixelsCommand struct
replacePixelsCommand表示替换图像像素的命令。
func Exec
Exec执行replacePixelsCommand。
type disposeImageCommand struct
disposeImageCommand表示处理图像的命令。
func Exec
Exec执行disposeImageCommand
type Image
Image 表示用 OpenGL 实现的图像。
func (*Image) Dump
转储将图像转储到指定路径。在路径中,'*' 被替换为图像的 ID。如果 blackbg 为 true,则转储图像中的任何 alpha 值将为 255。这是为了测试使用。
func (*Image) Pixels
像素返回图像的像素。发生 OpenGL 错误时,像素可能会返回 nil。
func InitializeGraphicsDriverState
InitializeGraphicsDriverState 初始化当前图形驱动程序状态。
func ResetGraphicsDriverStat
ResetGraphicsDriverState 重置当前图形驱动程序状态。如果图形驱动程序没有用于重置的 API,则 ResetGraphicsDriverState 不执行任何操作。