Commit 6e98b4f6 authored by Ken Martin's avatar Ken Martin
Browse files

Fix SynchronizedRenderers to work with use OpenGL2

Change-Id: Ic11b6de4c5a216dc9cf40960ecfa53f25c452c8e
parent 017033ac
......@@ -217,6 +217,10 @@ public:
float *verts, float *tcoords,
vtkShaderProgram *program, vtkgl::VertexArrayObject *vao);
// Description:
// Replacement for the old glDrawPixels function
virtual void DrawPixels(int x1, int y1, int x2, int y2, int numComponents, int dataType, void *data);
protected:
vtkOpenGLRenderWindow();
~vtkOpenGLRenderWindow();
......@@ -299,10 +303,6 @@ protected:
vtkTextureObject *DrawPixelsTextureObject;
// Description:
// Replacement for the old glDrawPixels function
void DrawPixels(int x1, int y1, int x2, int y2, int numComponents, int dataType, void *data);
bool Initialized; // ensure glewinit has been called
private:
......
......@@ -25,9 +25,9 @@
#include "vtkObjectFactory.h"
#include "vtkParallelRenderManager.h"
#include "vtkPNGWriter.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkOpenGLRenderer.h"
#include "vtkOpenGLRenderWindow.h"
#include "vtkOpenGLError.h"
#ifndef VTKGL2
......@@ -654,7 +654,7 @@ bool vtkSynchronizedRenderers::vtkRawImage::PushToViewport(vtkRenderer* ren)
return false;
}
// FIXME: This will not work when non-power-of-two textures are not supported.
this->Renderer = ren;
double viewport[4];
ren->GetViewport(viewport);
const int* window_size = ren->GetVTKWindow()->GetActualSize();
......@@ -685,6 +685,19 @@ bool vtkSynchronizedRenderers::vtkRawImage::PushToFrameBuffer()
vtkOpenGLClearErrorMacro();
#ifdef VTKGL2
double viewport[4];
this->Renderer->GetViewport(viewport);
const int* window_size = this->Renderer->GetVTKWindow()->GetActualSize();
vtkOpenGLRenderWindow *renWin = vtkOpenGLRenderWindow::SafeDownCast(this->Renderer->GetVTKWindow());
// always draw the entire image on the entire viewport
renWin->DrawPixels(viewport[0]*window_size[0], viewport[1]*window_size[1],
viewport[2]*window_size[0]-1, viewport[2]*window_size[0]-1,
this->Data->GetNumberOfComponents(), VTK_UNSIGNED_CHAR,
this->GetRawPtr()->GetVoidPointer(0));
#else
glPushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT| GL_TEXTURE_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
......@@ -749,6 +762,7 @@ bool vtkSynchronizedRenderers::vtkRawImage::PushToFrameBuffer()
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glPopAttrib();
#endif
vtkOpenGLStaticCheckErrorMacro("failed after PushToFrameBuffer");
return true;
......
......@@ -126,6 +126,7 @@ public:
this->Valid = false;
this->Size[0] = this->Size[1] = 0;
this->Data = vtkSmartPointer<vtkUnsignedCharArray>::New();
this->Renderer = 0;
}
void Resize(int dx, int dy, int numcomps)
......@@ -166,6 +167,7 @@ public:
bool Valid;
int Size[2];
vtkSmartPointer<vtkUnsignedCharArray> Data;
vtkRenderer *Renderer;
void Allocate(int dx, int dy, int numcomps);
};
......
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