The following code gives an updated bmp to my program except where the wave "runs out of space" and it does not fill the other side of the target. So previously written portions remain there (i.e. stripes).
al_set_target_bitmap(bmp); al_use_shader(waves); al_set_shader_sampler("tex", wtr, 0); al_set_shader_float("tx" , tx); al_draw_bitmap(wtr, 0, 0, 0); al_use_shader(NULL); al_set_target_backbuffer(display); al_clear_to_color(al_map_rgb(215, 255, 255)); al_draw_bitmap(bmp, 0, 0, 0); etc..
// Vertex varying vec2 v_texCoord; void main() { v_texCoord = gl_MultiTexCoord0; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
I don't know what to do about this.
return vec2(fmod(p.x+x , 1.0f), p.y);
Thanks, it gives "no matching overloaded function found" which I can fix by using this
rx = (p.x+x) - 1.0f * floor((p.x+x) / 1.0f); return vec2(rx, p.y);
What do I need for fmod? Should it run through a C preprocessor?
(Sorry this is not in the right forum.)
mod in GLSL is equivalent to C's fmod. Does that resolve your issue?
It does thanks,
return vec2(mod(p.x+x , 1.0f), mod(p.y+y , 1.0f));
I send an offset (p.x = p.x + delta_x) with every shader call. Can older GLSL versions (like 2.1) have such a 'counter' running inside them?
Shouldn't this just be a texture wrapping mode change? That's going to be far more efficient than using the mod() function.
I searched for that before asking, "texture wrapping mode" like e.g. GL_REPEAT right?
https://learnopengl.com/Getting-started/Textures says that's repeating a texture within a bitmap I understand.
I'm looking for Doom's Wall of Faces: https://www.youtube.com/watch?v=xhs0Gk7E-U8
Shouldn't this just be a texture wrapping mode change? That's going to be far more efficient than using the mod() function.
Bob, how do you do that with a sub texture without the use of mod? Say, in the case of a sprite atlas?
Yeah I use mod in my game for maps because all the map tiles are on the same texture. RuneScape does the same thing for its giant texture atlases.
Yes, fixed-function texture wrapping (like GL_REPEAT) doesn't work for atlases. It wasn't clear from the OP that atlases were involved.
FWIW, texture arrays are preferred if you can fit your atlas as equally-sized textures.
Using mod() has some edge cases that need to be handled: large coordinates, negative coordinates, correct padding for anisotropic filters, ... which you don't need to think about with the HW-provided features.
Yeah, my solution for those problems is don't worry about it. Haha.