Skip to content

Commit

Permalink
#154 webglパッケージをv2へ移行(WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Sep 11, 2024
1 parent 0eec20b commit e21cf04
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/CoreUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const $PREFIX: string = "__next2d__";
* @type {number}
* @const
*/
export const $devicePixelRatio: number = window.devicePixelRatio;
export const $devicePixelRatio: number = Math.min(2, window.devicePixelRatio);

/**
* @param {number} value
Expand Down
2 changes: 1 addition & 1 deletion packages/webgl/src/Context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ export class Context
drawPixels (node: Node, pixels: Uint8Array): void
{
contextDrawPixelsUseCase(node, pixels);
}
};

/**
* @description マスクを開始準備
Expand Down
54 changes: 27 additions & 27 deletions packages/webgl/src/Mesh/service/MeshFillGenerateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

buffer[position++] = vertex[idx] as number;
buffer[position++] = vertex[idx + 1] as number;
Expand All @@ -71,13 +71,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

buffer[position++] = vertex[idx + 3] as number;
buffer[position++] = vertex[idx + 4] as number;
Expand All @@ -91,13 +91,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

} else if (vertex[idx + 5]) {

Expand All @@ -113,13 +113,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

buffer[position++] = vertex[idx] as number;
buffer[position++] = vertex[idx + 1] as number;
Expand All @@ -133,13 +133,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

buffer[position++] = vertex[idx + 6] as number;
buffer[position++] = vertex[idx + 7] as number;
Expand All @@ -153,13 +153,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

} else {

Expand All @@ -175,13 +175,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

buffer[position++] = vertex[idx] as number;
buffer[position++] = vertex[idx + 1] as number;
Expand All @@ -195,13 +195,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;

buffer[position++] = vertex[idx + 3] as number;
buffer[position++] = vertex[idx + 4] as number;
Expand All @@ -215,13 +215,13 @@ export const execute = (vertex: IPath, buffer: Float32Array, index: number): num

buffer[position++] = matrix[0];
buffer[position++] = matrix[1];
buffer[position++] = matrix[2];
buffer[position++] = 0;
buffer[position++] = matrix[3];
buffer[position++] = matrix[4];
buffer[position++] = matrix[5];
buffer[position++] = 0;
buffer[position++] = matrix[6];
buffer[position++] = matrix[7];
buffer[position++] = matrix[8];
buffer[position++] = 0;
}

index += 3;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { ShaderManager } from "../../ShaderManager";
import {
$context,
$RENDER_MAX_SIZE,
$inverseMatrix
$inverseMatrix,
$getViewportWidth,
$getViewportHeight
} from "../../../WebGLUtil";

/**
Expand Down Expand Up @@ -55,8 +56,8 @@ export const execute = (
highp[19] = inverseMatrix[8];

// vertex: u_viewport
highp[3] = $RENDER_MAX_SIZE;
highp[7] = $RENDER_MAX_SIZE;
highp[3] = $getViewportWidth();
highp[7] = $getViewportHeight();

let index = 20;
if (has_grid) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ShaderManager } from "../../ShaderManager";
import {
$RENDER_MAX_SIZE,
$context
$context,
$getViewportHeight,
$getViewportWidth
} from "../../../WebGLUtil";

/**
Expand Down Expand Up @@ -34,6 +35,6 @@ export const execute = (shader_manager: ShaderManager, width: number, height: nu
highp[14] = 1;

// vertex: u_viewport
highp[7] = $RENDER_MAX_SIZE;
highp[11] = $RENDER_MAX_SIZE;
highp[7] = $getViewportWidth();
highp[11] = $getViewportHeight();
};
1 change: 0 additions & 1 deletion packages/webgl/src/shader/fragment/FragmentShaderSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export const SOLID_COLOR = (): string =>
return `#version 300 es
precision mediump float;
uniform vec4 u_mediump;
in vec4 v_color;
out vec4 o_color;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export const execute = (
vertexShaderSource = FILL_TEMPLATE(
highpLength, true, false, has_grid
);
console.log(vertexShaderSource);
}

const fragmentShaderSource = repeat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { GRADIENT_TEMPLATE } from "../../../Fragment/FragmentShaderSourceGradien
* @description グラデーションのシェーダを生成して返却
* Generate and return the shader of gradient
*
* @param {boolean} is_stroke
* @param {boolean} has_grid
* @param {boolean} is_radial
* @param {boolean} has_focal_point
* @param {number} spread_method
* @param {boolean} is_stroke
* @param {boolean} has_grid
* @param {boolean} is_radial
* @param {boolean} has_focal_point
* @param {number} spread_method
* @return {ShaderManager}
* @method
* @protected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const execute = (is_stroke: boolean, has_grid: boolean): ShaderManager =>
highpLength, fragmentIndex,
false, has_grid
);
console.log(vertexShaderSource);
} else {
vertexShaderSource = FILL_TEMPLATE(
highpLength, false, false, has_grid
Expand Down
2 changes: 1 addition & 1 deletion packages/webgl/src/shader/vertex/VertexShaderSourceFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ ${gridFunction}
void main() {
${colorStatement}
${uvStatement}
vec2 pos = applyMatrix(a_vertex) ;
vec2 pos = applyMatrix(a_vertex);
pos = pos * 2.0 - 1.0;
gl_Position = vec4(pos.x, -pos.y, 0.0, 1.0);
}`;
Expand Down

0 comments on commit e21cf04

Please sign in to comment.