0

I'm trying to draw square pixels using GL_POINTS but the pixels are rounded. I've tried using glDisable(GL_POINT_SMOOTH) but it doesn't seem to change anything.

Here's my code:

glDisable(GL_POINT_SMOOTH);
glPointSize(8); 
glBegin(GL_POINTS); 
glVertex2i(500, 400); 
glEnd();
Ziggy
  • 1
  • 2
  • 1
    If you really need squares/rectangles, you probably need to draw them as squares/rectangles (or a pair of triangles). – Jerry Coffin Jul 31 '22 at 21:30

1 Answers1

0

The glPointSize reference page (https://registry.khronos.org/OpenGL-Refpages/gl4/html/glPointSize.xhtml) notes that if you (or any library you're using) has called glEnable(GL_PROGRAM_POINT_SIZE) then the vertex shader will control the size of the points (rather than glPointSize() being in control).

Also, some platforms may have rather severe limits on the maximum point size: It might be the case that the maximum size is 1 (!) which means that (in effect) you don't have the ability to do square pixels at all. To check your platform's capabilities:

GLint sizeRange[2];
glGetIntegerv(GL_POINT_SIZE_RANGE,sizeRange);
//sizeRange[0] is the minimum; sizeRange[1] is the maximum

[ref: https://registry.khronos.org/OpenGL-Refpages/gl4/html/glGet.xhtml]

jh100
  • 416
  • 2
  • 7
  • glGetIntegerv(GL_POINT_SIZE_RANGE,sizeRange); returns a seemingly random hex value if sizeRange is 2 or more (it's different every time I run it but stays the same during runtime), and if sizeRange is 1 I get an exeption thrown : Run-Time Check Failure #2 - Stack around the variable 'sizeRange' was corrupted. – Ziggy Aug 02 '22 at 06:06
  • You aren't trying to print sizeRange *itself* are you? In that case, you'll get the address of the array...you'd want to output the individual elements by using sizeRange[0] or sizeRange[1] – jh100 Aug 04 '22 at 00:02
  • For some reason it randomly started working, I didn't change anything but print sizeRange and now I have nice square pixels, thank you! – Ziggy Aug 05 '22 at 03:06
  • Well now it's back to how it was(round pixels), and sizeRange[1] is printing 190. When it was working, sizeRange[1] would print 20. I didn't touch any code so I don't understand how it's changing. – Ziggy Aug 05 '22 at 18:11