vtk/0001-clean-up-some-old-opengl-es-stuff.patch
Stefan Brüns 6775ff2422 Accepting request 821682 from home:StefanBruens:branches:science
- Update to version 9.0.1:
  * Drop obsolete patches:
    + bundled_exodusii_add_missing_libpthread.patch
    + vtk-parallelgeometry-dependency.patch
    + vtk-qt-5.15-include-QPainterPath.patch
- Explicitly enable module RenderingContextOpenGL2 required for PCL
- Conditionally add pugixml-devel Requires in devel package
- Make devel package installable even when built without Java
- Remove CAPITALIZATION from comments
- Drop obsolete TK build dependency
- Drop unused wget build dependency
- Wrap devel-doc generation in bcond (keep defaulted to off), and
  drop the essentially empty package when disabled.
- Fix build on ARM/Qt GLES (boo#1172723):
  * set VTK_OPENGL_USE_GLES
  * Add 0001-clean-up-some-old-opengl-es-stuff.patch
  * Add 0001-Remove-duplicate-check-for-QOpenGLFunctions_3_2_Core.patch
  * Rebase 0001-Allow-compilation-on-GLES-platforms.patch
  * Add 0001-Replace-last-glDrawBuffer-call-with-glDrawBuffers-1.patch
  * Add 0001-Use-2D-textures-for-1D-texture-emulation-on-GLES.patch
  * Add 0001-Add-missing-guard-required-for-GLES-to-disable-stere.patch
  * Add 0001-Correct-GL_BACK-GL_BACK_LEFT-mapping-on-GLES.patch
  * Add 0002-Use-GL_DRAW_BUFFER0-instead-of-GL_DRAW_BUFFER-for-GL.patch
  * Add 0001-GL_POINT_SPRITE-is-only-available-for-Compatibility-.patch
  * Add 0002-Guard-GL_LINE_SMOOTH-for-GLES.patch
  * Add 0001-Guard-glPointSize-with-GL_ES_VERSION_3_0.patch
- Add 0001-Fix-PyVTKAddFile_-function-signature-mismatch.patch
- Add 0001-Replace-invalid-GL_LINE-with-GL_LINES-for-glDrawArra.patch

OBS-URL: https://build.opensuse.org/request/show/821682
OBS-URL: https://build.opensuse.org/package/show/science/vtk?expand=0&rev=164
2020-07-18 22:18:35 +00:00

248 lines
8.0 KiB
Diff

From 13956bf0d47391046e7bb08bb0b581d0850738a9 Mon Sep 17 00:00:00 2001
From: Ken Martin <ken.martin@kitware.com>
Date: Tue, 23 Jun 2020 14:31:15 -0400
Subject: [PATCH] clean up some old opengl es stuff
No longer have the version option so remove
Partially implement 1D textures as 2D
---
Examples/Android/ReadMe.txt | 6 +-
Rendering/OpenGL2/CMakeLists.txt | 6 +-
Rendering/OpenGL2/vtkTextureObject.cxx | 95 +++++++++++++++++++++++++-
ThirdParty/glew/vtk_glew.h.in | 45 ++++++------
4 files changed, 118 insertions(+), 34 deletions(-)
diff --git a/Examples/Android/ReadMe.txt b/Examples/Android/ReadMe.txt
index 7b43476bdd..9c6f5a102d 100644
--- a/Examples/Android/ReadMe.txt
+++ b/Examples/Android/ReadMe.txt
@@ -41,10 +41,6 @@ To build VTK and these examples follow the steps below.
* Run cmake on vtkandroid with -DVTK_ANDROID_BUILD=ON, if you use the gui add a
* boolean entry with that name prior to configuring and set it on.
-If you want OpenGL ES 3.0 support make sure to change the setting of
-OPENGL_ES_VERSION to 3.0. Volume Rendering requires ES 3.0. Make sure to turn on
-VTK_BUILD_EXAMPLES
-
* configure and generate as usual
* Once done run ninja or make as appropriate
@@ -60,4 +56,4 @@ cd into CMakeExternals/Build/vtk-android/Examples/Android/ExampleName/bin
You should see some apk files in this directory.
-You can adb install -r ExampleName-debug.apk and then run the example on your device
\ No newline at end of file
+You can adb install -r ExampleName-debug.apk and then run the example on your device
diff --git a/Rendering/OpenGL2/CMakeLists.txt b/Rendering/OpenGL2/CMakeLists.txt
index da43adb85f..0ea0ee3200 100644
--- a/Rendering/OpenGL2/CMakeLists.txt
+++ b/Rendering/OpenGL2/CMakeLists.txt
@@ -3,6 +3,7 @@ set(classes
vtkClearRGBPass
vtkClearZPass
vtkCompositePolyDataMapper2
+ vtkDataTransferHelper
vtkDefaultPass
vtkDepthImageProcessingPass
vtkDepthOfFieldPass
@@ -93,11 +94,6 @@ set(classes
vtkValuePass
vtkVolumetricPass)
-if (NOT DEFINED OPENGL_ES_VERSION)
- list(APPEND classes
- vtkDataTransferHelper)
-endif()
-
set(headers
vtkCompositePolyDataMapper2Internal.h
vtkOpenGL.h
vtkStateStorage.h
diff --git a/Rendering/OpenGL2/vtkTextureObject.cxx b/Rendering/OpenGL2/vtkTextureObject.cxx
index 6afef26d97..b491c62e89 100644
--- a/Rendering/OpenGL2/vtkTextureObject.cxx
+++ b/Rendering/OpenGL2/vtkTextureObject.cxx
@@ -1030,6 +1030,99 @@ bool vtkTextureObject::CreateTextureBuffer(
#else
+// Emulate 1D textures as 2D. Note that the any shader code will likely
+// have to be modified as well for this to work.
+
+//------------------------------------------------------------------------------
+bool vtkTextureObject::Create1D(
+ int numComps, vtkPixelBufferObject* pbo, bool shaderSupportsTextureInt)
+{
+ assert(this->Context);
+ assert(pbo->GetContext() == this->Context.GetPointer());
+
+ GLenum target = GL_TEXTURE_2D;
+
+ // Now, determine texture parameters using the information from the pbo.
+
+ // * internalFormat depends on number of components and the data type.
+ GLenum internalFormat =
+ this->GetInternalFormat(pbo->GetType(), numComps, shaderSupportsTextureInt);
+
+ // * format depends on the number of components.
+ GLenum format = this->GetFormat(pbo->GetType(), numComps, shaderSupportsTextureInt);
+
+ // * type if the data type in the pbo
+ GLenum type = this->GetDefaultDataType(pbo->GetType());
+
+ if (!internalFormat || !format || !type)
+ {
+ vtkErrorMacro("Failed to determine texture parameters.");
+ return false;
+ }
+
+ this->Target = target;
+ this->Context->ActivateTexture(this);
+ this->CreateTexture();
+ this->Bind();
+
+ pbo->Bind(vtkPixelBufferObject::UNPACKED_BUFFER);
+
+ // Source texture data from the PBO.
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glTexImage2D(target, 0, static_cast<GLint>(internalFormat),
+ static_cast<GLsizei>(pbo->GetSize() / static_cast<unsigned int>(numComps)), 1, 0, format, type,
+ BUFFER_OFFSET(0));
+ vtkOpenGLCheckErrorMacro("failed at glTexImage1D");
+ pbo->UnBind();
+ this->Deactivate();
+
+ this->Target = target;
+ this->Format = format;
+ this->Type = type;
+ this->Components = numComps;
+ this->Width = pbo->GetSize();
+ this->Height = 1;
+ this->Depth = 1;
+ this->NumberOfDimensions = 1;
+ return true;
+}
+
+//------------------------------------------------------------------------------
+bool vtkTextureObject::Create1DFromRaw(unsigned int width, int numComps, int dataType, void* data)
+{
+ assert(this->Context);
+
+ // Now determine the texture parameters using the arguments.
+ this->GetDataType(dataType);
+ this->GetInternalFormat(dataType, numComps, false);
+ this->GetFormat(dataType, numComps, false);
+
+ if (!this->InternalFormat || !this->Format || !this->Type)
+ {
+ vtkErrorMacro("Failed to determine texture parameters.");
+ return false;
+ }
+
+ GLenum target = GL_TEXTURE_2D;
+ this->Target = target;
+ this->Components = numComps;
+ this->Width = width;
+ this->Height = 1;
+ this->Depth = 1;
+ this->NumberOfDimensions = 1;
+ this->Context->ActivateTexture(this);
+ this->CreateTexture();
+ this->Bind();
+
+ glTexImage2D(this->Target, 0, this->InternalFormat, static_cast<GLsizei>(this->Width), 1, 0,
+ this->Format, this->Type, static_cast<const GLvoid*>(data));
+
+ vtkOpenGLCheckErrorMacro("failed at glTexImage1D");
+
+ this->Deactivate();
+ return true;
+}
+
// Description:
// Create a texture buffer basically a 1D texture that can be
// very large for passing data into the fragment shader
@@ -1037,7 +1130,7 @@ bool vtkTextureObject::CreateTextureBuffer(
unsigned int numValues, int numComps, int dataType, vtkOpenGLBufferObject* bo)
{
assert(this->Context);
- vtkErrorMacro("TextureBuffers not supported in OPenGL ES");
+ vtkErrorMacro("TextureBuffers not supported in OpenGL ES");
// TODO: implement 1D and Texture buffers using 2D textures
return false;
}
diff --git a/ThirdParty/glew/vtk_glew.h.in b/ThirdParty/glew/vtk_glew.h.in
index 6aa8c2ee9e..009f230b19 100644
--- a/ThirdParty/glew/vtk_glew.h.in
+++ b/ThirdParty/glew/vtk_glew.h.in
@@ -35,42 +35,41 @@
#endif
#if VTK_MODULE_vtkglew_GLES3
-# include <GLES3/gl3.h>
+#include <GLES3/gl3.h>
#elif TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
-# include <OpenGLES/ES3/gl.h>
+#include <OpenGLES/ES3/gl.h>
#elif VTK_MODULE_USE_EXTERNAL_vtkglew
-# include <GL/glew.h>
-# ifdef _WIN32
-# include <GL/wglew.h>
-# endif
+#include <GL/glew.h>
+#ifdef _WIN32
+#include <GL/wglew.h>
+#endif
#else
-# include <vtkglew/include/GL/glew.h>
-# ifdef _WIN32
-# include <vtkglew/include/GL/wglew.h>
-# endif
+#include <vtkglew/include/GL/glew.h>
+#ifdef _WIN32
+#include <vtkglew/include/GL/wglew.h>
+#endif
#endif
/* some fixes for both ES 2 and 3 */
#ifdef GL_ES_VERSION_3_0
-# define glDrawBuffer(arg)
-# define GL_BACK_LEFT 0
-# define GL_BACK_RIGHT 0
-# define GL_FRONT_LEFT 0
-# define GL_FRONT_RIGHT 0
+#define glDrawBuffer(arg)
+#define GL_BACK_LEFT 0
+#define GL_BACK_RIGHT 0
+#define GL_FRONT_LEFT 0
+#define GL_FRONT_RIGHT 0
/* this sends all the data each time as opposed to allowing a subset */
-# define glMultiDrawElements(mode, counts, type, indicies, primcount) \
- for (size_t eCount = 0; eCount < primcount; ++eCount) \
- { \
- glDrawElements(mode, *(counts + eCount), \
- type, (GLvoid *)(indicies[eCount])); \
- }
+#define glMultiDrawElements(mode, counts, type, indicies, primcount) \
+ for (size_t eCount = 0; eCount < primcount; ++eCount) \
+ { \
+ glDrawElements(mode, *(counts + eCount), type, (GLvoid*)(indicies[eCount])); \
+ }
#endif
/*** deal with some GLES 3.0 specific issues ***/
#ifdef GL_ES_VERSION_3_0
-# define GLEW_ARB_vertex_array_object 1
-# define GLEW_ARB_instanced_arrays 1
+#define GLEW_ARB_vertex_array_object 1
+#define GLEW_ARB_instanced_arrays 1
#endif
#endif
--
2.27.0