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 7778797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:29:17+00:00 2026-06-01T18:29:17+00:00

I would like to make a mesh with Pyglet that is changing every frame.

  • 0

I would like to make a mesh with Pyglet that is changing every frame. Therefore I need to update the vertices very often and I thought that a VBO would be the fastest way to go here (correct me if I am wrong). Below an example for Points. Is this the correct way of doing it? I read that the number of glBindBuffer calls should be minimised, but here it is called every frame. also GL_DYNAMIC_DRAW is enabled, but if I change it to GL_STATIC_DRAW it is still working. It makes me wondering if this is a correct setup for fast computation

import pyglet
import numpy as np
from pyglet.gl import *
from ctypes import pointer, sizeof

vbo_id = GLuint()
glGenBuffers(1, pointer(vbo_id))

window = pyglet.window.Window(width=800, height=800)

glClearColor(0.2, 0.4, 0.5, 1.0)

glEnableClientState(GL_VERTEX_ARRAY)

c = 0

def update(dt):
    global c
    c+=1
    data = (GLfloat*4)(*[500+c, 100+c,300+c,200+c])
    glBindBuffer(GL_ARRAY_BUFFER, vbo_id)
    glBufferData(GL_ARRAY_BUFFER, sizeof(data), 0, GL_DYNAMIC_DRAW)
    glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(data), data)


pyglet.clock.schedule(update)

glPointSize(10)

@window.event
def on_draw():

    glClear(GL_COLOR_BUFFER_BIT)
    glColor3f(0, 0, 0)

    glVertexPointer(2, GL_FLOAT, 0, 0)
    glDrawArrays(GL_POINTS, 0, 2)


pyglet.app.run()
  • 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-06-01T18:29:19+00:00Added an answer on June 1, 2026 at 6:29 pm

    You don’t need to call glBufferData every single time in update – create and fill the VBO once (see setup_initial_points) and only update it with glBufferSubData. In case you are only working with a single VBO, you can also comment out the glBindBuffer call in update() (see code below).
    GL_DYNAMIC_DRAW vs GL_STATIC_DRAW won’t make a big difference in this example since you are pushing very few data onto the GPU.

    import pyglet
    from pyglet.gl import *
    from ctypes import pointer, sizeof
    
    window = pyglet.window.Window(width=800, height=800)
    
    ''' update function  '''
    c = 0
    def update(dt):
        global c
        c+=1
        data = calc_point(c)
        # if there's only on VBO, you can comment out the 'glBindBuffer' call
        glBindBuffer(GL_ARRAY_BUFFER, vbo_id)
        glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(data), data)
    
    pyglet.clock.schedule(update)
    
    
    ''' draw function  '''
    @window.event
    def on_draw():
    
        glClear(GL_COLOR_BUFFER_BIT)
        glColor3f(0, 0, 0)
    
        glVertexPointer(2, GL_FLOAT, 0, 0)
        glDrawArrays(GL_POINTS, 0, 2)
    
    
    ''' calculate coordinates given counter 'c' '''
    def calc_point(c):
        data = (GLfloat*4)(*[500+c, 100+c, 300+c, 200+c])
        return data
    
    
    ''' setup points '''
    def setup_initial_points(c):
        vbo_id = GLuint()
        glGenBuffers(1, pointer(vbo_id))
    
        data = calc_point(c)
        glBindBuffer(GL_ARRAY_BUFFER, vbo_id)
        glBufferData(GL_ARRAY_BUFFER, sizeof(data), 0, GL_DYNAMIC_DRAW)
    
        return vbo_id
    
    
    ############################################
    
    vbo_id = setup_initial_points(c)
    
    glClearColor(0.2, 0.4, 0.5, 1.0)
    glEnableClientState(GL_VERTEX_ARRAY)
    
    glPointSize(10)
    pyglet.app.run()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like make a script in Jquery that automove my cursor every 20
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make a php script that can capture a page from
I would like to make a JComboBox that has check boxes for items instead
I would like make an java app that communicates with a serial device(handheld scanner)
I would like to make a package that would copy data from a table
I would like to make a nightly cron job that fetches my stackoverflow page
I would like to make a child class that has a method of the
I would like to make sure that when user log in it will stay
I would like to make a plugin that lets you use the google fonts.

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.