Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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()
share|improve this question
add comment (requires an account with 50 reputation)

closed as not a real question by Josh Petrie, bummzack, msell, Anko, Laurent Couvidou May 17 at 22:46

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

The event VIDEORESIZE is triggered from windowing system, not from pygame. In response to event, program should update display with calling pygame.display.set_mode(newsize, sameoptions)

share|improve this answer
add comment (requires an account with 50 reputation)

Not the answer you're looking for? Browse other questions tagged or ask your own question.