can write to any location
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@
|
|||||||
uniform float iTime;
|
uniform float iTime;
|
||||||
uniform vec2 iResolution;
|
uniform vec2 iResolution;
|
||||||
in vec2 vUV;
|
in vec2 vUV;
|
||||||
out vec3 fragColor;
|
layout(location = 0) out vec3 fragColor;
|
||||||
uniform sampler2D frame0;
|
uniform sampler2D frame0;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -12,5 +12,5 @@ void main() {
|
|||||||
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
|
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
|
||||||
vec3 color = vec3(vUV, sin(iTime * 0.5) * 0.5 + 0.5);
|
vec3 color = vec3(vUV, sin(iTime * 0.5) * 0.5 + 0.5);
|
||||||
color *= 1 - step(cos(iTime) * 0.1 + 0.4, length(uv1));
|
color *= 1 - step(cos(iTime) * 0.1 + 0.4, length(uv1));
|
||||||
fragColor = color + texture(frame0, vUV - 0.01).xyz * 0.5;
|
fragColor = color + texture(frame0, vUV - 0.04).xyz * 0.5;
|
||||||
}
|
}
|
||||||
+3
-3
@@ -12,10 +12,10 @@
|
|||||||
#define ANSI_COLOR_RESET "\x1b[0m"
|
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||||
|
|
||||||
#define log_debug(format, ...) \
|
#define log_debug(format, ...) \
|
||||||
fprintf(stderr, ANSI_COLOR_MAGENTA "[DEBUG] " format ANSI_COLOR_RESET \
|
fprintf(stderr, ANSI_COLOR_MAGENTA "[DEBG] " format ANSI_COLOR_RESET \
|
||||||
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||||
#define log_success(format, ...) \
|
#define log_success(format, ...) \
|
||||||
fprintf(stdout, ANSI_COLOR_GREEN "[SUCCESS] " format ANSI_COLOR_RESET \
|
fprintf(stdout, ANSI_COLOR_GREEN "[SUCC] " format ANSI_COLOR_RESET \
|
||||||
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||||
#define log_info(format, ...) \
|
#define log_info(format, ...) \
|
||||||
fprintf(stdout, "[INFO] " format "\n" __VA_OPT__(, ) __VA_ARGS__)
|
fprintf(stdout, "[INFO] " format "\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
fprintf(stderr, ANSI_COLOR_YELLOW "[WARN] " format ANSI_COLOR_RESET \
|
fprintf(stderr, ANSI_COLOR_YELLOW "[WARN] " format ANSI_COLOR_RESET \
|
||||||
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||||
#define log_error(format, ...) \
|
#define log_error(format, ...) \
|
||||||
fprintf(stderr, ANSI_COLOR_RED "[ERROR] " format ANSI_COLOR_RESET \
|
fprintf(stderr, ANSI_COLOR_RED "[FAIL] " format ANSI_COLOR_RESET \
|
||||||
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+8
-6
@@ -56,17 +56,19 @@ bool init_textures(ShaderProgram *program, Context context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_framebuffers(ShaderProgram *program) {
|
void init_framebuffers(ShaderProgram *program) {
|
||||||
int i;
|
int i, j;
|
||||||
|
|
||||||
glGenFramebuffers(BUFFER_COUNT, program->frame_buffers);
|
glGenFramebuffers(BUFFER_COUNT, program->frame_buffers);
|
||||||
|
|
||||||
for (i = 0; i < BUFFER_COUNT; i++) {
|
for (i = 0; i < BUFFER_COUNT; i++) {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, program->frame_buffers[i]);
|
glBindFramebuffer(GL_FRAMEBUFFER, program->frame_buffers[i]);
|
||||||
|
|
||||||
|
for (j = 0; j < BUFFER_COUNT; j++) {
|
||||||
// attaches a selected mipmap level or image of a texture object as one of
|
// attaches a selected mipmap level or image of a texture object as one of
|
||||||
// the logical buffers of the framebuffer object
|
// the logical buffers of the framebuffer object
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + j,
|
||||||
program->textures[i], 0);
|
GL_TEXTURE_2D, program->textures[j], 0);
|
||||||
|
}
|
||||||
|
|
||||||
// check framebuffer status
|
// check framebuffer status
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
@@ -77,6 +79,8 @@ void init_framebuffers(ShaderProgram *program) {
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_success("Framebuffer %d initialized", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -157,9 +161,7 @@ void init_single_program(ShaderProgram *program, int i, bool output) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ShaderProgram init_program(File fragment_shader, Context context) {
|
ShaderProgram init_program(File fragment_shader, Context context) {
|
||||||
int i, j;
|
int i;
|
||||||
char uniform_name[32];
|
|
||||||
|
|
||||||
ShaderProgram program = {.error = false,
|
ShaderProgram program = {.error = false,
|
||||||
.last_width = context.width,
|
.last_width = context.width,
|
||||||
.last_height = context.height};
|
.last_height = context.height};
|
||||||
|
|||||||
Reference in New Issue
Block a user