mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-30 20:13:22 +08:00
adjusted comments from article feedback
This commit is contained in:
@@ -10,7 +10,7 @@ layout (local_size_x = 10, local_size_y = 10, local_size_z = 1) in;
|
|||||||
|
|
||||||
layout(rgba32f, binding = 0) uniform image2D imgOutput;
|
layout(rgba32f, binding = 0) uniform image2D imgOutput;
|
||||||
|
|
||||||
layout (location = 0) uniform float t; /**< Time */
|
layout (location = 0) uniform float t; /** Time */
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
@@ -22,7 +22,7 @@ void main() {
|
|||||||
vec4 value = vec4(0.0, 0.0, 0.0, 1.0);
|
vec4 value = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
ivec2 texelCoord = ivec2(gl_GlobalInvocationID.xy);
|
ivec2 texelCoord = ivec2(gl_GlobalInvocationID.xy);
|
||||||
float speed = 0.5;
|
float speed = 0.5;
|
||||||
value.x = float(int((float(texelCoord.x)/(gl_NumWorkGroups.x)+t*speed)*100)%100)/100;
|
value.x = float(int((float(texelCoord.x)/(gl_NumWorkGroups.x*gl_WorkGroupSize.x)+t*speed)*100)%100)/100;
|
||||||
value.y = float(texelCoord.y)/(gl_NumWorkGroups.y);
|
value.y = float(texelCoord.y)/(gl_NumWorkGroups.y*gl_WorkGroupSize.y);
|
||||||
imageStore(imgOutput, texelCoord, value);
|
imageStore(imgOutput, texelCoord, value);
|
||||||
}
|
}
|
||||||
@@ -93,7 +93,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
// Create texture for opengl operation
|
// Create texture for opengl operation
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
GLuint texture;
|
unsigned int texture;
|
||||||
|
|
||||||
glGenTextures(1, &texture);
|
glGenTextures(1, &texture);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
@@ -115,7 +115,7 @@ int main(int argc, char* argv[])
|
|||||||
while (!glfwWindowShouldClose(window))
|
while (!glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
// Set frame time
|
// Set frame time
|
||||||
GLfloat currentFrame = glfwGetTime();
|
float currentFrame = glfwGetTime();
|
||||||
deltaTime = currentFrame - lastFrame;
|
deltaTime = currentFrame - lastFrame;
|
||||||
lastFrame = currentFrame;
|
lastFrame = currentFrame;
|
||||||
if(fCounter > 500) {
|
if(fCounter > 500) {
|
||||||
@@ -127,7 +127,7 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
computeShader.use();
|
computeShader.use();
|
||||||
computeShader.setFloat("t", currentFrame);
|
computeShader.setFloat("t", currentFrame);
|
||||||
glDispatchCompute((GLuint)TEXTURE_WIDTH/10, (GLuint)TEXTURE_HEIGHT/10, 1);
|
glDispatchCompute((unsigned int)TEXTURE_WIDTH/10, (unsigned int)TEXTURE_HEIGHT/10, 1);
|
||||||
|
|
||||||
// make sure writing to image has finished before read
|
// make sure writing to image has finished before read
|
||||||
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
glMemoryBarrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
|
||||||
|
|||||||
Reference in New Issue
Block a user