[英]Sharing data between OpenGL contexts on OS X (different version / profile)
[英]OpenGL Version Support on OS X
我嘗試以現代管道實現的方式在OS X 10.9上使用Qt(v5.1.1)編寫OpenGL項目。 但是我從教程中重建程序遇到了一些問題,例如http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt
簡單的三角形沒有出現,但是沒有警告,程序本身就出現了。 我懷疑我的mac可能不支持GLSL。 所以我找了一種方法來打印一些信息。 我發現有類似問題的人這樣做了。
#include <QApplication>
#include <QGLFormat>
#include "glwidget.h"
int main(int argc, char* argv[])
{
QApplication mApplication(argc, argv);
QGLFormat mGlFormat;
mGlFormat.setVersion(3, 3);
mGlFormat.setProfile(QGLFormat::CoreProfile);
mGlFormat.setSampleBuffers(true);
qDebug() << "OpenGL context QFlags " << mGlFormat.openGLVersionFlags();
qDebug() << "OpenGL context " << mGlFormat;
GLWidget mWidget(mGlFormat);
mWidget.show();
qDebug() << "OpenGL context" << mWidget.format();
qDebug() << "Driver Version String:" << glGetString(GL_VERSION);
return mApplication.exec();
}
我得到了結果。
OpenGL上下文QFlags QFlags(0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x1000 | 0x2000 | 0x4000 | 0x8000)
OpenGL上下文QGLFormat(選項QFlags(0x1 | 0x2 | 0x4 | 0x20 | 0x80 | 0x200 | 0x400),plane 0,depthBufferSize -1,accumBufferSize -1,stencilBufferSize -1,redBufferSize -1,greenBufferSize -1,blueBufferSize -1,alphaBufferSize -1,樣本-1,swapInterval -1,majorVersion 3,minorVersion 3,profile 1)
OpenGL上下文QGLFormat(選項QFlags(0x1 | 0x2 | 0x4 | 0x20 | 0x80 | 0x200 | 0x400),plane 0,depthBufferSize 1,accumBufferSize -1,stencilBufferSize 1,redBufferSize -1,greenBufferSize -1,blueBufferSize -1,alphaBufferSize -1 ,樣本4,swapInterval -1,majorVersion 3,minorVersion 3,profile 1)
驅動程序版本字符串:0x10800e6be
即使我不確定這個的確切含義,從這個想法的來源寫的,似乎0x8000意味着首先支持OpenGL 3.3但由於后來的標志只有0x400,版本支持以某種方式丟失一路上。
我的顯卡是NVIDIA GeForce 9400M 256 MB,它應該支持OpenGL 3.3。 https://developer.apple.com/graphicsimaging/opengl/capabilities/
看來我並不是唯一一個在本教程中掙扎的人,我在這里找到了解決方案。 即使提到它,也缺少綁定VAO的教程的源代碼。
在m_shader.setAttributeBuffer之前的initializeGL中添加:
uint vao;
typedef void (APIENTRY *_glGenVertexArrays) (GLsizei, GLuint*);
typedef void (APIENTRY *_glBindVertexArray) (GLuint);
_glGenVertexArrays glGenVertexArrays;
_glBindVertexArray glBindVertexArray;
glGenVertexArrays = (_glGenVertexArrays) QGLWidget::context()->getProcAddress("glGenVertexArrays");
glBindVertexArray = (_glBindVertexArray) QGLWidget::context()->getProcAddress("glBindVertexArray");
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.