Skip to content

Commit

Permalink
It works YIPPIE!!11!
Browse files Browse the repository at this point in the history
  • Loading branch information
David-Orangemoon authored Jul 23, 2024
1 parent 33fbe0c commit 909932c
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions extensions/PenP/experi.js
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@

//console.log(this.triUniforms,uniforms,uniforms == this.triUniforms)
if (
(this.triPointCount <= TRIANGLES_PER_BUFFER * 3) &&
(this.triPointCount < TRIANGLES_PER_BUFFER * 3) &&
(shader == this.triShader &&
isDefault == this.triIsDefault &&
texture == this.triTexture) &&
Expand Down Expand Up @@ -1082,6 +1082,7 @@
const activeAttributes = gl.getProgramParameter(shaderDat.info.program, gl.ACTIVE_ATTRIBUTES);

const bufferInitilizer = {};
const dataInitilizer = {};

for (let attribID = 0; attribID < activeAttributes; attribID++) {
const attribDat = gl.getActiveAttrib(shaderDat.info.program, attribID);
Expand Down Expand Up @@ -1118,12 +1119,18 @@
}

declaration.data = createArray(declaration.unitSize * 3);
dataInitilizer[name] = new Float32Array(TRIANGLES_PER_BUFFER * declaration.unitSize * 3)

bufferInitilizer[name] = new Float32Array(TRIANGLES_PER_BUFFER * declaration.unitSize * 3);
bufferInitilizer[name] = {
numComponents:declaration.unitSize,
data:new Float32Array(TRIANGLES_PER_BUFFER * declaration.unitSize * 3)
};
this.programs[shaderName].attribDat[name] = declaration;
}

this.programs[shaderName].data = bufferInitilizer;
console.log(dataInitilizer);

this.programs[shaderName].data = dataInitilizer;
this.programs[shaderName].buffer = twgl.createBufferInfoFromArrays(
gl,
bufferInitilizer
Expand Down Expand Up @@ -1204,6 +1211,9 @@
_parseProjectShaders() {
Object.keys(this.shaders).forEach((shaderKey) => {
let shader = this.shaders[shaderKey];
//If we don't have webgl2 support. Don't
if (shader.projectData.vertShader.includes("#version 300 es") && (!isWebGL2)) return;

this.programs[shaderKey] = {
info: twgl.createProgramInfo(gl, [
shader.projectData.vertShader,
Expand Down Expand Up @@ -1309,6 +1319,10 @@
modifyDate: Date.now(),
};


//If we don't have webgl2 support. Don't
if (data.vertShader.includes("#version 300 es") && (!isWebGL2)) return;

this.programs[name] = {
info: twgl.createProgramInfo(gl, [data.vertShader, data.fragShader]),
uniformDat: {},
Expand Down Expand Up @@ -1827,6 +1841,12 @@
opcode: "getAllShaders",
text: "shaders in project",
},
{
disableMonitor: true,
opcode: "supportsWEBGL_TWO",
blockType: Scratch.BlockType.BOOLEAN,
text: "supports GLSL 3.0?"
},
{
disableMonitor: true,
opcode: "drawShaderTri",
Expand Down Expand Up @@ -4285,6 +4305,11 @@
document.body.appendChild(this.IFrame);
}

//Feature
supportsWEBGL_TWO() {
return isWebGL2;
}

//?Shader blocks
drawShaderTri({ shader, x1, y1, x2, y2, x3, y3 }, util) {
if (!this.programs[shader]) return;
Expand Down

0 comments on commit 909932c

Please sign in to comment.