0

I'm trying to do my uni project and I'm using pyglet for the task . This is part of the code that makes me a problem.

from pyglet.gl import *
from pyglet.window import key
from pyglet.window import mouse


window=pyglet.window.Window(resizable=True)

@window.event
def on_draw():

    glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE)
    glutInitWindowSize (width, height)
    glutInitWindowPosition (100, 100)


    glClearColor( 1.0, 1.0, 1.0, 1.0)
    glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    myObject ()
    glutSwapBuffers() 

When i searched for functions glutInitDisplayMode, glutInitWindowSize and glutInitWindowPosition it only shows pyOpenGL threads, so do they exist for pyglet or im just defining them wrong?

Terminal Output:

glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE)

NameError: global name 'glutInitDisplayMode' is not defined

and same is for other two

djidara696
  • 35
  • 8

1 Answers1

0

So, glutInitDisplayMode is a GL function but as far as I know, it's not made avilable by Pyglet because it's not really needed.

Now, these are some what speculations and correct me if I'm wrong.
But calling the following will set up the context for you:

pyglet.window.Window(...)

There for all these are unnecessary:

glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE)
glutInitWindowSize (width, height)
glutInitWindowPosition (100, 100)

Instead what you want to do is:

window = pyglet.window.Window(width=800, height=600)
window.set_location(100, 100)

There's also the option to create a specific config and context and inject:

config = pyglet.gl.Config(double_buffer=True)
context = context = config.create_context(shared_context)
window = pyglet.window.Window(config=config, context=context)

Hope this clarify anything for you.

Torxed
  • 22,866
  • 14
  • 82
  • 131
  • @smrkelj Ah, it all depends on how you import `Config`, It's under `pyglet.gl.Config` --> `` – Torxed Jun 04 '16 at 19:35
  • I've ued this code: `config = gl.Config(double_buffer=True) context = context = config.create_context(shared_context) window = pyglet.window.Window(config=config, context=context)` and then i got this error: line 29, in config = gl.Config(double_buffer=True) AttributeError: 'module' object has no attribute 'Config' so i changed it with this: `context = window.context config = context.config config.double_buffer window = pyglet.window.Window(config=config, context=context, display=display)` will i lose anything by this schange, or its the same? – djidara696 Jun 04 '16 at 19:36
  • @smrkelj Usually you don't need `context` at all, Pyglet does these things for you. It's more if you want the option to create a context yourself and share it between Windows etc. See my updated answer + my comment above about `gl.Config()`. – Torxed Jun 04 '16 at 19:38