Skip to content

fix text texture updating #3697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/webgl/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,7 @@ p5.RendererGL.prototype._renderText = function(p, line, x, y, maxY) {
var initializeShader = !this._defaultFontShader;
var sh = this._getFontShader();
sh.init();
sh.bindShader(); // first time around, bind the shader fully

if (initializeShader) {
// these are constants, really. just initialize them one-time.
Expand Down Expand Up @@ -688,7 +689,6 @@ p5.RendererGL.prototype._renderText = function(p, line, x, y, maxY) {
try {
var dx = 0; // the x position in the line
var glyphPrev = null; // the previous glyph, used for kerning
var shaderBound = false;
// fetch the glyphs in the line of text
var glyphs = font.stringToGlyphs(line);
for (var ig = 0; ig < glyphs.length; ++ig) {
Expand All @@ -709,12 +709,7 @@ p5.RendererGL.prototype._renderText = function(p, line, x, y, maxY) {
sh.setUniform('uGlyphRect', gi.uGlyphRect);
sh.setUniform('uGlyphOffset', dx);

if (!shaderBound) {
shaderBound = true;
sh.bindShader(); // first time around, bind the shader fully
} else {
sh.bindTextures(); // afterwards, only textures need updating
}
sh.bindTextures(); // afterwards, only textures need updating

// draw it
gl.drawElements(gl.TRIANGLES, 6, this.GL.UNSIGNED_SHORT, 0);
Expand Down