Magnum::Platform::WindowlessCglApplication class

Windowless CGL application.

Application for offscreen rendering using WindowlessCglContext. This application library is available on desktop OpenGL on macOS.

Bootstrap application

Fully contained windowless application using WindowlessCglApplication along with CMake setup is available in base-windowless branch of Magnum Bootstrap repository, download it as tar.gz or zip file. After extracting the downloaded archive you can build and run the application with these four commands:

mkdir build && cd build
cmake ..
cmake --build .
./src/MyApplication # or ./src/Debug/MyApplication

See Usage with CMake for more information.

General usage

This application library is built if MAGNUM_WITH_WINDOWLESSCGLAPPLICATION is enabled when building Magnum. To use this library from CMake, request the WindowlessCglApplication component of the Magnum package and link to the Magnum::WindowlessCglApplication target:

find_package(Magnum REQUIRED)
if(CORRADE_TARGET_APPLE)
    find_package(Magnum REQUIRED WindowlessCglApplication)
endif()

# ...
if(CORRADE_TARGET_APPLE)
    target_link_libraries(your-app PRIVATE Magnum::WindowlessCglApplication)
endif()

Additionally, if you're using Magnum as a CMake subproject, do the following before calling find_package() to ensure it's enabled, as the library is not built by default:

set(MAGNUM_WITH_WINDOWLESSCGLAPPLICATION ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL)

If no other application is requested, you can also use the generic Magnum::WindowlessApplication alias to simplify porting. Again, see Downloading and building and Usage with CMake for more information.

Place your code into exec(). The subclass can be then used directly in main() — see convenience macro MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN(). See Platform support for more information.

class MyApplication: public Platform::WindowlessCglApplication {
    // implement required methods...
};
MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN(MyApplication)

If no other application header is included, this class is also aliased to Platform::WindowlessApplication and the macro is aliased to MAGNUM_WINDOWLESSAPPLICATION_MAIN() to simplify porting.

Public types

struct Arguments
Application arguments.
using Configuration = WindowlessCglContext::Configuration
Configuration.

Constructors, destructors, conversion operators

WindowlessCglApplication(const Arguments& arguments, const Configuration& configuration = Configuration{}) explicit
Default constructor.
WindowlessCglApplication(const Arguments& arguments, NoCreateT) explicit
Construct without creating the context.
WindowlessCglApplication(const WindowlessCglApplication&) deleted
Copying is not allowed.
WindowlessCglApplication(WindowlessCglApplication&&) deleted
Moving is not allowed.

Public functions

auto operator=(const WindowlessCglApplication&) -> WindowlessCglApplication& deleted
Copying is not allowed.
auto operator=(WindowlessCglApplication&&) -> WindowlessCglApplication& deleted
Moving is not allowed.
auto exec() -> int pure virtual
Execute application.
auto glContext() -> CGLContextObj new in 2020.06
Underlying OpenGL context.

Protected functions

void createContext(const Configuration& configuration = Configuration())
Create context with given configuration.
auto tryCreateContext(const Configuration& configuration) -> bool
Try to create context with given configuration.

Typedef documentation

typedef WindowlessCglContext::Configuration Magnum::Platform::WindowlessCglApplication::Configuration

Configuration.

Function documentation

Magnum::Platform::WindowlessCglApplication::WindowlessCglApplication(const Arguments& arguments, const Configuration& configuration = Configuration{}) explicit

Default constructor.

Parameters
arguments Application arguments
configuration Configuration

Creates application with default or user-specified configuration. See Configuration for more information. The program exits if the context cannot be created, see tryCreateContext() for an alternative.

Magnum::Platform::WindowlessCglApplication::WindowlessCglApplication(const Arguments& arguments, NoCreateT) explicit

Construct without creating the context.

Parameters
arguments Application arguments

Unlike above, the context is not created and must be created later with createContext() or tryCreateContext().

int Magnum::Platform::WindowlessCglApplication::exec() pure virtual

Execute application.

Returns Value for returning from main()

See MAGNUM_WINDOWLESSCGLAPPLICATION_MAIN() for usage information.

CGLContextObj Magnum::Platform::WindowlessCglApplication::glContext() new in 2020.06

Underlying OpenGL context.

Use in case you need to call CGL functionality directly or in order to create a shared context. Returns nullptr in case the context was not created yet.

void Magnum::Platform::WindowlessCglApplication::createContext(const Configuration& configuration = Configuration()) protected

Create context with given configuration.

Must be called if and only if the context wasn't created by the constructor itself. Error message is printed and the program exits if the context cannot be created, see tryCreateContext() for an alternative.

bool Magnum::Platform::WindowlessCglApplication::tryCreateContext(const Configuration& configuration) protected

Try to create context with given configuration.

Unlike createContext() returns false if the context cannot be created, true otherwise.