#Attempting to copy the OpenGL Hello Triangle in Odin

8 messages · Page 1 of 1 (latest)

forest trail
#

New to graphics programming, decided I want to use Odin. I am trying to follow the 'Hello Triangle' example from LearnOpenGL, but I cannot get the triangle to display, only the background. From what I can see I am doing the equivalent of their example: https://learnopengl.com/code_viewer_gh.php?code=src/1.getting_started/2.2.hello_triangle_indexed/hello_triangle_indexed.cpp

Here is my code, (too long for message): https://gist.github.com/3than3/178094f16454e763aee0e66b5eba87ad

Gist

OpenGL Hello Triangle. GitHub Gist: instantly share code, notes, and snippets.

final crown
#

I think this has been the 3rd time someone made a similar mistake 😄 . The problem might be in this line c gl.BufferData(gl.ARRAY_BUFFER, size_of(vertices), raw_data(vertices), gl.STATIC_DRAW)

#

More specifically i think that the size_of(vertices) returns 16 bytes which is the size of a slice type

#

I would try with size_of(vertices[0]) * len(vertices)

forest trail
#

That fixed it! Thanks, I would never have figured that out

final crown
#

All good 🙂

#

A pointer and length = 16 bytes