Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a resizeble window in pygame with Opengl

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)
like image 288
ChastyEsc Avatar asked Dec 01 '25 11:12

ChastyEsc


1 Answers

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])
like image 92
Rabbid76 Avatar answered Dec 04 '25 01:12

Rabbid76