Ejemplo n.º 1
0
// -----------------------------------------------------------------
// Name : reloadAllTextures
// -----------------------------------------------------------------
void TextureEngine::reloadAllTextures()
{
    for (u16 i = 0; i < m_AllTextures.size(); i++)
    {
        Texture * pTex = m_AllTextures[i];
        if (pTex->load()) {
        	textureLoaded(pTex);
        }
    }
}
Ejemplo n.º 2
0
Window::Window()
{
	m_shouldDisplayFeather = true;
	std::cout<<"Initializing Mallard main window ";
    glWidget = new GLWidget;
	m_tools = new ToolBox;
	m_barbEdit = new BarbEdit(this);
	m_renderEdit = new RenderEdit(this);
	
	glWidget->setInteractContext(m_tools);
	m_brushControl = new BrushControl(glWidget->brush(), this);
	m_featherEdit = new FeatherEdit(this);
	FeatherExample::FeatherLibrary = glWidget;
	m_timeControl = new TimeControl(this);
	glWidget->setPlayback(m_timeControl);
	
	m_sceneEdit = new SceneEdit(glWidget, this);
	
	addToolBar(m_tools);

	setCentralWidget(glWidget);
    setWorkTitle(tr("untitled"));
	createActions();
	createMenus();
    
	connect(m_tools, SIGNAL(contextChanged(int)), this, SLOT(receiveToolContext(int)));
	connect(m_tools, SIGNAL(contextChanged(int)), m_brushControl, SLOT(receiveToolContext(int)));
    connect(m_tools, SIGNAL(actionTriggered(int)), this, SLOT(receiveToolAction(int)));
	connect(m_tools, SIGNAL(stateChanged(int)), this, SLOT(receiveToolState(int)));
	connect(m_brushControl, SIGNAL(brushChanged()), glWidget, SLOT(receiveBrushChanged()));
	connect(m_brushControl, SIGNAL(paintModeChanged(int)), glWidget, SLOT(receivePaintMode(int)));
	connect(glWidget, SIGNAL(sceneNameChanged(QString)), this, SLOT(setWorkTitle(QString)));
	connect(glWidget, SIGNAL(sendMessage(QString)), this, SLOT(showMessage(QString)));
	connect(m_featherEdit, SIGNAL(textureLoaded(QString)), glWidget, SLOT(receiveFeatherEditBackground(QString)));
	connect(m_featherEdit, SIGNAL(featherAdded()), glWidget, SLOT(receiveFeatherAdded()));
	connect(glWidget, SIGNAL(sendFeatherEditBackground(QString)), m_featherEdit, SLOT(receiveTexture(QString)));
	connect(m_timeControl, SIGNAL(currentFrameChanged(int)), glWidget, SLOT(updateOnFrame(int)));
	connect(m_featherEdit->uvView(), SIGNAL(selectionChanged()), m_barbEdit->barbControl(), SLOT(receiveSelectionChanged()));
	connect(glWidget, SIGNAL(featherSelectionChanged()), m_barbEdit->barbControl(), SLOT(receiveSelectionChanged()));
	connect(m_featherEdit->uvView(), SIGNAL(shapeChanged()), m_barbEdit->barbView(), SLOT(receiveShapeChanged()));
	connect(glWidget, SIGNAL(renderResChanged(QSize)), m_renderEdit, SLOT(resizeRenderView(QSize)));
	connect(glWidget, SIGNAL(renderEngineChanged(QString)), m_renderEdit, SLOT(setRenderEngine(QString)));
	connect(glWidget, SIGNAL(renderStarted(QString)), m_renderEdit, SLOT(startRender(QString)));
	connect(m_renderEdit, SIGNAL(cancelRender()), glWidget, SLOT(receiveCancelRender()));
	connect(m_barbEdit->barbControl(), SIGNAL(shapeChanged()), glWidget, SLOT(receiveBarbChanged()));
	connect(glWidget, SIGNAL(sceneOpened()), m_sceneEdit, SLOT(reloadScene()));
	connect(m_sceneEdit->model(), SIGNAL(cameraChanged()), glWidget, SLOT(receiveCameraChanged()));
	
	std::cout<<"Ready\n";
	statusBar()->showMessage(tr("Ready"));
}
Ejemplo n.º 3
0
// -----------------------------------------------------------------
// Name : loadTexture
// -----------------------------------------------------------------
Texture * TextureEngine::loadTexture(string sFilename, bool bComposed, bool bMipmap, int ustart, int uend, int vstart, int vend)
{
    if (sFilename == "") {
        return NULL;
    }

    Texture * pTex = findTexture(sFilename);
    if (pTex != NULL) { // Texture already loaded
        return pTex;
    }

    pTex = new Texture(sFilename, bComposed, bMipmap);
    m_AllTextures.push_back(pTex);
    if (!pTex->load()) {
        return pTex;
    } else {
        textureLoaded(pTex);
    }

    pTex->m_bIsLoadedInVideo = true;

    // Set u/v coords
    if (ustart >= 0)
    {
        pTex->m_fU0 = (GLfloat)ustart / (GLfloat)pTex->getWidth();
        pTex->m_fU1 = (GLfloat)uend / (GLfloat)pTex->getWidth();
    }
    else
    {
        pTex->m_fU0 = 0.0f;
        pTex->m_fU1 = 1.0f;
    }
    if (vstart >= 0)
    {
        pTex->m_fV0 = (GLfloat)vstart / (GLfloat)pTex->getHeight();
        pTex->m_fV1 = (GLfloat)vend / (GLfloat)pTex->getHeight();
    }
    else
    {
        pTex->m_fV0 = 0.0f;
        pTex->m_fV1 = 1.0f;
    }
    return pTex;
}
Ejemplo n.º 4
0
TextureManager::TextureManager(QGLWidget *primaryGLWidget, QGLWidget *secondaryGLWidget)
: mPrimaryGLWidget(primaryGLWidget)
{
	// создаем фоновый поток
	mBackgroundThread = new QThread(this);

	// создаем загрузчик текстур и переносим его в фоновый поток
	mTextureLoader = new TextureLoader(secondaryGLWidget);
	qRegisterMetaType<QSharedPointer<Texture> >("QSharedPointer<Texture>");
	connect(this, SIGNAL(textureQueued(QString)), mTextureLoader, SLOT(onTextureQueued(QString)));
	connect(mTextureLoader, SIGNAL(textureLoaded(QString, QSharedPointer<Texture>)), this, SLOT(onTextureLoaded(QString, QSharedPointer<Texture>)));
	mTextureLoader->moveToThread(mBackgroundThread);

	// создаем объект слежения за файловой системой
	mWatcher = new QFileSystemWatcher(this);
	connect(mWatcher, SIGNAL(fileChanged(const QString &)), this, SLOT(onFileChanged(const QString &)));

	// запускаем фоновый поток
	mBackgroundThread->start();

	// запускаем таймер для отслеживания изменений файлов
	startTimer(250);
}