Skip to content

Why are we using GLmod

Oipo edited this page Aug 28, 2011 · 1 revision
<sequenceGeek> ok, I'll familiarize myself with the code now
<sequenceGeek> so this GLwidget is a basically the core of the graphics
<Oipo> Yeap
<sequenceGeek> so this VBO is a data structure that contains all the vertexes, etc. that will be batch drawn in one operation?
<Oipo> That's the idea. Though glmod takes it one step further
<Oipo> It finds all VBOs with the same texture id, and draws ALL those VBOs in one batch operation
<sequenceGeek> how are we making use of cpp code?
<sequenceGeek> in python
<Oipo> The cpp library exposes functions that python can work with. Upon loading the library, python gets told "I have these functions for you to use"
<Oipo> And you can use them from python.
<Oipo> See the very last function in glmod.cpp
<sequenceGeek> is it using Cython or something like that?
<Oipo> Nope, actual Python library
<sequenceGeek> (get ready for ignorance :P )
<sequenceGeek> I thought python was written in C?
<sequenceGeek> or at least the version (CPython) I'm using
<Oipo> Oooh, yeah. It uses the CPython implementation, yeah
<sequenceGeek> so how is it we are using cpp code to make a python module?
<Oipo> The python interpretter itself is C, right?
<sequenceGeek> I should mention I'm a biochemist by trade right now, haha
<Oipo> Lol.
<Oipo> Interesting, wonder how you got here :P
<Oipo> Anyways, the interpretter gets a request from a python file to load the glmod library
<Oipo> it opens the library with some C calls internally
<Oipo> Looks for the list of functions that this module exports, and stores them in memory
<Oipo> The python code then gets to call those functions.
<sequenceGeek> so glmod is a cpp implementation of some of the stuff pyOpenGL does
<Oipo> PyOpengl has nothing to do with glmod, aside from that both use opengl :P
<Oipo> Pyopengl uses opengl to tell stuff to the graphics card, and so does glmod.
<Oipo> The interaction they have is that they know of the same data, since it's the same program doing it all.
<sequenceGeek> so why use glmod over Pyopengl?
<Oipo> The speed of glmod is very, very much higher than pyopengl, since we're not using some generic data format and generic error checking
<Oipo> Everything *is* possible with pyopengl alone, but it'll be slower. A lot.
<sequenceGeek> ok
<sequenceGeek> so is there the same python function call overhead when we use glmod?
<Oipo> The function call overhead is the same. It's the functions that are different.
<Oipo> (Sorry for nitpicking here)
<sequenceGeek> no please, I appreciate it
<Oipo> The functions in pyopengl work with different data formats. Formats that make it more python-esque, and accept multiple ways of data representation
<Oipo> As well as checking every command for errors, and giving accurate errors
<Oipo> But since checking for errors means having to ask the gfx card what is wrong, there is a lot of waiting for synchronization
<sequenceGeek> http://www.reddit.com/r/Python/comments/hy1hl/why_are_graphics_bindings_slower_in_python/
<Oipo> glmod doesn't do any of that, saving a lot of CPU cycles, graphics card cycles etc
<sequenceGeek> I c
<sequenceGeek> So I can just thing of glmod as a regular python module.
<Oipo> Yeap
<Oipo> One with a very, very specific purpose.
<sequenceGeek> And the reason we use this custom module is to speed things by making assumptions about the data format and the simplifying errors
<sequenceGeek> ok
Clone this wiki locally