Back-port 2017-05-12 osg-sample article
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
Title: Заглушка
|
||||
Date: 2017-06-03 00:00
|
||||
Category: Stub
|
||||
Slug: stub
|
||||
Lang: ru
|
||||
|
||||
TODO Импортировать предыдущие статьи Opensource Game Studio с Wordpress.
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
Title: Stub
|
||||
Date: 2017-06-03 00:00
|
||||
Category: Stub
|
||||
Slug: stub
|
||||
Lang: en
|
||||
|
||||
TODO Import previous Opensource Game Studio articles from Wordpress.
|
||||
|
||||
59
pelican/content/articles/2017-05-12_osg-sample-ru.md
Normal file
59
pelican/content/articles/2017-05-12_osg-sample-ru.md
Normal file
@@ -0,0 +1,59 @@
|
||||
Title: Приложение OpenSceneGraph
|
||||
Date: 2017-05-12 00:00
|
||||
Category: News
|
||||
Slug: osg-sample
|
||||
Lang: ru
|
||||
|
||||
![OSG sample][screenshot]
|
||||
|
||||
|
||||
Эта статья описывает создание самоучителей по сборке приложения OpenSceneGraph на Linux, macOS, Windows и Android в апреле 2017.
|
||||
|
||||
Предыдущие самоучители описывали установку OpenSceneGraph на Linux, macOS, Windows и отображение модели с помощью стандартного инструмента **osgviewer**. На этот раз результатом нашей работы стало [приложение OpenSceneGraph](https://github.com/OGStudio/openscenegraph-cross-platform-guide-application), которое работает на Linux, macOS, Windows и Android.
|
||||
|
||||
Приложение очень простое. Оно умеет следующее:
|
||||
|
||||
0. Создание окна для отрисовки
|
||||
0. Загрузка модели
|
||||
0. Отрисовка модели с помощью простых шейдеров GLSL
|
||||
0. Перемещение модели с помощью мыши на Linux, macOS, Windows и пальца на Android
|
||||
|
||||
|
||||
|
||||
Создать самоучители для Linux, macOS, Windows было настолько простой и понятной задачей, что мы справились с ней за пару недель. Оставшуюся половину месяца мы потратили на создание самоучителя для Android.
|
||||
|
||||
Наша [первая успешная сборка под Android](http://www.opengame.epizy.com/lang/ru/news/2414) в прошлом году требовала множество неочивидных телодвижений. В этот раз мы хотели получить более чистый, быстрый и дешёвый подход.
|
||||
|
||||
Нам это удалось. В результате всё, что нужно для работы приложения OpenSceneGraph на Android, уместилось в набор из нескольких файлов и небольших изменений для стандартного проекта Android Studio (с поддержкой C++).
|
||||
|
||||
Краткий перечень файлов:
|
||||
|
||||
0. Поверхность GLES2
|
||||
0. Activity для отрисовки на этой поверхности
|
||||
0. Интерфейс Java для нативной библиотеки
|
||||
0. Реализация нативной библиотеки на C++
|
||||
0. Файл CMake для сборки нативной библиотеки
|
||||
0. Activity layout
|
||||
0. Модель для отрисовки
|
||||
|
||||
|
||||
|
||||
Краткий перечень изменений проекта:
|
||||
|
||||
0. Обновление Android manifest для использования GLES2 и Activity
|
||||
0. Использование файла CMake нативной библиотеки в проектном файле CMake
|
||||
|
||||
|
||||
|
||||
Документация OpenSceneGraph предполагает сборку OpenSceneGraph вне Android Studio с помощью CMake. Такой подход имеет следующие ограничения:
|
||||
|
||||
0. Ручная сборка OpenSceneGraph под каждую платформу
|
||||
0. Ручное копирование собранных библиотек OpenSceneGraph в проект Android Studio
|
||||
|
||||
|
||||
|
||||
Наш подход включает в себя сборку OpenSceneGraph для тех платформ, для которых собирается проект Android Studio. К тому же, OpenSceneGraph используется как часть проекта, поэтому нет никакой дополнительной рутины: достаточно просто пересобрать проект, и всё готово.
|
||||
|
||||
На этом мы заканчиваем описание создания самоучителей по сборке приложения OpenSceneGraph на Linux, macOS, Windows и Android в апреле 2017.
|
||||
|
||||
[screenshot]: {attach}/images/2017-05_osg-sample.png
|
||||
59
pelican/content/articles/2017-05-12_osg-sample.md
Normal file
59
pelican/content/articles/2017-05-12_osg-sample.md
Normal file
@@ -0,0 +1,59 @@
|
||||
Title: OpenSceneGraph sample
|
||||
Date: 2017-05-12 00:00
|
||||
Category: News
|
||||
Slug: osg-sample
|
||||
Lang: en
|
||||
|
||||
![OSG sample][screenshot]
|
||||
|
||||
|
||||
This article describes creation of the tutorials for building sample OpenSceneGraph application under Linux, macOS, Windows, and Android in April 2017.
|
||||
|
||||
Previous tutorials described how to install OpenSceneGraph under Linux, macOS, Windows and render a model using the standard **osgviewer** tool. This time we worked on a [sample OpenSceneGraph application](https://github.com/OGStudio/openscenegraph-cross-platform-guide-application) that would run under Linux, macOS, Windows, and Android.
|
||||
|
||||
The application is very basic and has the following features:
|
||||
|
||||
0. Render window creation
|
||||
0. Model loading
|
||||
0. Model rendering with simple GLSL shaders
|
||||
0. Model motion with a mouse under Linux, macOS, Windows and a finger under Android
|
||||
|
||||
|
||||
|
||||
Creating the tutorials for Linux, macOS, Windows was so easy and straightforward, that it only took us half a month. We spent the second half of the month creating Android tutorial.
|
||||
|
||||
Our [first successful Android build](http://www.opengame.epizy.com/lang/en/news/2414) last year included hacks and non-obvious steps to make OpenSceneGraph run under Android. This time we wanted a cleaner, faster, and cheaper approach.
|
||||
|
||||
The approach we ended up with requires just a few files and a few changes to the original Android Studio project (with C++ support) to make sample OpenSceneGraph application run under Android.
|
||||
|
||||
Here's a quick rundown of the files:
|
||||
|
||||
0. GLES2 surface
|
||||
0. Render activity to render to the surface
|
||||
0. Native library Java interface
|
||||
0. Native library C++ implementation
|
||||
0. CMake file to build native library
|
||||
0. Render activity layout
|
||||
0. Model to display
|
||||
|
||||
|
||||
|
||||
Here's a quick rundown of the project changes:
|
||||
|
||||
0. Update Android manifest to use GLES2 and render activity
|
||||
0. Reference native library's CMake file in the project's CMake file
|
||||
|
||||
|
||||
|
||||
OpenSceneGraph documentation suggests building OpenSceneGraph outside Android Studio with CMake. However, this approach has the following limitations:
|
||||
|
||||
0. You have to build OpenSceneGraph for each target architecture
|
||||
0. You have to manually copy/reference built OpenSceneGraph libraries into Android Studio project
|
||||
|
||||
|
||||
|
||||
Our approach includes building OpenSceneGraph for those target architectures that Android Studio project is built for. Also, OpenSceneGraph is already referenced, so no extra work is required: you just need to rebuild the project, and you're done.
|
||||
|
||||
That's it for describing the creation of the tutorials for building sample OpenSceneGraph application under Linux, macOS, Windows, and Android in April 2017.
|
||||
|
||||
[screenshot]: {attach}/images/2017-05_osg-sample.png
|
||||
Reference in New Issue
Block a user