Commit f435cb46 authored by Aashish Chaudhary's avatar Aashish Chaudhary

Optimizing the code a bit

After reading the spec carefully realized that
we don't need to treat texture type as basis
for texture dimension. Also added note clarification
on what does size means.
parent 44019fcf
Pipeline #2111 passed with stage
......@@ -18,7 +18,6 @@ vtk_add_test_cxx(${vtk-module}CxxTests tests
TestSobelGradientMagnitudePass.cxx
TestEDLPass.cxx
TestCoincident.cxx
TestMaximumTextureSize.cxx
)
vtk_test_cxx_executable(${vtk-module}CxxTests tests RENDERING_FACTORY)
/*=========================================================================
Program: Visualization Toolkit
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.
=========================================================================*/
// This test queries the maximum texture size for 1D/2D/3D textures.
//
// The command line arguments are:
// -I => run in interactive mode; unless this is used, the program will
// not allow interaction and exit
#include <vtkTestUtilities.h>
#include <vtkNew.h>
#include <vtkOpenGLRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkTextureObject.h>
int TestMaximumTextureSize(int vtkNotUsed(argc),
char* vtkNotUsed(argv)[])
{
vtkNew<vtkRenderWindowInteractor> iren;
vtkNew<vtkRenderWindow> renWin;
renWin->SetMultiSamples(0);
renWin->SetAlphaBitPlanes(1);
iren->SetRenderWindow(renWin.Get());
vtkNew<vtkRenderer> renderer;
renWin->AddRenderer(renderer.Get());
renWin->SetSize(500,500);
renWin->Render();
vtkOpenGLRenderWindow* glContext =
vtkOpenGLRenderWindow::SafeDownCast(renWin.GetPointer());
if (glContext)
{
int maxTextureSize1D =
vtkTextureObject::GetMaximumTextureSize1D(glContext);
int maxTextureSize2D =
vtkTextureObject::GetMaximumTextureSize1D(glContext);
int maxTextureSize3D =
vtkTextureObject::GetMaximumTextureSize1D(glContext);
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
if (maxTextureSize1D != -1 && maxTextureSize2D != -1 &&
maxTextureSize3D != -1)
#else
if (maxTextureSize2D != -1 && maxTextureSize3D != -1)
#endif
{
return 0;
}
return 1;
}
return 0;
}
......@@ -215,42 +215,6 @@ static const char *DepthInternalFormatFilterAsString[6]=
};
*/
//----------------------------------------------------------------------------
class vtkTextureObject::vtkInternal
{
public:
// Constructor
//--------------------------------------------------------------------------
vtkInternal(vtkTextureObject* parent)
{
this->Parent = parent;
}
// Query maximum texture size
//--------------------------------------------------------------------------
static int GetMaximumTextureSize(int param, vtkRenderWindow* context)
{
int maxSize = -1;
if (context and context->IsCurrent())
{
bool textureEnabled = glIsEnabled(param);
if (!textureEnabled)
{
glEnable(param);
}
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
if (!textureEnabled)
{
glDisable(param);
}
}
return maxSize;
}
vtkTextureObject* Parent;
};
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkTextureObject);
......@@ -2071,24 +2035,17 @@ void vtkTextureObject::CopyFromFrameBuffer(int srcXmin,
vtkOpenGLCheckErrorMacro("failed at glCopyTexImage2D " << this->Format);
}
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
//----------------------------------------------------------------------------
int vtkTextureObject::GetMaximumTextureSize1D(vtkOpenGLRenderWindow* context)
int vtkTextureObject::GetMaximumTextureSize(vtkOpenGLRenderWindow* context)
{
return vtkInternal::GetMaximumTextureSize(GL_TEXTURE_1D, context);
}
#endif
int maxSize = -1;
//----------------------------------------------------------------------------
int vtkTextureObject::GetMaximumTextureSize2D(vtkOpenGLRenderWindow* context)
{
return vtkInternal::GetMaximumTextureSize(GL_TEXTURE_2D, context);
}
if (context && context->IsCurrent())
{
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxSize);
}
//----------------------------------------------------------------------------
int vtkTextureObject::GetMaximumTextureSize3D(vtkOpenGLRenderWindow* context)
{
return vtkInternal::GetMaximumTextureSize(GL_TEXTURE_3D, context);
return maxSize;
}
//----------------------------------------------------------------------------
......
......@@ -528,22 +528,15 @@ public:
vtkGetMacro(GenerateMipmap,bool);
vtkSetMacro(GenerateMipmap,bool);
#if GL_ES_VERSION_2_0 != 1 || GL_ES_VERSION_3_0 == 1
// Description:
// Query and return maximum 1D texture size supported by the OpenGL
// driver for a particular context.
static int GetMaximumTextureSize1D(vtkOpenGLRenderWindow* context);
#endif
// Description:
// Query and return maximum 2D texture size supported by the OpenGL
// driver for a particular context.
static int GetMaximumTextureSize2D(vtkOpenGLRenderWindow* context);
// Description:
// Query and return maximum 3D texture size supported by the OpenGL
// driver for a particular context.
static int GetMaximumTextureSize3D(vtkOpenGLRenderWindow* context);
// Query and return maximum texture size (dimension) supported by the
// OpenGL driver for a particular context. It should be noted that this
// size does not consider the internal format of the texture and therefore
// there is no guarentee that a texture of this size will be allocated by
// the driver. Also, the method does not make the context current so
// if the passed context is not valid or current, a value of -1 will
// be returned.
static int GetMaximumTextureSize(vtkOpenGLRenderWindow* context);
// Description:
// Returns if the context supports the required extensions. If flags
......@@ -670,9 +663,6 @@ protected:
// for texturebuffers we hold on to the Buffer
vtkOpenGLBufferObject *BufferObject;
class vtkInternal;
vtkInternal* Impl;
private:
vtkTextureObject(const vtkTextureObject&); // Not implemented.
void operator=(const vtkTextureObject&); // Not implemented.
......
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