Reputation: 14445
I'm working on a C#/OpenGL code base that runs on several platforms: iOS/OpenGL ES 2.0 through MonoTouch, Windows/OpenGL through OpenTK, as well as others.
When switching from quads to GL_POINTS
rendering, I noticed that the rectangles I'm drawing are rendered with an offset on iOS.
It seems that, on Windows, gl_Position
defines the center of the rectangle to be drawn. This is the behavior I'm expecting.
On iOS/OpenGL ES 2.0/MonoTouch, gl_Position
seems to set the upper-left corner of the rectangle.
I have spent several hours trying to identify the cause for this, because, of course, I think that this is caused by a bug in my code.
But before I lose more time on that: When using GL_POINTS
, what exactly does gl_Position
define? The center or the corner of the rectangle?
Upvotes: 2
Views: 541
Reputation: 43339
GL_POINTS
are not rectangles, first and foremost. It is an easy assumption to make, but implementations may draw them as circles if you enable point smoothing (deprecated) or multisampling. Point primitives are clipped against the location defined by gl_Position
, but rasterization behaves as described here.
My best guess has to do with sub-pixel precision during rasterization, GL ES tends to have less of it and things that have to be snapped to integer coordinates will behave less favorably. You can try a sub-pixel shift (e.g. 0.375 or 0.5) and see if that changes anything. Compliant implementations of OpenGL and OpenGL ES are both subject to the same rules when it comes to rasterizing point primitives.
Out of curiosity, what point size are you using? Anything other than exactly 1.0 is not guaranteed to be supported. Coupled with things like point size granularity, limited range and variable rasterization shape, GL_POINTS
are actually a poor substitute for quads.
Upvotes: 3