Skip to content

Commit 54fc0f2

Browse files
Merge pull request #21 from divital-coder/multi_image_support
Final Google Summer of Code 2024, Pull Request
2 parents 181a53b + 31fdbda commit 54fc0f2

24 files changed

+1771
-492
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ FreeTypeAbstraction = "663a7486-cb36-511b-a19d-713bb74d65c9"
1515
GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
1616
GeometryTypes = "4d00f742-c7ba-57c2-abde-4428a4b178cb"
1717
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
18+
KernelAbstractions = "63c18a36-062a-441e-b654-da1e3ab1ce7c"
19+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1820
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
1921
MedEval3D = "07fe485e-7252-451c-a484-d20a4cdbbf79"
2022
MedImages = "fbff095b-7891-4fc4-b5e5-3cd99b9dd225"
2123
ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301"
24+
NIfTI ="a3a9e032-41b5-5fc4-967a-a6b7a19844d3"
2225
Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
2326
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
2427
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"

src/MedEye3d.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export SegmentationDisplay
1616
export OpenGLDisplayUtils
1717
# export DisplayWords.textLinesFromStrings
1818
export StructsManag
19+
export ShadersAndVerticiesForSuperVoxels
1920
# export DisplayWords.textLinesFromStrings
2021
# export StructsManag.getThreeDims
2122

@@ -35,10 +36,10 @@ include(joinpath("display", "GLFW", "DispUtils", "OpenGLDisplayUtils.jl"))
3536
include(joinpath("display", "GLFW", "shadersEtc", "ShadersAndVerticies.jl"))
3637
include(joinpath("display", "GLFW", "shadersEtc", "ShadersAndVerticiesForText.jl"))
3738
include(joinpath("display", "GLFW", "shadersEtc", "Uniforms.jl"))
38-
3939
include(joinpath("display", "GLFW", "textRender", "DisplayWords.jl"))
40-
4140
include(joinpath("display", "GLFW", "DispUtils", "TextureManag.jl"))
41+
include(joinpath("display", "GLFW", "shadersEtc", "ShadersAndVerticiesForLine.jl"))
42+
include(joinpath("display", "GLFW", "shadersEtc", "ShadersAndVerticiesForSupervoxels.jl"))
4243
include(joinpath("display", "GLFW", "startModules", "PrepareWindow.jl"))
4344

4445

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11

22
module OpenGLDisplayUtils
3-
export basicRender
3+
export basicRender
44
using ModernGL
5-
using GLFW,Base.Threads
6-
7-
8-
9-
5+
using GLFW, Base.Threads
6+
# using ..ShadersAndVerticiesForLine
107

118
"""
129
As most functions will deal with just addind the quad to the screen
1310
and swapping buffers
11+
12+
Incorporating rendering for crosshair
1413
"""
14+
# function basicRender(window)
15+
# glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, C_NULL)
16+
# end
17+
1518
function basicRender(window)
16-
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, C_NULL)
17-
# Swap front and back buffers
18-
GLFW.SwapBuffers(window)
19+
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, C_NULL)
20+
# Swap front and back buffers
21+
GLFW.SwapBuffers(window)
1922
end
20-
21-
2223
end #..OpenGLDisplayUtils

src/display/GLFW/DispUtils/StructsManag.jl

Lines changed: 70 additions & 229 deletions
Large diffs are not rendered by default.

src/display/GLFW/DispUtils/TextureManag.jl

Lines changed: 85 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ stores functions needed to create bind and update OpenGl textues
33
"""
44
module TextureManag
55
using Base: Float16
6+
using GLFW
67
using ModernGL, Base.Threads, Logging, Setfield
78
using ..OpenGLDisplayUtils, ..ForDisplayStructs, ..Uniforms, ..CustomFragShad, ..DataStructs, ..DisplayWords
89
export activateTextures, addTextToTexture, initializeTextures, createTexture, getProperGL_TEXTURE, updateImagesDisplayed, updateTexture, assignUniformsAndTypesToMasks
910

1011

12+
13+
1114
"""
1215
uploading data to given texture; of given types associated - specified in TextureSpec
1316
if we want to update only part of the texture we need to specify offset and size of texture we use
@@ -138,45 +141,112 @@ function getProperGL_TEXTURE(index::Int)::UInt32
138141
return eval(Meta.parse("GL_TEXTURE$(index)"))
139142
end#getProperGL_TEXTURE
140143

144+
"""
145+
Defines the switching of vao buffers for the rendering of
146+
dynamic crosshair
147+
"""
148+
# function crosshairDisplay(crosshair::GlShaderAndBufferFields, mainRect::GlShaderAndBufferFields, forDisplayConstants::forDisplayObjects)
149+
# #render onto the screen
150+
# glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, C_NULL) #taken out from the basicRender
151+
# ############################################
152+
# # glBindVertexArray(0) #unbinding the vao for main rect
153+
# # glUseProgram(crosshair.shaderProgram)
154+
# glBindVertexArray(crosshair.vao[]) #binding the vao for crosshair
155+
# glDrawElements(GL_LINES, 4, GL_UNSIGNED_INT, C_NULL)
156+
157+
# glBindVertexArray(0)
158+
# # glUseProgram(mainRect.shaderProgram) #unbinding the vao for crosshair
159+
# glBindVertexArray(mainRect.vao[])
160+
# ############################################
161+
162+
# GLFW.SwapBuffers(forDisplayConstants.window) #from basic render function
163+
164+
# end
165+
function crosshairDisplay(crosshair::GlShaderAndBufferFields, mainRect::GlShaderAndBufferFields, forDisplayConstants::forDisplayObjects)
166+
# Render main image
167+
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, C_NULL)
168+
169+
# Switch to crosshair shader and render crosshair
170+
glUseProgram(crosshair.shaderProgram)
171+
glBindVertexArray(crosshair.vao[])
172+
glDrawElements(GL_LINES, 4, GL_UNSIGNED_INT, C_NULL)
173+
174+
# Switch back to main shader program
175+
# using the shader program from the mainRect causes the image render to disappear, so better use the one from forDisplayConstants !!
176+
glUseProgram(forDisplayConstants.shader_program)
177+
glBindVertexArray(mainRect.vao[])
178+
179+
GLFW.SwapBuffers(forDisplayConstants.window)
180+
end
141181
"""
142182
coordinating updating all of the images, masks...
143183
singleSliceDat - holds data we want to use for update
144184
forDisplayObjects - stores all needed constants that holds reference to GLFW and OpenGL
145185
"""
146-
function updateImagesDisplayed(singleSliceDat::SingleSliceDat, forDisplayConstants::forDisplayObjects, wordsDispObj::ForWordsDispStruct, calcDimStruct::CalcDimsStruct, valueForMaskToSett::valueForMasToSetStruct)
186+
function updateImagesDisplayed(
187+
singleSliceDat::SingleSliceDat,
188+
forDisplayConstants::forDisplayObjects,
189+
wordsDispObj::ForWordsDispStruct,
190+
calcDimStruct::CalcDimsStruct,
191+
valueForMaskToSett::valueForMasToSetStruct,
192+
crosshair::GlShaderAndBufferFields,
193+
mainRect::GlShaderAndBufferFields,
194+
displayMode::DisplayMode)
195+
196+
197+
updateImagesDisplayed_inner(
198+
singleSliceDat,
199+
forDisplayConstants,
200+
wordsDispObj,
201+
calcDimStruct,
202+
valueForMaskToSett,
203+
crosshair,
204+
mainRect,
205+
displayMode)
206+
end
207+
208+
function updateImagesDisplayed_inner(
209+
singleSliceDat::SingleSliceDat,
210+
forDisplayConstants::forDisplayObjects,
211+
wordsDispObj::ForWordsDispStruct,
212+
calcDimStruct::CalcDimsStruct,
213+
valueForMaskToSett::valueForMasToSetStruct,
214+
crosshair::GlShaderAndBufferFields,
215+
mainRect::GlShaderAndBufferFields,
216+
displayMode::DisplayMode)
147217

148218

149-
updateImagesDisplayed_inner(singleSliceDat, forDisplayConstants, wordsDispObj, calcDimStruct, valueForMaskToSett)
150-
end
151219

152-
function updateImagesDisplayed_inner(singleSliceDat::SingleSliceDat, forDisplayConstants::forDisplayObjects, wordsDispObj::ForWordsDispStruct, calcDimStruct::CalcDimsStruct, valueForMaskToSett::valueForMasToSetStruct)
153-
# @info "top of updateimaegsDisplayed_inner"
154220
modulelistOfTextSpecs = forDisplayConstants.listOfTextSpecifications
155221

156222
for updateDat in singleSliceDat.listOfDataAndImageNames
157223
findList = findall((texSpec) -> texSpec.name == updateDat.name, modulelistOfTextSpecs)
158-
texSpec = !isempty(findList) ? modulelistOfTextSpecs[findList[1]] : throw(DomainError(findList, "no such name specified in start configuration - $( updateDat[1])"))
159-
updateTexture(updateDat.type, updateDat.dat, texSpec, 0, 0, calcDimStruct.imageTextureWidth, calcDimStruct.imageTextureHeight)
224+
# texSpec = !isempty(findList) ? modulelistOfTextSpecs[findList[1]] : throw(DomainError(findList, "no such name specified in start configuration - $( updateDat[1])"))
225+
texSpec = Nothing
226+
if !isempty(findList)
227+
texSpec = modulelistOfTextSpecs[findList[1]]
228+
updateTexture(updateDat.type, updateDat.dat, texSpec, 0, 0, calcDimStruct.imageTextureWidth, calcDimStruct.imageTextureHeight)
229+
end
160230
end #for
161231
#render text associated with this slice
162232

163-
# @info "above activate for text display"
164233
activateForTextDisp(
165234
wordsDispObj.shader_program_words, wordsDispObj.vbo_words, calcDimStruct)
166235

167-
168-
# @info "below activate for text display"
169236
matr = addTextToTexture(wordsDispObj, [singleSliceDat.textToDisp..., valueForMaskToSett.text], calcDimStruct)
170237

171238
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, C_NULL)
172239

173-
# @info "inside updateImagesDisplayed_inner"
174-
175240
reactivateMainObj(forDisplayConstants.shader_program, forDisplayConstants.vbo, calcDimStruct)
176241

177242

178-
#render onto the screen
243+
#only display crosshair in multi-image display mode
244+
# if displayMode == SingleImage
179245
OpenGLDisplayUtils.basicRender(forDisplayConstants.window)
246+
# elseif displayMode == MultiImage
247+
# crosshairDisplay(crosshair, mainRect, forDisplayConstants) #[source of issue in multi image and images do no apeear]
248+
# end
249+
180250
glFinish()
181251
end
182252

@@ -189,7 +259,7 @@ It would also assign proper openGl types to given julia data type, and pass data
189259
textSpecs - list of texture specificaton that we want to enrich by adding information about ..Uniforms
190260
return list of texture specifications enriched by information about ..Uniforms
191261
"""
192-
function assignUniformsAndTypesToMasks(textSpecs::Vector{TextureSpec}, shader_program::UInt32, windowControlStruct::WindowControlStruct)
262+
function assignUniformsAndTypesToMasks(textSpecs::Vector{TextureSpec{Float32}}, shader_program::UInt32)
193263

194264

195265
mapped = map(x -> setuniforms(x, shader_program), textSpecs)
@@ -375,3 +445,4 @@ end #addTextToTexture
375445

376446

377447
end #..TextureManag
448+

0 commit comments

Comments
 (0)