Commit 81055241 authored by Frédéric Larue's avatar Frédéric Larue
Browse files

SelectionManagerMeshTexels modified so that the size of the managed texture...

SelectionManagerMeshTexels modified so that the size of the managed texture can be changed on-the-fly.
parent 68f3a56d
......@@ -96,10 +96,13 @@ const char* SelectionManagerMeshTexels::s_RealTimeSelectionShaderFSH =
" selectionState = vec4( -1.0, -1.0, -1.0, 1.0 );"
"}";
void SelectionManagerMeshTexels::initTexture()
bool SelectionManagerMeshTexels::initTexture()
{
if( m_Texture.IsInstantiated() )
return;
return true;
if( m_ImageWidth == -1 || m_ImageHeight == -1 )
return false;
GLenum formats[] = { GL_R8, GL_RGB8, GL_NONE,
GL_RGB32F, GL_NONE };
......@@ -120,24 +123,23 @@ void SelectionManagerMeshTexels::initTexture()
glClearColor( clearColor[0], clearColor[1], clearColor[2], clearColor[3] );
m_Buffer.Create( m_ImageWidth, m_ImageHeight );
m_Buffer.Attach( GL_COLOR_ATTACHMENT0, &m_Texture );
return m_Texture.IsInstantiated();
}
SelectionManagerMeshTexels::SelectionManagerMeshTexels( GPU::VBO& meshVBO,
const std::string& posAttribName,
const std::string& uvAttribName,
int texW, int texH ) :
const std::string& uvAttribName ) :
TexelSelectionManager(),
m_MeshVBO( meshVBO ),
m_PosAttribName( posAttribName ),
m_UVAttribName( uvAttribName )
m_UVAttribName ( uvAttribName ),
m_ImageWidth ( -1 ),
m_ImageHeight( -1 )
{
m_ImageWidth = texW;
m_ImageHeight = texH;
GPU::CreateShaderFromSources(
m_DisplayShader,
s_DisplayShaderVSH,
......@@ -158,7 +160,8 @@ void SelectionManagerMeshTexels::onRecompilingSelectionShader( SelectionTool *to
void SelectionManagerMeshTexels::onUpdatingSelection( SelectionTool *tool )
{
initTexture();
if( !initTexture() )
return;
tool->initSelectionShader( m_SelectionShader );
GLfloat updateValue = tool->selectionMode()==SelectionTool::SELECTION_MODE_REMOVE? 0.0f : 1.0f;
......@@ -246,3 +249,11 @@ bool SelectionManagerMeshTexels::getSelectionMask( std::vector<uint8_t> &mask )
else
return false;
}
void SelectionManagerMeshTexels::setTextureSize( int texW, int texH )
{
m_ImageWidth = texW;
m_ImageHeight = texH;
m_Texture.Release();
}
......@@ -27,20 +27,21 @@ class SelectionManagerMeshTexels : public TexelSelectionManager
GPU::Texture2D m_Texture;
GPU::FrameBuffer m_Buffer;
void initTexture();
bool initTexture();
public:
SelectionManagerMeshTexels( GPU::VBO& meshVBO,
const std::string& posAttribName,
const std::string& uvAttribName,
int texW, int texH );
void onRecompilingSelectionShader( SelectionTool *tool );
void onUpdatingSelection( SelectionTool *tool );
void onDisplay( GLViewer *viewer,
const QMatrix4x4 &localTransfo );
void clearSelection();
bool getSelectionMask( std::vector<uint8_t> &mask );
const std::string& uvAttribName );
void onRecompilingSelectionShader( SelectionTool *tool );
void onUpdatingSelection( SelectionTool *tool );
void onDisplay( GLViewer *viewer,
const QMatrix4x4 &localTransfo );
void clearSelection();
bool getSelectionMask( std::vector<uint8_t> &mask );
void setTextureSize( int texW, int texH );
};
......
Supports Markdown
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