Open pirelaurent opened 3 years ago
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.
I will work on this issue.
@pirelaurent For some reason, when I switched to P2D mode, no text is displayed on the screen anymore. @stalgiag any thought on this?
Perhaps the translate(-width / 2, -height /2)
line? The coordinate system is different in WebGL with (0,0) as the center of the canvas.
i don't know what you call 'switch'. You cannot change mode while running. You must run once with a webgl canvas, then stop, change to p2d, run again. if you use a p2d graphics to create text while in webgl (what i do frequently for response time), think about to advance image a little bit on z to be on top of background things for camera. Hth
When the text()
function gets called with P2D
renderer,in every call the _textAscent
property is NULL
. But when the text()
function gets called with WebGL
renderer, the _textAscent
property is NULL
for the 1st call and then it stays as it is for any further calls.
And the textAscend()
function only updates the values when _textAscent
is NULL
.
So the problem originates from the _renderer
properties where _textAscent
is initiated differently for P2D
and WebGL
. Further, the _texAscent
is updated via _updateTextMetrics()
only when _texAscent
property is NULL
.
Hence, it's not getting updated for new calls to textAscend()
.
Most appropriate sub-area of p5.js?
Details about the bug:
in Webgl Mode, textAscent() stays sticked to the first call result and is never updated.
in P2D textAScent() works correctly with same code :
Same thing of course for textDescent() .
function draw() { translate(-width/2,-height/2); background(0); fill('white'); textFont(consola); textSize(12); text('WEBGL : textAscent', 200,20); text('12: '+textAscent(), 20,20); textSize(14); text('14: '+textAscent(), 20,40); textSize(16); text('16: '+textAscent(), 20,60); textSize(32); text('32: '+textAscent(), 20,100); }