本文整理汇总了C++中GLContext::activate方法的典型用法代码示例。如果您正苦于以下问题:C++ GLContext::activate方法的具体用法?C++ GLContext::activate怎么用?C++ GLContext::activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLContext
的用法示例。
在下文中一共展示了GLContext::activate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderWindow
void Canvas::renderWindow(WindowPtr pWindow, MCFBOPtr pFBO, const IntRect& viewport)
{
GLContext* pContext = pWindow->getGLContext();
pContext->activate();
GLContextManager::get()->uploadDataForContext();
renderFX(pContext);
glm::mat4 projMat;
if (pFBO) {
pFBO->activate(pContext);
glm::vec2 size = m_pRootNode->getSize();
projMat = glm::ortho(0.f, size.x, 0.f, size.y);
glViewport(0, 0, GLsizei(size.x), GLsizei(size.y));
} else {
glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
projMat = glm::ortho(float(viewport.tl.x), float(viewport.br.x),
float(viewport.br.y), float(viewport.tl.y));
IntPoint windowSize = pWindow->getSize();
glViewport(0, 0, windowSize.x, windowSize.y);
}
{
ScopeTimer Timer(VATransferProfilingZone);
m_pVertexArray->update(pContext);
}
clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
!pFBO);
GLContext::checkError("Canvas::renderWindow: glViewport()");
m_pVertexArray->activate(pContext);
{
ScopeTimer timer(RootRenderProfilingZone);
m_pRootNode->maybeRender(pContext, projMat);
}
renderOutlines(pContext, projMat);
}
示例2: getFrameFromPBO
void VideoWriter::getFrameFromPBO()
{
if (m_bFramePending) {
BitmapPtr pBmp;
GLContext* pOldContext = GLContext::getCurrent();
m_pMainGLContext->activate();
if (m_pFilter) {
pBmp = m_pFilter->getFBO(m_pMainGLContext)->getImageFromPBO();
} else {
pBmp = m_pFBO->getImageFromPBO();
}
pOldContext->activate();
sendFrameToEncoder(pBmp);
m_bFramePending = false;
}
}
示例3: windowDimensions
SecondaryWindow::SecondaryWindow(const WindowParams& wp, bool bIsFullscreen,
GLConfig glConfig)
: Window(wp, bIsFullscreen)
{
#ifdef linux
GLContext* pMainContext = GLContext::getCurrent();
GLContext* pGLContext;
IntRect windowDimensions(wp.m_Pos, wp.m_Pos+wp.m_Size);
string sDisplay = ":0." + toString(wp.m_DisplayServer);
pGLContext = new SecondaryGLXContext(glConfig, sDisplay, windowDimensions,
wp.m_bHasWindowFrame);
setGLContext(pGLContext);
pMainContext->activate();
#endif
}
示例4: getFrameFromFBO
void VideoWriter::getFrameFromFBO()
{
if (m_pFBO) {
GLContext* pOldContext = GLContext::getCurrent();
m_pMainGLContext->activate();
if (m_pFilter) {
m_pFilter->apply(m_pMainGLContext, m_pFBO->getTex());
FBOPtr pYUVFBO = m_pFilter->getFBO(m_pMainGLContext);
pYUVFBO->moveToPBO();
} else {
m_pFBO->moveToPBO();
}
pOldContext->activate();
m_bFramePending = true;
} else {
BitmapPtr pBmp = Player::get()->getDisplayEngine()->screenshot(GL_BACK);
sendFrameToEncoder(pBmp);
}
}
示例5: onFrameEnd
void VideoWriter::onFrameEnd()
{
// The VideoWriter handles OffscreenCanvas and MainCanvas differently:
// For MainCanvas, it simply does a screenshot onFrameEnd and sends that to the
// VideoWriterThread immediately.
// For OffscreenCanvas, an asynchronous PBO readback is started in onFrameEnd.
// In the next frame's onFrameEnd, the data is read into a bitmap and sent to
// the VideoWriterThread.
if (m_pFBO) {
// Read last frame's bitmap.
GLContext* pOldContext = GLContext::getCurrent();
m_pMainGLContext->activate();
getFrameFromPBO();
pOldContext->activate();
}
if (m_StartTime == -1) {
m_StartTime = Player::get()->getFrameTime();
}
if (!m_bPaused) {
if (m_bSyncToPlayback) {
getFrameFromFBO();
} else {
long long movieTime = Player::get()->getFrameTime() - m_StartTime
- m_PauseTime;
float timePerFrame = 1000.f/m_FrameRate;
int wantedFrame = int(movieTime/timePerFrame+0.1);
if (wantedFrame > m_CurFrame) {
getFrameFromFBO();
if (wantedFrame > m_CurFrame + 1) {
m_CurFrame = wantedFrame - 1;
}
}
}
}
if (!m_pFBO) {
getFrameFromPBO();
}
}
示例6: Exception
VideoWriter::VideoWriter(CanvasPtr pCanvas, const string& sOutFileName, int frameRate,
int qMin, int qMax, bool bSyncToPlayback)
: m_pCanvas(pCanvas),
m_sOutFileName(sOutFileName),
m_FrameRate(frameRate),
m_QMin(qMin),
m_QMax(qMax),
m_bHasValidData(false),
m_bSyncToPlayback(bSyncToPlayback),
m_bPaused(false),
m_PauseTime(0),
m_bStopped(false),
m_CurFrame(0),
m_StartTime(-1),
m_bFramePending(false)
{
if (!pCanvas) {
throw Exception(AVG_ERR_INVALID_ARGS, "VideoWriter needs a canvas to write to.");
}
if (GLContext::getCurrent()->isGLES()) {
throw Exception(AVG_ERR_UNSUPPORTED, "VideoWriter not supported under GLES.");
}
#ifdef WIN32
int fd = _open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, _S_IREAD | _S_IWRITE);
#elif defined __linux__
int fd = open64(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
#else
int fd = open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
#endif
if (fd == -1) {
throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
string("Could not open output file '") + m_sOutFileName + "'. Reason: " +
strerror(errno));
}
#ifdef WIN32
_close(fd);
#else
close(fd);
#endif
remove(m_sOutFileName.c_str());
CanvasPtr pMainCanvas = Player::get()->getMainCanvas();
DisplayEngine* pDisplayEngine = Player::get()->getDisplayEngine();
if (pMainCanvas == m_pCanvas) {
m_FrameSize = pDisplayEngine->getWindowSize();
} else {
m_FrameSize = m_pCanvas->getSize();
GLContext* pOldContext = GLContext::getCurrent();
m_pMainGLContext = pDisplayEngine->getWindow(0)->getGLContext();
m_pMainGLContext->activate();
m_pFBO = dynamic_pointer_cast<OffscreenCanvas>(m_pCanvas)->
getFBO(m_pMainGLContext);
if (GLContext::getCurrent()->useGPUYUVConversion()) {
m_pFilter = GPURGB2YUVFilterPtr(new GPURGB2YUVFilter(m_FrameSize));
}
pOldContext->activate();
}
VideoWriterThread writer(m_CmdQueue, m_sOutFileName, m_FrameSize, m_FrameRate,
qMin, qMax);
m_pThread = new boost::thread(writer);
m_pCanvas->registerPlaybackEndListener(this);
m_pCanvas->registerFrameEndListener(this);
}