Many thanks! It would save me a lot of time to find the trick ^ v ^




At 2016-12-05 13:52:11, "Benjamin Moran" <[email protected]> wrote:

Hi Simon,

You almost got it. You have to create ctypes arrays like this:   "a = (GLfloat 
* 2)()".  I know it looks a little funny, but oh well.
Also, if you want to print it, you have to type "print(a[:])". Here is a 
working example:


for i in range(10):        
   glPointSize(i+0.5)
   a =(GLfloat*2)()
   glGetFloatv(GL_POINT_SIZE_RANGE,a)
   print(a[:])
   glBegin(GL_POINTS)
   glColor3f(1.0,1.0,0.0)
       glVertex3f(i-5.0,1.0,0.0)
       glEnd()




On Monday, December 5, 2016 at 2:20:26 PM UTC+9, Simon wrote:
Hi, Ben, 


Many thanks for your detailed explaination, I think I get the ideas. Well, I 
think I have already meet ctype problems, I want to use glGet() to get values, 
and the code I wrote.


    for i in range(10):        
        glPointSize(i+0.5)
        a = GLfloat() * 2
        glGetFloatv(GL_POINT_SIZE_RANGE,a)
        print(a)
        glBegin(GL_POINTS)
        glColor3f(1.0,1.0,0.0)
        glVertex3f(i-5.0,1.0,0.0)
        glEnd()


It does not work, I think I meet the problem of ctypes, I read your code you 
showed to me, it is precise. I will check the Ctypes first, thank you very much!


BTW, it seemed that my post is auto to be a maillist. ^ v ^ Maybe I can reply 
it by E-mail instead of VPN. 



在 2016年12月4日星期日 UTC+8下午10:17:14,Benjamin Moran写道:
Pyglet's OpenGL bindings should support very recent versions. (If not, please 
file a bug so that they can be updated).

Internally, Pyglet only uses "classic" OpenGL. This older OpenGL is much 
simpler, and is enough for most simple games and applications. This is what the 
pyglet text, sprite, and graphics modules are based on.
Modern OpenGL can be used by simply requesting a newer OpenGL context when 
creating the window. However, you have to give up on the sprite and graphics 
modules because they will try to call some older OpenGL functions that may not 
be available with a newer context.

Working with shaders does require knowing some ctypes, but there is a nice 
library here that hides that: https://github.com/gabdube/pyshaders
I also wrote a very basic shader program wrapper here: 
https://bitbucket.org/treehousegames/pyglet/src/28d33a50ba8c1f140613ca90de7791260a3d9daa/pyglet/graphics/shader.py?at=shader_class&fileviewer=file-view-default
I would probably not recommend the one i wrote, but it might give you an idea 
of the ctypes involved. Ctypes is actually very easy to use, but if you don't 
understand the basic C concepts it will be challenging.




On Sunday, December 4, 2016 at 9:33:27 PM UTC+9, [email protected] wrote:
 I can use from pyglet.gl import * to use OpenGL, in docs, it is said that 
pyglet provides an interface to OpenGL and GLU. To use it you will need a good 
knowledge of OpenGL, C and ctypes. To be honest, I know nothing about OpenGL, 
but I knew OpenGL has its own versions, and which version is used in pyglet? It 
seemed that there are modern OpenGL (OpenGL 3 and 4) , and  “old” OpenGL 
(OpenGL 1 and 2). Is there much difference between them? Could I use pyglet to 
learn OpenGL, or only C++ is fine?


--
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to