[FIXED] add OpenGL 3.2 Core support for Mac OS X Lion

Started by void256, July 22, 2011, 21:41:30

Previous topic - Next topic

spasi

Sounds like the new code works and the new attributes are being passed. This is the native code:

if (gl32) {
	putAttrib(&attribs, 99); // NSOpenGLPFAOpenGLProfile
	putAttrib(&attribs, 0x3200); // NSOpenGLProfileVersion3_2Core
}


I've no idea why it fails.

void256

Hmm, when I understand the native code in context.m correctly there are some Pixelformat Attributes always set. Would it be possible - for an additional test - to only set the new attributes?

Using plain Obj-C it works with a minimal version:

+ (NSOpenGLPixelFormat*) basicPixelFormat
{
    NSOpenGLPixelFormatAttribute attributes [] = {
        NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
        (NSOpenGLPixelFormatAttribute)nil
    };
    return [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease];
}


So, I'm curious what would happen when there would be no attribute set at all - besides the new NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core of course.

I understand that we want to specify some of the attributes of course. This would just be a test what would happen when we create exactly the same NSOpenGLPixelFormatAttribute[] I had luck with in the native example. Maybe something is conflicting with the new NSOpenGLPFAOpenGLProfile stuff?

kappa

void256 would it be possible if you could just build lwjgl on your end? main issue here is lack of access to an OS X 10.7, should be as easy as checking out of svn and running build.xml to compile lwjgl. Would allow you to quickly test the different combinations to find the correct one.

princec

I've just got me 10.7 on my Mini - I should try and get a dev environment going on it to help you out...

Cas :)

void256

Ok, I've build LWJGL from svn which worked out quite well. Since 10.7 does not support building for ppc anymore I need to comment out a couple of lines in one of the build.xml files but after that I've got the jars and the native libs.

Unfortunatly when I try to use them I only get that - somewhat familiar :) - exception:

Exception in thread "main" java.lang.LinkageError: Version mismatch: jar version is '20', native library version is '19'


Usually you get that one when you're using the wrong jar with the wrong native libs. But I've double and triple ^^ checked my classpath and I think I'm using exactly the versions from my own build of LWJGL.

Is there some additional trick to align these version numbers somehow?

kappa

That version check is a last line of defence to make sure your using the right natives with the correct jars.

If you look inside MacOSXSysImplementation.java (found in the org.lwjgl.* package), you'll see the line
Quoteprivate static final int JNI_VERSION = 20;
this value is obtained by the natives when compiling directly from the above java class using
Quoteorg_lwjgl_MacOSXSysImplementation_JNI_VERSION
see org_lwjgl_opengl_Display.m (inside src/native/macosx).

So its either your compiler compiling with older lwjgl java classes or the natives you're running with are old (do quadruple check :), maybe try deleting any precompiled natives already in the lwjgl folder).

spasi

Get in the LWJGL root directory and run this:

java -cp bin -Djava.library.path=libs/macosx org.lwjgl.test.opengl.VersionTest 3 2 core

void256

Ok, the quadruple check solved it ;) Somehow I ended up using the wrong native libs, oops :-[ but now it works!

With some testing it seems that Apple doesn't like the attribute:

if (support_window)
  putAttrib(&attribs, NSOpenGLPFAWindow);


Which is odd, because the doc says:

NSOpenGLPFAWindow

    A Boolean attribute. If present, this attribute indicates that only renderers that are capable of rendering to a window are considered. This attribute is implied if neither NSOpenGLPFAFullScreen nor NSOpenGLPFAOffScreen is specified.

    Available in Mac OS X v10.0 and later.


Without NSOpenGLPFAWindow my OpenGL implementation finally reported:

opengl version: 3.2 ATI-7.4.10


I still get a warning about some other invalid pixel format attribute though:

2011-09-15 13:19:44.054 java[3338:1903] invalid pixel format attribute


but the exception is gone. I've not yet tested if I can render anything but this looks pretty good so far.

From what I understand the support_window boolean is not accessible from the outside and is set to false when using MacOSXPbufferPeerInfo only and set to true when using MacOSXCanvasPeerInfo (or a subclass).

What are these PeerInfos? =)

void256

With brute force out commenting of the line "putAttrib(&attribs, NSOpenGLPFAWindow);" and then running:

java -cp bin -Djava.library.path=libs/macosx org.lwjgl.test.opengl.VersionTest 3 2 core


I've got that:

Setting display mode to: 1024 x 768 x 32 @85Hz
2011-09-15 14:01:00.429 java[3658:c07] invalid pixel format attribute

---------

Requested ContextAttribs: Version=3.2 - Layer=0 - Debug=false - ForwardCompatible=false - RobustAccess=false - Profile=Core

GL_VERSION returned : 3.2 ATI-7.4.10
	Core profile: true
	Compatibility profile: false
ARB_compatibility present: false
Deprecated functionality present: false

---------

Version 3.2 or greater is requested, the context returned may
implement any of the following versions:

1) The requested profile of the requested version.
	true

2) The requested profile of any later version, so long as no
features have been removed from that later version and profile.
	false

TEST SUCCEEDED


And just for the record - with the NSOpenGLPFAWindow line in place it looks like that:

Setting display mode to: 1024 x 768 x 32 @85Hz
2011-09-15 14:03:31.546 java[3768:c07] invalid pixel format attribute
2011-09-15 14:03:31.547 java[3768:c07] invalid pixel format attribute
The VersionTest program was terminated because an error occured.

Reason: Could not create pixel format

kappa

oh nice work void256, guess as it stands we just need to change the code to something like:

if (support_window && !gl32)
 	putAttrib(&attribs, NSOpenGLPFAWindow);

spasi

If you don't mind, could you please comment out the other attributes one-by-one as well? So that we can get rid of the other "invalid pixel format attribute" message.

void256

Sure, here is it. With that commented out as well it does not complain anymore:

NSOpenGLPFAPixelBuffer

    A Boolean attribute. If present, this attribute indicates that rendering to a pixel buffer is enabled.

    Available in Mac OS X v10.3 and later.


Not sure if that makes sense but maybe PBOs are explicitly available when requesting the Core profile so it's not necessary to request support?

spasi

That makes sense. It's the pbuffer flag and pbuffers have been deprecated in 10.7 in favor of FBOs. I have applied a fix now, try the next build to make sure it works please.