Tutorial: Create a basic 3-D application
In this tutorial, we'll show you how to create a rotating, multicolored cube using OpenGL ES 1.1 or OpenGL ES 2.0. We'll discuss several concepts, such as defining the geometry of the cube, initializing the model, and adjusting the model per frame, and we'll show you how to implement these concepts in main().
You will learn to:
- Create and configure your project
- Create and color your cube
- Draw the cube with OpenGL ES 1.1
- Draw the cube with OpenGL ES 2.0
Before you begin
You should have a basic understanding of the C language and some experience running applications using the Momentics IDE for BlackBerry. Before starting this tutorial, you should have the following things ready:
- The BlackBerry 10 Native SDK
- Your BlackBerry 10 device or the BlackBerry 10 Device Simulator
Create your project
Since we don't want to write all of the setup code from scratch, let's create a project using the BlackBerry 10 OS OpenGL ES <version> Application Template Project, where <version> is the version of OpenGL ES you want to use. One advantage of using the template is that the main.c file comes with a bunch of boilerplate OpenGL ES code that we can borrow from. The template also includes a file called bbutil.c, which contains a set of convenient functions that you can call from your application (for example, functions for performing common tasks such as initializing and terminating EGL, loading and rendering text and textures, and changing the screen orientation). For more information about the functions in bbutil.c, see Functions in the bbutil API.
This project template also includes several libraries that add capabilities to the application. You can view the included libraries by looking at the C/C++ build settings under the project properties. To create a project using this template, complete the following:
- In the Momentics IDE, click File > New > BlackBerry Project.
- In the Project Type section, select Core Native. Click Next.
- In the Templates section, select the version of OpenGL that you want to use. Click Next.
- In the Basic Settings section, enter a name for your project (for example, "MyProject") in the text box at the top. Click Next.
- In the API Level section, select the API level that you want to use.
- Click Finish.
A new project appears in the Project Explorer view. If you expand the project, you'll notice that it contains three source files in the src folder: bbutil.c, bbutil.h, and main.c. These files contain the fundamental code for our app.
Last modified: 2013-10-30