0
\$\begingroup\$

There are plenty of examples of posts that describe how to set the default interpolation of specific images to GL_NEAREST, for example here, but they all have to be run after the image texture is defined.

My question is simply this: is there any way to set the default interpolation of every image, including ones that have not been created yet, to GL_NEAREST in a single statement? I will never use any other scaling method as I am making a pixel-based game, and I do not want to have to set the interpolation every time on_draw() is run. If there is no answer, then please say so.

\$\endgroup\$
0
\$\begingroup\$

Default OpenGL states are given in the OpenGL specification and other related documentation, and there is typically no global override for these; if you want to use a different state you must set it yourself.

Firstly, you don't need to set interpolation (via glTexParameter) every time you draw; instead you only set it once per texture and after you initially create the texture, following which the setting "sticks".

If you're pushing all of your texture creation through a single function (and if not, you should be) then this is the appropriate place to set it.

Alternatively, if your GL implementation has sampler objects available, you may create and bind one sampler object per texture unit (GL_TEXTURE0, GL_TEXTURE1, etc) you use, and this overrides settings from glTexParameter. Again, this would only need to be done once, at program startup, rather than every time you draw.

\$\endgroup\$
  • \$\begingroup\$ This does not answer my quesiton, I am asking about a permanent modification of GL settings for my program to change the default interpolation for every sprite I create. \$\endgroup\$ – Zach K Oct 1 '19 at 22:11
  • \$\begingroup\$ I'm also confused as to how I would even accomplish this. Pyglet is very limited in documentation and doesn't explain how to bind textures (and animations) and enable opengl and set the default interpolation to nearest. At least it would be nice if you could describe a good tutorial on OpenGL that I can easily use for pyglet. \$\endgroup\$ – Zach K Oct 1 '19 at 22:19
  • \$\begingroup\$ @ZachK - edited to clarify re: default states; requests for totorials are off-topic for this site, but you could consider asking in Chat or on another site such as Gamedev.net. \$\endgroup\$ – Maximus Minimus Oct 2 '19 at 12:39
  • \$\begingroup\$ I was asking for examples in your post about how to bind textures, but you answered my question that there is no global override. \$\endgroup\$ – Zach K Oct 2 '19 at 14:41

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.