Game Development Reference
In-Depth Information
If the size of the image is not a power of two, then the zoom flag will be set to 1 and the
horizontal and vertical zoom factors will be computed. Then, the empty texture will be
created by calling CreateEmptyTextureRGB565 with the width, height, and XY offset values of
the texture. Finally, the SDL surface is created by calling SDL_CreateRGBSurface with:
SDL_SWSURFACE : It tells SDL to create a software surface.
Width, height : It defines the size of the surface.
Bpp : It defines the bits per pixel (resolution) of the surface (8, 16, 24, or 32).
Rmask, gmask, bmask, amask : These are mask values for the red, green,
blue, and alpha (transparency) components of the pixel format. Set them
to 0 to let SDL take care of it.
Hybrid Scaler Rules of Thumb
Always keep in mind the following rules of thumb when using a hybrid scaler like this in your
games:
Always set the video size, if you can, to a power of two, such as
256x256 or 512x56. Values above 512 are simply too big for this
technique.
If you cannot set the video size but still want a full screen display, use
the SDL software scaler from the previous section to scale to the closest
power of two resolution, then use the hardware scaler.
This scaling technique may not be useful (performance wise) if your
video size if greater than 512x512.
Summary
The veil has been lifted to reveal a new frontier of 3D development for Android. The
techniques demonstrated in this chapter can help you to bring a large number of 3D PC
games to the platform, at an enormous savings in development costs.
In this chapter, you learned a trick to mix OpenGL code in Java. You started by looking at
a simple OpenGL example and then moving to a more complex tumbling cubes sample
provided by Google. You saw that the sample's rendering process included EGL initialization,
the main loop, drawing, buffer swap, and cleanup. Then you saw how to reimplement the
cube rendering invoked within the main loop. You learned how to create the cube renderer
and cube class used to render the cubes.
Finally, you looked at the limitations of OpenGL ES when it comes to advanced 3D games.
I hope this chapter will help you create your own 3D games for Android with minimal effort and
maximum code reuse. This is a prelude to the next chapters, in which you will look at more
details about the efficiency, graphics, and portability of the new OpenGL ES version 3.1.
 
Search WWH ::




Custom Search