Is there a way to make multiple IndexedVertexLists refer to the same vertices while having different lists of indices

Viewed 25

I want to have two (or more) IndexedVertexLists which refer to the same vertices while having different lists of indices. The problem I am having is that, if I were to create two (or more) IndexedVertexLists with the same vertices, it would take up twice the amount of the GPU's memory compared to what it actually needs.

What I mean:

import pyglet


vertices = [
        0, 0,
        0, 0.5,
        0.5, 0,
        0.5, 0.5
]

indices1 = [0, 1, 2]
indices2 = [0, 2, 3]

vertex_list_indexed_1 = pyglet.graphics.vertex_list_indexed(4, indices1, ('v2f', vertices))
vertex_list_indexed_2 = pyglet.graphics.vertex_list_indexed(4, indices2, ('v2f', vertices))

What I want would be something like this (this does not work, obviously):

import pyglet


vertices = [
        0, 0,
        0, 0.5,
        0.5, 0,
        0.5, 0.5
]

indices1 = [0, 1, 2]
indices2 = [0, 2, 3]

vertex_list  = pyglet.graphics.vertex_list(4, ('v2f', vertices))

vertex_list_indexed_1 = pyglet.graphics.vertex_list_indexed(4, indices1, vertex_list)
vertex_list_indexed_2 = pyglet.graphics.vertex_list_indexed(4, indices2, vertex_list)

I couldn't find anything in the pyglet documentation that would solve my problem.

0 Answers
Related