In test setup, i use no matrix transformations (screen coord space, -1.0 to 1.0) The shader is simply gl_Position = position.
After resize i get correctly scaled render, but viewport is cropped into old viewport range and shifted weirdly.
Do i miss something in this setup?
from OpenGL import GL
import pygame as pg
def main():
import os, sys
pg.init()
os.environ['SDL_VIDEO_CENTERED'] = '1'
screen = pg.display.set_mode((800,600),pg.HWSURFACE|pg.OPENGL|pg.DOUBLEBUF|pg.RESIZABLE)
GL.glMatrixMode(GL.GL_PROJECTION)
GL.glLoadIdentity()
GL.glMatrixMode(GL.GL_MODELVIEW)
GL.glLoadIdentity()
running = True
while running:
GL.glClear(GL.GL_COLOR_BUFFER_BIT)
GL.glBegin(GL.GL_TRIANGLES)
GL.glVertex3f(-1.0, -1.0, 0.0)
GL.glVertex3f(0.0, 1.0, 0.0)
GL.glVertex3f(1.0, 0.0, 0.0)
GL.glEnd()
pg.display.flip()
for ev in pg.event.get():
if ev.type == pg.VIDEORESIZE:
GL.glViewport(0, 0, ev.w, ev.h)
if ev.type == pg.QUIT or (ev.type==pg.KEYDOWN and ev.key==pg.K_ESCAPE):
running = False
break
main()