Browse Source

Documented also CMake side of platform portability.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
2040e34dd6
  1. 53
      doc/portability.dox

53
doc/portability.dox

@ -166,10 +166,15 @@ In most cases the entry point is classic `main()` function, but some platforms
(e.g. Native Client) have different requirements. To make things easier, entry (e.g. Native Client) have different requirements. To make things easier, entry
points are handled using macros, which take care of the rest. points are handled using macros, which take care of the rest.
If only one `*Application` or `*WindowlessApplication` header is included, the If exactly one `*Application` or `*Windowless*Application` header is included,
application class is aliased to `Platform::Application` or `Platform::WindowlessApplication` the application class is aliased to `Platform::Application` or
and the macro is aliased to `MAGNUM_APPLICATION_MAIN()` or `MAGNUM_WINDOWLESSAPPLICATION_MAIN()` `Platform::WindowlessApplication` and the macro is aliased to
to simplify porting. `MAGNUM_APPLICATION_MAIN()` or `MAGNUM_WINDOWLESSAPPLICATION_MAIN()` to
simplify porting. The same is with CMake code, if exactly one `*Application` or
`Windowless*Application` component , the libraries and include dirs are
available in `MAGNUM_APPLICATION_LIBRARIES` / `MAGNUM_WINDOWLESSAPPLICATION_LIBRARIES`
and `MAGNUM_APPLICATION_INCLUDE_DIRS` / `MAGNUM_WINDOWLESSAPPLICATION_INCLUDE_DIRS`
variables.
Example application, which targets both embedded Linux (using plain X and EGL) Example application, which targets both embedded Linux (using plain X and EGL)
and desktop (using SDL2 toolkit). Thanks to static polymorphism most of the and desktop (using SDL2 toolkit). Thanks to static polymorphism most of the
@ -184,26 +189,38 @@ particular *Event class implementations:
class MyApplication: public Platform::Application { class MyApplication: public Platform::Application {
public: public:
MyApplication(int& argc, char** argv): Platform::Application(argc, argv, "My Application") { MyApplication(int& argc, char** argv): Platform::Application(argc, argv, "My Application");
// ...
}
protected: protected:
void viewportEvent(const Vector2i& size) override { void viewportEvent(const Vector2i& size) override;
// ... void drawEvent() override;
} void keyPressEvent(KeyEvent& event) override;
void drawEvent() override {
// ...
}
void keyPressEvent(KeyEvent& event) override {
// ...
}
}; };
// ...
MAGNUM_APPLICATION_MAIN(MyApplication) MAGNUM_APPLICATION_MAIN(MyApplication)
@endcode @endcode
And corresponding CMake code. Note that we need to call `find_package()` twice,
first to get variable `MAGNUM_TARGET_GLES` and then again to find proper
application library based on its value:
@code
find_package(Magnum REQUIRED)
if(MAGNUM_TARGET_GLES)
find_package(Magnum REQUIRED Sdl2Application)
else()
find_package(Magnum REQUIRED XEglApplication)
endif()
include_directories(${MAGNUM_INCLUDE_DIRS} ${MAGNUM_APPLICATION_INCLUDE_DIRS})
add_executable(myapplication MyApplication.cpp)
target_link_libraries(myapplication
${MAGNUM_LIBRARIES}
${MAGNUM_APPLICATION_LIBRARIES})
@endcode
*/ */
} }

Loading…
Cancel
Save