Open zeffii opened 9 years ago
Not exactly sure where to find equivalent opengl 3.1 written in python.. I imagine the untested code comes close enough..
bgl.GL_FLOAT( maybe? not work
yeah, underscores :)
the data type names are wrapped using different names .. also GLunit
, becomes GL_UNSIGNED_INT
I think.
or just GL_INT
I didn't even try to run that code yet @nortikin :)
@zeffii you are amazing man, to write and not test. I cannot do like this )))
Mmm, for me the function doesn't seem to be bound to anything, None isn't the return value but the value of the function object.
it's possible that on OSX the openGL is different
@nortikin apparently I can't do this either :)) because it didn't work.
But normally I do write a lot of code before attempting to run it, especially if i'm familiar with the API. let the brain compile until it needs to be tested :)
51 functions are None
when I test with the below.
>>> [f for f in dir(bgl) if getattr(bgl,f) is None]
['__doc__', 'glBindBufferBase', 'glBindBufferRange', 'glBindVertexArray', 'glColorP3ui', 'glColorP3uiv', 'glColorP4ui', 'glColorP4uiv', 'glDeleteVertexArrays', 'glFramebufferTexture', 'glGenVertexArrays', 'glGetActiveUniformBlockName', 'glGetActiveUniformBlockiv', 'glGetActiveUniformName', 'glGetActiveUniformsiv', 'glGetBufferParameteri64v', 'glGetInteger64i_v', 'glGetIntegeri_v', 'glGetMultisamplefv', 'glGetUniformBlockIndex', 'glGetUniformIndices', 'glIsVertexArray', 'glMultiTexCoordP1ui', 'glMultiTexCoordP1uiv', 'glMultiTexCoordP2ui', 'glMultiTexCoordP2uiv', 'glMultiTexCoordP3ui', 'glMultiTexCoordP3uiv', 'glMultiTexCoordP4ui', 'glMultiTexCoordP4uiv', 'glNormalP3ui', 'glNormalP3uiv', 'glSampleMaski', 'glSecondaryColorP3ui', 'glSecondaryColorP3uiv', 'glTexCoordP1ui', 'glTexCoordP1uiv', 'glTexCoordP2ui', 'glTexCoordP2uiv', 'glTexCoordP3ui', 'glTexCoordP3uiv', 'glTexCoordP4ui', 'glTexCoordP4uiv', 'glTexImage2DMultisample', 'glTexImage3DMultisample', 'glUniformBlockBinding', 'glVertexP2ui', 'glVertexP2uiv', 'glVertexP3ui', 'glVertexP3uiv', 'glVertexP4ui', 'glVertexP4uiv']
Need to ask in IRC I guess.
>>> len([f for f in dir(bgl) if getattr(bgl,f) is None])
48
if was just glColorP3ui
I wouldn't worry but some of functions that are in every OpenGL 3 tutorial are there.
On a happier side node. Some code to create a triangulated bbl Buffer object of vertices. Here a monkey but could be any. Could be better of course with index access to bm.faces
def create_monkey():
bm = bmesh.new()
bmesh.ops.create_monkey(bm)
bmesh.ops.triangulate(bm, faces=bm.faces[:])
bm.faces.ensure_lookup_table()
verts = bgl.Buffer(bgl.GL_FLOAT, [len(bm.faces) * 3, 3])
for i, face in enumerate(bm.faces):
for j, v in enumerate(face.verts):
verts[i * 3 + j] = v.co
return verts
where is opengl3 in bgl development flow?
we need make openGL3 branch.
Yeah that was the idea. 2.8 will take some time.
My idea was to play here and backport as makes sense.
Had a quick look at seems like I only have OpenGL 2.x functions. Vaguely remember that for OS X you can't have 3.X and 1.X code in the same application. So for now I guess OpenGL 2 is our target. Anyway from 2.X to 3.X seems like a simpler change. Note that this needs to be confirmed...
I imagined that something like this could work but no luck.
def draw_callback_view(verts, faces):
VERT = 0
FACES = 1
buffers = bgl.Buffer(bgl.GL_INT, [2])
bgl.glGenBuffers(2, buffers)
bgl.glBindBuffer(bgl.GL_ARRAY_BUFFER, buffers[VERT])
bgl.glBufferData(bgl.GL_ARRAY_BUFFER, 4 * 3 * len(verts), verts, bgl.GL_STATIC_DRAW)
bgl.glVertexPointer(3, bgl.GL_FLOAT, 0, verts)
bgl.glEnableClientState(bgl.GL_VERTEX_ARRAY)
bgl.glBindBuffer(bgl.GL_ELEMENT_ARRAY_BUFFER, buffers[FACES])
bgl.glBufferData(bgl.GL_ELEMENT_ARRAY_BUFFER, 4*3*len(faces), faces, bgl.GL_STATIC_DRAW)
bgl.glDrawElements(bgl.GL_TRIANGLES, len(faces), bgl.GL_INT, bgl.Buffer(bgl.GL_INT,[1]))
The problem being DrawElements, that needs a 0 value as a pointer, but the bgl module doesn't let me pass a 0 value but it has to be a bgl.Buffer
object. Nothing sensible is drawn.
some .c code https://gist.github.com/zeffii/131fb3a0f6fc3ca117fb some untested .py code https://gist.github.com/zeffii/c210322b4b5f489b2886