Commit 34100347 authored by Ken Martin's avatar Ken Martin

many changes to support glew and android

Change-Id: I52ea4f3f003436fa002ea86962153d5ea4cb532a
parent 0781dcff
......@@ -59,7 +59,6 @@ set(Module_SRCS
vtkglShader.cxx
vtkglShaderProgram.cxx
vtkglVertexArrayObject.cxx
vtkFrameBufferObject.cxx
vtkOpenGLActor.cxx
vtkOpenGLCamera.cxx
vtkOpenGLImageMapper.cxx
......@@ -76,14 +75,20 @@ set(Module_SRCS
vtkOpenGLShaderCache.cxx
vtkOpenGLTexture.cxx
vtkOpenGLTextureUnitManager.cxx
vtkPixelBufferObject.cxx
vtkRenderbuffer.cxx
vtkRenderPass.cxx
vtkRenderState.cxx
vtkTextureObject.cxx
${CMAKE_CURRENT_BINARY_DIR}/${vtk-module}ObjectFactory.cxx
)
if (NOT ANDROID)
set(Module_SRCS ${Module_SRCS}
vtkPixelBufferObject.cxx
vtkFrameBufferObject.cxx
vtkTextureObject.cxx
)
endif()
set(${vtk-module}_HDRS
vtkOpenGL.h
${CMAKE_CURRENT_BINARY_DIR}/vtkTDxConfigure.h
......
......@@ -12,6 +12,7 @@
=========================================================================*/
#include "vtkCamera.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
......@@ -37,14 +38,15 @@ int TestVBOPLYMapper(int argc, char *argv[])
vtkNew<vtkPolyDataMapper> mapper;
renderer->SetBackground(0.0, 0.0, 0.0);
vtkNew<vtkRenderWindow> renderWindow;
renderWindow->SetSize(300, 300);
renderWindow->SetSize(900, 900);
renderWindow->AddRenderer(renderer.Get());
renderer->AddActor(actor.Get());
vtkNew<vtkLightKit> lightKit;
lightKit->AddLightsToRenderer(renderer.Get());
const char* fileName = vtkTestUtilities::ExpandDataFileName(argc, argv,
"Data/dragon.ply");
"Data/dragon.ply");
//const char* fileName = "C:\\Users\\ken.martin\\Documents\\vtk\\VTKData\\Data\\lucy.ply";
vtkNew<vtkPLYReader> reader;
reader->SetFileName(fileName);
......@@ -70,23 +72,40 @@ int TestVBOPLYMapper(int argc, char *argv[])
vtkNew<vtkRenderWindowInteractor> interactor;
interactor->SetRenderWindow(renderWindow.Get());
renderWindow->SetMultiSamples(0);
interactor->Initialize();
vtkNew<vtkTimerLog> timer;
double time(0.0);
for (int i = 0; i < 10; ++i)
timer->StartTimer();
renderWindow->Render();
timer->StopTimer();
double firstRender = timer->GetElapsedTime();
cerr << "first render time: " << firstRender << endl;
timer->StartTimer();
int numRenders = 85;
for (int i = 0; i < numRenders; ++i)
{
timer->StartTimer();
renderer->GetActiveCamera()->Azimuth(1);
renderer->GetActiveCamera()->Elevation(1);
renderWindow->Render();
timer->StopTimer();
cout << "Rendering frame " << i << ": " << timer->GetElapsedTime() << endl;
time += timer->GetElapsedTime();
}
cout << "Average time: " << time / 10.0 << endl;
timer->StopTimer();
double elapsed = timer->GetElapsedTime();
cerr << "interactive render time: " << elapsed / numRenders << endl;
unsigned int numTris = reader->GetOutput()->GetPolys()->GetNumberOfCells();
cerr << "number of triangles: " << numTris << endl;
cerr << "triangles per second: " << numTris*(numRenders/elapsed) << endl;
renderer->GetActiveCamera()->SetPosition(0,0,1);
renderer->GetActiveCamera()->SetFocalPoint(0,0,0);
renderer->GetActiveCamera()->SetViewUp(0,1,0);
renderer->ResetCamera();
renderWindow->SetSize(300, 300);
interactor->Start();
delete [] fileName;
//delete [] fileName;
return EXIT_SUCCESS;
}
......@@ -19,7 +19,6 @@
#include "vtkObjectFactory.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkTextureObject.h"
#include "vtkRenderbuffer.h"
#include "vtkPixelBufferObject.h"
#include "vtkOpenGLError.h"
......
......@@ -35,7 +35,6 @@
class vtkRenderWindow;
class vtkTextureObject;
class vtkRenderbuffer;
class vtkPixelBufferObject;
class vtkOpenGLRenderWindow;
......
......@@ -72,21 +72,23 @@ const char *vtkOpenGLStrError(unsigned int code)
case GL_INVALID_OPERATION:
return "Invalid operation";
break;
case GL_OUT_OF_MEMORY:
return "Out of memory";
break;
#if GL_ES_VERSION_2_0 != 1
case GL_STACK_OVERFLOW:
return "Stack overflow";
break;
case GL_STACK_UNDERFLOW:
return "Stack underflow";
break;
case GL_OUT_OF_MEMORY:
return "Out of memory";
break;
case GL_TABLE_TOO_LARGE:
return "Table too large";
break;
case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
return "Invalid framebuffer operation";
break;
#endif
}
return "Unknown error";
}
......
......@@ -53,26 +53,13 @@ public:
}
}
// Description:
// Check if lighting is enabled.
bool QueryLighting()
{
if (glIsEnabled(GL_LIGHTING))
{
return true;
}
else
{
return false;
}
}
// Description:
// Enable/disable multisampling.
void EnableMultisampling(bool mode)
{
if (this->MultisampleSupport)
{
#if GL_ES_VERSION_2_0 != 1
if (mode)
{
glEnable(GL_MULTISAMPLE);
......@@ -81,6 +68,7 @@ public:
{
glDisable(GL_MULTISAMPLE);
}
#endif
}
}
......@@ -88,6 +76,7 @@ public:
// Check if multisample is enabled.
bool QueryMultisampling()
{
#if GL_ES_VERSION_2_0 != 1
if (this->MultisampleSupport && glIsEnabled(GL_MULTISAMPLE))
{
return true;
......@@ -96,6 +85,9 @@ public:
{
return false;
}
#else
return false;
#endif
}
// Description:
......@@ -157,7 +149,7 @@ void vtkOpenGLHardwareSelector::BeginRenderProp(vtkRenderWindow *context)
this->Internals->SetContext(context);
// Disable multisample, lighting, and blending.
// Disable multisample, and blending.
this->Internals->OriginalMultisample = this->Internals->QueryMultisampling();
this->Internals->EnableMultisampling(false);
......@@ -172,7 +164,7 @@ void vtkOpenGLHardwareSelector::EndRenderProp(vtkRenderWindow *)
cerr << "=====vtkOpenGLHardwareSelector::EndRenderProp" << endl;
#endif
// Restore multisample, lighting, and blending.
// Restore multisample, and blending.
this->Internals->EnableMultisampling(this->Internals->OriginalMultisample);
this->Internals->EnableBlending(this->Internals->OriginalBlending);
}
......
......@@ -159,7 +159,11 @@ void vtkOpenGLImageMapperRenderDouble(vtkOpenGLImageMapper *self, vtkImageData *
double range[2];
data->GetPointData()->GetScalars()->GetDataTypeRange( range );
#ifdef GL_UNPACK_ALIGNMENT
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
#else
assert("width must be a multiple of 4" && width ==4);
#endif
// reformat data into unsigned char
......@@ -270,7 +274,11 @@ void vtkOpenGLImageMapperRenderShort(vtkOpenGLImageMapper *self, vtkImageData *d
double range[2];
data->GetPointData()->GetScalars()->GetDataTypeRange( range );
#ifdef GL_UNPACK_ALIGNMENT
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
#else
assert("width must be a multiple of 4" && width ==4);
#endif
// Find the number of bits to use for the fraction:
// continue increasing the bits until there is an overflow
......@@ -397,9 +405,14 @@ void vtkOpenGLImageMapperRenderChar(vtkOpenGLImageMapper *self, vtkImageData *da
double range[2];
data->GetPointData()->GetScalars()->GetDataTypeRange( range );
#ifdef GL_UNPACK_ALIGNMENT
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
#else
assert("width must be a multiple of 4" && width ==4);
#endif
//
#ifdef GL_UNPACK_ROW_LENGTH
if (bpp == 3)
{ // feed through RGB bytes without reformatting
if (inInc1 != width*bpp)
......@@ -419,6 +432,7 @@ void vtkOpenGLImageMapperRenderChar(vtkOpenGLImageMapper *self, vtkImageData *da
static_cast<void *>(dataPtr));
}
else
#endif
{ // feed through other bytes without reformatting
T *inPtr = dataPtr;
T *inPtr1 = inPtr;
......@@ -492,7 +506,9 @@ void vtkOpenGLImageMapperRenderChar(vtkOpenGLImageMapper *self, vtkImageData *da
delete [] newPtr;
}
#ifdef GL_UNPACK_ROW_LENGTH
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
#endif
vtkOpenGLStaticCheckErrorMacro("failed after ImageMapperRenderChar");
}
......
......@@ -370,11 +370,6 @@ void vtkOpenGLImageSliceMapper::RenderTexturedPolygon(
this->RenderBackground(this->BackgroundPolyDataActor, points, extent, ren);
}
if (useFragmentProgram)
{
glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
vtkOpenGLCheckErrorMacro("failed after RenderTexturedPolygon");
}
......@@ -598,73 +593,8 @@ void vtkOpenGLImageSliceMapper::BindFragmentProgram(
{
vtkOpenGLClearErrorMacro();
int xdim, ydim, zdim; // orientation of texture wrt input image
vtkImageSliceMapper::GetDimensionIndices(this->Orientation, xdim, ydim);
zdim = 3 - xdim - ydim; // they sum to three
double *spacing = this->DataSpacing;
double *origin = this->DataOrigin;
int *extent = this->DisplayExtent;
// Bind the bicubic interpolation fragment program, it will
// not do anything if modern shader objects are also in play.
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB,
this->FragmentShaderIndex);
// checkerboard information
double checkSpacing[2], checkOffset[2];
property->GetCheckerboardSpacing(checkSpacing);
property->GetCheckerboardOffset(checkOffset);
// transformation to permute texture-oriented coords to data coords
double mat[16];
vtkMatrix4x4::Identity(mat);
mat[0] = mat[5] = mat[10] = 0.0;
mat[4*xdim] = mat[1+4*ydim] = 1.0;
int dimsep = ydim - xdim + 3*(xdim > ydim);
mat[2+4*zdim] = (((dimsep % 3) == 1) ? 1.0 : -1.0);
mat[4*zdim+3] = origin[zdim] + spacing[zdim]*extent[2*zdim];
// checkerboard uses view coordinates
vtkMatrix4x4 *m = this->GetDataToWorldMatrix();
vtkMatrix4x4 *c = ren->GetActiveCamera()->GetViewTransformMatrix();
vtkMatrix4x4::Multiply4x4(*m->Element, mat, mat);
vtkMatrix4x4::Multiply4x4(*c->Element, mat, mat);
// first parameter: texture size needed for bicubic interpolator
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 0,
static_cast<float>(this->TextureSize[0]),
static_cast<float>(this->TextureSize[1]),
static_cast<float>(1.0/this->TextureSize[0]),
static_cast<float>(1.0/this->TextureSize[1]));
// second parameter: scale and offset for converting texture coords
// into the input image's data coords
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 1,
static_cast<float>(this->TextureSize[0]*spacing[xdim]),
static_cast<float>(this->TextureSize[1]*spacing[ydim]),
static_cast<float>(origin[xdim] +
spacing[xdim]*(extent[2*xdim] - 0.5)),
static_cast<float>(origin[ydim] +
spacing[ydim]*(extent[2*ydim] - 0.5)));
// third parameter: scale and offset for converting data coords into
// checkboard square indices, for checkerboarding
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 2,
static_cast<float>(0.5/checkSpacing[0]),
static_cast<float>(0.5/checkSpacing[1]),
static_cast<float>(-0.5*checkOffset[0]),
static_cast<float>(-0.5*checkOffset[1]));
// fourth, fifth param: first two rows of the transformation matrix
// from data coords to camera coords (including a pre-translation of
// z from zero to the z position of the slice, since the texture coords
// are 2D and do not provide the z position)
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 3,
static_cast<float>(mat[0]), static_cast<float>(mat[1]),
static_cast<float>(mat[2]), static_cast<float>(mat[3]));
glProgramLocalParameter4fARB(GL_FRAGMENT_PROGRAM_ARB, 4,
static_cast<float>(mat[4]), static_cast<float>(mat[5]),
static_cast<float>(mat[6]), static_cast<float>(mat[7]));
// TODO: change all this
vtkOpenGLCheckErrorMacro("failed after BindFragmentProgram");
}
......@@ -673,123 +603,12 @@ void vtkOpenGLImageSliceMapper::BindFragmentProgram(
vtkStdString vtkOpenGLImageSliceMapper::BuildFragmentProgram(
vtkImageProperty *property)
{
// TODO change all this
vtkStdString prog =
"!!ARBfp1.0\n"
"\n";
// parameters needed for cubic interpolation:
// texdim is texture size {width, height, 1.0/width, 1.0/height}
// parameters needed for checkerboarding:
// todata is for converting tex coords to VTK data coords
// togrid converts transformed data coords to checkerboard squares
// mx, my are first two rows of matrix for transforming data coords
prog.append(
"PARAM texdim = program.local[0];\n"
"PARAM todata = program.local[1];\n"
"PARAM togrid = program.local[2];\n"
"PARAM mx = program.local[3];\n"
"PARAM my = program.local[4];\n"
"TEMP coord, coord2;\n"
"TEMP c, c1, c2;\n"
"TEMP weightx, weighty;\n"
"\n");
// checkerboard
if (property->GetCheckerboard())
{
prog.append(
"# generate a checkerboard pattern\n"
"MOV coord.xyzw, {0, 0, 0, 1};\n"
"MAD coord.xy, fragment.texcoord.xyxy, todata.xyxy, todata.zwzw;\n"
"DP4 coord2.x, coord, mx;\n"
"DP4 coord2.y, coord, my;\n"
"MAD coord.xy, coord2.xyxy, togrid.xyxy, togrid.zwzw;\n"
"FRC coord.xy, coord;\n"
"SUB coord.xy, coord, {0.5, 0.5, 0.5, 0.5};\n"
"MUL coord.x, coord.x, coord.y;\n"
"KIL coord.x;\n"
"\n");
}
// interpolate
if (property->GetInterpolationType() == VTK_CUBIC_INTERPOLATION)
{
// create a bicubic interpolation program
prog.append(
"# compute the {rx, ry, fx, fy} fraction vector\n"
"MAD coord, fragment.texcoord.xyxy, texdim.xyxy, {0.5, 0.5, 0.5, 0.5};\n"
"FRC coord, coord;\n"
"SUB coord.xy, {1, 1, 1, 1}, coord;\n"
"\n"
"# compute the x weights\n"
"MAD weightx, coord.zzxx, {0.5, 1.5, 1.5, 0.5}, {0,-1,-1, 0};\n"
"MAD weightx, weightx, coord.xzxz, {0,-1,-1, 0};\n"
"MUL weightx, weightx, -coord.xxzz;\n"
"\n"
"# compute the y weights\n"
"MAD weighty, coord.wwyy, {0.5, 1.5, 1.5, 0.5}, {0,-1,-1, 0};\n"
"MAD weighty, weighty, coord.ywyw, {0,-1,-1, 0};\n"
"MUL weighty, weighty, -coord.yyww;\n"
"\n"
"# get the texture coords for the coefficients\n"
"ADD coord, coord.xyxy, {-2,-2,-1,-2};\n"
"MAD coord, coord, texdim.zwzw, fragment.texcoord.xyxy;\n"
"MAD coord2, texdim.zwzw, {2, 0, 2, 0}, coord;\n"
"\n");
// loop through the rows of the kernel
for (int i = 0; i < 4; i++)
{
prog.append(
"# do a row of texture lookups and weights\n"
"TEX c2, coord.xyzw, texture, 2D;\n"
"MUL c1, c2, weightx.xxxx;\n"
"TEX c2, coord.zwxy, texture, 2D;\n"
"MAD c1, c2, weightx.yyyy, c1;\n"
"TEX c2, coord2.xyzw, texture, 2D;\n"
"MAD c1, c2, weightx.zzzz, c1;\n"
"TEX c2, coord2.zwxy, texture, 2D;\n"
"MAD c1, c2, weightx.wwww, c1;\n");
// choose the y weight for current row
static const char *rowsum[4] = {
"MUL c, weighty.xxxx, c1;\n\n",
"MAD c, weighty.yyyy, c1, c;\n\n",
"MAD c, weighty.zzzz, c1, c;\n\n",
"MAD c, weighty.wwww, c1, c;\n\n"
};
prog.append(rowsum[i]);
if (i < 3)
{
prog.append(
"# advance y coord to next row\n"
"ADD coord.yw, coord, texdim.wwww;\n"
"ADD coord2.yw, coord2, texdim.wwww;\n"
"\n");
}
}
}
else
{
// use currently set texture interpolation
prog.append(
"# interpolate the texture\n"
"TEX c, fragment.texcoord, texture, 2D;\n"
"\n");
}
// modulate the fragment color with the texture
prog.append(
"# output the color\n"
"MUL result.color, fragment.color, c;\n"
"\n");
// end program
prog.append(
"END\n");
return prog;
}
......@@ -835,17 +654,10 @@ bool vtkOpenGLImageSliceMapper::TextureSizeOK(const int size[2])
return 0;
}
// Test a proxy texture to see if it fits in memory
glTexImage2D(GL_PROXY_TEXTURE_2D, 0, GL_RGBA8, size[0], size[1],
0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
GLint params = 0;
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH,
&params);
vtkOpenGLCheckErrorMacro("failed after TextureSizeOK");
// if it does fit, we will render it later
return (params == 0 ? 0 : 1);
return 1;
}
//----------------------------------------------------------------------------
......@@ -896,28 +708,8 @@ void vtkOpenGLImageSliceMapper::Render(vtkRenderer *ren, vtkImageSlice *prop)
glPolygonOffset(f,u);
}
// Add all the clipping planes
int numClipPlanes = this->GetNumberOfClippingPlanes();
if (numClipPlanes > 6)
{
vtkErrorMacro(<< "OpenGL has a limit of 6 clipping planes");
}
for (int i = 0; i < 6; i++)
{
GLenum clipPlaneId = static_cast<GLenum>(GL_CLIP_PLANE0+i);
if (i < numClipPlanes)
{
double planeEquation[4];
this->GetClippingPlaneInDataCoords(matrix, i, planeEquation);
glClipPlane(clipPlaneId, planeEquation);
glEnable(clipPlaneId);
}
else
{
glDisable(clipPlaneId);
}
}
// Add all the clipping planes TODO: really in the mapper
//int numClipPlanes = this->GetNumberOfClippingPlanes();
// Whether to write to the depth buffer and color buffer
glDepthMask(this->DepthEnable ? GL_TRUE : GL_FALSE); // supported in all
......
......@@ -734,7 +734,9 @@ void vtkOpenGLPolyDataMapper::RenderPieceStart(vtkRenderer* ren, vtkActor *actor
this->lastBoundBO = NULL;
// Set the PointSize and LineWidget
glPointSize(actor->GetProperty()->GetPointSize());
#if GL_ES_VERSION_2_0 != 1
glPointSize(actor->GetProperty()->GetPointSize()); // not on ES2
#endif
glLineWidth(actor->GetProperty()->GetLineWidth()); // supported by all OpenGL versions
if ( this->GetResolveCoincidentTopology() )
......@@ -821,9 +823,6 @@ void vtkOpenGLPolyDataMapper::RenderPieceDraw(vtkRenderer* ren, vtkActor *actor)
}
if (actor->GetProperty()->GetRepresentation() == VTK_WIREFRAME)
{
// TODO wireframe of triangles is not lit properly right now
// you either have to generate normals and send them down
// or use a geometry shader.
glMultiDrawElements(GL_LINE_LOOP,
(GLsizei *)(&this->tris.elementsArray[0]),
GL_UNSIGNED_INT,
......@@ -1011,9 +1010,6 @@ void vtkOpenGLPolyDataMapper::RenderEdges(vtkRenderer* ren, vtkActor *actor)
this->Information->Set(vtkPolyDataPainter::DISABLE_SCALAR_COLOR(), 1);
this->Information->Remove(vtkPolyDataPainter::DISABLE_SCALAR_COLOR());
// reset the default.
glPolygonMode(face, GL_FILL);
*/
}
}
......
......@@ -572,8 +572,9 @@ void vtkOpenGLPolyDataMapper2D::RenderOverlay(vtkViewport* viewport,
if (this->Internal->points.indexCount)
{
// Set the PointSize
glPointSize(actor->GetProperty()->GetPointSize());
#if GL_ES_VERSION_2_0 != 1
glPointSize(actor->GetProperty()->GetPointSize()); // not on ES2
#endif
this->Internal->points.ibo.Bind();
glDrawRangeElements(GL_POINTS, 0,
static_cast<GLuint>(layout.VertexCount - 1),
......
......@@ -62,18 +62,18 @@ void vtkOpenGLProperty::Render(vtkActor *anActor, vtkRenderer *ren)
// Set the LineStipple
if (this->LineStipplePattern != 0xFFFF)
{
glEnable(GL_LINE_STIPPLE);
glLineStipple(this->LineStippleRepeatFactor,
static_cast<GLushort>(this->LineStipplePattern));
// glEnable(GL_LINE_STIPPLE);
// glLineStipple(this->LineStippleRepeatFactor,
// static_cast<GLushort>(this->LineStipplePattern));
//vtkOpenGLGL2PSHelper::EnableStipple(); // must be called after glLineStipple
}
else
{
// still need to set this although we are disabling. else the ATI X1600
// (for example) still manages to stipple under certain conditions.
glLineStipple(this->LineStippleRepeatFactor,
static_cast<GLushort>(this->LineStipplePattern));
glDisable(GL_LINE_STIPPLE);
// glLineStipple(this->LineStippleRepeatFactor,
// static_cast<GLushort>(this->LineStipplePattern));
// glDisable(GL_LINE_STIPPLE);
//vtkOpenGLGL2PSHelper::DisableStipple();
}
......@@ -81,7 +81,6 @@ void vtkOpenGLProperty::Render(vtkActor *anActor, vtkRenderer *ren)
if (! this->BackfaceCulling && ! this->FrontfaceCulling)
{
glDisable (GL_CULL_FACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
else if (this->BackfaceCulling)
{
......@@ -122,7 +121,6 @@ void vtkOpenGLProperty::PostRender(vtkActor *actor, vtkRenderer *renderer)
if (this->BackfaceCulling || this->FrontfaceCulling)
{
glDisable(GL_CULL_FACE);
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
this->Superclass::PostRender(actor, renderer);
......
This diff is collapsed.
......@@ -77,7 +77,6 @@ vtkOpenGLRenderer::vtkOpenGLRenderer()
this->CurrentRGBATexture = NULL;
this->DepthPeelingActor = NULL;
this->DepthFormat =0;
this->DepthPeelingHigherLayer=0;
this->BackgroundTexture = 0;
......@@ -173,22 +172,22 @@ void vtkOpenGLRenderer::DeviceRender(void)
}
vtkOpenGLTexture *vtkOpenGLRendererCreateDepthPeelingTexture(
int width, int height, int numComponents, int tFormat)
int width, int height, int numComponents, bool isDepth)
{
vtkOpenGLTexture *result = vtkOpenGLTexture::New();
vtkImageData *id = vtkImageData::New();
id->SetExtent(0,width-1, 0,height-1, 0,0);
if (tFormat == GL_DEPTH)
if (isDepth == true)
{
id->AllocateScalars(VTK_FLOAT, numComponents);
result->SetIsDepthTexture(1);
}
else
{
id->AllocateScalars(VTK_UNSIGNED_CHAR, numComponents);
}
result->SetTextureFormat(tFormat);
result->SetTextureType(GL_TEXTURE_RECTANGLE);
result->InterpolateOff();
......@@ -236,31 +235,19 @@ void vtkOpenGLRenderer::DeviceRenderTranslucentPolygonalGeometry()
this->GetTiledSizeAndOrigin(&this->ViewportWidth, &this->ViewportHeight,
&this->ViewportX, &this->ViewportY);
// get z bits
GLint depthBits;
glGetIntegerv(GL_DEPTH_BITS,&depthBits);
if(depthBits == 16)
{
this->DepthFormat = GL_DEPTH_COMPONENT16_ARB;
}
else
{
this->DepthFormat = GL_DEPTH_COMPONENT24_ARB;
}
// create textures actors we need if not done already
if (this->OpaqueZTexture == NULL)
{
this->OpaqueZTexture = vtkOpenGLRendererCreateDepthPeelingTexture(
this->ViewportWidth, this->ViewportHeight, 1, GL_DEPTH);
this->ViewportWidth, this->ViewportHeight, 1, true);
this->TranslucentZTexture = vtkOpenGLRendererCreateDepthPeelingTexture(
this->ViewportWidth, this->ViewportHeight, 1, GL_DEPTH);
this->ViewportWidth, this->ViewportHeight, 1, true);
this->OpaqueRGBATexture = vtkOpenGLRendererCreateDepthPeelingTexture(
this->ViewportWidth, this->ViewportHeight, 4, GL_RGBA);
this->ViewportWidth, this->ViewportHeight, 4, false);
this->TranslucentRGBATexture = vtkOpenGLRendererCreateDepthPeelingTexture(
this->ViewportWidth, this->ViewportHeight, 4, GL_RGBA);
this->ViewportWidth, this->ViewportHeight, 4, false);
this->CurrentRGBATexture = vtkOpenGLRendererCreateDepthPeelingTexture(
this->ViewportWidth, this->ViewportHeight, 4, GL_RGBA);
this->ViewportWidth, this->ViewportHeight, 4, false);
this->DepthPeelingActor = vtkTexturedActor2D::New();
vtkNew<vtkPolyDataMapper2D> mapper;
......@@ -328,8 +315,10 @@ void vtkOpenGLRenderer::DeviceRenderTranslucentPolygonalGeometry()
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.0,0.0,0.0,0.0); // always clear to black
glClearDepth(static_cast<GLclampf>(1.0));
//glClearDepth(static_cast<GLclampf>(1.0));
#ifdef GL_MULTISAMPLE
glDisable(GL_MULTISAMPLE);
#endif
glDisable(GL_BLEND);
// Get opaqueRGBA
......@@ -357,8 +346,10 @@ void vtkOpenGLRenderer::DeviceRenderTranslucentPolygonalGeometry()
// Do render loop until complete
unsigned int threshold=static_cast<unsigned int>(this->ViewportWidth*this->ViewportHeight*OcclusionRatio);
#if GL_ES_VERSION_2_0 != 1
GLuint queryId;