Results 1 to 4 of 4

Thread: pyopengl hangs

  1. #1

    pyopengl hangs

    this the code in python since im using pyopengl. when i run it simpky hangs and only the top bar is visible. Other programs are working fine, which means there is no problem with the library and OS. Here is the code

    Code :
    try:
      from OpenGL.GLUT import *
      from OpenGL.GL import *
      from OpenGL.GLU import *
     
    except: print '''ERROR: PyOpenGL not installed properly.'''
     
    import sys
     
    def init():
        glEnable(GL_TEXTURE_2D)
        glClearColor(0.0, 0.0, 0.0, 0.0)	
        glClearDepth(1.0)			
        glDepthFunc(GL_LESS)			
        glEnable(GL_DEPTH_TEST)			
        glShadeModel(GL_SMOOTH)			
        glMatrixMode(GL_PROJECTION)
        glClear(GL_COLOR_BUFFER_BIT)
        glLoadIdentity()
        glColor3d(0,0,1)
     
     
     
    def main():
      glutInit(sys.argv)
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB)
      glutInitWindowSize (640,480)
      glutInitWindowPosition (0,0)
      window=glutCreateWindow ("Solar")
      glutIdleFunc(mydisplay)  
      glutDisplayFunc(mydisplay)
      glutKeyboardFunc(mydisplay)
      glutKeyboardFunc(mydisplay)
      init()
      glutMainLoop()
      exit()
     
    def mydisplay():
      glBegin(GL_POINTS)
      glVertex2i(10,20)
      glEnd()
     
     
    main()

  2. #2
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: pyopengl hangs

    Code :
      glutIdleFunc(mydisplay)  
      glutKeyboardFunc(mydisplay)
      glutKeyboardFunc(mydisplay)

    This is not good at all. You can have a look here for more details about how to use these functions here: http://www.opengl.org/documentation/...ec3/spec3.html

  3. #3

    Re: pyopengl hangs

    thanks but the code works for
    Code :
       glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)

    instead of GLUT|DOUBLE
    what could be the reason?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Oct 2010
    Location
    France
    Posts
    458

    Re: pyopengl hangs

    When using double buffer, you draw in the background buffer (so nothing is drawn on screen), and when swapping the buffer, what you drawn is displayed, and so on.

    While on single buffer, you always draw on screen.

    You really need to take into account what I said before too.

Similar Threads

  1. Draw a sphere in Gtk.GlArea using pyopengl
    By brudra in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-17-2018, 01:15 AM
  2. VAO/glUniformMatrix4fv slow with PyOpenGL
    By BuggyCode in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-06-2018, 08:50 AM
  3. Animating a 3D car in PyOpenGL
    By Aft3rbur3r in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-01-2016, 04:36 PM
  4. Augmented textures with PyOpenGL
    By JMGloyens in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 05-29-2013, 05:41 PM
  5. gl extension, blending, and pyOpenGL
    By fwest in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 11-13-2004, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean