How to program graphics tablet sensitivity in OpenGL?

My name is Brandon SHIMAJE, I am currently trying to create a drawing software in Open GL, I would like to know if someone of you could kindly provide me with a controller or some function to be able to control the graphic tablet with open GL and to be able to program the part of sensitivity when drawing a line.
I know that you can use the left and right keys but to make the effect of the sensitivity as shown in the image I would have to use.
I have configured both the pen and the tablet to be left or right click but I don’t know where to have a controller for the sensitivity part.
Thank you.

if i understand correctly, you want to control the width of the line you are currently drawing, probably depending on the pressure. that is a hardware feature of the tablet/pen you are using, and it has nothing to do with OpenGL. OpenGL is a library that draws triangles, points and lines. it doesn’t handle any kind of user input (by mouse, keyboard, pens etc.), though there are some utility libraries which provide those functions. if you have an android tablet, there are probably functions for handling pen input in the android SDK.

1 Like

Ok, I saw that for what I’m doing I could use better GLFW and GLEW, although it is true I continue with the insertion of being able to control the width of the brush, I will take your possible solution. Thanks a lot.
I’m still open to more opinions.

As RigidBody notes, OpenGL only deals with rendering, not input.

You can control the width of lines with glLineWidth. When drawing multiple lines with a single drawing command (i.e. a mode of GL_LINES, GL_LINE_STRIP or GL_LINE_LOOP), all lines have the same width. Also, you can’t vary the width over the course of a single line segment. Another issue with “thick” lines is that OpenGL doesn’t draw “joins” between segments; each segment is a rectangle whose ends are perpendicular to the line direction, so this can leave visible gaps if the line thickness is large and the change in direction at a vertex is significant.

So for thick lines, you have two main options:

  1. Draw a sequence of lines where the individual segments are small enough that neither the change in width along the segment nor the change in angle between segments are significant.
  2. Tessellate the “stroke” into triangles. Essentially, the line becomes a sequence of trapezoids, with each trapezoid split into two triangles. But thin triangles can leave gaps; without anti-aliasing, a triangle only affects pixels whose centres lie inside the triangle. So unless the line width is guaranteed to be wider than a pixel (at least √2 pixels wide to allow for diagonal lines), you should also draw a thin line along the centre of the stroke.

Great, now I understand more what I could do, Thanks !!