Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
VTK
VTK
Commits
d2335a5d
Commit
d2335a5d
authored
Apr 23, 2015
by
Ken Martin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some more fixes for apple to make VTK more 3.2 core compliant
Apple with 3.2 must use VAOs
parent
780a38c1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
69 additions
and
37 deletions
+69
-37
Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx
Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx
+10
-5
Rendering/ContextOpenGL2/vtkOpenGLContextDevice3D.cxx
Rendering/ContextOpenGL2/vtkOpenGLContextDevice3D.cxx
+4
-2
Rendering/OpenGL2/vtkTextureObject.cxx
Rendering/OpenGL2/vtkTextureObject.cxx
+10
-6
Rendering/OpenGL2/vtkTextureObject.h
Rendering/OpenGL2/vtkTextureObject.h
+2
-0
Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx
Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx
+37
-22
Rendering/VolumeOpenGL2/vtkOpenGLRayCastImageDisplayHelper.cxx
...ring/VolumeOpenGL2/vtkOpenGLRayCastImageDisplayHelper.cxx
+1
-0
Rendering/VolumeOpenGL2/vtkVolumeStateRAII.h
Rendering/VolumeOpenGL2/vtkVolumeStateRAII.h
+5
-2
No files found.
Rendering/ContextOpenGL2/vtkOpenGLContextDevice2D.cxx
View file @
d2335a5d
...
...
@@ -399,8 +399,9 @@ void vtkOpenGLContextDevice2D::ReadyVBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"uniform vec4 vertexColor;
\n
"
"void main() { gl_Frag
Color
= vertexColor; }"
,
"void main() { gl_Frag
Data[0]
= vertexColor; }"
,
// geometry shader
""
);
}
...
...
@@ -429,8 +430,9 @@ void vtkOpenGLContextDevice2D::ReadyVCBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"varying vec4 vertexColor;
\n
"
"void main() { gl_Frag
Color
= vertexColor; }"
,
"void main() { gl_Frag
Data[0]
= vertexColor; }"
,
// geometry shader
""
);
}
...
...
@@ -459,9 +461,10 @@ void vtkOpenGLContextDevice2D::ReadyVTBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"varying vec2 tcoord;
\n
"
"uniform sampler2D texture1;
\n
"
"void main() { gl_Frag
Color
= texture2D(texture1, tcoord); }"
,
"void main() { gl_Frag
Data[0]
= texture2D(texture1, tcoord); }"
,
// geometry shader
""
);
}
...
...
@@ -487,9 +490,10 @@ void vtkOpenGLContextDevice2D::ReadySBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"uniform vec4 vertexColor;
\n
"
"uniform sampler2D texture1;
\n
"
"void main() { gl_Frag
Color
= vertexColor*texture2D(texture1, gl_PointCoord); }"
,
"void main() { gl_Frag
Data[0]
= vertexColor*texture2D(texture1, gl_PointCoord); }"
,
// geometry shader
""
);
}
...
...
@@ -518,9 +522,10 @@ void vtkOpenGLContextDevice2D::ReadySCBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"varying vec4 vertexColor;
\n
"
"uniform sampler2D texture1;
\n
"
"void main() { gl_Frag
Color
= vertexColor*texture2D(texture1, gl_PointCoord); }"
,
"void main() { gl_Frag
Data[0]
= vertexColor*texture2D(texture1, gl_PointCoord); }"
,
// geometry shader
""
);
}
...
...
Rendering/ContextOpenGL2/vtkOpenGLContextDevice3D.cxx
View file @
d2335a5d
...
...
@@ -296,6 +296,7 @@ void vtkOpenGLContextDevice3D::ReadyVBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"uniform vec4 vertexColor;
\n
"
"uniform int numClipPlanes;
\n
"
"varying float clipDistances[6];
\n
"
...
...
@@ -304,7 +305,7 @@ void vtkOpenGLContextDevice3D::ReadyVBOProgram()
" {
\n
"
" if (clipDistances[planeNum] < 0.0) discard;
\n
"
" }
\n
"
" gl_Frag
Color
= vertexColor; }"
,
" gl_Frag
Data[0]
= vertexColor; }"
,
// geometry shader
""
);
}
...
...
@@ -340,6 +341,7 @@ void vtkOpenGLContextDevice3D::ReadyVCBOProgram()
"gl_Position = vertex*MCWCMatrix*WCDCMatrix; }
\n
"
,
// fragment shader
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"varying vec4 vertexColor;
\n
"
"uniform int numClipPlanes;
\n
"
"varying float clipDistances[6];
\n
"
...
...
@@ -348,7 +350,7 @@ void vtkOpenGLContextDevice3D::ReadyVCBOProgram()
" {
\n
"
" if (clipDistances[planeNum] < 0.0) discard;
\n
"
" }
\n
"
" gl_Frag
Color
= vertexColor; }"
,
" gl_Frag
Data[0]
= vertexColor; }"
,
// geometry shader
""
);
}
...
...
Rendering/OpenGL2/vtkTextureObject.cxx
View file @
d2335a5d
...
...
@@ -97,9 +97,11 @@ static const char *DepthTextureCompareFunctionAsString[8]=
//----------------------------------------------------------------------------
static
GLenum
OpenGLAlphaInternalFormat
[
5
]
=
{
GL_R
,
GL_R8
,
GL_R16
GL_R8
,
GL_R16
,
GL_R16F
,
GL_R32F
};
#else
...
...
@@ -122,9 +124,11 @@ static const char *DepthTextureCompareFunctionAsString[8]=
//----------------------------------------------------------------------------
static
GLenum
OpenGLAlphaInternalFormat
[
5
]
=
{
GL_R
,
GL_R
,
GL_R
GL_RED
,
GL_RED
,
GL_RED
,
GL_RED
,
GL_RED
};
#endif
...
...
@@ -1017,7 +1021,7 @@ unsigned int vtkTextureObject::GetInternalFormat(int vtktype, int numComps,
switch
(
numComps
)
{
case
1
:
this
->
InternalFormat
=
GL_R
;
this
->
InternalFormat
=
GL_R
ED
;
break
;
case
2
:
this
->
InternalFormat
=
GL_RG
;
...
...
Rendering/OpenGL2/vtkTextureObject.h
View file @
d2335a5d
...
...
@@ -106,6 +106,8 @@ public:
alpha
=
0
,
alpha8
,
alpha16
,
alpha16f
,
alpha32f
,
NumberOfAlphaFormats
};
...
...
Rendering/VolumeOpenGL2/vtkOpenGLGPUVolumeRayCastMapper.cxx
View file @
d2335a5d
...
...
@@ -88,9 +88,7 @@ public:
this
->
LoadDepthTextureExtensionsSucceeded
=
false
;
this
->
CameraWasInsideInLastUpdate
=
false
;
this
->
CubeVBOId
=
0
;
#ifndef __APPLE__
this
->
CubeVAOId
=
0
;
#endif
this
->
CubeIndicesId
=
0
;
this
->
VolumeTextureObject
=
0
;
this
->
NoiseTextureObject
=
0
;
...
...
@@ -251,9 +249,7 @@ public:
bool
HandleLargeDataTypes
;
GLuint
CubeVBOId
;
#ifndef __APPLE__
GLuint
CubeVAOId
;
#endif
GLuint
CubeIndicesId
;
vtkTextureObject
*
VolumeTextureObject
;
...
...
@@ -573,7 +569,7 @@ bool vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::LoadVolume(vtkRenderer* ren,
switch
(
noOfComponents
)
{
case
1
:
internalFormat
=
GL_R
8
;
internalFormat
=
GL_R
ED
;
format
=
GL_RED
;
break
;
case
2
:
...
...
@@ -1687,9 +1683,14 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateVolumeGeometry(
// Now create new ones
this
->
CreateBufferObjects
();
#ifndef __APPLE__
glBindVertexArray
(
this
->
CubeVAOId
);
// TODO: should realy use the built in VAO class
// which handles these apple issues internally
#ifdef __APPLE__
if
(
this
->
ContextCache
->
GetContextSupportsOpenGL32
())
#endif
{
glBindVertexArray
(
this
->
CubeVAOId
);
}
// Pass cube vertices to buffer object memory
glBindBuffer
(
GL_ARRAY_BUFFER
,
this
->
CubeVBOId
);
glBufferData
(
GL_ARRAY_BUFFER
,
points
->
GetData
()
->
GetDataSize
()
*
...
...
@@ -1707,15 +1708,20 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::UpdateVolumeGeometry(
}
else
{
#ifndef __APPLE__
glBindVertexArray
(
this
->
CubeVAOId
);
#else
glBindBuffer
(
GL_ARRAY_BUFFER
,
this
->
CubeVBOId
);
this
->
ShaderProgram
->
EnableAttributeArray
(
"in_vertexPos"
);
this
->
ShaderProgram
->
UseAttributeArray
(
"in_vertexPos"
,
0
,
0
,
VTK_FLOAT
,
3
,
vtkShaderProgram
::
NoNormalize
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
this
->
CubeIndicesId
);
#ifdef __APPLE__
if
(
!
this
->
ContextCache
->
GetContextSupportsOpenGL32
())
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
this
->
CubeVBOId
);
this
->
ShaderProgram
->
EnableAttributeArray
(
"in_vertexPos"
);
this
->
ShaderProgram
->
UseAttributeArray
(
"in_vertexPos"
,
0
,
0
,
VTK_FLOAT
,
3
,
vtkShaderProgram
::
NoNormalize
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
this
->
CubeIndicesId
);
}
else
#endif
{
glBindVertexArray
(
this
->
CubeVAOId
);
}
}
}
...
...
@@ -1918,9 +1924,12 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::
//----------------------------------------------------------------------------
void
vtkOpenGLGPUVolumeRayCastMapper
::
vtkInternal
::
CreateBufferObjects
()
{
#if
n
def __APPLE__
glGenVertexArrays
(
1
,
&
this
->
CubeVAOId
);
#ifdef __APPLE__
if
(
this
->
ContextCache
->
GetContextSupportsOpenGL32
())
#endif
{
glGenVertexArrays
(
1
,
&
this
->
CubeVAOId
);
}
glGenBuffers
(
1
,
&
this
->
CubeVBOId
);
glGenBuffers
(
1
,
&
this
->
CubeIndicesId
);
}
...
...
@@ -1928,12 +1937,15 @@ void vtkOpenGLGPUVolumeRayCastMapper::vtkInternal::CreateBufferObjects()
//----------------------------------------------------------------------------
void
vtkOpenGLGPUVolumeRayCastMapper
::
vtkInternal
::
DeleteBufferObjects
()
{
#ifndef __APPLE__
if
(
this
->
CubeVAOId
)
{
glDeleteVertexArrays
(
1
,
&
this
->
CubeVAOId
);
}
#ifdef __APPLE__
if
(
this
->
ContextCache
->
GetContextSupportsOpenGL32
())
#endif
{
glDeleteVertexArrays
(
1
,
&
this
->
CubeVAOId
);
}
}
if
(
this
->
CubeVBOId
)
{
...
...
@@ -2933,9 +2945,12 @@ void vtkOpenGLGPUVolumeRayCastMapper::GPURender(vtkRenderer* ren,
this
->
Impl
->
ShaderProgram
->
SetUniform4fv
(
"in_componentWeight"
,
1
,
&
fvalue4
);
}
#if
n
def __APPLE__
glBindVertexArray
(
this
->
Impl
->
CubeVAOId
);
#ifdef __APPLE__
if
(
this
->
Impl
->
ContextCache
->
GetContextSupportsOpenGL32
())
#endif
{
glBindVertexArray
(
this
->
Impl
->
CubeVAOId
);
}
glDrawElements
(
GL_TRIANGLES
,
this
->
Impl
->
BBoxPolyData
->
GetNumberOfCells
()
*
3
,
GL_UNSIGNED_INT
,
0
);
...
...
Rendering/VolumeOpenGL2/vtkOpenGLRayCastImageDisplayHelper.cxx
View file @
d2335a5d
...
...
@@ -203,6 +203,7 @@ void vtkOpenGLRayCastImageDisplayHelper::RenderTextureInternal( vtkVolume *vol,
std
::
string
VSSource
=
vtkTextureObjectVS
;
std
::
string
FSSource
=
"//VTK::System::Dec
\n
"
"//VTK::Output::Dec
\n
"
"varying vec2 tcoordVC;
\n
"
"uniform sampler2D source;
\n
"
"uniform float scale;
\n
"
...
...
Rendering/VolumeOpenGL2/vtkVolumeStateRAII.h
View file @
d2335a5d
...
...
@@ -56,9 +56,12 @@ class vtkVolumeStateRAII
~
vtkVolumeStateRAII
()
{
#if
n
def __
A
PPLE__
glBi
nd
V
er
texArray
(
0
);
#ifdef __PPLE__
if
(
vtkOpenGLRe
nder
Window
::
GetContextSupports32
())
#endif
{
glBindVertexArray
(
0
);
}
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
glBindBuffer
(
GL_ELEMENT_ARRAY_BUFFER
,
0
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment