0
\$\begingroup\$

Say my window is 1280x720. I want to render my stuff to lower resolution and then stretch it to window. I've tried this:

glViewport(0, 0, 1280 / 2, 720 / 2);

When I call glViewport and pass lesser width and height than window, I get all my OpenGL rendering in left bottom 1/4 of window. I need to scale it (linear filtering preferably) back to window size so I would get a pixelated effect.

I wonder if there is such possibility within glad/glfw API.

\$\endgroup\$
  • \$\begingroup\$ It is unclear what your main problem is, you should describe more widely what you're trying to do. The code you included, is it what you have tried so far? What happened when you didn't succeed? \$\endgroup\$ – liggiorgio May 24 '18 at 14:06
  • \$\begingroup\$ Pretty sure i described my problem well enough. When I call glViewport and pass lesser width and height than window i get all my opengl rendering in left bottom 1/4 of window. I need to scale it (linear filtering preferably) back to window size so i would get pixelated effect. \$\endgroup\$ – user1378398 May 24 '18 at 14:54
0
\$\begingroup\$

One way to achieve what you want is to render into a texture-backed FBO that is half the width and height of the window, then draw that texture into the window at the full size.

You say:

I need to scale it (linear filtering preferably) back to window size so I would get a pixelated effect.

This is a contradictory statement. If you want pixelation, you probably want nearest neighbor filtering. Linear filtering will cause it to be smoothed out.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Yeah well I'm sorry, I mean nearest neighbor. \$\endgroup\$ – user1378398 May 24 '18 at 17:42
  • \$\begingroup\$ Okay probably that's my best option here. \$\endgroup\$ – user1378398 May 24 '18 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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