Attempting to get 1.91 built on Mac

Discussion and announcements regarding the Mac port… er, original version of Oolite.

Moderators: winston, another_commander

User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4809
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Attempting to get 1.91 built on Mac

Post by phkb »

Some additional debugging has found the following:

Code: Select all

   OOGL(glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE));
and

Code: Select all

   OOGL(glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE));
FaIl with the error "invaliud enumerant". So I guess it's not as simple as just adding those definitions.

Everything down to the first instance of the line

Code: Select all

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
doesn't fail, per se, in that no error codes are being flagged.
The framebuffer failure error is 0x8CD6, which is GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4809
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: Attempting to get 1.91 built on Mac

Post by phkb »

I'm wondering if the issue is something to do with the initialisation settings. For clarity, this is what I've currently got:

Code: Select all

	// Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
	NSOpenGLPixelFormatAttribute attrs[] =
	{
		// Specify that we want a windowed OpenGL context.
		// Must be first or we'll hit an assert in the legacy fullscreen controller.
		// NSOpenGLPFAWindow, // enabling this will force OpenGL to v2.1
		NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
		
		// We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over.
		// For this demo, we'll specify the main screen.
		NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
		
		// Specifying "NoRecovery" gives us a context that cannot fall back to the software renderer.
		// This makes the View-based context a compatible with the fullscreen context, enabling us to use the "shareContext"
		// feature to share textures, display lists, and other OpenGL objects between the two.
		NSOpenGLPFANoRecovery,
		
		// Attributes Common to FullScreen and non-FullScreen
		// NSOpenGLPFACompliant, // enabling this will force OpenGL to v2.1
		
		NSOpenGLPFAColorSize, 32,
		NSOpenGLPFADepthSize, 32, // I've also tried 24 in this spot
		NSOpenGLPFADoubleBuffer,
		//NSOpenGLPFAAccelerated, // enabling this will force OpenGL to v2.1
#if FSAA
		// Need a preference or other sane way to activate this
		NSOpenGLPFAMultisample,
		NSOpenGLPFASampleBuffers, 1,
		NSOpenGLPFASamples,4,
#endif
		0
	};
I've also tried enabling the FSAA options. Any suggestions very welcome!
User avatar
hiran
Theorethicist
Posts: 2315
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: Attempting to get 1.91 built on Mac

Post by hiran »

This does not answer a question but may make it easier for more people looking at the code in the future: Add Doxygen style comments.

These comments not only sit in the code - they also get extracted by Doxygen and placed in the easy-to-browse Oolite API Documentation.

Or, should someone have the right IDE, it would be displayed inline wherever needed.
Sunshine - Moonlight - Good Times - Oolite
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6604
Joined: Wed Feb 28, 2007 7:54 am

Re: Attempting to get 1.91 built on Mac

Post by another_commander »

phkb wrote: Mon Jul 15, 2024 4:25 am
Some additional debugging has found the following:

Code: Select all

   OOGL(glClampColor(GL_CLAMP_VERTEX_COLOR, GL_FALSE));
and

Code: Select all

   OOGL(glClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE));
FaIl with the error "invaliud enumerant". So I guess it's not as simple as just adding those definitions.
This should hopefully not be a problem. According to the OpenGL 4.1 core spec (see page 417 here), the targets CLAMP_VERTEX_COLOR and CLAMP_FRAGMENT_COLOR are deprecated. Hopefully we can still do the necessary unclamping with the target that remains, CLAMP_READ_COLOR, which does not result in an invalid enumerant error.
Everything down to the first instance of the line

Code: Select all

if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
doesn't fail, per se, in that no error codes are being flagged.
The framebuffer failure error is 0x8CD6, which is GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
Two suggestions on this and mind you, I'm shooting in the dark here and hopefully no damage will occur:
1. I've read somewhere - but can't find the source now, that the Metal interop to OpenGL works only with 8-bit buffers. To test this, try changing one framebuffer attachment setup from this: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_FLOAT, NULL) to this: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)viewSize.width, (GLsizei)viewSize.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL)
I don't expect the game to work correctly if this passes, but it would be a good indication of where we stand with the Metal interop. Change just one framebuffer and see if its error messages cease.
2. Change all occurrences of GL_DEPTH_COMPONENT32F to GL_DEPTH_COMPONENT24 (or GL_DEPTH_COMPONENT if the 24 doesn't work). Maybe Apple OpenGL doesn't have automatic fallbacks to 24 bit depth buffer like Windows and Linux have.
Post Reply