1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Implement the count parameter in RenderingServer.canvas_item_add_triangle_array()

This commit is contained in:
chocola-mint
2025-05-14 22:42:18 +09:00
parent 09fcbb8645
commit 101dc9868f
8 changed files with 20 additions and 18 deletions

View File

@@ -2424,7 +2424,7 @@ void RasterizerCanvasGLES3::reset_canvas() {
void RasterizerCanvasGLES3::draw_lens_distortion_rect(const Rect2 &p_rect, float p_k1, float p_k2, const Vector2 &p_eye_center, float p_oversample) {
}
RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights) {
RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, const Vector<int> &p_bones, const Vector<float> &p_weights, int p_count) {
// We interleave the vertex data into one big VBO to improve cache coherence
uint32_t vertex_count = p_points.size();
uint32_t stride = 2;
@@ -2552,15 +2552,15 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
if (p_indices.size()) {
//create indices, as indices were requested
Vector<uint8_t> index_buffer;
index_buffer.resize(p_indices.size() * sizeof(int32_t));
index_buffer.resize(p_count * sizeof(int32_t));
{
uint8_t *w = index_buffer.ptrw();
memcpy(w, p_indices.ptr(), sizeof(int32_t) * p_indices.size());
memcpy(w, p_indices.ptr(), sizeof(int32_t) * p_count);
}
glGenBuffers(1, &pb.index_buffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pb.index_buffer);
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ELEMENT_ARRAY_BUFFER, pb.index_buffer, p_indices.size() * 4, index_buffer.ptr(), GL_STATIC_DRAW, "Polygon 2D index buffer");
pb.count = p_indices.size();
GLES3::Utilities::get_singleton()->buffer_allocate_data(GL_ELEMENT_ARRAY_BUFFER, pb.index_buffer, p_count * 4, index_buffer.ptr(), GL_STATIC_DRAW, "Polygon 2D index buffer");
pb.count = p_count;
}
glBindVertexArray(0);