-
-
Notifications
You must be signed in to change notification settings - Fork 380
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
VolumeMapper & OpenGLTexture: support updating image regions #3077
base: master
Are you sure you want to change the base?
Changes from all commits
5637574
f9152fc
8622fcf
fb9b67d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,24 +220,39 @@ function vtkOpenGLImageResliceMapper(publicAPI, model) { | |
|
||
const tex = model._openGLRenderWindow.getGraphicsResourceForObject(scalars); | ||
const reBuildTex = !tex?.vtkObj?.getHandle() || tex?.hash !== toString; | ||
if (reBuildTex) { | ||
if (!model.openGLTexture) { | ||
model.openGLTexture = vtkOpenGLTexture.newInstance(); | ||
model.openGLTexture.setOpenGLRenderWindow(model._openGLRenderWindow); | ||
} | ||
// Build the image scalar texture | ||
const dims = image.getDimensions(); | ||
// Use norm16 for the 3D texture if the extension is available | ||
const hasUpdatedExtents = !!model.renderable.getUpdatedExtents().length; | ||
|
||
if (!model.openGLTexture) { | ||
model.openGLTexture = vtkOpenGLTexture.newInstance(); | ||
model.openGLTexture.setOpenGLRenderWindow(model._openGLRenderWindow); | ||
} | ||
|
||
// reset the scalars texture if there are no updated extents | ||
if (reBuildTex && !hasUpdatedExtents) { | ||
// Use norm16 for scalar texture if the extension is available | ||
model.openGLTexture.setOglNorm16Ext( | ||
model.context.getExtension('EXT_texture_norm16') | ||
); | ||
|
||
model.openGLTexture.releaseGraphicsResources(model._openGLRenderWindow); | ||
model.openGLTexture.resetFormatAndType(); | ||
} | ||
|
||
if (reBuildTex || hasUpdatedExtents) { | ||
// If hasUpdatedExtents, then the texture is partially updated | ||
const updatedExtents = [...model.renderable.getUpdatedExtents()]; | ||
// clear the array to acknowledge the update. | ||
model.renderable.setUpdatedExtents([]); | ||
|
||
// Build the image scalar texture | ||
const dims = image.getDimensions(); | ||
model.openGLTexture.create3DFilterableFromDataArray( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should consider transitioning from positional arguments to object-based arguments. It would make it easier to track which arguments have default values and which ones need to be added. It wouldn't be a breaking change since this are not really public APIs that people use IMO There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good idea to consider. Probably best to wrap up such a change with the next major version increment anyways to be safe from a public API standpoint (even if it's mostly used internally). |
||
dims[0], | ||
dims[1], | ||
dims[2], | ||
scalars | ||
scalars, | ||
false, | ||
updatedExtents | ||
); | ||
if (scalars) { | ||
model._openGLRenderWindow.setGraphicsResourceForObject( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code has changed and there will be conflicts here
Look at how shared textures are handled in the mappers to make sure you do not break the resource sharing or create memory leaks