OpenGLES bad polygon?

__Aeon____Aeon__ Posts: 37Member
edited December 2017 in 2D

OpenGLES continuously reports that the rectangular polygon drawn by the following script snippet is invalid, or a 'bad polygon', i however can not see as to why it so is, i believe i'm doing everything according to the docs.

The code draws four circles where the corners of the polygon are, but not the polygon, am i missing something here?

extends Node2D

var points
var point1
var point2
var point3
var point4

var colour = Color(175,175,175,1)

func _ready():


func _set_vec():
    points = Vector2Array()

    var dim_x = get_viewport().get_rect().size.x / 2
    var dim_y = get_viewport().get_rect().size.y / 2
    var offset_x = get_viewport().get_rect().size.x / 3
    var offset_y = get_viewport().get_rect().size.y / 3

    # add 4 points to the array
    point1 = Vector2(dim_x - offset_x, dim_y - offset_y)
    point2 = Vector2(dim_x - offset_x, dim_y + offset_y)
    point3 = Vector2(dim_x + offset_x, dim_y - offset_y)
    point4 = Vector2(dim_x + offset_x, dim_y + offset_y)



func _print_debug_dots():

func _process(delta):

func _draw():
    draw_circle(point1, 20, colour)
    draw_circle(point2, 20, colour)
    draw_circle(point3, 20, colour)
    draw_circle(point4, 20, colour)

    draw_colored_polygon(points, colour)


  • TwistedTwiglegTwistedTwigleg Posts: 4,292Admin

    Maybe use PoolVector2Array instead of a Vector2Array?

    It’s been awhile since I’ve worked with Godot to make polygons, but if what I remember holds you have to use a PoolVector2Array for any mesh/polygon. Things could have changed since I lasted used Godot though, so I’m not sure if that’s the case anymore...

  • __Aeon____Aeon__ Posts: 37Member

    PoolVector2Array does not appear to be a valid constructor/available in the latest stable release, nor can be found at the stable's version docs. However, it appears to be similar in nature to Vector2Array.

    I've successfully found an example that uses Vector2Array only, yet that example sometimes works while other times it echoes 'bad polygon' errors onto the console.

    I wanted to find out how this thing worked with this snippet example. Should there be an order to how points are added to the array?

  • TwistedTwiglegTwistedTwigleg Posts: 4,292Admin

    Strange, I guess they renamed it... Sorry about misleading you.

    I’m not sure if the order matters or not, but you could test it adding the vertices in an order like in this article and see if that works? Maybe looking at the source code (for Godot) will help?

    I’m not sure why it’s not working though. Maybe it’s a bug?

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file