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

Refactor texture-related classes #5277

Closed
jfirebaugh opened this issue Sep 12, 2017 · 1 comment
Closed

Refactor texture-related classes #5277

jfirebaugh opened this issue Sep 12, 2017 · 1 comment

Comments

@jfirebaugh
Copy link
Contributor

#5101 introduced RenderTexture and #5190 introduced Texture. There's also #4811, an older take on the same idea by @mourner, and existing code that uses texture-related WebGL calls directly without using either class.

We should refactor and sort this out. Here's my proposed design:

  • We need a state-tracking wrapper like gl-native's gl::State<T> and associated value traits.
  • However, the way that native does texture binding is not quite right. All that should be publicly exposed are property setters and methods on the Texture class. Internally, a property setter should:
    1. Check the tracked state, and exit if it's a redundant operation.
    2. If not, then check that tracked state of the texture binding for the current texture unit. If changing that is a redundant operation skip it, otherwise bind the texture.
    3. Update the state.
  • For texture handling that's not connected to a draw call (e.g. stuff that happens in the upload step), just always use texture unit 0. For texture handling during a draw call, there should be a way of supplying Texture references as the value of uniforms, and having the internals handle assigning unique texture units, binding the textures, and setting the unit identifiers with glUniform*.
@ryanhamley
Copy link
Contributor

Closing as outdated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants