gpt4 book ai didi

user-interface - WxWidgets 和现代 opengl (3.3+)

转载 作者:行者123 更新时间:2023-12-01 13:39:57 25 4
gpt4 key购买 nike

有谁知道 WxWidgets 库是否与现代着色器风格的 openGL (3.3+) 兼容?我发现的所有东西似乎都在使用旧样式。我希望在我的应用程序中使用 QT 或 WxWidgets,但似乎让着色器的东西与小部件一起使用可能是一场噩梦。有任何人对此有经验吗?

最佳答案

在 wxWidgets >= 3.1 中使用 wxGLContext 具有适当的核心上下文 wxGLContextAttrs 应该工作:

wxGLContextAttrs cxtAttrs;
cxtAttrs.CoreProfile().OGLVersion(3, 3).EndList();

Ripi2 pointed out来自 pyramid sample :
//We create a wxGLContext in this constructor.
//We do OGL initialization at OnSize().
MyGLCanvas::MyGLCanvas(MyFrame* parent, const wxGLAttributes& canvasAttrs)
: wxGLCanvas(parent, canvasAttrs)
{
m_parent = parent;

m_oglManager = NULL;
m_winHeight = 0; // We have not been sized yet

// Explicitly create a new rendering context instance for this canvas.
wxGLContextAttrs ctxAttrs;
#ifndef __WXMAC__
// An impossible context, just to test IsOk()
ctxAttrs.PlatformDefaults().OGLVersion(99, 2).EndList();
m_oglContext = new wxGLContext(this, NULL, &ctxAttrs);

if ( !m_oglContext->IsOK() )
{
#if wxUSE_LOGWINDOW
wxLogMessage("Trying to set OpenGL 99.2 failed, as expected.");
#endif // wxUSE_LOGWINDOW
delete m_oglContext;
ctxAttrs.Reset();
#endif //__WXMAC__
ctxAttrs.PlatformDefaults().CoreProfile().OGLVersion(3, 2).EndList();
m_oglContext = new wxGLContext(this, NULL, &ctxAttrs);
#ifndef __WXMAC__
}
#endif //__WXMAC__

if ( !m_oglContext->IsOK() )
{
wxMessageBox("This sample needs an OpenGL 3.2 capable driver.\nThe app will end now.",
"OpenGL version error", wxOK | wxICON_INFORMATION, this);
delete m_oglContext;
m_oglContext = NULL;
}
else
{
#if wxUSE_LOGWINDOW
wxLogMessage("OpenGL Core Profile 3.2 successfully set.");
#endif // wxUSE_LOGWINDOW
}

}

关于user-interface - WxWidgets 和现代 opengl (3.3+),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41145024/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com