go-gl / gl

Go bindings for OpenGL (generated via glow)
MIT License
1.09k stars 73 forks source link

Resizing window does not adjust relative coordinates #119

Closed drakbar closed 5 years ago

drakbar commented 5 years ago

So I have a simple triangle geometry like so

+0.0, +0.5, +0.0, // Top
+0.5, -0.5, +0.0,  // Bottom Right
-0.5, -0.5, +0.0,   // Bottom Left

When I first run the program the shape is render as expected. n

However when I resize the window by either the width or height it appears the origin is no longer centered in the window.

w h

I expect that the triangle should stay centered in the screen, as the geometry is specified in relative coordinates.

I am not sure what is causing the observed behavior, gl or glfw. Any suggestions as to what is causing this?

jeff-emanuel commented 5 years ago

You likely are not updating your viewport on resize.

On Tue, Aug 13, 2019, 9:53 AM Matt notifications@github.com wrote:

So I have a simple triangle geometry like so

+0.0, +0.5, +0.0, // Top +0.5, -0.5, +0.0, // Bottom Right -0.5, -0.5, +0.0, // Bottom Left

When I first run the program the shape is render as expected. [image: n] https://user-images.githubusercontent.com/20728117/62955917-8506f000-bdb7-11e9-9cce-3d5599951b7f.png

However when I resize the window by either the width or height it appears the origin is no longer centered in the window.

[image: w] https://user-images.githubusercontent.com/20728117/62956021-bd0e3300-bdb7-11e9-8436-ff9dbc0d6b8f.png [image: h] https://user-images.githubusercontent.com/20728117/62956026-bf708d00-bdb7-11e9-918c-32b1777f1ef3.png

I expect that the triangle should stay centered in the screen, as the geometry is specified in relative coordinates.

I am not sure what is causing the observed behavior, gl or glfw. Any suggestions as to what is causing this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/go-gl/gl/issues/119?email_source=notifications&email_token=AIMEUJ5HZHGTHOX2BDIBU7TQELKIJA5CNFSM4ILMIJA2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HE7Z64Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AIMEUJYTAXSP7XRQQHUNUM3QELKIJANCNFSM4ILMIJAQ .

drakbar commented 5 years ago

@jeff-emanuel Thanks, you were right. I have never used glfw to create a window, and I didn't know that you would need to set up that up also.