Godot: Some 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work

Created on 19 Feb 2017  路  4Comments  路  Source: godotengine/godot

Tested on Godot 3.0 master 5e3fc7d06956dcda8b50cd4f028c83cf967f7223
Windows 10 64 bits

All nodes using VisualServer::canvas_item_add_triangle_array can't be seen.
I thought backface culling was on, so I tried inverting index order in Line2D, but no luck.

image

bug confirmed rendering

Most helpful comment

polygons are now drawn, so closing this

All 4 comments

Can confirm with some Shape2D nodes.

Adding another confirmation to the choir. Has this been narrowed down to canvas_item_add_triangle_array or does it perhaps pass some unexpected arguments to canvas_item_add_polygon?

EDIT: I thought I saw some funkiness in the indices. That turns out not to be the case.

For a horizontal line from 0,0 to 10,0:

0 : 0.000000, -5.000000 // Bottom left
3 : 10.000000, 5.000000 // Top right
1 : 0.000000, 5.000000 // Top left
0 : 0.000000, -5.000000 // Bottom Left
2 : 10.000000, -5.000000 // Bottom right
3 : 10.000000, 5.000000 // Top right

GL_FRONT_FACING is CCW by default, so this looks okay.

EDIT2: Just noticed that in rasterizer_canvas_gles3.cpp : 626, _draw_polygon is commented out:

case Item::Command::TYPE_POLYGON: {

    Item::CommandPolygon *polygon = static_cast<Item::CommandPolygon *>(c);
    _set_texture_rect_mode(false);

    RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(polygon->texture);

    if (texture) {
        Size2 texpixel_size(1.0 / texture->width, 1.0 / texture->height);
        state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
    }
    //_draw_polygon(polygon->count,polygon->indices.ptr(),polygon->points.ptr(),polygon->uvs.ptr(),polygon->colors.ptr(),polygon->texture,polygon->colors.size()==1);

} break;

And with good reason:

ERROR: _gl_debug_print: GL ERROR: Source: OpenGL Type: Error ID: 1282 Severity: High Message: GL_INVALID_OPERATION error generated. Array object is not active.
At: drivers\gles3\rasterizer_gles3.cpp:122

Seems like the default vertex array object (the name zero) became deprecated in GLES 3.3. The _draw_polygon function binds data using VertexAttribPointer, which now fails because the default VAO is no longer there. Binding a non-default VAO also seems to fails because VertexAttribPointer then cannot specify client-side data.

rasterizer_canvas_gles3.cpp : 250

void RasterizerCanvasGLES3::_draw_polygon(int p_vertex_count, const int *p_indices, const Vector2 *p_vertices, const Vector2 *p_uvs, const Color *p_colors, const RID &p_texture, bool p_singlecolor) {
    ...
    glBindVertexArray(data.canvas_quad_array) // attempt to bind non-default VAO
    glEnableVertexAttribArray(VS::ARRAY_VERTEX);
    glVertexAttribPointer(VS::ARRAY_VERTEX, 2, GL_FLOAT, false, sizeof(Vector2), p_vertices);
    if (do_colors) {

        glEnableVertexAttribArray(VS::ARRAY_COLOR);
        glVertexAttribPointer(VS::ARRAY_COLOR, 4, GL_FLOAT, false, sizeof(Color), p_colors);
    } else {
        glDisableVertexAttribArray(VS::ARRAY_COLOR);
    }

    if (texture && p_uvs) {

        glEnableVertexAttribArray(VS::ARRAY_TEX_UV);
        glVertexAttribPointer(VS::ARRAY_TEX_UV, 2, GL_FLOAT, false, sizeof(Vector2), p_uvs);
    } else {
        glDisableVertexAttribArray(VS::ARRAY_TEX_UV);
    }

    if (p_indices) {
        glDrawElements(GL_TRIANGLES, p_vertex_count, GL_UNSIGNED_INT, p_indices);
    } else {
        glDrawArrays(GL_TRIANGLES, 0, p_vertex_count);
    }
    ...
}

ERROR: _gl_debug_print: GL ERROR: Source: OpenGL Type: Error ID: 2100 Severity: High Message: glVertexAttribPointer failed because it is not allowed to specify a client-side vertex or element array when a non-default vertex array object is bound (GL_INVALID_OPERATION)
At: drivers\gles3\rasterizer_gles3.cpp:123

Any ideas? I'm not at all an expert on OpenGL, so I'm hoping someone can point out flaws with this.

polygons are now drawn, so closing this

Was this page helpful?
0 / 5 - 0 ratings