2

So what I am looking to do is to render a texture onto a flat plane, using OpenGL and c++, as a way to show an image.

However I need to ensure that there is nothing done to the texture when it is rendered ie. anti-aliasing, interpolation, smoothing, blurring etc.

Is this the default way OpenGL handles rendering textures? Or do some flags need to be set in order to disable any processing?

colossus47
  • 99
  • 9
  • 1
    If you're rendering the texture to exactly the same number of pixels that are in the texture, I think you just need to offset your rendering by 0.5 pixels so that you're rendering to the centre of each pixel. If you are zooming in and out on the texture, you will need to specify the `GL_TEXTURE_MIN_FILTER` and `GL_TEXTURE_MAG_FILTER` appropriately. – Joseph Mansfield Jan 16 '15 at 13:55
  • ... where "appropriately" means `GL_NEAREST` – leemes Jan 16 '15 at 14:00
  • 1
    Another crazy idea: build a framebuffer object, attach exactly the image in the texture you want to draw, then use `glBlitFramebuffer`. – peppe Jan 16 '15 at 15:17
  • Why do you want no min nor mag filtering on your texture? Are you rendering 2d sprites? Or making a kind of GUI? If so the above answers/comments should help you. Make sure that you do set the min/mag filters to nearest and the wrap modes otherwise (in my experience) even though you don't plan to use them otherwise the texture may not be "complete" and may not render at all – Lloyd Crawley Jan 16 '15 at 16:40
  • Thanks, 'GL_TEXTURE_MIN_FILTER', 'GL_TEXTURE_MAG_FILTER', and 'GL_NEAREST' were the things I was looking for. The advice about offsetting the render by 0.5 pixels, and the wrap mode should also be very helpful. I was looking to do this as I am debayering images, and don't want to give a false impression of the camera's resolution through post processing, as well any filtering could give a false impression of the camera's resolving power. – colossus47 Jan 16 '15 at 18:00
  • @peppe Why would that be a crazy idea? It's the easiest solution. See http://stackoverflow.com/a/24278779/3530129. – Reto Koradi Jan 16 '15 at 23:13

1 Answers1

1

Pretty much everything is said here : http://www.mindcontrol.org/~hplus/graphics/opengl-pixel-perfect.html.

There's no need to offset anything by 0.5, as long as you projection matrix is a glOrtho equivalent matching the viewport pixel resolution.

You may find interessting a related/similar question : Opengl pixel perfect 2D drawing

Community
  • 1
  • 1
rotoglup
  • 5,223
  • 25
  • 37