1

So I've written a shader that I want to draw across the whole screen of my Codea app, although I have supplied 4 varying vec2's as the vertices table it only draws a triangle. Why is this happening?

Here's my code

board = mesh()
board.shader = shader("Documents:golBoard")

board.vertices = {vec2(0, 0),
    vec2(0, HEIGHT), 
    vec2(WIDTH, HEIGHT),
    vec2(WIDTH, 0)}

And here's what I get..

golBoard

Dave Mackintosh
  • 2,738
  • 2
  • 31
  • 40

2 Answers2

1

So I needed to define 6 points, 3 for each triangle.

here is the new code

board = mesh()
board.shader = shader("Documents:golBoard")

board.vertices = {vec2(0, 0),
    vec2(0, HEIGHT), 
    vec2(WIDTH, HEIGHT),

    vec2(WIDTH, HEIGHT),
    vec2(WIDTH, 0),
    vec2(0, 0)}
Dave Mackintosh
  • 2,738
  • 2
  • 31
  • 40
1

You can also use:

board:addRect( WIDTH/2, HEIGHT/2, WIDTH, HEIGHT )

This adds the necessary triangles to the mesh to construct the rectangle.

See the docs for more details

simeon
  • 4,466
  • 2
  • 38
  • 42