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

Add copy and clone methods in Program class #155

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RAX7
Copy link
Contributor

@RAX7 RAX7 commented Aug 3, 2022

In some cases it is necessary to create programs with the same shader code but different uniforms (eg texture or color). The clone method creates a shallow copy of Program class. Copies all properties by reference except the uniforms. If uniform value has a clone method (eg Vec2, Mat4), it will be used, otherwise (eg Texture) the value is copied by reference.

@Nam-Hai
Copy link
Contributor

Nam-Hai commented Nov 16, 2022

what is the difference by using the Program in the multiple Mesh you need and then change Mesh.program.uniforms.uTexture by hand ? Or am I mission something

@eXponenta
Copy link
Contributor

eXponenta commented Nov 16, 2022

@Nam-Hai Yep, clone doings fullcopy of programm include a uniforms state. You should know all copies of programm if you want to change uniforms state for all of them.

This is why i did proposal use a Material wrapper that will have shared program/material state.
#139

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.

3 participants