So I know that glDrawPixels is deprecated. Is there any function that does the same thing? I thought of using textures, but they are modified by the current matrix, unlike pixels that are drawn by glDrawPixels.
An alternative to glDrawPixels in OpenGL 3.0?
3.5k Views Asked by Pilpel At
3
There are 3 best solutions below
0

You could use a fragment shader where a function of gl_FragCoord
is used to sample a rectangular texture.
Alternatively, you could use a more traditional approach and just set up your transformation matrices to approximate the pixel coordinate system of your window and then draw a textured quad with your image.
0

You need to draw a quad with :
- A specific ModelViewProjection Matrix which will place it where you want (as Nicol said, there is no "current" matrix anymore)
- A simple vertex shader which will use said Matrix to actually transform the vertices
- A simple fragment shader which will sample the texture
- And of course, adequate texture coordinates.
For starters, use an Identity matrix, and a mesh with X and Y coords between 0 and 1.
You might want to use a mix of http://www.opengl-tutorial.org/beginners-tutorials/tutorial-2-the-first-triangle/ and http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-11-2d-text/ (though the latter one should be improved regarding the matrix used)
The "current matrix" is deprecated in 3.0 and removed in 3.1+ as well. So if you're not using
glDrawPixels
, you wouldn't be using matrix functions either. So it's nothing to be concerned about.