Jump to content

Search the Community

Showing results for tags 'v2 to v3'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. Hi, I'm having a bit of trouble with my conversion of a piece of code. I have a layering object than "clips" a region of the screen before it draws it's children. On v2 it was quite easy to do: WindowLayer.prototype._webglMaskRect = function(renderSession, x, y, w, h) { if (w > 0 && h > 0) { var gl = renderSession.gl; var projection = renderSession.projection; console.log(renderSession); var offset = renderSession.offset; var shader = renderSession.shaderManager.primitiveShader; renderSession.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.translationMatrix, false, this._translationMatrix); gl.uniform1f(shader.flipY, 1); gl.uniform2f(shader.projectionVector, projection.x, -projection.y); gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); gl.stencilFunc(gl.EQUAL, 0, 0xFF); gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); var data = new Float32Array([x, y, x+w, y, x, y+h, x, y+h, x+w, y, x+w, y+h]); gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); gl.enableVertexAttribArray(shader.aVertexPosition); gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLES, 0, 6); gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }};Right now I could move the projection matrix to this: WindowLayer.prototype._webglMaskRect = function(renderSession, x, y, w, h) { if (w > 0 && h > 0) { var gl = renderSession.gl; var projection = renderSession.currentRenderTarget.projectionMatrix; console.log(renderSession); // but here is the problem var offset = new Point(0, 0); var shader = renderSession.shaderManager.primitiveShader; renderSession.shaderManager.setShader(shader); gl.uniformMatrix3fv(shader.translationMatrix, false, this._translationMatrix); gl.uniform1f(shader.flipY, 1); gl.uniform2f(shader.projectionVector, projection.x, -projection.y); gl.uniform2f(shader.offsetVector, -offset.x, -offset.y); gl.stencilFunc(gl.EQUAL, 0, 0xFF); gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR); var data = new Float32Array([x, y, x+w, y, x, y+h, x, y+h, x+w, y, x+w, y+h]); gl.bindBuffer(gl.ARRAY_BUFFER, this._vertexBuffer); gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW); gl.enableVertexAttribArray(shader.aVertexPosition); gl.vertexAttribPointer(shader.aVertexPosition, 2, gl.FLOAT, false, 0, 0); gl.drawArrays(gl.TRIANGLES, 0, 6); gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP); }};But the offset (using 0,0 by now because I don't want to crash everything) is not correct if you move the origin of an sprite or tilling sprite... I don't find any translationPoint nor offsetPoint to do that. Does anyone knows how can I archieve the same effect? Thanks for reading my post
×
×
  • Create New...