OSX Mojave and Cerberus X

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
Hi folks,

I noticed some comments in the net, which indicate that Apple has dropped OpenGL in OSX Mojave.
After I had updated my machine and prior to updating to XCode 10, an initial mojo1 test ran succesfully. But I still need to upgrade to Xcode 10 and test mojo1/mojo2.
My gut feeling tells me that at least mojo2 might not run, but I will report back when I know exactly.

So I suggest to wait with an upgrade to Mojave if you depend on a working OSX/CX solution.

Cheers
Michael
 

dawlane

Active Member
CX Code Contributor
Joined
Jun 21, 2017
It's been on the cards for some time that Apple will end the inclusion of OpenGL/ES in their devices with them going it alone with there own take on Vulkan. The possible quick fix would be for the end developer to include MoltenGL. But from past experience with using paid for closed source API's, there's no guarantee that they will be around in a few years. I'm still surprised that GCC was still included with the xcode command line tools. Frankly dealing with Apple devices is starting to more trouble than it's worth; especially for small developers who haven't the resources to keep up with Apple and their whims.

Eventually OpenGL will stopped being developed when Vulkan starts to become the main API of choice. It would be a question then if the GPU vendors will still supply the OpenGL drivers for the hardware.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
Apple has set on Metal 2 and Swift. I am waiting that they will through out ObjC.
MoltenVK is all fine, but it will be only a paid solution. Nothing we can provide for CX. :(
 

Ferdi

Member
3rd Party Target Dev
Joined
Jun 21, 2017
I read about Mojave dropping OpenGL this week. Most probably Apple will drop OpenGL for iOS too. I haven't seen announcement about it though. I also read that Apple wants users to use Metal.

I started looking Internet for a solution. And I found bgfx (https://github.com/bkaradzic/bgfx). You can see who uses Bgfx in the Github page.

Bgfx supports Direct3D 9, 11, 12, Metal, and Open GL. And if you look at the source they have started on Vulkan too. (Source to Vulkan backend: https://github.com/bkaradzic/bgfx/blob/master/src/renderer_vk.cpp)

This is very early work, but here is the hello world example converted to Cerberus:

Code:
Import mojo.app

' these lines will be in bgfx.cxs

Import "native/bgfx.cpp"

'  ///
Const BGFX_CLEAR_NONE:Int =                  $0000 '//!< No clear flags.
Const BGFX_CLEAR_COLOR:Int =                 $0001 '//!< Clear color.
Const BGFX_CLEAR_DEPTH:Int =                 $0002 '//!< Clear depth.
Const BGFX_CLEAR_STENCIL:Int =               $0004 '//!< Clear stencil.
Const BGFX_CLEAR_DISCARD_COLOR_0:Int =       $0008 '//!< Discard frame buffer attachment 0.
Const BGFX_CLEAR_DISCARD_COLOR_1:Int =       $0010 '//!< Discard frame buffer attachment 1.
Const BGFX_CLEAR_DISCARD_COLOR_2:Int =       $0020 '//!< Discard frame buffer attachment 2.
Const BGFX_CLEAR_DISCARD_COLOR_3:Int =       $0040 '//!< Discard frame buffer attachment 3.
Const BGFX_CLEAR_DISCARD_COLOR_4:Int =       $0080 '//!< Discard frame buffer attachment 4.
Const BGFX_CLEAR_DISCARD_COLOR_5:Int =       $0100 '//!< Discard frame buffer attachment 5.
Const BGFX_CLEAR_DISCARD_COLOR_6:Int =       $0200 '//!< Discard frame buffer attachment 6.
Const BGFX_CLEAR_DISCARD_COLOR_7:Int =       $0400 '//!< Discard frame buffer attachment 7.
Const BGFX_CLEAR_DISCARD_DEPTH:Int =         $0800 '//!< Discard frame buffer depth attachment.
Const BGFX_CLEAR_DISCARD_STENCIL:Int =       $1000 '//!< Discard frame buffer stencil attachment.

Extern

Function bgfxSetDebug:Void( _debug:Int )="bgfx_set_debug"
Function bgfxSetViewClear:Void( _id:Int, _flags:Int, _rgba:Int, _depth:Float, _stencil:Int)="bgfx_set_view_clear"
Function bgfxSetViewRect:Void( _id:Int, _x:Int, _y:Int, _width:Int, _height:Int)="bgfx_set_view_rect"
Function bgfxTouch:Void( _id:Int )="bgfx_touch"
Function bgfxDbgTextClear:Void( _attr:Int, _small:Bool)="bgfx_dbg_text_clear"
'  Function bgfxDbgTextImage:Void( _x:Int, _y:Int, _width:Int, _height:Int, _data:DataBuffer, _pitch:Int)="bgfx_dbg_text_image"
Function bgfxDbgTextPrintf:Void( _x:Int, _y:Int, _attr:Int, _format:String )="_bgfx_dbg_text_printf"
Function bgfxFrame:Void( _capture:Bool )="bgfx_frame"

Public

Class MojoGame Extends App

    Field width:Int = 1280
    Field height:Int = 720

    Field debug:Int = BGFX_DEBUG_TEXT
'      Field reset:Int = BGFX_RESET_VSYNC

    Method OnCreate:Int()

        SetUpdateRate(60)

        ' Enable debug text.
'          bgfxSetDebug(debug)

        Return 0
    End

    Method OnUpdate:Int()
        Return 0
    End

    Method OnRender:Int()

'          bgfxSetViewClear(0, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH, $303030ff, 1.0, 0)

        ' Set view 0 default viewport.
        bgfxSetViewRect(0, 0, 0, width, height)

        ' This dummy draw call is here to make sure that view 0 is cleared
        ' if no other draw calls are submitted to view 0.
        bgfxTouch(0)

        ' Use debug font to print information about this example.
        bgfxDbgTextClear(0, False)
'          bgfxDbgTextImage(Max(width/2/8, 20)-20, Max(height/2/16, 6)-6, 40, 12, s_logo, 160)
        bgfxDbgTextPrintf(0, 1, $4f, "bgfx/examples/25-c99")
        bgfxDbgTextPrintf(0, 2, $6f, "Description: Initialization and debug text with C99 API.")

        ' Advance to next frame. Rendering thread will be kicked to
        ' process submitted rendering primitives.
        bgfxFrame(False)

        Return 0
    End
End

Function Main:Int()
    New MojoGame()
    Return 0
End
The original C file is here: https://github.com/bkaradzic/bgfx/blob/master/examples/25-c99/helloworld.c

So if I get this working it will be like the Cerberus opengl.gles20 module. Then may be I can gut out mojo2 and replace all OpenGL call with bgfx, not sure if this will work.

This is all very experimental. I am not sure what other option is on the table. I am open to hearing other options. Will Cerberus users be interested in this?
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
From all the render frameworks, bgfx seems to me to be the one that is running on all platforms we need. So definitely something to look into.
 

dawlane

Active Member
CX Code Contributor
Joined
Jun 21, 2017
I have to say that bgfx looks promising.

EDIT: Just checked out the licence for bgfx. I think most people can live with BSD-Clause 2.

Apple has set on Metal 2 and Swift. I am waiting that they will through out ObjC.
MoltenVK is all fine, but it will be only a paid solution. Nothing we can provide for CX.
MoltenVK is under the Apache V2 licence, so there shouldn't be a problem there other than having to switch to Vulkan instead of OpenGL, but MoltenGL is a pay per feature set affair. I cannot see Apple dropping OjbC. They would have to completely rewrite their code base from scratch. From what I understand even MS Windows and OS X are still stuck in the C world for parts of the OS, so the chance that they would completely rewrite the lot would be slim. The only time that I can imagine Apple doing a rewrite is when they introduce one of their own custom CPU's and release Mac OS XI.
 
Last edited:

Ferdi

Member
3rd Party Target Dev
Joined
Jun 21, 2017
I think even if C is dropped it will be like how HTML5 has emscripten, there is just too many legacy code that other companies don't want to rewrite.

I start another thread and come up with a simple plan (more like a task list), so people knows what is going on and I can ask questions on how certain parts of the bgfx module should be implemented.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
Yes do that. Need to implement dawlanes stuff. And the whole render part needs a push into the future. Maybe bgfx can replace it, maybe it is time for a cx2.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
Just to let you know guys, IPhone XS Max simulator with IOS 12 works too with mojo1/mojo2.
I think that is great news as we still have time to prepare CX for when Apple completely takes out OpenGL.
 

Pierrou

Active Member
Joined
Jul 6, 2017
Hello
My 2011 Mac Mini is dead but if someone is interested in publishing my upcoming app, I might buy another one to build a MacOS version. I've gone through a few threads here and still don't understand if CX apps on MacOS are still going to be a thing in the near future or not. Does someone know it? Thanks!
 

MikeHart

Administrator
Joined
Jun 19, 2017
Location
Germany
As long as I have hardware to develop on the latest OSX version, I plan on supporting it.
Nobody knows when Apple will remove OpenGL/ES but it wil happen. With OSX Catalina, you will see now warnings, that certain OpenGL calls are depreciated. That is new to Xcode, so Apple is working to remove it alltogether.

A new backend is not decided on. But I am motivated to keep CX running on OSX and IOS in the future, so don't worry.
 

Pierrou

Active Member
Joined
Jul 6, 2017
Thanks for the answer and for your commitment!
People who bought some of my apps like 5-10 years ago from the publisher still expect it to work today since they are part of their daily toolset so I guess I really must be able to fully support MacOS for years to come if I tell the publisher there is a MacOS version (moreover Macs are quite expensive so it must be worth the buy). Dropping Mac support would probably not affect the sales too much and it would free me from some hassle so I'm still wondering...
 
Top Bottom