Commit 304b6e7f authored by Burlen Loring's avatar Burlen Loring Committed by Code Review
Browse files

Merge topic 'legacy-graphic-error-api' into master

c544585c Make "graphic error" api legacy
parents d2c542a2 c544585c
......@@ -255,7 +255,6 @@ void MyProcess::Execute()
renderer->AddActor(actor);
vtkRenderWindow *renWin = prm->MakeRenderWindow();
renWin->SetReportGraphicErrors(true);
renWin->SetMultiSamples(0);
renWin->SetAlphaBitPlanes(1);
......
......@@ -136,7 +136,6 @@ void MyProcess::Execute()
}
vtkRenderWindow *renWin = prm->MakeRenderWindow();
renWin->SetReportGraphicErrors(true);
renWin->SetMultiSamples(0);
renWin->SetAlphaBitPlanes(1);
......
......@@ -80,7 +80,9 @@ vtkRenderWindow::vtkRenderWindow()
this->AnaglyphColorMask[0] = 4; // red
this->AnaglyphColorMask[1] = 3; // cyan
this->PainterDeviceAdapter = vtkPainterDeviceAdapter::New();
this->ReportGraphicErrors=1; // false
#ifndef VTK_LEGACY_REMOVE
this->ReportGraphicErrors = 0; // false
#endif
this->AbortCheckTime = 0.0;
this->CapturingGL2PSSpecialProps = 0;
......@@ -912,10 +914,54 @@ void vtkRenderWindow::PrintSelf(ostream& os, vtkIndent indent)
os << indent << "MultiSamples: " << this->MultiSamples << "\n";
os << indent << "StencilCapable: " <<
(this->StencilCapable ? "True" : "False") << endl;
#ifndef VTK_LEGACY_REMOVE
os << indent << "ReportGraphicErrors: "
<< (this->ReportGraphicErrors ? "On" : "Off")<< "\n";
#endif
}
#ifndef VTK_LEGACY_REMOVE
//----------------------------------------------------------------------------
void vtkRenderWindow::SetReportGraphicErrors(int val)
{
VTK_LEGACY_BODY(vtkRenderWindow::SetReportGraphicsErrors, "VTK 6.1");
if (this->ReportGraphicErrors != val)
{
this->ReportGraphicErrors = val;
this->Modified();
}
}
//----------------------------------------------------------------------------
void vtkRenderWindow::SetReportGraphicErrorsOn()
{
VTK_LEGACY_BODY(vtkRenderWindow::SetReportGraphicsErrorsOn, "VTK 6.1");
if (this->ReportGraphicErrors == 0)
{
this->ReportGraphicErrors = 1;
this->Modified();
}
}
//----------------------------------------------------------------------------
void vtkRenderWindow::SetReportGraphicErrorsOff()
{
VTK_LEGACY_BODY(vtkRenderWindow::GetReportGraphicsErrorsOff, "VTK 6.1");
if (this->ReportGraphicErrors != 0)
{
this->ReportGraphicErrors = 0;
this->Modified();
}
}
//----------------------------------------------------------------------------
int vtkRenderWindow::GetReportGraphicErrors()
{
VTK_LEGACY_BODY(vtkRenderWindow::GetReportGraphicsErrors, "VTK 6.1");
return this->ReportGraphicErrors;
}
#endif
//----------------------------------------------------------------------------
// Update the system, if needed, due to stereo rendering. For some stereo
// methods, subclasses might need to switch some hardware settings here.
......
......@@ -73,17 +73,24 @@ class vtkUnsignedCharArray;
#define VTK_CURSOR_HAND 9
#define VTK_CURSOR_CROSSHAIR 10
//
#ifndef VTK_LEGACY_REMOVE
// This macro should not be used, see vtkOpenGLError.h for
// GL error handling functions and macros.
//
#define vtkGraphicErrorMacro(renderWindow,message) \
renderWindow->CheckGraphicError(); \
if ( renderWindow->GetReportGraphicErrors() \
&& renderWindow->HasGraphicError() ) \
{ \
vtkErrorMacro(<<message<<" "<<renderWindow->GetLastGraphicErrorString()); \
#if defined NDEBUG
# define vtkGraphicErrorMacro(renderWindow,message) \
renderWindow->CheckGraphicError();
#else
# define vtkGraphicErrorMacro(renderWindow,message) \
renderWindow->CheckGraphicError(); \
if ( renderWindow->GetReportGraphicErrors() \
&& renderWindow->HasGraphicError() ) \
{ \
vtkErrorMacro( \
<< message << " " \
<< renderWindow->GetLastGraphicErrorString()); \
}
# endif
#endif
class VTKRENDERINGCORE_EXPORT vtkRenderWindow : public vtkWindow
{
......@@ -559,37 +566,22 @@ public:
vtkBooleanMacro(StencilCapable, int);
// Description:
// Turn on/off report of graphic errors. Initial value is false (off).
// This flag is used by vtkGraphicErrorMacro.
vtkSetMacro(ReportGraphicErrors,int);
vtkGetMacro(ReportGraphicErrors,int);
vtkBooleanMacro(ReportGraphicErrors,int);
// Description:
// Update graphic error status, regardless of ReportGraphicErrors flag.
// It means this method can be used in any context and is not restricted to
// debug mode. Errors codes are querried until no-errors are reported,
// ensureing internal error flags are clear after each check. Error status
// and description are recorded internally, may be retrieved with HasGraphicError
// and GetGraphicErrorString methods.
virtual void CheckGraphicError()=0;
// Description:
// Clear the graphics error status, without recording or reporting detected errors.
virtual void ClearGraphicError()=0;
// @deprecated Replaced by
// the CMakeLists variable VTK_REPORT_OPENGL_ERRORS
// error reporting is enabled/disabled at compile time
VTK_LEGACY(void SetReportGraphicErrors(int val));
VTK_LEGACY(void SetReportGraphicErrorsOn());
VTK_LEGACY(void SetReportGraphicErrorsOff());
VTK_LEGACY(int GetReportGraphicErrors());
#ifndef VTK_LEGACY_REMOVE
// Description:
// Return the number of graphics errors found in the most recent call to
// CheckGraphicError. If no errors were detected then the return will be 0.
// Descriptions for each of the errors may be obtained by calling
// GetGraphicErrorString.
virtual int HasGraphicError()=0;
virtual int GetNumberOfGraphicErrors()=0;
// Description:
// Return a string matching the last graphic error status. See
// GetGraphicErrorString.
virtual const char *GetLastGraphicErrorString()=0;
// @deprecated Replaced by
// vtkOpenGLCheckErrorMacro
virtual void CheckGraphicError() = 0;
virtual int HasGraphicError() = 0;
virtual const char *GetLastGraphicErrorString() = 0;
#endif
protected:
vtkRenderWindow();
......@@ -638,10 +630,13 @@ protected:
int StencilCapable;
int CapturingGL2PSSpecialProps;
#ifndef VTK_LEGACY_REMOVE
// Description:
// Boolean flag telling if errors from the graphic library have to be
// reported by vtkGraphicErrorMacro. Initial value is false (off).
// @deprecated Replaced by
// the CMakeLists variable VTK_REPORT_OPENGL_ERRORS
// error reporting is enabled/disabled at compile time
int ReportGraphicErrors;
#endif
// Description:
// The universal time since the last abort check occurred.
......
......@@ -122,7 +122,6 @@ int SurfaceLIC( int argc, char * argv[] )
VTK_CREATE_NEW(renWin, vtkRenderWindow);
VTK_CREATE_NEW(renderer, vtkRenderer);
VTK_CREATE_NEW(iren, vtkRenderWindowInteractor);
renWin->SetReportGraphicErrors(1);
renWin->AddRenderer(renderer);
renWin->SetSize(300,300);
iren->SetRenderWindow(renWin);
......
......@@ -323,7 +323,6 @@ int vtkImageDataLIC2D::RequestData(
}
this->Context->MakeCurrent();
this->Context->SetReportGraphicErrors(1);
// Noise.
vtkInformation *noiseInfo = inputVector[1]->GetInformationObject(0);
......
......@@ -439,8 +439,6 @@ int vtkStructuredGridLIC2D::RequestData(
renWin = NULL; // to be released via this->context
this->OwnWindow = true;
}
this->Context->SetReportGraphicErrors(1);
vtkInformation * outInfo = outputVector->GetInformationObject(0);
vtkStructuredGrid * output = vtkStructuredGrid::SafeDownCast(
......@@ -647,9 +645,7 @@ int vtkStructuredGridLIC2D::RequestData(
vtkDebugMacro( << "glFinish before rendering quad" << endl );
glFinish(); // debug: GL break point
vtkGraphicErrorMacro(this->Context,"error1");
fbo->RenderQuad(0, width-1,0,height-1);
vtkGraphicErrorMacro(this->Context,"error2");
vtkDebugMacro( << "glFinish after rendering quad" << endl );
glFinish(); // debug: GL break point
......
......@@ -77,9 +77,9 @@ vtkOpenGLRenderWindow::vtkOpenGLRenderWindow()
this->BackBuffer=static_cast<unsigned int>(GL_BACK);
this->FrontBuffer=static_cast<unsigned int>(GL_FRONT);
this->NumberOfGraphicErrors = 0;
this->LastGraphicErrorString
= new vtkStdString("0 OpenGL errors detected");
#ifndef VTK_LEGACY_REMOVE
this->LastGraphicError=static_cast<unsigned int>(GL_NO_ERROR);
#endif
this->OwnContext=1;
}
......@@ -106,8 +106,6 @@ vtkOpenGLRenderWindow::~vtkOpenGLRenderWindow()
this->SetTextureUnitManager(0);
this->SetExtensionManager(0);
this->SetHardwareSupport(0);
delete this->LastGraphicErrorString;
}
// ----------------------------------------------------------------------------
......@@ -1882,92 +1880,68 @@ void vtkOpenGLRenderWindow::DestroyHardwareOffScreenWindow()
assert("post: destroyed" && !this->OffScreenUseFrameBuffer);
}
// ----------------------------------------------------------------------------
const char *vtkOpenGLRenderWindow::OpenGLStrError(unsigned int code)
{
return vtkOpenGLStrError(code);
}
// ----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::PrintOpenGLErrors(ostream &os)
{
const int maxErrors = 16;
unsigned int errCode[maxErrors] = {GL_NO_ERROR};
const char *errDesc[maxErrors] = {NULL};
int numErrors = vtkGetOpenGLErrors(
maxErrors,
errCode,
errDesc);
vtkPrintOpenGLErrors(
os,
maxErrors,
numErrors,
errCode,
errDesc);
}
// ----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::PrintOpenGLErrors(
ostream &os,
int maxErrors,
int numErrors,
unsigned int *errCode,
const char **errDesc)
{
vtkPrintOpenGLErrors(os, maxErrors, numErrors, errCode, errDesc);
}
// ----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::ClearOpenGLErrors()
{
vtkClearOpenGLErrors();
}
// ----------------------------------------------------------------------------
int vtkOpenGLRenderWindow::GetOpenGLErrors(
int maxNum,
unsigned int *errCode,
const char **errDesc)
{
return vtkGetOpenGLErrors(maxNum, errCode, errDesc);
}
// ----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::ClearGraphicError()
#ifndef VTK_LEGACY_REMOVE
//----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::CheckGraphicError()
{
vtkClearOpenGLErrors();
VTK_LEGACY_BODY(vtkRenderWindow::CheckGraphicError, "VTK 6.1");
this->LastGraphicError=static_cast<unsigned int>(glGetError());
}
// ----------------------------------------------------------------------------
void vtkOpenGLRenderWindow::CheckGraphicError()
//----------------------------------------------------------------------------
int vtkOpenGLRenderWindow::HasGraphicError()
{
const int maxErrors = 16;
unsigned int errCode[maxErrors] = {GL_NO_ERROR};
const char *errDesc[maxErrors] = {NULL};
this->NumberOfGraphicErrors = vtkGetOpenGLErrors(
maxErrors,
errCode,
errDesc);
ostringstream oss;
vtkPrintOpenGLErrors(
oss,
maxErrors,
this->NumberOfGraphicErrors,
errCode,
errDesc);
*this->LastGraphicErrorString = oss.str();
VTK_LEGACY_BODY(vtkRenderWindow::HasGraphics, "VTK 6.1");
return static_cast<GLenum>(this->LastGraphicError)!=GL_NO_ERROR;
}
// ----------------------------------------------------------------------------
//----------------------------------------------------------------------------
const char *vtkOpenGLRenderWindow::GetLastGraphicErrorString()
{
return this->LastGraphicErrorString->c_str();
VTK_LEGACY_BODY(vtkRenderWindow::GetLastGraphicErrorString, "VTK 6.1");
const char *result;
switch(static_cast<GLenum>(this->LastGraphicError))
{
case GL_NO_ERROR:
result="No error";
break;
case GL_INVALID_ENUM:
result="Invalid enum";
break;
case GL_INVALID_VALUE:
result="Invalid value";
break;
case GL_INVALID_OPERATION:
result="Invalid operation";
break;
case GL_STACK_OVERFLOW:
result="Stack overflow";
break;
case GL_STACK_UNDERFLOW:
result="Stack underflow";
break;
case GL_OUT_OF_MEMORY:
result="Out of memory";
break;
case vtkgl::TABLE_TOO_LARGE:
// GL_ARB_imaging
result="Table too large";
break;
case vtkgl::INVALID_FRAMEBUFFER_OPERATION_EXT:
// GL_EXT_framebuffer_object
result="Invalid framebuffer operation";
break;
case vtkgl::TEXTURE_TOO_LARGE_EXT:
// GL_EXT_texture
result="Texture too large";
break;
default:
result="Unknown error";
break;
}
return result;
}
#endif
// ----------------------------------------------------------------------------
// Description:
......
......@@ -160,76 +160,11 @@ public:
unsigned int GetFrontBuffer();
// Description:
// Query OpenGL for errors until all have been reported. This has the affect
// of clearing the error flags. This method is static and may be used
// without an instance to check for errors and clear OpenGL error flags(eg from
// other static methods).
static
void ClearOpenGLErrors();
// Description:
// Query OpenGL for errors until all have been reported. Return the number of
// errors detected. The user supplied arrays of maxNum entries is filled with
// codes and descriptions of the errors. This method is static and may be used
// without an instance to check for errors and clear OpenGL error flags(eg from
// other static methods).
static
int GetOpenGLErrors(int maxNum, unsigned int *code, const char **description);
// Description:
// Given an error code obtained from GetOpenGLErrors return a string literal
// description of the error. This method is static and may be used
// without an instance to check for errors and clear OpenGL error flags(eg from
// other static methods).
static
const char *OpenGLStrError(unsigned int code);
// Description:
// Check for and send detected errors to the given stream. This method is static
// and may be used without an instance to check for errors and clear OpenGL error
// flags(eg from other static methods).
static
void PrintOpenGLErrors(ostream &os);
// Description:
// Send given set of error codes and descriptions obtained from GetOpenGLErrors
// to the given stream. This method is static and may be used without an instance
// to check for errors and clear OpenGL error flags(eg from other static methods).
static
void PrintOpenGLErrors(
ostream &os,
int maxErrors,
int nErrors,
unsigned int *errCode,
const char **errDesc);
// Description:
// Update graphic error status, regardless of ReportGraphicErrors flag.
// It means this method can be used in any context and is not restricted to
// debug mode. Errors codes are querried until no-errors are reported,
// ensureing internal error flags are clear after each check. Error status
// and description are recorded internally, may be retrieved with HasGraphicError
// and GetGraphicErrorString methods.
virtual void CheckGraphicError();
// Description:
// Clear the graphics error status, without recording or reporting detected errors.
virtual void ClearGraphicError();
// Description:
// Return the number of graphics errors found in the most recent call to
// CheckGraphicError. If no errors were detected then the return will be 0.
// Descriptions for each of the errors may be obtained by calling
// GetGraphicErrorString.
virtual int HasGraphicError()
{ return this->NumberOfGraphicErrors; }
virtual int GetNumberOfGraphicErrors()
{ return this->NumberOfGraphicErrors; }
// Description:
// Return a string matching the last graphic error status.
virtual const char *GetLastGraphicErrorString();
// @deprecated Replaced by
// vtkOpenGLCheckErrorMacro
VTK_LEGACY(virtual void CheckGraphicError());
VTK_LEGACY(virtual int HasGraphicError());
VTK_LEGACY(virtual const char *GetLastGraphicErrorString());
// Description:
// Get the time when the OpenGL context was created.
......@@ -315,8 +250,12 @@ protected:
unsigned int FrontBuffer;
unsigned int BackBuffer;
int NumberOfGraphicErrors;
vtkStdString *LastGraphicErrorString;
#ifndef VTK_LEGACY_REMOVE
// Description:
// @deprecated Replaced by
// vtkOpenGLCheckErrorMacro
unsigned int LastGraphicError;
#endif
// Description:
// Flag telling if the context has been created here or was inherited.
......
......@@ -137,7 +137,6 @@ void MyProcess::Execute()
}
vtkRenderWindow *renWin = prm->MakeRenderWindow();
renWin->SetReportGraphicErrors(true);
renWin->SetMultiSamples(0);
renWin->SetAlphaBitPlanes(1);
......
......@@ -137,7 +137,6 @@ void MyProcess::Execute()
}
vtkRenderWindow *renWin = prm->MakeRenderWindow();
renWin->SetReportGraphicErrors(true);
renWin->SetMultiSamples(0);
renWin->SetAlphaBitPlanes(1);
......
......@@ -133,7 +133,6 @@ void MyProcess::Execute()
}
vtkRenderWindow *renWin = prm->MakeRenderWindow();
renWin->SetReportGraphicErrors(true);
renWin->SetMultiSamples(0);
renWin->SetAlphaBitPlanes(1);
......
......@@ -104,7 +104,6 @@ volumeMapper.AddClippingPlane(plane4)
# Okay now the graphics stuff
ren1 = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.ReportGraphicErrorsOn()
renWin.AddRenderer(ren1)
renWin.SetSize(256, 256)
......
......@@ -105,7 +105,6 @@ volumeMapper AddClippingPlane plane4
# Okay now the graphics stuff
vtkRenderer ren1
vtkRenderWindow renWin
renWin ReportGraphicErrorsOn
renWin AddRenderer ren1
renWin SetSize 256 256
vtkRenderWindowInteractor iren
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment