简体   繁体   English

OS X上的OpenGL版本支持

[英]OpenGL Version Support on OS X

I try to code an OpenGL project with Qt (v5.1.1) on OS X 10.9, in the manner of the modern pipeline implementation. 我尝试以现代管道实现的方式在OS X 10.9上使用Qt(v5.1.1)编写OpenGL项目。 However I encounter some problems to rebuild programs from tutorials as eg http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt 但是我从教程中重建程序遇到了一些问题,例如http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt

The simple triangle does not show up, however there are no warnings and the program itself shows up. 简单的三角形没有出现,但是没有警告,程序本身就出现了。 I suspected that my mac might not support the GLSL. 我怀疑我的mac可能不支持GLSL。 So I looked for a way to print some information. 所以我找了一种方法来打印一些信息。 I found someone with a similar problem who did it like this. 我发现有类似问题的人这样做了。

#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();
}

And I got as a result. 我得到了结果。

OpenGL context QFlags QFlags(0x1|0x2|0x4|0x8|0x10|0x20|0x40|0x1000|0x2000|0x4000|0x8000) OpenGL上下文QFlags QFlags(0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x40 | 0x1000 | 0x2000 | 0x4000 | 0x8000)

OpenGL context QGLFormat(options QFlags(0x1|0x2|0x4|0x20|0x80|0x200|0x400) , plane 0 , depthBufferSize -1 , accumBufferSize -1 , stencilBufferSize -1 , redBufferSize -1 , greenBufferSize -1 , blueBufferSize -1 , alphaBufferSize -1 , samples -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,样本-1,swapInterval -1,majorVersion 3,minorVersion 3,profile 1)

OpenGL context QGLFormat(options QFlags(0x1|0x2|0x4|0x20|0x80|0x200|0x400) , plane 0 , depthBufferSize 1 , accumBufferSize -1 , stencilBufferSize 1 , redBufferSize -1 , greenBufferSize -1 , blueBufferSize -1 , alphaBufferSize -1 , samples 4 , 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)

Driver Version String: 0x10800e6be 驱动程序版本字符串:0x10800e6be

Even though I am not sure about the exact meaning of this, derived from what was written at the source of this idea, it seems that the 0x8000 meant that OpenGL 3.3 is first supported but since later flags are only 0x400 the version support is lost somehow along the way. 即使我不确定这个的确切含义,从这个想法的来源写的,似乎0x8000意味着首先支持OpenGL 3.3但由于后来的标志只有0x400,版本支持以某种方式丢失一路上。

My graphic card is NVIDIA GeForce 9400M 256 MB which should support OpenGL 3.3. 我的显卡是NVIDIA GeForce 9400M 256 MB,它应该支持OpenGL 3.3。 https://developer.apple.com/graphicsimaging/opengl/capabilities/ https://developer.apple.com/graphicsimaging/opengl/capabilities/

  • Does that mean I am not able to use the GLSL under these configurations? 这是否意味着我无法在这些配置下使用GLSL?
  • If so, is it possible to upgrade some library or graphics driver? 如果是这样,是否可以升级某些库或图形驱动程序?
  • What happens to applications using the core profile when started on a computer that does not support the very same? 在不支持相同的计算机上启动时,使用核心配置文件的应用程序会发生什么?

Similar post Can't set desired OpenGL version in QGLWidget 类似帖子无法在QGLWidget中设置所需的OpenGL版本

It seems I was not the only one struggling with this tutorial , and I found the solution here . 看来我并不是唯一一个在本教程中挣扎的人,我在这里找到了解决方案。 Even though it is mentioned the source code of the tutorial is missing to bind the VAO. 即使提到它,也缺少绑定VAO的教程的源代码。

Add this in initializeGL before m_shader.setAttributeBuffer: 在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