3

I want to make resizeble window in pygame using Pyopengl, and trying to use this code

pygame.display.set_mode(display, DOUBLEBUF|OPENGL, RESIZABLE)

or this

pygame.display.set_mode(display, DOUBLEBUF|OPENGL, pygame.RESIZABLE)

Resizable does not appear. This code is working now:

def main():
pygame.init()
display = (800,600)
pygame.display.set_mode(display, DOUBLEBUF|OPENGL, RESIZABLE)
gluPerspective(45, (display[0]/display[1]), 0.1, 500.0) # настройка камеры угол обзора дальняя и ближняя дистанция рендера
clock = pygame.time.Clock()
FPS = 60
angle=0
distance=20
while True:
     ...
pygame.display.flip()
clock.tick(FPS)
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
ChastyEsc
  • 45
  • 3

2 Answers2

2

You must adjust the size of the viewport to the size of the window and the current framebuffer, by glViewport:

glViewport(0, 0, display[0], display[1])
Rabbid76
  • 202,892
  • 27
  • 131
  • 174
1

Assuming you are importing pygame.locals it should be like this:

pygame.display.set_mode(display, DOUBLEBUF | OPENGL | RESIZABLE)

Basically all your display flags should be joined with a "|" (pipe) character.

I. Al.
  • 166
  • 1
  • 6