此函数将顶点缓冲区的内容提交到图形管道以供着色器使用。
您提供顶点缓冲区、基本基元类型 (请参阅下面的常量) 和要使用的纹理。基本基元类型仅用于指定绘制和连接缓冲区中存储的顶点的顺序,但每个顶点使用的实际数据将是您在创建顶点缓冲区时定义的数据。
警告 使用表面作为纹理 (由 surface_get_texture 返回) 时,应确保表面本身存在 (surface_exists) 。
有关可用的不同基本基元的视觉示例,请参见下图:
常量 | 描述 |
---|---|
pr_pointlist | A point list - A point is drawn for every vertex. |
pr_linelist | A line list - A line is drawn between the first and the second vertex, between the third and fourth vertex, etc. |
pr_linestrip | A 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_trianglelist | A triangle list - A triangle is drawn for the first, second and third vertex, then for the fourth, fifth and sixth vertex, etc. |
pr_trianglestrip | A triangle strip - A triangle is drawn for the first, second and third vertex, then for the second, third and fourth vertex, etc. |
pr_trianglefan | A 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);
参数 | 类型 | 描述 |
---|---|---|
buffer | Vertex Buffer | 要使用的顶点缓冲区。 |
primitive | 基本类型常量 | 基本体基本类型。 |
texture | Texture | 要使用的纹理 (或 -1 表示无纹理)。 |
N/A
shader_set(shader_prim);
vertex_submit(buff, pr_trianglelist, sprite_get_texture(sprite_index, 0));
shader_reset();
上述代码将顶点缓冲区提交到变量 buff 中,以便使用着色器 shader_prim 进行绘制,使用三角形列表作为基本基元,并使用运行代码的实例的精灵纹理。