Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Zylann opened this issue Feb 19, 2017 · 4 comments
Closed

Comments

@Zylann
Copy link
Contributor

Zylann commented Feb 19, 2017

Tested on Godot 3.0 master 5e3fc7d
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

@Zylann Zylann changed the title 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work Some 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work Feb 19, 2017
@Zylann Zylann changed the title Some 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work [3.0] Some 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work Feb 19, 2017
@bojidar-bg
Copy link
Contributor

Can confirm with some Shape2D nodes.

@kubecz3k kubecz3k added this to the 3.0 milestone Feb 20, 2017
@JosephCatrambone
Copy link
Contributor

JosephCatrambone commented Mar 22, 2017

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

@jmoon1506
Copy link

jmoon1506 commented Apr 23, 2017

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.

@akien-mga akien-mga changed the title [3.0] Some 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work Some 2D nodes aren't visible: canvas_item_add_triangle_array() doesn't work May 18, 2017
@reduz
Copy link
Member

reduz commented Jun 13, 2017

polygons are now drawn, so closing this

@reduz reduz closed this as completed Jun 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants