can write to any location
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@
|
||||
uniform float iTime;
|
||||
uniform vec2 iResolution;
|
||||
in vec2 vUV;
|
||||
out vec3 fragColor;
|
||||
layout(location = 0) out vec3 fragColor;
|
||||
uniform sampler2D frame0;
|
||||
|
||||
void main() {
|
||||
@@ -12,5 +12,5 @@ void main() {
|
||||
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
|
||||
vec3 color = vec3(vUV, sin(iTime * 0.5) * 0.5 + 0.5);
|
||||
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 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__)
|
||||
#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__)
|
||||
#define log_info(format, ...) \
|
||||
fprintf(stdout, "[INFO] " format "\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||
@@ -23,7 +23,7 @@
|
||||
fprintf(stderr, ANSI_COLOR_YELLOW "[WARN] " format ANSI_COLOR_RESET \
|
||||
"\n" __VA_OPT__(, ) __VA_ARGS__)
|
||||
#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__)
|
||||
|
||||
#endif
|
||||
+8
-6
@@ -56,17 +56,19 @@ bool init_textures(ShaderProgram *program, Context context) {
|
||||
}
|
||||
|
||||
void init_framebuffers(ShaderProgram *program) {
|
||||
int i;
|
||||
int i, j;
|
||||
|
||||
glGenFramebuffers(BUFFER_COUNT, program->frame_buffers);
|
||||
|
||||
for (i = 0; i < BUFFER_COUNT; 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
|
||||
// the logical buffers of the framebuffer object
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
|
||||
program->textures[i], 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + j,
|
||||
GL_TEXTURE_2D, program->textures[j], 0);
|
||||
}
|
||||
|
||||
// check framebuffer status
|
||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
@@ -77,6 +79,8 @@ void init_framebuffers(ShaderProgram *program) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
log_success("Framebuffer %d initialized", i);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -157,9 +161,7 @@ void init_single_program(ShaderProgram *program, int i, bool output) {
|
||||
}
|
||||
|
||||
ShaderProgram init_program(File fragment_shader, Context context) {
|
||||
int i, j;
|
||||
char uniform_name[32];
|
||||
|
||||
int i;
|
||||
ShaderProgram program = {.error = false,
|
||||
.last_width = context.width,
|
||||
.last_height = context.height};
|
||||
|
||||
Reference in New Issue
Block a user