Welcome to the Android OpenGL C++ NDK starter project! This project serves as a basic starting point for developing Android applications using OpenGL and the Native Development Kit (NDK) with C++. Follow the instructions below to get started.
- Prerequisites
- Project Structure
- Setup and Build
- Running the App
- Project Details
- Contributing
- License
Before you begin, ensure you have met the following requirements:
- Android Studio: Download and install Android Studio.
- Android NDK: Install the NDK through the Android Studio SDK Manager.
- CMake: Ensure CMake is installed. It can be installed through the Android Studio SDK Manager.
- A Physical Device or Emulator: Set up an Android device or emulator for testing.
AndroidOpenGLNDK/
├── app/
│ ├── src/
│ │ ├── main/
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ └── main.cpp
│ │ │ ├── java/
│ │ │ │ └── com/
│ │ │ │ └── example/
│ │ │ │ └── android_game_dev_learn/
│ │ │ │ └── MainActivity.java
│ │ │ ├── res/
│ │ │ │ └── layout/
│ │ │ │ └── activity_main.xml
│ │ │ └── AndroidManifest.xml
│ └── build.gradle
├── build.gradle
└── settings.gradle
-
Clone the Repository:
git clone https://github.com/rahulsenna/Android_OpenGL_CPP_Starter.git cd Android_OpenGL_CPP_Starter
-
Open in Android Studio:
- Open Android Studio.
- Click on
Open an existing Android Studio project
. - Navigate to the cloned repository folder and select it.
-
Configure CMake and NDK:
- Open
File
>Project Structure
. - Under
SDK Location
, ensure the NDK location is correctly set. - Sync the project by clicking on
File
>Sync Project with Gradle Files
.
- Open
-
Build the Project:
- Click on the
Build
menu and selectMake Project
.
- Click on the
-
Connect a Device or Start an Emulator:
- Connect your Android device via USB, or start an Android emulator.
-
Run the Application:
- Click the
Run
button (green play button) in Android Studio. - Select the connected device or emulator and click
OK
.
- Click the
The MainActivity
class uses GameActivity from the Android Game SDK. It initializes the native library and sets up an immersive full-screen mode.
This file contains the rendering code using OpenGL ES. It sets up the shaders, buffers, and renders the frame.
This file defines the CMake configuration for building the native libraries.
Contributions are welcome! Please fork this repository and submit pull requests with your improvements.
https://github.com/DanAlbert/ndk-app-template
This project is licensed under the MIT License. See the LICENSE file for details.
Happy coding! If you have any questions, feel free to open an issue or contact the project maintainers.