In our third shaders tutorial we will use the knowledge we have gained from the second tutorial and we use it to create gray scaled textures. You can create a texture that is already gray scaled and use it with our simple texture shader and you are right, however, there are some situation in which you want to be able to do it runtime. We will show you various forms of gray scaling available using shaders.
In this second installment of our OpenGL ES 2.0 Shader tutorials for Android we will look into using textures in our shaders. In our previous tutorial we have explained the whole shader system in OpenGL ES 2.0 and we have made an app that renders a colored triangle. This is nice but if we want to make a game more appealing we should use images instead of only colored objects. In our Real 2D tutorials we have already explained and given code to render textured quads on screen representing an game object. This tutorial will explain just a bit more of what we can do with shaders regarding textures and colors.
In the previous tutorials we have created a textured 2D image that we can control and transform. We have talked about the texturing just a little bit. The shader parts will be explained in great detail in our future tutorials about shaders. The OpenGL ES 2.0 part of the code is what we are going to handle in this tutorial. I will have to warn you, this tutorial will be theory for the most part as it will try to explain how the texture system works in OpenGL ES 2.0.
There are a lot of different phones, tablets and hardware configurations available when it comes to Android. Assuming that everything is working correctly right from the factory may be a little bit naive. At the moment a lot of developers still support Android 2.3 and some phones like the HTC Desire, HTC Desire S and Samsung Galaxy Ace have a little GPU from the Adreno 200 series (200 & 205) that does not work as all the other GPU’s regarding textures. Let us elaborate a bit on this as you should incorporate our hack if you use multiple textures per shaderprogram so that those users won’t complain .
OpenGL ES 2.0 requires us to use shaders, which is very nice because it lets us do a lot of nice things. This series of tutorials will go into the subject of shaders. This installment will cover the basic setup of a shader and explains a bit what’s what.
In the previous tutorial we had created and rendered a 2D triangle on your screen. In this tutorial we will load and render a 2D image on screen. This tutorial will continue on the code of the previous tutorial. Rendering a 2D image on screen using OpenGL ES 2.0 is not that different from rendering a triangle on screen. Instead of 1 triangle we render 2 triangles and the shaders changes a bit. Let begin with the next installment of our Real OpenGL ES 2.0 2D tutorials.
When we first searched the internet for information about Open GL ES 2 for Android, we found a lot of useful tutorials. The problem we encountered however was that none of the tutorials we found really explained the 2D part of Open GL ES 2. Since we were at first looking for 2D only code, we were a bit disappointed. There are quite a few questions on websites that cover such things but creating a full 2D engine based on separate question is not the way you want to go about it. Therefor we have decided to create a few handy tutorials for 2D only. We hope a lot of beginning coders will find this information useful.