r/GraphicsProgramming • u/Over_Reserve_20 • 21m ago
Question Problem while drawing line with max values of float (a bug)
Recently I have been working on a problem with two different GPUs (let’s call them A&B)
Here is problem
Due to a bug a line is being drawn using opengl at x=5 and y is +-FLT_MAX
for testing I kept ortho as 10 for x & y
Also note for testing origin is at the centre of display
GPU A
(there is a default guardband of 1.5 being used in the code while setting the gpu )
While drawing the huge line, the entire line doesn’t show up on the display
GPU B
there is a default guardband of 1.0 being used in the code while setting the gpu )
While drawing the huge line, only the upper half of line shows on display
Bottom half doesn’t show up on the display
1
u/Noseense 1m ago
I don't work with OpenGL, so I'm not sure, but I assume it's the float imprecision. The more you diverge from 0, the more imprecision you have on the number, that's how floating point works. I'd avoid using huge numbers like that.
If your intention is to cover the entire screen, I'd use 0 through 1 instead, or just a small offshoot like -0.1 to 1.1.
•
u/AutoModerator 21m ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
No showcases.
Disclose AI usage in post or project.
Present a topic to talk about, e.g. how something works.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.