Game Development Reference
In-Depth Information
Type : It specifies the data type of the pixel data, in this case
RGB565 (16 bit).
Pixels : It specifies a pointer to the image data in memory. It must be
encoded as RGR656.
Note The size of the texture must be a power of two: 256, 512, 1024, etc.). However, the size of
the video image can be arbitrary. This means the size of the texture must be a power of two equal
to or greater than the size of the video. This is a caveat that will be explained later.
Listing 3-10. Create an Empty Texture as RGB656
// Texture ID
static unsigned int mTextureID;
// These are used to compute an XY offset of the image drawn into the texture
static int xoffset;
static int yoffset;
/**
* Create an empty texture as RGB565
* params: (w,h) width, height of the texture
* (x_offsety_offset): XY offset of the image drawn into the texture
*/
static void CreateEmptyTextureRGB565 (int w, int h, int x_offset, int y_offset)
{
int size = w * h * 2;
xoffset = x_offset;
yoffset = y_offset;
// buffer
unsigned short * pixels = (unsigned short *)malloc(size);
memset(pixels, 0, size);
// Init GL sate
glDisable(GL_DITHER);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
glClearColor(.5f, .5f, .5f, 1);
glShadeModel(GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
// Create texture
glGenTextures(1, &mTextureID);
glBindTexture(GL_TEXTURE_2D, mTextureID);
Search WWH ::




Custom Search