void QmlCameraSource::start()
{
    if (view == nullptr)
    {
        qWarning() << "No view. Cannot find QML Camera";
        return;
    }
    
    QObject *qmlCamera = view->rootObject()->findChild<QObject*>("qrCameraQML");
    
    if (qmlCamera == nullptr)
    {
        qWarning() << "Cannot find QML camera object";
        return;
    }
    
    camera = qvariant_cast<QCamera*>(qmlCamera->property("mediaObject"));
    
    if (camera == nullptr)
    {
        qWarning() << "Cannot retrieve camera from qml object";
        return;
    }
    
    LOG_INFO() << camera->supportedViewfinderResolutions();
    LOG_INFO() << camera->viewfinderSettings().resolution();
    connect(&probe,SIGNAL(videoFrameProbed(QVideoFrame)),this,SLOT(onFrame(QVideoFrame)));
    probe.setSource(camera);
    connect(view, SIGNAL(closing(QQuickCloseEvent)), qApp, SLOT(quit()));
}
void Animator::play(const std::string& sequenceName, bool bLoop, bool bForce)
{
	m_bFinished = false;

	const AnimationSequence* oldSeq = m_sequence;
	m_sequence = &sequence(sequenceName);

	m_curSequenceName = sequenceName;

	if (m_sequence->duration == 0)
	{
		m_bFinished = true;
		m_bPlay = false;
		m_frame = 0;
	}
	else if (m_sequence != oldSeq || bForce)
	{
		m_frame = 0;
		m_scale = 1;
		m_bPlay = true;
		onFrame(frame());
	}

	m_bLoop = bLoop;
}
void Animator::update(float delta)
{
	if (m_sequence->duration == 0 || !m_bPlay)
		return;

	uint numFrames = m_sequence->frames.size();

	if (numFrames == 0)
		return;

	int oldFrame = (int)m_frame;

	m_frame += delta * ((float)numFrames / m_sequence->duration) * m_scale;
	if (m_frame >= numFrames)
	{
		if (m_bLoop)
		{
			assert(fimod(m_frame, numFrames) >= 0 && fimod(m_frame, numFrames) < numFrames);
			m_frame = fimod(m_frame, numFrames);
		}
		else
		{
			m_bFinished = true;
			m_bPlay = false;
			m_frame = (float)numFrames - 1;
		}
	}

	if ((int)m_frame != oldFrame)
		onFrame(frame());

	assert(m_frame >= 0 && m_frame < numFrames);
}
Exemple #4
0
void Loop::frameHandler()
{
	_frameRound++;

	//处理异步Post
	auto posts = _asyncPosts.moveAll();
	for (auto data : posts)
	{
		try
		{
			_postHandler ? _postHandler(*data) : onPost(*data);
		}
		catch (...) {}
		delete data;
	}

	//处理异步Call请求
	auto requests = _asyncRequests.moveAll();
	for (auto context : requests)
	{
		try
		{
			auto asyncHandlerIter = _asyncHandlers.find(context->cmd);
			(asyncHandlerIter != _asyncHandlers.end()) ?
				asyncHandlerIter->second(context->cmd, context->request, context->response) :
				onAsync(context->cmd, context->request, context->response);
		}
		catch (...) {};

		ec::Loop *fromLoop = ec::Loop::get(context->loopId);
		if ((NULL == fromLoop) || (!context->handler))
		{
			delete context;
			continue;
		}
		fromLoop->_asyncResponses.push(context);
	}

	//处理异步Call返回
	auto responses = _asyncResponses.moveAll();
	for (auto context : responses)
	{
		_asyncPendingCount--;
		context->handler(context->cmd, context->request, context->response);
		delete context;
	}

	//处理每幀逻辑
	try
	{
		_frameHandler ? _frameHandler(_frameRound) : onFrame(_frameRound);
	}
	catch (...) {}

	if (_isStopping && (_asyncPendingCount == 0))
	{
		stop(false);
	}
}
Exemple #5
0
bool
RenderArea::on_expose_event (GdkEventExpose *event) {
    try {
        /*GdkGLDrawable *gldrawable =*/ gtk_widget_get_gl_drawable (GTK_WIDGET(gobj()));
        ScopedGLContext myContext(this);

        if (_myRenderer && _myScene) {
            if (_isFirstFrame) {
                _myRenderer->getCurrentScene()->updateAllModified();
                _isFirstFrame = false;
            }

            STOP_TIMER(frames);
            asl::getDashboard().cycle();
            START_TIMER(frames);

            onFrame();

            //START_TIMER(dispatchEvents);
            //y60::EventDispatcher::get().dispatch();
            //STOP_TIMER(dispatchEvents);

            START_TIMER(handleRequests);
            _myRequestManager.handleRequests();
            STOP_TIMER(handleRequests);

            renderFrame();
            swapBuffers();

            /** done rendering **/
        } else {
            // nothing to render... just clear the buffer to avoid pixel garbage
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            swapBuffers();
        }

        if (_myJSContext) {
            MAKE_SCOPE_TIMER(gc);
            JS_GC(_myJSContext);
        }
    } catch (const asl::Exception & ex) {
        AC_FATAL << "Exception caught: " << ex;
    } catch (const exception & ex) {
        AC_FATAL << "Exception caught: " << ex.what();
    } catch (...) {
        AC_FATAL << "Unknown exception";
    }
    return true;
}
Exemple #6
0
void Debugger::update() {
	Party &party = *_vm->_party;
	Spells &spells = *_vm->_spells;

	if (_spellId != -1) {
		// Cast any specified spell
		MagicSpell spellId = (MagicSpell)_spellId;
		_spellId = -1;
		Character *c = &party._activeParty[0];
		c->_currentSp = 99;
		spells.castSpell(c, spellId);
	}

	onFrame();
}
DWORD WINAPI tickThreadProc(HANDLE handle) {
	// Give plenty of time for main thread to finish setting up
	Sleep( 50 );
	ShowWindow( hwnd, SW_SHOW );
	// Retrieve the window's DC
	HDC hdc = GetDC( hwnd );
	// Create DC with shared pixels to variable 'pixels'
	hdcMem = CreateCompatibleDC( hdc );
	HBITMAP hbmOld = (HBITMAP)SelectObject( hdcMem, hbmp );
	// Milliseconds to wait each frame
	int delay = 1000 / fps;
	for ( ;; ) {
		// Do stuff with pixels
		onFrame( pixels );
		// Draw pixels to window
		BitBlt( hdc, 0, 0, mW, mH, hdcMem, 0, 0, SRCCOPY );
		// Wait
		//Sleep( delay );
	}
	SelectObject( hdcMem, hbmOld );
	DeleteDC( hdc );
}
Exemple #8
0
void LampGameObject::doFrame()
{

	//if is culled return;
	//Give the renderer our transform
	Lamp::getEngine().getRenderer()->setTransform(&m_transform);

	//Call our on frame function
	onFrame();

	//Tell all our components that this game object is ready to be drawn or whatever
	for (unsigned int i = 0; i < m_vComponents.size(); i++)
	{
		m_vComponents[i]->onFrame();
	}

	//Give the message to all our children
	for (unsigned int i = 0; i < m_vChildren.size(); i++)
	{
		m_vChildren[i]->doFrame();
	}

}
Exemple #9
0
void TlevelsPage::map2dlg(void)
{
    isMap=SUCCEEDED(deciV->getLevelsMap(map));
    onFrame();
}
Exemple #10
0
void Console::notifyWatch(const char *filename, const char *symbol, const char *newValue) {
	debugPrintf("Watch: %s:%s <---- %s\n", filename, symbol, newValue);
	printSource(0);
	attach();
	onFrame();
}
Exemple #11
0
void Console::notifyStep(const char *filename, int line) {
	debugPrintf("Step: %s:%d\n", filename, line);
	printSource(0);
	attach();
	onFrame();
}
Exemple #12
0
void Console::notifyBreakpoint(const char *filename, int line) {
	debugPrintf("Breakpoint hit %s: %d\n", filename, line);
	printSource(0);
	attach();
	onFrame();
}
Exemple #13
0
bool Listener::sendFrame() {
    if (!running_)
        onFrame(controller_);

    return !running_;
}
JNIEXPORT void JNICALL Java_com_n0n3m4_q3e_Q3EJNI_drawFrame(JNIEnv *env, jclass c)
{
    onFrame();
}
	void callHandlersOnFrame() { CALL(onFrame()); }