繁体   English   中英

OS X上的OpenGL版本支持

[英]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/

  • 这是否意味着我无法在这些配置下使用GLSL?
  • 如果是这样,是否可以升级某些库或图形驱动程序?
  • 在不支持相同的计算机上启动时,使用核心配置文件的应用程序会发生什么?

类似帖子无法在QGLWidget中设置所需的OpenGL版本

看来我并不是唯一一个在本教程中挣扎的人,我在这里找到了解决方案。 即使提到它,也缺少绑定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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM