Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 697311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:09:18+00:00 2026-05-14T03:09:18+00:00

This question repeats my earlier one but my earlier one was a failure because

  • 0

This question repeats my earlier one but my earlier one was a failure because I didn’t copy some vital information correctly, so I have to redo it.

I’m getting an error with a call to an OpenGL function. Maybe pyglet isn’t initialising OpenGL correctly? The error happens with a simple function that worked before:

 def setup_framebuffer(surface):
   #Create texture if not done already
   if surface.texture is None:
      create_texture(surface)
   #Render child to parent
   if surface.frame_buffer is None:
      surface.frame_buffer =  glGenFramebuffersEXT(1)
   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer)
   glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, surface.texture, 0)
   glPushAttrib(GL_VIEWPORT_BIT)
   glViewport(0,0,surface._scale[0],surface._scale[1])
   glMatrixMode(GL_PROJECTION)
   glLoadIdentity() #Load the projection matrix
   gluOrtho2D(0,surface._scale[0],0,surface._scale[1])

The error is:

glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface.frame_buffer)
ctypes.ArgumentError: argument 2: : wrong type

Wrong type? Then is glGenFramebuffersEXT(1) giving the wrong type now? Why would that be?

Before that function is called I initialise a class instance which manages my game. Here’s the init method:

pyglet.options['audio'] = ('alsa','openal','directsound','silent')
  self.keys = [False] * 323
  self.events = []
  self.title = title
  self.game_size = game_size
  self.first_screen = (1280,720) #Take 120 pixels from the height because the menu bar, window bar and dock takes space
  config = pyglet.gl.Config(alpha_size=8,double_buffer=True,sample_buffers=1,samples=4)
  self.window = pyglet.window.Window(game_size[0],game_size[1],title,True,config=config)
  self.window.set_handler('on_draw',self.game_loop)
  self.window.set_handler('on_resize',self.reshaped)
  self.window.set_handler('on_key_press',self.keydown)
  self.window.set_handler('on_key_release',self.keyup)
  self.window.set_handler('on_mouse_press',self.mouse_func)
  glViewport(0,0,self.first_screen[0],self.first_screen[1]) #Creates the viewport which is mapped to the window
  glEnable(GL_BLEND) #Enable alpha blending
  glEnable(GL_TEXTURE_2D) #Enable 2D Textures
  glEnable(GL_MULTISAMPLE) #Enable Multisampling anti-aliasing
  glEnable(GL_POLYGON_SMOOTH) #Enable antialiased polygons
  glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST)
  glHint(GL_LINE_SMOOTH_HINT, GL_NICEST)
  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
  glMatrixMode(GL_PROJECTION)
  glLoadIdentity() #Load the projection matrix
  gluOrtho2D(0,1280,720,0) #Set an orthorgraphic view
  self.game_gap = (0,0)
  self.on_exit = on_exit
  self.mod_key = 1024 if sys.platform == "darwin" else 64
  Surface.__init__(self,game_size)
  self.screen_change = True
  self.frames = [time.time()]
  self.fps = 60
  self.last_time = 0
  self.fade_surface = Surface([1280,720])
  pyglet.font.add_file(os.path.dirname(sys.argv[0]) + "/NEUROPOL.ttf")
  pyglet.font.load('NEUROPOL')

Surface is a class that I made which acts a bit like the pygame.Surface class but uses OpenGL textures.

That method sets up the Window and OpenGL (Probably not properly which is the problem?) and after calling it I set-up some things for my game which uses the setup_framebuffer function for rendering to textures. Then pyglet.app.run() is called which should hopefully run my game_loop method since I did self.window.set_handler(‘on_draw,self.game_loop) but my game crashes before it gets there.

This is the first time I’ve use pyglet. The documentation doesn’t explain to me what I’m doing wrong. Can anyone help?

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:09:18+00:00Added an answer on May 14, 2026 at 3:09 am

    glBindFramebufferEXT expects pointer to a buffer. AFAIK, you have to use ctypes in this case.

    from pyglet.gl import *
    from ctypes import c_uint, byref
    
    fb = c_uint()
    glGenFramebuffersEXT(1, byref(fb))
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb) 
    

    Search pyglet mailing list for better examples. And BTW:

    >> glGenFramebuffersEXT(1)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: this function takes at least 2 arguments (1 given)
    

    Edit:
    I should have guessed that you are using pyOpenGL:

    fb = int(glGenFramebuffersEXT(1))
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm pretty sure that this question has allready been asked (but i didn't find
I know this seems like a repeat question, but i've read all the others
This question is similar in concept to this one , except I see I
I'm studying for upcoming interviews and have encountered this question several times (written verbatim)
This isn't exactly specifically a programming question (or is it?) but I was wondering:
Ok, this may seem like a dupe question, but if you bear with me
Not a real question because I already found out the answer, but still interesting
Related to this question here , but I decided to ask another question for
I have looked at every instance of this question on Stack as well as
I have a question...I have my header class like this .header{ background-color:#626262; width:250px; height:745px;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.