Ejemplo n.º 1
0
/*
 * Draw a bitmap character
 */
void FGAPIENTRY 
glutBitmapCharacterTex(void* fontID, int x, int y, int character)
{
#if (GL_OES_VERSION_1_1 >= 1)
    const GLubyte* face;
    SFG_Font* font = fghFontByID(fontID);
	GLint v[] = {0, 0, _INT2FIXED(64), _INT2FIXED(64)}; //face[0], font->Height};
	GLubyte buff[64*64];
	GLuint tid;

	if(!font)
		return;

    if(!(character >= 1)&&(character < 256))
		return;

    /*
     * Find the character we want to draw (???)
     */
    face = font->Characters[ character - 1 ];
	
	memset(buff, 0, 64*64*sizeof(GLubyte));
	BitsToBytes(face+1, face[0], font->Height, buff, 64, 64);

	glGenTextures(1, &tid);
    glBindTexture(GL_TEXTURE_2D, tid);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
                            64, 64, 0, GL_ALPHA, GL_UNSIGNED_BYTE,
                            buff);

    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

	glEnable(GL_TEXTURE_2D);

    glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
	glEnable(GL_ALPHA_TEST);
    glAlphaFuncx(GL_EQUAL, 0);

	glTexParameterxv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, v);

	glDrawTexxOES(_INT2FIXED(x), _INT2FIXED(y), _INT2FIXED(0), _INT2FIXED(16), _INT2FIXED(16)); //face[0], font->Height);

    glDisable(GL_ALPHA_TEST);
    glDisable(GL_TEXTURE_2D);

	glDeleteTextures(1, &tid);
#endif
}
void glDrawTexxOESLogged(GLfixed x, GLfixed y, GLfixed z, GLfixed width, GLfixed height) {
	printf("glDrawTexxOES(%i, %i, %i, %i, %i)\n", x, y, z, width, height);
	glDrawTexxOES(x, y, z, width, height);
}