Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebGL Tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
최형택
WebGL Tutorial
Commits
54ed78b0
Commit
54ed78b0
authored
5 years ago
by
Pavel Dobryakov
Browse files
Options
Downloads
Patches
Plain Diff
can't figure this out rn, would come later
parent
bfb46362
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
script.js
+14
-5
14 additions, 5 deletions
script.js
with
14 additions
and
5 deletions
script.js
+
14
−
5
View file @
54ed78b0
...
@@ -201,7 +201,7 @@ function supportRenderTextureFormat (gl, internalFormat, format, type) {
...
@@ -201,7 +201,7 @@ function supportRenderTextureFormat (gl, internalFormat, format, type) {
gl
.
bindFramebuffer
(
gl
.
FRAMEBUFFER
,
fbo
);
gl
.
bindFramebuffer
(
gl
.
FRAMEBUFFER
,
fbo
);
gl
.
framebufferTexture2D
(
gl
.
FRAMEBUFFER
,
gl
.
COLOR_ATTACHMENT0
,
gl
.
TEXTURE_2D
,
texture
,
0
);
gl
.
framebufferTexture2D
(
gl
.
FRAMEBUFFER
,
gl
.
COLOR_ATTACHMENT0
,
gl
.
TEXTURE_2D
,
texture
,
0
);
cons
t
status
=
gl
.
checkFramebufferStatus
(
gl
.
FRAMEBUFFER
);
le
t
status
=
gl
.
checkFramebufferStatus
(
gl
.
FRAMEBUFFER
);
return
status
==
gl
.
FRAMEBUFFER_COMPLETE
;
return
status
==
gl
.
FRAMEBUFFER_COMPLETE
;
}
}
...
@@ -400,7 +400,7 @@ function createProgram (vertexShader, fragmentShader) {
...
@@ -400,7 +400,7 @@ function createProgram (vertexShader, fragmentShader) {
gl
.
linkProgram
(
program
);
gl
.
linkProgram
(
program
);
if
(
!
gl
.
getProgramParameter
(
program
,
gl
.
LINK_STATUS
))
if
(
!
gl
.
getProgramParameter
(
program
,
gl
.
LINK_STATUS
))
throw
gl
.
getProgramInfoLog
(
program
);
console
.
trace
(
gl
.
getProgramInfoLog
(
program
)
)
;
return
program
;
return
program
;
}
}
...
@@ -423,7 +423,7 @@ function compileShader (type, source, keywords) {
...
@@ -423,7 +423,7 @@ function compileShader (type, source, keywords) {
gl
.
compileShader
(
shader
);
gl
.
compileShader
(
shader
);
if
(
!
gl
.
getShaderParameter
(
shader
,
gl
.
COMPILE_STATUS
))
if
(
!
gl
.
getShaderParameter
(
shader
,
gl
.
COMPILE_STATUS
))
throw
gl
.
getShaderInfoLog
(
shader
);
console
.
trace
(
gl
.
getShaderInfoLog
(
shader
)
)
;
return
shader
;
return
shader
;
};
};
...
@@ -858,8 +858,10 @@ const vorticityShader = compileShader(gl.FRAGMENT_SHADER, `
...
@@ -858,8 +858,10 @@ const vorticityShader = compileShader(gl.FRAGMENT_SHADER, `
force *= curl * C;
force *= curl * C;
force.y *= -1.0;
force.y *= -1.0;
vec2 vel = texture2D(uVelocity, vUv).xy;
vec2 velocity = texture2D(uVelocity, vUv).xy;
gl_FragColor = vec4(vel + force * dt, 0.0, 1.0);
velocity += force * dt;
velocity = min(max(velocity, -1000.0), 1000.0);
gl_FragColor = vec4(velocity, 0.0, 1.0);
}
}
`
);
`
);
...
@@ -934,10 +936,17 @@ const blit = (() => {
...
@@ -934,10 +936,17 @@ const blit = (() => {
gl
.
clearColor
(
0.0
,
0.0
,
0.0
,
1.0
);
gl
.
clearColor
(
0.0
,
0.0
,
0.0
,
1.0
);
gl
.
clear
(
gl
.
COLOR_BUFFER_BIT
);
gl
.
clear
(
gl
.
COLOR_BUFFER_BIT
);
}
}
// CHECK_FRAMEBUFFER_STATUS();
gl
.
drawElements
(
gl
.
TRIANGLES
,
6
,
gl
.
UNSIGNED_SHORT
,
0
);
gl
.
drawElements
(
gl
.
TRIANGLES
,
6
,
gl
.
UNSIGNED_SHORT
,
0
);
}
}
})();
})();
function
CHECK_FRAMEBUFFER_STATUS
()
{
let
status
=
gl
.
checkFramebufferStatus
(
gl
.
FRAMEBUFFER
);
if
(
status
!=
gl
.
FRAMEBUFFER_COMPLETE
)
console
.
trace
(
"
Framebuffer error:
"
+
status
);
}
let
dye
;
let
dye
;
let
velocity
;
let
velocity
;
let
divergence
;
let
divergence
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment