Commit ec84991f authored by Ken Martin's avatar Ken Martin

Convert Context2D to use more modern OpenGL

Also a few tweaks to get closer to OpenGL 32 support
for mesa.
parent ea6d55eb
......@@ -6,14 +6,12 @@ include(vtkObjectFactory)
set(module_SRCS
vtkOpenGLContextActor.cxx
vtkOpenGL2ContextDevice2D.cxx
vtkOpenGLContextBufferId.cxx
vtkOpenGLContextDevice2D.cxx
vtkOpenGLContextDevice3D.cxx
)
set_source_files_properties(
vtkOpenGL2ContextDevice2D
vtkOpenGLContextBufferId
vtkOpenGLContextDevice2D
vtkOpenGLContextDevice3D
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOpenGL2ContextDevice2D.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkOpenGL2ContextDevice2D.h"
#include "vtkVector.h"
#include "vtkRect.h"
#include "vtkPen.h"
#include "vtkBrush.h"
#include "vtkTextProperty.h"
#include "vtkPoints2D.h"
#include "vtkMatrix3x3.h"
#include "vtkFloatArray.h"
#include "vtkSmartPointer.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkViewport.h"
#include "vtkWindow.h"
#include "vtkTexture.h"
#include "vtkImageData.h"
#include "vtkRenderer.h"
#include "vtkOpenGLRenderer.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLError.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLContextDevice2DPrivate.h"
//-----------------------------------------------------------------------------
vtkStandardNewMacro(vtkOpenGL2ContextDevice2D);
//-----------------------------------------------------------------------------
bool vtkOpenGL2ContextDevice2D::IsSupported(vtkViewport *)
{
return true;
}
//-----------------------------------------------------------------------------
vtkOpenGL2ContextDevice2D::vtkOpenGL2ContextDevice2D()
{
}
//-----------------------------------------------------------------------------
vtkOpenGL2ContextDevice2D::~vtkOpenGL2ContextDevice2D()
{
}
//-----------------------------------------------------------------------------
void vtkOpenGL2ContextDevice2D::DrawPointSprites(vtkImageData *sprite,
float *points, int n,
unsigned char *colors,
int nc_comps)
{
vtkOpenGLClearErrorMacro();
if (points && n > 0)
{
this->SetPointSize(this->Pen->GetWidth());
if (sprite)
{
if (!this->Storage->SpriteTexture)
{
this->Storage->SpriteTexture = vtkTexture::New();
}
int properties = this->Brush->GetTextureProperties();
this->Storage->SpriteTexture->SetInputData(sprite);
this->Storage->SpriteTexture->SetRepeat(properties & vtkContextDevice2D::Repeat);
this->Storage->SpriteTexture->SetInterpolate(properties & vtkContextDevice2D::Linear);
this->Storage->SpriteTexture->Render(this->Renderer);
glEnable(GL_TEXTURE_2D);
}
// We can actually use point sprites here
glEnable(GL_POINT_SPRITE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
glPointParameteri(GL_POINT_SPRITE_COORD_ORIGIN, GL_LOWER_LEFT);
this->DrawPoints(points, n, colors, nc_comps);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_FALSE);
glDisable(GL_POINT_SPRITE);
if (sprite)
{
this->Storage->SpriteTexture->PostRender(this->Renderer);
glDisable(GL_TEXTURE_2D);
}
}
else
{
vtkWarningMacro(<< "Points supplied without a valid image or pointer.");
}
vtkOpenGLCheckErrorMacro("failed after DrawPointSprites");
}
//-----------------------------------------------------------------------------
void vtkOpenGL2ContextDevice2D::DrawImage(float p[2], float scale,
vtkImageData *image)
{
vtkOpenGLClearErrorMacro();
this->SetTexture(image);
this->Storage->Texture->Render(this->Renderer);
glEnable(GL_TEXTURE_2D);
int *extent = image->GetExtent();
float points[] = { p[0] , p[1],
p[0]+scale*extent[1]+1.0f, p[1],
p[0]+scale*extent[1]+1.0f, p[1]+scale*extent[3]+1.0f,
p[0] , p[1]+scale*extent[3]+1.0f };
float texCoord[] = { 0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f };
glColor4ub(255, 255, 255, 255);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
glTexCoordPointer(2, GL_FLOAT, 0, &texCoord[0]);
glDrawArrays(GL_QUADS, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
this->Storage->Texture->PostRender(this->Renderer);
glDisable(GL_TEXTURE_2D);
vtkOpenGLCheckErrorMacro("failed after DrawImage");
}
//-----------------------------------------------------------------------------
void vtkOpenGL2ContextDevice2D::DrawImage(const vtkRectf& pos,
vtkImageData *image)
{
vtkOpenGLClearErrorMacro();
GLuint index = this->Storage->TextureFromImage(image);
// this->SetTexture(image);
// this->Storage->Texture->Render(this->Renderer);
glEnable(GL_TEXTURE_2D);
float points[] = { pos.GetX() , pos.GetY(),
pos.GetX() + pos.GetWidth(), pos.GetY(),
pos.GetX() + pos.GetWidth(), pos.GetY() + pos.GetHeight(),
pos.GetX() , pos.GetY() + pos.GetHeight() };
float texCoord[] = { 0.0, 0.0,
1.0, 0.0,
1.0, 1.0,
0.0, 1.0 };
glColor4ub(255, 255, 255, 255);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &points[0]);
glTexCoordPointer(2, GL_FLOAT, 0, &texCoord[0]);
glDrawArrays(GL_QUADS, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
// this->Storage->Texture->PostRender(this->Renderer);
glDisable(GL_TEXTURE_2D);
glDeleteTextures(1, &index);
vtkOpenGLCheckErrorMacro("failed after DrawImage");
}
//----------------------------------------------------------------------------
void vtkOpenGL2ContextDevice2D::ReleaseGraphicsResources(vtkWindow *window)
{
this->vtkOpenGLContextDevice2D::ReleaseGraphicsResources(window);
}
//-----------------------------------------------------------------------------
void vtkOpenGL2ContextDevice2D::PrintSelf(ostream &os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkOpenGL2ContextDevice2D.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkOpenGL2ContextDevice2D - Class for drawing 2D primitives using
// OpenGL 2.
//
// .SECTION Description
// This class takes care of drawing the 2D primitives for the vtkContext2D class.
// In general this class should not be used directly, but called by vtkContext2D
// which takes care of many of the higher level details.
//
// It assumes that OpenGL 2 is available, which is taken care of by the
// vtkContextActor class. If OpenGL 2 is not available, but OpenGL rendering is
// required the vtkOpenGLContextDevice2D class should be used (employs GL 1.1).
//
// .SECTION See Also
// vtkOpenGLContextDevice2D
#ifndef vtkOpenGL2ContextDevice2D_h
#define vtkOpenGL2ContextDevice2D_h
#include "vtkOpenGLContextDevice2D.h"
class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGL2ContextDevice2D :
public vtkOpenGLContextDevice2D
{
public:
vtkTypeMacro(vtkOpenGL2ContextDevice2D, vtkOpenGLContextDevice2D);
virtual void PrintSelf(ostream &os, vtkIndent indent);
// Description:
// Creates a 2D Painter object.
static vtkOpenGL2ContextDevice2D *New();
// Description:
// Return true if the current rendering context supports this device.
static bool IsSupported(vtkViewport *viewport);
// Description:
// Draw a series of point sprites, images centred at the points supplied.
// The supplied vtkImageData is the sprite to be drawn, only squares will be
// drawn and the size is set using SetPointSize. Points are colored by colors array
// which has nc_comps components
virtual void DrawPointSprites(vtkImageData *sprite, float *points, int n,
unsigned char* colors = 0, int nc_comps = 0);
// Description:
// Draw the supplied image at the given x, y (p[0], p[1]) (bottom corner),
// scaled by scale (1.0 would match the image).
virtual void DrawImage(float p[2], float scale, vtkImageData *image);
// Description:
// Draw the supplied image at the given position. The origin, width, and
// height are specified by the supplied vtkRectf variable pos. The image
// will be drawn scaled to that size.
void DrawImage(const vtkRectf& pos, vtkImageData *image);
// Description:
// Release any graphics resources that are being consumed by this device.
// The parameter window could be used to determine which graphic
// resources to release.
virtual void ReleaseGraphicsResources(vtkWindow *window);
protected:
vtkOpenGL2ContextDevice2D();
virtual ~vtkOpenGL2ContextDevice2D();
private:
vtkOpenGL2ContextDevice2D(const vtkOpenGL2ContextDevice2D &); // Not implemented.
void operator=(const vtkOpenGL2ContextDevice2D &); // Not implemented.
};
#endif //vtkOpenGL2ContextDevice2D_h
......@@ -15,13 +15,12 @@
#include "vtkOpenGLContextActor.h"
#include "vtkContext2D.h"
#include "vtkOpenGLContextDevice2D.h"
#include "vtkOpenGL2ContextDevice2D.h"
#include "vtkContext3D.h"
#include "vtkOpenGLContextDevice3D.h"
#include "vtkContextScene.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLContextDevice2D.h"
#include "vtkOpenGLContextDevice3D.h"
#include "vtkRenderer.h"
vtkStandardNewMacro(vtkOpenGLContextActor);
......@@ -52,26 +51,44 @@ void vtkOpenGLContextActor::ReleaseGraphicsResources(vtkWindow *window)
}
//----------------------------------------------------------------------------
void vtkOpenGLContextActor::Initialize(vtkViewport* viewport)
// Renders an actor2D's property and then it's mapper.
int vtkOpenGLContextActor::RenderOverlay(vtkViewport* viewport)
{
vtkOpenGLContextDevice3D *dev = vtkOpenGLContextDevice3D::New();
this->Context3D->Begin(dev);
dev->Delete();
vtkDebugMacro(<< "vtkContextActor::RenderOverlay");
vtkContextDevice2D *device = NULL;
if (vtkOpenGL2ContextDevice2D::IsSupported(viewport))
if (!this->Context.GetPointer())
{
vtkDebugMacro("Using OpenGL 2 for 2D rendering.")
device = vtkOpenGL2ContextDevice2D::New();
vtkErrorMacro(<< "vtkContextActor::Render - No painter set");
return 0;
}
else
if (!this->Initialized)
{
vtkDebugMacro("Using OpenGL 1 for 2D rendering.")
device = vtkOpenGLContextDevice2D::New();
this->Initialize(viewport);
}
vtkOpenGLContextDevice3D::SafeDownCast(
this->Context3D->GetDevice())->Begin(viewport);
return this->Superclass::RenderOverlay(viewport);
}
//----------------------------------------------------------------------------
void vtkOpenGLContextActor::Initialize(vtkViewport* viewport)
{
vtkOpenGLContextDevice2D *device = NULL;
vtkDebugMacro("Using OpenGL 2 for 2D rendering.")
device = vtkOpenGLContextDevice2D::New();
if (device)
{
this->Context->Begin(device);
vtkOpenGLContextDevice3D *dev = vtkOpenGLContextDevice3D::New();
dev->Initialize(vtkRenderer::SafeDownCast(viewport), device);
this->Context3D->Begin(dev);
dev->Delete();
device->Delete();
this->Initialized = true;
}
......
......@@ -38,6 +38,10 @@ public:
// resources to release.
virtual void ReleaseGraphicsResources(vtkWindow *window);
// Description:
// We only render in the overlay for the context scene.
virtual int RenderOverlay(vtkViewport *viewport);
protected:
vtkOpenGLContextActor();
~vtkOpenGLContextActor();
......
......@@ -167,16 +167,9 @@ vtkIdType vtkOpenGLContextBufferId::GetPickedItem(int x, int y)
glDisable(GL_BLEND);
}
// Fixed-pipeline stuff
glActiveTexture(GL_TEXTURE0);
this->Texture->Bind();
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_REPLACE);
glEnable(GL_TEXTURE_2D);
this->Texture->CopyToFrameBuffer(x,y,x,y,x,y,
this->Context->GetSize()[0],
this->Context->GetSize()[1],NULL,NULL);
glDisable(GL_TEXTURE_2D);
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // restore
GLint savedReadBuffer;
glGetIntegerv(GL_READ_BUFFER,&savedReadBuffer);
......
......@@ -30,14 +30,22 @@
#include "vtkRenderingContextOpenGL2Module.h" // For export macro
#include "vtkContextDevice2D.h"
#include <vector> // STL Header
#include <list> // for std::list
class vtkMatrix4x4;
class vtkWindow;
class vtkViewport;
class vtkRenderer;
class vtkStringToImage;
class vtkOpenGLRenderWindow;
class vtkOpenGLExtensionManager;
class vtkTransform;
class vtkShaderProgram;
namespace vtkgl
{
class CellBO;
}
class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice2D : public vtkContextDevice2D
{
......@@ -272,6 +280,11 @@ public:
// resources to release.
virtual void ReleaseGraphicsResources(vtkWindow *window);
// Description:
// Get the projection matrix this is needed
vtkMatrix4x4 *GetProjectionMatrix();
vtkMatrix4x4 *GetModelMatrix();
//BTX
protected:
vtkOpenGLContextDevice2D();
......@@ -313,6 +326,24 @@ protected:
// The OpenGL render window being used by the device
vtkOpenGLRenderWindow* RenderWindow;
vtkgl::CellBO *VCBO; // vertex + color
void ReadyVCBOProgram();
vtkgl::CellBO *VBO; // vertex
void ReadyVBOProgram();
vtkgl::CellBO *VTBO; // vertex + tcoord
void ReadyVTBOProgram();
vtkgl::CellBO *SCBO; // sprite + color
void ReadySCBOProgram();
vtkgl::CellBO *SBO; // sprite
void ReadySBOProgram();
void SetMatrices(vtkShaderProgram *prog);
void BuildVBO(vtkgl::CellBO *cbo,
float *v, int nv,
unsigned char *coolors, int nc,
float *tcoords);
void CoreDrawTriangles(std::vector<float> &tverts);
private:
vtkOpenGLContextDevice2D(const vtkOpenGLContextDevice2D &); // Not implemented.
void operator=(const vtkOpenGLContextDevice2D &); // Not implemented.
......@@ -337,6 +368,9 @@ private:
}
};
vtkTransform *ProjectionMatrix;
vtkTransform *ModelMatrix;
std::list<vtkMarkerCacheObject> MarkerCache;
int MaximumMarkerCacheSize;
......
......@@ -225,7 +225,6 @@ public:
this->TextureProperties = vtkContextDevice2D::Linear |
vtkContextDevice2D::Stretch;
this->SpriteTexture = NULL;
this->SavedLighting = GL_TRUE;
this->SavedDepthTest = GL_TRUE;
this->SavedAlphaTest = GL_TRUE;
this->SavedStencilTest = GL_TRUE;
......@@ -236,8 +235,6 @@ public:
this->SavedClearColor[3] = 0.0f;
this->TextCounter = 0;
this->GLExtensionsLoaded = true;
this->OpenGL15 = true;
this->OpenGL20 = true;
this->GLSL = true;
this->PowerOfTwoTextures = false;
}
......@@ -258,7 +255,6 @@ public:
void SaveGLState(bool colorBuffer = false)
{
this->SavedLighting = glIsEnabled(GL_LIGHTING);
this->SavedDepthTest = glIsEnabled(GL_DEPTH_TEST);
if (colorBuffer)
......@@ -273,7 +269,6 @@ public:
void RestoreGLState(bool colorBuffer = false)
{
this->SetGLCapability(GL_LIGHTING, this->SavedLighting);
this->SetGLCapability(GL_DEPTH_TEST, this->SavedDepthTest);
if (colorBuffer)
......@@ -435,10 +430,6 @@ public:
GL_UNSIGNED_BYTE, static_cast<const GLvoid *>(dataPtr));
glAlphaFunc(GL_GREATER, static_cast<GLclampf>(0));
glEnable(GL_ALPHA_TEST);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
delete [] dataPtr;
return tmpIndex;
}
......@@ -478,10 +469,6 @@ public:
GL_UNSIGNED_BYTE, static_cast<const GLvoid *>(dataPtr));
glAlphaFunc(GL_GREATER, static_cast<GLclampf>(0));
glEnable(GL_ALPHA_TEST);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
return tmpIndex;
}
......@@ -489,7 +476,6 @@ public:
unsigned int TextureProperties;
vtkTexture *SpriteTexture;
// Store the previous GL state so that we can restore it when complete
GLboolean SavedLighting;
GLboolean SavedDepthTest;
GLboolean SavedAlphaTest;
GLboolean SavedStencilTest;
......@@ -501,8 +487,6 @@ public:
vtkVector2i Dim;
vtkVector2i Offset;
bool GLExtensionsLoaded;
bool OpenGL15;
bool OpenGL20;
bool GLSL;
bool PowerOfTwoTextures;
......
......@@ -25,9 +25,19 @@
#include "vtkRenderingContextOpenGL2Module.h" // For export macro
#include "vtkContextDevice3D.h"
#include "vtkNew.h" // For ivars.
#include <vector> // STL Header
class vtkBrush;
class vtkOpenGLRenderWindow;
class vtkOpenGLContextDevice2D;
class vtkPen;
class vtkRenderer;
class vtkTransform;
class vtkShaderProgram;
namespace vtkgl
{
class CellBO;
}
class VTKRENDERINGCONTEXTOPENGL2_EXPORT vtkOpenGLContextDevice3D : public vtkContextDevice3D
{
......@@ -101,6 +111,14 @@ public:
void EnableClippingPlane(int i, double *planeEquation);
void DisableClippingPlane(int i);
// Description
// This must be set during initialization
void Initialize(vtkRenderer *, vtkOpenGLContextDevice2D *);
// Description:
// Begin drawing, pass in the viewport to set up the view.
virtual void Begin(vtkViewport* viewport);
protected:
vtkOpenGLContextDevice3D();
~vtkOpenGLContextDevice3D();
......@@ -113,6 +131,31 @@ protected:
// End drawing, turn off the depth buffer.
virtual void DisableDepthBuffer();
vtkgl::CellBO *VCBO; // vertex + color
void ReadyVCBOProgram();
vtkgl::CellBO *VBO; // vertex
void ReadyVBOProgram();
void SetMatrices(vtkShaderProgram *prog);
void BuildVBO(vtkgl::CellBO *cbo,
const float *v, int nv,
const unsigned char *coolors, int nc,
float *tcoords);
void CoreDrawTriangles(std::vector<float> &tverts);
vtkTransform *ModelMatrix;
// Description:
// The OpenGL render window being used by the device
vtkOpenGLRenderWindow* RenderWindow;
// Description:
// We need to store a pointer to get the camera mats
vtkRenderer *Renderer;
std::vector<bool> ClippingPlaneStates;
std::vector<double> ClippingPlaneValues;
private:
vtkOpenGLContextDevice3D(const vtkOpenGLContextDevice3D &); // Not implemented.
void operator=(const vtkOpenGLContextDevice3D &); // Not implemented.
......@@ -122,6 +165,11 @@ private:
class Private;
Private *Storage;
// we need a pointer to this because only
// the 2D device gets a Begin and sets up
// the ortho matrix
vtkOpenGLContextDevice2D *Device2D;
vtkNew<vtkBrush> Brush;
vtkNew<vtkPen> Pen;
};
......
......@@ -393,12 +393,15 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderValues(std::string &VSSource,
}
else
{
substitute(FSSource,"//VTK::System::Dec",
"#ifdef GL_ES\n"
"#extension GL_OES_standard_derivatives : enable\n"
"#endif\n"
"//VTK::System::Dec\n",
false);
if (!vtkOpenGLRenderWindow::GetContextSupportsOpenGL32())
{
substitute(FSSource,"//VTK::System::Dec",
"#ifdef GL_ES\n"
"#extension GL_OES_standard_derivatives : enable\n"
"#endif\n"
"//VTK::System::Dec\n",
false);
}
if (actor->GetProperty()->GetRepresentation() == VTK_WIREFRAME)
{
// generate a normal for lines, it will be perpendicular to the line
......@@ -495,10 +498,13 @@ void vtkOpenGLPolyDataMapper::ReplaceShaderValues(std::string &VSSource,
// so we request the shader4 extension. This is particularly useful for apple
// systems that do not provide gl_PrimitiveId otherwise.
// we put this before the System Declarations
substitute(FSSource,"//VTK::System::Dec",
"#extension GL_EXT_gpu_shader4 : enable\n"
"//VTK::System::Dec\n",
false);
if (!vtkOpenGLRenderWindow::GetContextSupportsOpenGL32())
{
substitute(FSSource,"//VTK::System::Dec",
"#extension GL_EXT_gpu_shader4 : enable\n"
"//VTK::System::Dec\n",
false);
}
if (substitute(FSSource, "//VTK::Picking::Dec",
"uniform vec3 mapperIndex;\n"
"uniform int pickingAttributeIDOffset;"))
......
......@@ -353,19 +353,6 @@ void vtkOpenGLRenderWindow::OpenGLInitState()
}
glEnable(GL_BLEND);
if (this->PointSmoothing)
{
#ifdef GL_POINT_SMOOTH
glEnable(GL_POINT_SMOOTH);
#endif
}
else
{
#ifdef GL_POINT_SMOOTH
glDisable(GL_POINT_SMOOTH);
#endif
}
if (this->LineSmoothing)
{
#ifdef GL_LINE_SMOOTH
......@@ -449,7 +436,16 @@ int vtkOpenGLRenderWindow::GetDepthBufferSize()
{
this->MakeCurrent();
size = 0;
glGetIntegerv( GL_DEPTH_BITS, &size );
if (vtkOpenGLRenderWindow::GetContextSupportsOpenGL32())
{
glGetFramebufferAttachmentParameteriv(GL_DRAW_FRAMEBUFFER,
GL_DEPTH,
GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE, &size);
}
else
{
glGetIntegerv( GL_DEPTH_BITS, &size );
}
return static_cast<int>(size);
}
else
......
<
......@@ -103,20 +103,41 @@ vtkShaderProgram *vtkOpenGLShaderCache::ReadyShader(
// desktops to not use percision statements
#if GL_ES_VERSION_2_0 != 1
std::string VSSource = vertexCode;
VSSource = replace(VSSource,"//VTK::System::Dec",
"#define highp\n"
"#define mediump\n"
"#define lowp");
std::string FSSource = fragmentCode;
FSSource = replace(FSSource,"//VTK::System::Dec",
std::string GSSource = geometryCode;
if (vtkOpenGLRenderWindow::GetContextSupportsOpenGL32())
{
VSSource = replace(VSSource,"//VTK::System::Dec",
"#version 150\n"
"#define highp\n"
"#define mediump\n"
"#define lowp");
std::string GSSource = geometryCode;
GSSource = replace(GSSource,"//VTK::System::Dec",
FSSource = replace(FSSource,"//VTK::System::Dec",
"#version 150\n"
"#define highp\n"