Hello Guest

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

  • 42 Replies
  • 72113 Views
*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #30 on: September 13, 2011, 18:09:38 »
Sounds like the new code works and the new attributes are being passed. This is the native code:

Code: [Select]
if (gl32) {
putAttrib(&attribs, 99); // NSOpenGLPFAOpenGLProfile
putAttrib(&attribs, 0x3200); // NSOpenGLProfileVersion3_2Core
}

I've no idea why it fails.

Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #31 on: September 13, 2011, 19:17:14 »
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:

Code: [Select]
+ (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?

*

Offline kappa

  • *****
  • 1319
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #32 on: September 13, 2011, 20:48:57 »
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.

*

Offline princec

  • *****
  • 1933
    • Puppygames
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #33 on: September 14, 2011, 11:48:54 »
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 :)

Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #34 on: September 15, 2011, 01:04:12 »
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:

Code: [Select]
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?
« Last Edit: September 15, 2011, 01:07:08 by void256 »

*

Offline kappa

  • *****
  • 1319
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #35 on: September 15, 2011, 08:54:40 »
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
Quote
private static final int JNI_VERSION = 20;
this value is obtained by the natives when compiling directly from the above java class using
Quote
org_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).

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #36 on: September 15, 2011, 09:03:59 »
Get in the LWJGL root directory and run this:

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

Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #37 on: September 15, 2011, 11:31:35 »
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:

Code: [Select]
if (support_window)
  putAttrib(&attribs, NSOpenGLPFAWindow);

Which is odd, because the doc says:

Code: [Select]
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:

Code: [Select]
opengl version: 3.2 ATI-7.4.10
I still get a warning about some other invalid pixel format attribute though:

Code: [Select]
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? =)

Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #38 on: September 15, 2011, 12:01:14 »
With brute force out commenting of the line "putAttrib(&attribs, NSOpenGLPFAWindow);" and then running:

Code: [Select]
java -cp bin -Djava.library.path=libs/macosx org.lwjgl.test.opengl.VersionTest 3 2 core
I've got that:

Code: [Select]
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:

Code: [Select]
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
« Last Edit: September 15, 2011, 12:04:16 by void256 »

*

Offline kappa

  • *****
  • 1319
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #39 on: September 15, 2011, 12:59:01 »
oh nice work void256, guess as it stands we just need to change the code to something like:

Code: [Select]
if (support_window && !gl32)
  putAttrib(&attribs, NSOpenGLPFAWindow);

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #40 on: September 15, 2011, 13:05:03 »
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.

Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #41 on: September 15, 2011, 16:15:21 »
Sure, here is it. With that commented out as well it does not complain anymore:

Code: [Select]
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?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: [RFE] add OpenGL 3.2 Core support for Mac OS X Lion
« Reply #42 on: September 15, 2011, 17:23:39 »
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.