Python minecraft pyglet glClear () drop frames

I recently downloaded fogleman a great demo of "Minecraft in 500 lines" from https://github.com/fogleman/Craft . I used the 2to3 tool and fixed some details manually to make it executable in python3. Now I wonder about the call self.clear()in the rendering method. This is my modified rendering method, which every frame is called a piglet:

def on_draw(self):
    """ Called by pyglet to draw the canvas.

    """
    frameStart = time.time()
    self.clear()
    clearTime = time.time()
    self.set_3d()
    glColor3d(1, 1, 1)
    self.model.batch.draw()
    self.draw_focused_block()
    self.set_2d()
    self.draw_label()
    self.draw_reticle()
    renderTime = time.time()

    self.clearBuffer.append(str(clearTime - frameStart))
    self.renderBuffer.append(str(renderTime - clearTime))

As you can see, I took the runtime self.clear()and the rest of the rendering method. The call self.clear()calls this pyglet method, which can be found in ... / pyglet / window / __ init __. Py:

def clear(self):
    '''Clear the window.

    This is a convenience method for clearing the color and depth
    buffer.  The window must be the active context (see `switch_to`).
    '''
    gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)

glClear().
( 60 FPS), , , glClear(). , 10 . glClear() - , :
glClear() .

. , , , .
glClear() , - "" . , ? ?
, OpenGL, .;)

+4
1

. , , . gl*, , , , .

gl* , . , GPU, , - . , ( ) VRAM, -. "" , , glFlush. OpenGL ( , , , Vulkan), , . gl*, , CPU GPU, .

glClear , , , ​​ . , .

, , , . (, glBufferData, glTexImage*), , , , glClear. ; , , , , .

, , , . OpenGL - .

, glClear , , . , .

0

Source: https://habr.com/ru/post/1649788/


All Articles