DrBwts
DrBwts

Reputation: 3657

PyOpenGL correct syntax for setting up array of type GLfloat

I'm trying to set up an array of 3D co-ordinates of type GLfloat but can only find reference to setting up a single variable of that type,

a = GLfloat(1.0)

I have tried,

a = GLfloat([0.0, 0.0, 0.0],[1.0, 1.0, 1.0],[2.0, 2.0, 2.0])

but get the following error,

TypeError: init expected at most 1 arguments, got 3

In C is easy,

Glfloat a[3][3] = {{0.0, 0.0, 0.0},{1.0, 1.0, 1.0},{2.0, 2.0, 2.0}}

So how do I do that in Python?

Upvotes: 2

Views: 846

Answers (1)

Lanting
Lanting

Reputation: 3068

you could get an array of glfloats with a list comprehension

pythonarray = [1, 2, 3, 4, 5, 6 ,7, 8]
glfloatarray = [GLfloat(x) for x in pythonarray]

But you're probably bettor off using pyopengls array extension possibly in combination with numpy float arrays. This allows you to easily create vbos of your data.

Upvotes: 2

Related Questions