Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update program.py #180

Merged
merged 1 commit into from
Apr 5, 2024
Merged

Update program.py #180

merged 1 commit into from
Apr 5, 2024

Conversation

loreno-heer
Copy link
Contributor

Better #include handling using regex

This should fix the issue with includes that contain "-escaped strings. Did not test it though.
This should also work: r"#include\s+[",']?([^",']+)"

Better #include handling using regex
@einarf
Copy link
Member

einarf commented Oct 27, 2023

Thanks. There might be some unit tests for this. Will take a look over the weekend.

@loreno-heer
Copy link
Contributor Author

Thanks for looking into it. There might be some other changes needed as well. I still can't get the lygia library to work. I guess the finders somehow get confused with the relative paths.

@einarf
Copy link
Member

einarf commented Oct 27, 2023

Right. Looking at this ... https://github.com/patriciogonzalezvivo/lygia#how-to-use-it

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2    u_resolution;
uniform float   u_time;

#include "lygia/space/ratio.glsl"
#include "lygia/math/decimate.glsl"
#include "lygia/draw/circle.glsl"

void main(void) {
    vec3 color = vec3(0.0);
    vec2 st = gl_FragCoord.xy/u_resolution.xy;
    st = ratio(st, u_resolution);
    
    color = vec3(st.x,st.y,abs(sin(u_time)));
    color = decimate(color, 20.);
    color += circle(st, .5, .1);
    
    gl_FragColor = vec4(color, 1.0);
}

I would guess we would need to add some absolute search path to make this work, but I haven't looked at this in ages. It looks very doable to find a solution. I can clone the repo and give it a try soon. Through the creation of this library I was kind of trying to avoid relative paths entirely since they are a source of a lot of issues.

moderngl_window.resources.register_program_dir(absolute_path) is likely to solve it, or just add it to the generic resource path that includes all resource types.

def register_program_dir(path: Union[Path, str]) -> None:

I guess the best way to obtain the absolute path is to base it on the location of a module in your project using the __file__ module member.

@loreno-heer
Copy link
Contributor Author

perfect. thanks for the response. moderngl_window.resources.register_program_dir(absolute_path) worked.

@einarf einarf merged commit 712f252 into moderngl:master Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants