本文整理汇总了C++中GLContext::makeCurrent方法的典型用法代码示例。如果您正苦于以下问题:C++ GLContext::makeCurrent方法的具体用法?C++ GLContext::makeCurrent怎么用?C++ GLContext::makeCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLContext
的用法示例。
在下文中一共展示了GLContext::makeCurrent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void GLContext::init(HDC hdc, HGLRC hglrc)
{
FW_ASSERT(hdc && hglrc);
// Initialize members.
m_hdc = hdc;
m_hglrc = hglrc;
m_viewPos = 0;
m_viewSize = 1;
m_viewScale = 2.0f;
m_numAttribs = 0;
m_vgFont = NULL;
// Setup text rendering.
m_memdc = CreateCompatibleDC(m_hdc);
if (!m_memdc)
failWin32Error("CreateCompatibleDC");
if (SetTextAlign(m_memdc, TA_TOP | TA_LEFT) == GDI_ERROR)
failWin32Error("SetTextAlign");
if (SetBkColor(m_memdc, RGB(0x00, 0x00, 0xFF)) == CLR_INVALID)
failWin32Error("SetTextColor");
if (SetTextColor(m_memdc, RGB(0xFF, 0xFF, 0x00)) == CLR_INVALID)
failWin32Error("SetTextColor");
setDefaultFont();
// Initialize GL state.
GLContext* oldContext = s_current;
makeCurrent();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
checkErrors();
if (oldContext)
oldContext->makeCurrent();
}
示例2: staticInit
GLContext::GLContext(HDC hdc, const Config& config)
: m_hdc (hdc),
m_memdc (NULL),
m_hglrc (NULL),
m_config (config),
m_viewPos (0),
m_viewSize (1),
m_viewScale (2.0f),
m_numAttribs (0),
m_vgFont (NULL)
{
FW_ASSERT(hdc);
staticInit();
// Choose pixel format.
if (s_cachedPixelFormat == -1 || memcmp(&s_cachedConfig, &config, sizeof(Config)) != 0)
{
s_cachedConfig = config;
if (!choosePixelFormat(s_cachedPixelFormat, m_hdc, config))
fail("No appropriate pixel format found!");
}
int formatIdx = s_cachedPixelFormat;
// Set pixel format.
if (!SetPixelFormat(m_hdc, formatIdx, NULL))
failWin32Error("SetPixelFormat");
// Create WGL context.
m_hglrc = wglCreateContext(m_hdc);
if (!m_hglrc)
fail("wglCreateContext() failed!");
if (s_default && !wglShareLists(s_default->m_hglrc, m_hglrc))
fail("wglShareLists() failed!");
// Setup text rendering.
m_memdc = CreateCompatibleDC(m_hdc);
if (!m_memdc)
failWin32Error("CreateCompatibleDC");
if (SetTextAlign(m_memdc, TA_TOP | TA_LEFT) == GDI_ERROR)
failWin32Error("SetTextAlign");
if (SetBkColor(m_memdc, RGB(0x00, 0x00, 0xFF)) == CLR_INVALID)
failWin32Error("SetTextColor");
if (SetTextColor(m_memdc, RGB(0xFF, 0xFF, 0x00)) == CLR_INVALID)
failWin32Error("SetTextColor");
setDefaultFont();
// Initialize GL state.
GLContext* oldContext = s_current;
makeCurrent();
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
checkErrors();
if (oldContext)
oldContext->makeCurrent();
}