vertex_submit

此函数将顶点缓冲区的内容提交到图形管道以供着色器使用。

您提供顶点缓冲区、基本基元类型 (请参阅下面的常量) 和要使用的纹理。基本基元类型仅用于指定绘制和连接缓冲区中存储的顶点的顺序,但每个顶点使用的实际数据将是您在创建顶点缓冲区时定义的数据。

警告 使用表面作为纹理 (由 surface_get_texture 返回) 时,应确保表面本身存在 (surface_exists) 。

使用说明

有关可用的不同基本基元的视觉示例,请参见下图:

The different primitive types

基本类型常量
常量描述
pr_pointlistA point list - A point is drawn for every vertex.
pr_linelistA line list - A line is drawn between the first and the second vertex, between the third and fourth vertex, etc.
pr_linestripA line strip - A line is drawn between the first and the second vertex, between the second and the third vertex, the third and the fourth vertex, etc.
pr_trianglelistA triangle list - A triangle is drawn for the first, second and third vertex, then for the fourth, fifth and sixth vertex, etc.
pr_trianglestripA triangle strip - A triangle is drawn for the first, second and third vertex, then for the second, third and fourth vertex, etc.
pr_trianglefanA triangle fan - Every two vertices connect to the first vertex to make a triangle.

WARNING This primitive type is not natively supported on some platforms and there could be a performance hit if you use it.

 

语法:

vertex_submit(buffer, primitive, texture);

参数类型描述
bufferVertex Buffer要使用的顶点缓冲区。
primitive基本类型常量基本体基本类型。
textureTexture要使用的纹理 (或 -1 表示无纹理)。

 

返回:

N/A

 

例子:

shader_set(shader_prim);
vertex_submit(buff, pr_trianglelist, sprite_get_texture(sprite_index, 0));
shader_reset();

上述代码将顶点缓冲区提交到变量 buff 中,以便使用着色器 shader_prim 进行绘制,使用三角形列表作为基本基元,并使用运行代码的实例的精灵纹理。