OpenGL 3.x Mac Lion
-
src/opengl/qgl_mac.mm sounds like a good place to start :)
-
cheers, downloading the 4.8 beta for a test then will get the source and have a play
-
it seems that Qt 4.8 Beta gives me the core profile under Lion ;-) however Lion has two drivers (compatibility and core) the compat is 2.0 only so I just need to remove a few deprecated functions from my library first.
For more details on the Mac GL this is good http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=104206#104206
Thanks for the help
-
spoke too soon, seem I had some legacy Mac code in my initializeGL function, the driver is initialsed and reports 3.2 but the context isn't created to the same so get crashes, oh well. Will download the 4.7 source and hack
-
In case if it is still actual topic. Here is some code, which allows to get opengl 3.2 core without hacking Qt4.7.
test_ogl_core_context.cpp:
@
#include <QApplication>#include <QGLWidget>
#include <QGLContext>#include <iostream>
void* select_3_2_mac_visual(GDHandle handle);
struct Core3_2_context : public QGLContext
{
Core3_2_context(const QGLFormat& format, QPaintDevice* device) : QGLContext(format,device) {}
Core3_2_context(const QGLFormat& format) : QGLContext(format) {}virtual void* chooseMacVisual(GDHandle handle)
{
return select_3_2_mac_visual(handle);
}
};struct OglWidget : public QGLWidget
{
OglWidget() : QGLWidget(new Core3_2_context(QGLFormat::defaultFormat()))
{
}
virtual void initializeGL()
{
std::cout<<glGetString(GL_VERSION)<<std::endl;
}
virtual void paintGL()
{
glClearColor(0,1,0,1);
glClear(GL_COLOR_BUFFER_BIT);
}
};int main(int argc, char *argv[])
{
QApplication app(argc,argv);OglWidget w;
w.show();return app.exec();
}
@core_profile_attributes.mm:
@
#include <QGLContext>void* select_3_2_mac_visual(GDHandle handle)
{
static const int Max = 40;
NSOpenGLPixelFormatAttribute attribs[Max];
int cnt = 0;attribs[cnt++] = NSOpenGLPFAOpenGLProfile; attribs[cnt++] = NSOpenGLProfileVersion3_2Core; attribs[cnt++] = NSOpenGLPFADoubleBuffer; attribs[cnt++] = NSOpenGLPFADepthSize; attribs[cnt++] = (NSOpenGLPixelFormatAttribute)16; attribs[cnt] = 0; Q_ASSERT(cnt < Max); return [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
}
@CMakeLists.txt:
@
PROJECT(qt4_lion_ogl32)
cmake_minimum_required(VERSION 2.8)FIND_PACKAGE(Qt4)
SET( QT_USE_QTOPENGL true )
INCLUDE( ${QT_USE_FILE} )FIND_PACKAGE(OpenGL)
ADD_EXECUTABLE( test_ogl_core_context
#test_ogl_core_context.cpp
core_profile_attributes.mm
)
TARGET_LINK_LIBRARIES( test_ogl_core_context
${QT_LIBRARIES}
${OPENGL_LIBRARIES}
"-framework Foundation"
"-framework Cocoa"
)
@Sorry, if it is written not in the best way. I am new for Mac.
-
Thanks will give it a go
-
Just to say I've finally got back from Holiday and integrated your code with my own and it works, thanks mcdi really useful. Will write up a full blog report / post soon and add a link here as got basic Qt + OpenGL 3.x and glsl 150 working on the mac
-
It worked like a charm, pure "core profile"! Thanks a lot mcdi!
For noobs on mac platform, like me, here is the trick for mixing objective-C directly in .pro file :
@ mac {
OBJECTIVE_SOURCES += core_profile_attributes.mm
LIBS += -framework Foundation -framework Cocoa
}@
"source":http://el-tramo.be/blog/mixing-cocoa-and-qt -
Not sure about mac as I have no way to test but support for getting an OpenGL Core profile context has been added to 4.8.0 in gitorious. See this "post":http://developer.qt.nokia.com/forums/viewthread/4856/P15/#30548
-
Hi everyone,
I tried to create a openGL 3.2 core context on my mac (mountain lion) with qt 4.8.3 and it was not possible....Fortunately, when using the code above it was working! :-) A very helpful thread....
The .pro-file is simply for completeness here:
opengl3_and_qt.pro
@
QT += core gui openglTARGET = opengl3_and_qt
TEMPLATE = appSOURCES += test_ogl_core_context.cpp
OBJECTIVE_SOURCES += core_profile_attributes.mm
LIBS += -framework Foundation -framework Cocoa
@Now the question: is there an other and more clean way on the mac with qt to create an opengl 3.2 context??
Thanks
Mike
-
OpenGL 3.2 Core Profile should work out of the box on OS X with Qt5 now.
-
[quote author="ZapB" date="1352755393"]OpenGL 3.2 Core Profile should work out of the box on OS X with Qt5 now.[/quote]
I tried to use the core profile on Mountain Lion with Qt 5.0.0, but it seems not to work. Does anyone has an working example (on OSX) with OpenGL 3.2 and Core Profile? All the OpenGL examples shipped with Qt are using OpenGL 2.
Thanks in advance
Mike
p.s. If there is a special git version of Qt I have to use I'm also fine with that.
-
Hi
I think I have to restate my sentence about "openGL 3.2 is not working". Actual it is working out of the box, but I used the "wrong" example. I tried it with this "tutorial":http://qt-project.org/wiki/How_to_use_OpenGL_Core_Profile_with_Qt unfortunately for Qt 5 the wrong headers are used, and then it is indeed not work....but this (shame to myself) is also written in the Qt documentation. However, after fixing the headers the simple example was working :-)
For the people interested I put the adopted variant "here":https://github.com/mikenicolai/qt5-opengl3-examples
Bests
Mike
-
Hi all,
I tried the above solution as well as the 07-core-profile from the wiki
"here":http://qt-project.org/wiki/How_to_useOpenGL_Core_Profile_with_Qt</a>, but on OS X 10.8.4, Qt 4.8.4 still won't budge out of GL version 2.1 with GLSL version 1.20. Here's the output from the above solution (with most of the shader stuff commented since the compiler was complaining about QOpenGLBuffer which I thought might be specific to Qt 5).The output I get is:
Widget OpenGl: 1.0
Context valid: 1
Really used OpenGl: 1.0
OpenGl information: VENDOR: NVIDIA Corporation
RENDERDER: NVIDIA Quadro K5000 OpenGL Engine
VERSION: 2.1 NVIDIA-8.12.47 310.40.00.05f01
GLSL VERSION: 1.20Any ideas what I might be missing? The 07-core-profile wiki entry has a bold comment about some OS X "issues" but I didn't see what those issues were or their resolution.
This started with me trying to use textureSize in a shader which should be supported under Mountain Lion (GLView app shows GL version 3.2 along with the Quadro K5000 NVidia driver as identified above).
Thanks!